API Reference
jinxed
Jinxed is an implementation of a subset of the Python curses library for Windows
- jinxed.setupterm(term=None, fd=-1)
Reimplementation of
curses.setupterm()
- jinxed.tigetflag(capname)
Reimplementation of
curses.tigetflag()
- jinxed.tigetnum(capname)
Reimplementation of
curses.tigetnum()
- jinxed.tigetstr(capname)
Reimplementation of
curses.tigetstr()
- jinxed.tparm(str[, ...])
Reimplementation of
curses.tparm()
- exception jinxed.error
Generic class for Jinxed errors
jinxed.win32
Support functions and wrappers for calls to the Windows API
Note
Some functions require a file descriptor while others require a file handle.
The windows library generally requires file handles, but some functions are intended
to mimic existing functions that use file descriptors. An example of a obtaining a
file descriptor is fd = sys.stdout.fileno()
. The file handle can then be
obtained with msvcrt.get_osfhandle(fd)
.
- jinxed.win32.VTMODE_SUPPORTED
True when the Windows version is 10.0.10586 or higher
- class jinxed.win32.ConsoleScreenBufferInfo
Python representation of a CONSOLE_SCREEN_BUFFER_INFO object
- jinxed.win32.get_csbi(filehandle=None)
- Parameters:
filehandle (int) – Windows filehandle object as returned by
msvcrt.get_osfhandle()
- Returns:
CONSOLE_SCREEN_BUFFER_INFO structure
- Return type:
Wrapper for GetConsoleScreenBufferInfo
If
filehandle
isNone
, uses the filehandle ofsys.__stdout__
.
- jinxed.win32.get_console_input_encoding()
- Returns:
Current console mode
- Return type:
Query for the console input code page and provide an encoding
If the code page can not be resolved to a Python encoding,
None
is returned.
- jinxed.win32.get_console_mode(filehandle)
- Parameters:
filehandle (int) – Windows filehandle object as returned by
msvcrt.get_osfhandle()
- Returns:
Current console mode
- Return type:
- Raises:
OSError – Error calling Windows API
Wrapper for GetConsoleMode
- jinxed.win32.set_console_mode(filehandle, mode)
- Parameters:
filehandle (int) – Windows filehandle object as returned by
msvcrt.get_osfhandle()
mode (int) – Desired console mode
- Raises:
OSError – Error calling Windows API
Wrapper for SetConsoleMode
- jinxed.win32.setcbreak(filehandle)
- Parameters:
filehandle (int) – Windows filehandle object as returned by
msvcrt.get_osfhandle()
- Raises:
OSError – Error calling Windows API
Convenience function which mimics
tty.setcbreak()
behaviorAll console input options are disabled except
ENABLE_PROCESSED_INPUT
and, if supported,ENABLE_VIRTUAL_TERMINAL_INPUT
- jinxed.win32.setraw(filehandle)
- Parameters:
filehandle (int) – Windows filehandle object as returned by
msvcrt.get_osfhandle()
- Raises:
OSError – Error calling Windows API
Convenience function which mimics
tty.setraw()
behaviorAll console input options are disabled except, if supported,
ENABLE_VIRTUAL_TERMINAL_INPUT
- jinxed.win32.enable_vt_mode(filehandle=None)
- Parameters:
filehandle (int) – Windows filehandle object as returned by
msvcrt.get_osfhandle()
- Raises:
OSError – Error calling Windows API
Enables virtual terminal processing mode for the given console
If
filehandle
isNone
, uses the filehandle ofsys.__stdout__
.
- jinxed.win32.get_terminal_size(fd)
- Parameters:
fd (int) – Python file descriptor
- Returns:
Named tuple representing terminal size
- Return type:
Convenience function for getting terminal size
In Python 3.3 and above, this is a wrapper for
os.get_terminal_size()
. In older versions of Python, this function calls GetConsoleScreenBufferInfo.
- jinxed.win32.flush_and_set_console(fd, mode)
- Parameters:
filehandle (int) – Windows filehandle object as returned by
msvcrt.get_osfhandle()
mode (int) – Desired console mode
Attempts to set console to specified mode, but will not raise on failure
If the file descriptor is STDOUT or STDERR, attempts to flush first
- jinxed.win32.get_term(fd, fallback=True)
- Parameters:
- Returns:
Terminal type
- Return type:
Attempts to determine and enable the current terminal type
The current logic is:
If TERM is defined in the environment, the value is returned
Else, if ANSICON is defined in the environment,
'ansicon'
is returnedElse, if virtual terminal mode is natively supported, it is enabled and
'vtwin10'
is returnedElse, if
fallback
isTrue
, Ansicon is loaded, and'ansicon'
is returnedIf no other conditions are satisfied,
'unknown'
is returned
This logic may change in the future as additional terminal types are added.