Changeset 68836 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Sep 22, 2017 4:37:46 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 118090
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/stream.cpp
r62592 r68836 60 60 #ifdef RT_OS_WINDOWS 61 61 # include <iprt/win/windows.h> 62 #endif 63 #ifndef RT_OS_WINDOWS 62 #else 64 63 # include <termios.h> 65 64 # include <unistd.h> … … 553 552 return rc; 554 553 } 554 555 556 RTR3DECL(bool) RTStrmIsTerminal(PRTSTREAM pStream) 557 { 558 AssertPtrReturn(pStream, false); 559 AssertReturn(pStream->u32Magic == RTSTREAM_MAGIC, false); 560 561 if (pStream->pFile) 562 { 563 int fh = fileno(pStream->pFile); 564 if (isatty(fh)) 565 { 566 #ifdef RT_OS_WINDOWS 567 DWORD dwMode; 568 HANDLE hCon = (HANDLE)_get_osfhandle(fh); 569 if (GetConsoleMode(hCon, &dwMode)) 570 return true; 571 #else 572 return true; 573 #endif 574 } 575 } 576 return false; 577 } 578 579 580 RTR3DECL(int) RTStrmQueryTerminalWidth(PRTSTREAM pStream, uint32_t *pcchWidth) 581 { 582 AssertPtrReturn(pcchWidth, VERR_INVALID_HANDLE); 583 *pcchWidth = 80; 584 585 AssertPtrReturn(pStream, VERR_INVALID_HANDLE); 586 AssertReturn(pStream->u32Magic == RTSTREAM_MAGIC, VERR_INVALID_HANDLE); 587 588 if (pStream->pFile) 589 { 590 int fh = fileno(pStream->pFile); 591 if (isatty(fh)) 592 { 593 #ifdef RT_OS_WINDOWS 594 CONSOLE_SCREEN_BUFFER_INFO Info; 595 HANDLE hCon = (HANDLE)_get_osfhandle(fh); 596 RT_ZERO(Info); 597 if (GetConsoleScreenBufferInfo(hCon, &Info)) 598 { 599 *pcchWidth = Info.dwSize.X ? Info.dwSize.X : 80; 600 return VINF_SUCCESS; 601 } 602 return RTErrConvertFromWin32(GetLastError()); 603 #else 604 struct winsize Info; 605 RT_ZERO(Info); 606 int rc = ioctl(fh, TIOCGWINSZ, &Info); 607 if (rc >= 0) 608 { 609 *pcchWidth = Info.ws_row ? Info.ws_row : 80; 610 return VINF_SUCCESS; 611 } 612 return RTErrConvertFromErrno(errno); 613 #endif 614 } 615 } 616 return VERR_INVALID_FUNCTION; 617 } 618 555 619 556 620
Note:
See TracChangeset
for help on using the changeset viewer.