-
Notifications
You must be signed in to change notification settings - Fork 32
Added functionality to access terminal window height (number of lines) #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
setton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for this contribution. I have left a few comments - only stylistic, the code itself looks good to me. Let us know if you're happy to make those changes.
src/terminals.c
Outdated
| CONSOLE_SCREEN_BUFFER_INFO csbiInfo; | ||
| if (GetConsoleScreenBufferInfo (handle, &csbiInfo)) { | ||
| return (int)csbiInfo.dwSize.X; | ||
| //return (int)csbiInfo.dwSize.X; // buffer width |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the commented-out line. (Same comment on line 148)
src/terminals.c
Outdated
| return (int)csbiInfo.dwSize.X; | ||
| //return (int)csbiInfo.dwSize.X; // buffer width | ||
| return (int)(csbiInfo.srWindow.Right | ||
| -csbiInfo.srWindow.Left + 1); // window width |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation of this line is off - please remove the tabs (same comment for line 150)
src/gnatcoll-terminal.ads
Outdated
| -- Whether the associated terminal is stdout (windows only) | ||
| end record; | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these extra lines.
src/gnatcoll-terminal.ads
Outdated
| -- Return the height of the terminal, or -1 if that height is either | ||
| -- unknown or does not apply (as is the case for files for instance). | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove one of these blank lines.
| return Internal (Boolean'Pos (Self.FD = Stderr)); | ||
| end if; | ||
| end Get_Width; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the extra blank lines - there should be at most one blank line as separation. (Same goes for lines 452-453.)
t-14
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general comment, can you also add a new test exercising the additional code?
|
Ok, I think all suggested changes have been made. And I attached a test driver in this message. |
Thanks, but this needs to be added as a new test case in |
Test of new get_lines function.
|
Ok. I just added it to ~testsuite/tests/terminal/testlines.adb |
Provide a Get_Lines function in GNATCOLL.Terminal. Github PR: #81
Merge #81 See merge request eng/toolchain/gnatcoll-core!86
For several of my apps I needed the window height. This change has been tested on OSX, Windows, and several flavors of linux.
See, for example, "RetroArcade". This is one of my projects on GitHub.