From 73f7a68dbe9dbabb126fecc9a7e12acbdb183e7a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 9 Nov 2005 17:19:34 +0000 Subject: [PATCH] Added writing of commandline options in getFormatedString when there is no description string. --- src/osg/ApplicationUsage.cpp | 119 ++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 57 deletions(-) diff --git a/src/osg/ApplicationUsage.cpp b/src/osg/ApplicationUsage.cpp index f9a0eef39..feeddf6f2 100644 --- a/src/osg/ApplicationUsage.cpp +++ b/src/osg/ApplicationUsage.cpp @@ -101,69 +101,74 @@ void ApplicationUsage::getFormattedString(std::string& str, const UsageMap& um,u std::string::size_type pos = 0; std::string::size_type offset = 0; bool firstInLine = true; - while (pos0 && - explanation[pos+width]!=' ' && - explanation[pos+width]!='\n') --width; - - if (width==0) - { - // word must be longer than a whole line so will need - // to concatinate it. - width = explanationWidth-1; - concatinated = true; - } - } + if (firstInLine) offset = 0; - line.replace(explanationPos+offset,explanationWidth, explanation, pos, width); + // skip any leading white space. + while (pos0 && + explanation[pos+width]!=' ' && + explanation[pos+width]!='\n') --width; + + if (width==0) + { + // word must be longer than a whole line so will need + // to concatinate it. + width = explanationWidth-1; + concatinated = true; + } + } + + line.replace(explanationPos+offset,explanationWidth, explanation, pos, width); + + if (concatinated) { str += line; str += "-\n"; } + else { str += line; str += "\n"; } + + // move to the next line of output. + line.assign(fullWidth,' '); + + pos += width+extraSkip; + + } + } + else + { + str += line; str += "\n"; } - } }