Changeset 68838 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Sep 22, 2017 4:55:24 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 118092
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r68485 r68838 24 24 #include <iprt/buildconfig.h> 25 25 #include <iprt/ctype.h> 26 #include <iprt/env.h> 26 27 #include <iprt/err.h> 27 28 #include <iprt/getopt.h> … … 86 87 static uint32_t getScreenWidth(PRTSTREAM pStrm) 87 88 { 88 static uint32_t s_acch[2] = { 0, 0 };89 static uint32_t s_acch[2] = { 0, 0 }; 89 90 uint32_t iWhich = pStrm == g_pStdErr ? 1 : 0; 90 91 uint32_t cch = s_acch[iWhich]; … … 92 93 return cch; 93 94 94 cch = 80; /** @todo screen width IPRT API. */ 95 const char *psz = RTEnvGet("VBOXMANAGE_SCREEN_WIDTH"); 96 if ( !psz 97 || RTStrToUInt32Full(psz, 0, &cch) != VINF_SUCCESS 98 || cch == 0) 99 { 100 int rc = RTStrmQueryTerminalWidth(pStrm, &cch); 101 if (rc == VERR_INVALID_FUNCTION) 102 { 103 /* It's not a console, but in case we're being piped to less/more/list 104 we look for a console handle on the other standard output handle 105 and standard input. (Latter doesn't work on windows.) */ 106 rc = RTStrmQueryTerminalWidth(pStrm == g_pStdErr ? g_pStdOut : g_pStdErr, &cch); 107 if (rc == VERR_INVALID_FUNCTION || rc == VERR_INVALID_HANDLE) 108 rc = RTStrmQueryTerminalWidth(g_pStdIn, &cch); 109 if (RT_FAILURE(rc)) 110 cch = 80; 111 } 112 } 113 95 114 s_acch[iWhich] = cch; 96 115 return cch; … … 155 174 { 156 175 RTStrmWrite(pStrm, g_szSpaces, cchIndent + cchHangingIndent); 157 size_t 158 bool 176 size_t offLine = cchIndent + cchHangingIndent; 177 bool fPendingSpace = false; 159 178 do 160 179 { … … 162 181 size_t cchWord = pszSpace ? pszSpace - psz : strlen(psz); 163 182 if ( offLine + cchWord + fPendingSpace > cchMaxWidth 164 && offLine != cchIndent) 183 && offLine != cchIndent 184 && fPendingSpace /* don't stop before first word */) 165 185 break; 166 186
Note:
See TracChangeset
for help on using the changeset viewer.