-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Save ('s') and restore ('u') support added #137
base: master
Are you sure you want to change the base?
Conversation
Existing 'get_position' method is flawed in the following ways: * Naming: its setter is 'set_cursor_position', not 'set_position' * Abstraction leak: returns internal Win32 structure * There is no way to get adjusted cursor position * Receives handle, instead of on_stderr flag
There are no more uses of get_position in the code base, so it could be deprecated, and, possibly, removed in future
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.
Generally, this looks good. Please see my review comments
@@ -89,31 +91,38 @@ def get_position(self, handle): | |||
position.Y += 1 | |||
return position | |||
|
|||
def get_cursor_position(self, on_stderr=False, adjust=True): |
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.
I'm not sure if we need this function. We already have get_position
which returns the cursor position (we can rename that function to make it clear it's about the cursor). Regarding the adjustments, we have a code for adjusting the cursor position in SetConsoleCursorPosition
. We can play with its adjust
parameter based on if it's needed or not when restoring with 'u', instead of having more code that deals with this adjustments.
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.
I'm sensitive to wiggin's criticism here which I think might be valid, but am enthusiastic about the PR overall. Assuming @kgeorgiy is not still around / motivated after 4 years, I'll take a closer look at this code tonight, and try to merge it...
Apologies for resurrecting this after ignoring it for years!
handle = win32.STDERR | ||
position = self.get_position(handle) | ||
adjusted_position = (position.Y + y, position.X + x) | ||
(cy, cx) = self.get_cursor_position(on_stderr, adjust=False) |
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.
If we decide to continue to use get_position instead of the new get_cursor_position, we will not need this change.
Hey. FYI, yesterday I created a PR to test releases before we push them to PyPI. When that is merged, I'll be more confident about resuming merges and releases. I'll try to look at this PR soon. Thank you for creating it! |
win32.SetConsoleTextAttribute(handle, attrs) | ||
|
||
@staticmethod | ||
def get_handle(on_stderr=False): | ||
return win32.STDERR if on_stderr else win32.STDOUT |
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.
I like this ^
I could have used this feature right now. Anyone with privileges, please take another look. |
Includes test and demo plus minor refactoring of ansitowin32