forked from manrajgrover/halo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cursor] Removes dependency (fixes manrajgrover#118)
- Loading branch information
1 parent
e773f3b
commit 6a7a083
Showing
4 changed files
with
152 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Source: https://stackoverflow.com/a/10455937/2692667 | ||
""" | ||
|
||
import sys | ||
import os | ||
|
||
if os.name == "nt": | ||
import ctypes | ||
|
||
class _CursorInfo(ctypes.Structure): | ||
_fields_ = [("size", ctypes.c_int), ("visible", ctypes.c_byte)] | ||
|
||
|
||
def hide_cursor(stream=sys.stdout): | ||
"""Hide cursor. | ||
Parameters | ||
---------- | ||
stream: sys.stdout, Optional | ||
Defines stream to write output to. | ||
""" | ||
if os.name == "nt": | ||
ci = _CursorInfo() | ||
handle = ctypes.windll.kernel32.GetStdHandle(-11) | ||
ctypes.windll.kernel32.GetConsoleCursorInfo(handle, ctypes.byref(ci)) | ||
ci.visible = False | ||
ctypes.windll.kernel32.SetConsoleCursorInfo(handle, ctypes.byref(ci)) | ||
elif os.name == "posix": | ||
stream.write("\033[?25l") | ||
stream.flush() | ||
|
||
|
||
def show_cursor(stream=sys.stdout): | ||
"""Show cursor. | ||
Parameters | ||
---------- | ||
stream: sys.stdout, Optional | ||
Defines stream to write output to. | ||
""" | ||
if os.name == "nt": | ||
ci = _CursorInfo() | ||
handle = ctypes.windll.kernel32.GetStdHandle(-11) | ||
ctypes.windll.kernel32.GetConsoleCursorInfo(handle, ctypes.byref(ci)) | ||
ci.visible = True | ||
ctypes.windll.kernel32.SetConsoleCursorInfo(handle, ctypes.byref(ci)) | ||
elif os.name == "posix": | ||
stream.write("\033[?25h") | ||
stream.flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.