- Timestamp:
- Jun 18, 2015 6:15:51 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r56479 r56533 44 44 enum HELP_CMD_VBOXMANAGE g_enmCurCommand = HELP_CMD_VBOXMANAGE_INVALID; 45 45 /** The scope maskt for the current subcommand. */ 46 uint64_t g_fCurSubcommandScope = UINT64_MAX; 47 46 uint64_t g_fCurSubcommandScope = REFENTRYSTR_SCOPE_GLOBAL; 47 /** String of spaces that can be used for indentation. */ 48 static const char g_szSpaces[] = " "; 48 49 49 50 /** … … 58 59 Assert(g_enmCurCommand == HELP_CMD_VBOXMANAGE_INVALID); 59 60 g_enmCurCommand = enmCommand; 60 g_fCurSubcommandScope = UINT64_MAX;61 g_fCurSubcommandScope = REFENTRYSTR_SCOPE_GLOBAL; 61 62 } 62 63 … … 104 105 * @param psz The string table string to print. 105 106 * @param cchMaxWidth The maximum output width. 106 */ 107 static uint32_t printString(PRTSTREAM pStrm, const char *psz, uint32_t cchMaxWidth) 107 * @param fFlags String flags that may affect formatting. 108 */ 109 static uint32_t printString(PRTSTREAM pStrm, const char *psz, uint32_t cchMaxWidth, uint64_t fFlags) 108 110 { 109 111 uint32_t cLinesWritten; … … 142 144 while (*psz == ' ') 143 145 cchIndent++, psz++; 146 Assert(cchIndent + 4 + 1 <= RT_ELEMENTS(g_szSpaces)); 147 144 148 if (cchIndent + 8 >= cchMaxWidth) 145 149 cchMaxWidth += cchIndent + 8; 146 150 147 151 /* Work our way thru the string, line by line. */ 152 uint32_t cchHangingIndent = 0; 148 153 cLinesWritten = 0; 149 154 do 150 155 { 151 RTStrmWrite(pStrm, pszIndent, cchIndent);152 size_t offLine = cchIndent;153 bool fPendingSpace = false;156 RTStrmWrite(pStrm, g_szSpaces, cchIndent + cchHangingIndent); 157 size_t offLine = cchIndent + cchHangingIndent; 158 bool fPendingSpace = false; 154 159 do 155 160 { … … 183 188 RTStrmPutCh(pStrm, '\n'); 184 189 cLinesWritten++; 190 191 /* Set up hanging indent if relevant. */ 192 if (fFlags & REFENTRYSTR_FLAGS_SYNOPSIS) 193 cchHangingIndent = 4; 185 194 } while (*psz != '\0'); 186 195 } … … 223 232 { 224 233 uint64_t fCurScope = pStrTab->paStrings[i].fScope; 225 if (fCurScope == REFENTRYSTR_SCOPE_SAME) 226 fCurScope = fPrevScope; 227 if (fCurScope & fScope) 234 if ((fCurScope & REFENTRYSTR_SCOPE_MASK) == REFENTRYSTR_SCOPE_SAME) 235 { 236 fCurScope &= ~REFENTRYSTR_SCOPE_MASK; 237 fCurScope |= (fPrevScope & REFENTRYSTR_SCOPE_MASK); 238 } 239 if (fCurScope & REFENTRYSTR_SCOPE_MASK & fScope) 228 240 { 229 241 const char *psz = pStrTab->paStrings[i].psz; … … 236 248 cLinesWritten++; 237 249 } 238 cLinesWritten += printString(pStrm, psz, cchWidth );250 cLinesWritten += printString(pStrm, psz, cchWidth, fCurScope & REFENTRYSTR_FLAGS_MASK); 239 251 } 240 252 else … … 255 267 * @returns Number of lines written. 256 268 * @param enmCommand The command. 257 * @param fSubcommandScope The subcommand scope, UINT64_MAX for all. 269 * @param fSubcommandScope The subcommand scope, REFENTRYSTR_SCOPE_GLOBAL 270 * for all. 258 271 * @param pStrm The output stream. 259 272 */ … … 301 314 * 302 315 * @param enmCommand The command. 303 * @param fSubcommandScope The subcommand scope, UINT64_MAX for all. 316 * @param fSubcommandScope The subcommand scope, REFENTRYSTR_SCOPE_GLOBAL 317 * for all. 304 318 * @param pStrm The output stream. 305 319 */ … … 343 357 { 344 358 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID); 345 Assert(g_fCurSubcommandScope == UINT64_MAX);359 Assert(g_fCurSubcommandScope == REFENTRYSTR_SCOPE_GLOBAL); 346 360 347 361 return errorSyntax("No subcommand specified"); … … 360 374 { 361 375 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID); 362 Assert(g_fCurSubcommandScope == UINT64_MAX);376 Assert(g_fCurSubcommandScope == REFENTRYSTR_SCOPE_GLOBAL); 363 377 364 378 /* check if help was requested. */ … … 387 401 { 388 402 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID); 389 Assert(g_fCurSubcommandScope != UINT64_MAX);403 Assert(g_fCurSubcommandScope != REFENTRYSTR_SCOPE_GLOBAL); 390 404 391 405 /* check if help was requested. */
Note:
See TracChangeset
for help on using the changeset viewer.