{"id":6687,"library":"jinxed","title":"Jinxed Terminal Library","description":"Jinxed is an implementation of a subset of the Python curses library, providing pure Python implementations of terminfo functions such as `tigetstr()` and `tparm()`. It also offers convenience methods for working with Windows terminals. Initially developed to support the Blessed library on Windows, Jinxed is designed to work across all platforms.","status":"active","version":"1.4.0","language":"en","source_language":"en","source_url":"https://github.com/Rockhopper-Technologies/jinxed","tags":["terminal","curses","terminfo","windows","cross-platform","console"],"install":[{"cmd":"pip install jinxed","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"For retrieving string capabilities from the terminfo database.","symbol":"tigetstr","correct":"from jinxed.terminfo import tigetstr"},{"note":"For instantiating parameterized terminfo strings.","symbol":"tparm","correct":"from jinxed.terminfo import tparm"},{"note":"For advanced Windows console input handling (introduced in v1.4.0).","symbol":"ConsoleInput","correct":"from jinxed.win32 import ConsoleInput"}],"quickstart":{"code":"import os\nfrom jinxed.terminfo import tigetstr, tparm\n\ndef main():\n    # Get the terminal type from environment, default to 'xterm'\n    term_type = os.environ.get('TERM', 'xterm')\n    print(f\"Using terminal type: {term_type}\")\n\n    # Get the 'cursor up' capability string\n    cursor_up_cap = tigetstr('cuu1')\n    if cursor_up_cap:\n        print(f\"'cursor up' capability: {cursor_up_cap!r}\")\n    else:\n        print(\"'cursor up' capability not found for this terminal.\")\n\n    # Get and apply a parameterized capability, e.g., 'cursor address' (cup)\n    # This moves the cursor to a specific row and column (0-indexed)\n    cursor_address_cap = tigetstr('cup')\n    if cursor_address_cap:\n        # Move cursor to row 5, column 10 (0-indexed)\n        # Note: tparm parameters are often 1-indexed in terminfo, but curses/jinxed often maps to 0-indexed.\n        # Actual behavior may depend on specific terminal and capability.\n        control_sequence = tparm(cursor_address_cap, 5, 10)\n        if control_sequence:\n            print(f\"Moving cursor to (5,10): {control_sequence!r}\")\n            os.write(1, control_sequence) # Write directly to stdout's file descriptor\n            os.write(1, b'Hello!\\n')\n    else:\n        print(\"'cursor address' capability not found.\")\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates how to use `jinxed` to retrieve and apply terminfo capabilities like moving the cursor. It fetches terminal capabilities using `tigetstr` and then uses `tparm` to instantiate parameterized strings, which are then written to the console."},"warnings":[{"fix":"Review `tparm` calls and ensure they do not rely on state persistence across invocations. Parameters should be explicitly passed for each call.","message":"The behavior of `tparm` changed in version 1.2.1. It no longer persists dynamic variables between calls, aligning with `ncurses` versions >=6.3. Code relying on the prior persistence of dynamic variables will behave differently.","severity":"breaking","affected_versions":">=1.2.1"},{"fix":"Adjust code to handle an empty string return for `b'%p1%s'` with no arguments instead of Null, if this specific pattern was used.","message":"In version 1.2.1, a specific `tparm` pattern (`b'%p1%s'` with no arguments) now returns an empty string in Jinxed, whereas `ncurses` would return Null. Code expecting a Null value may encounter different behavior.","severity":"breaking","affected_versions":">=1.2.1"},{"fix":"Upgrade to Python 3.5 or newer.","message":"Support for Python 3.4 was dropped in version 1.0.0.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"If your Windows application requires `ENABLE_VIRTUAL_TERMINAL_INPUT` to be explicitly set, ensure it is configured independently or verify its state before relying on Jinxed to activate it implicitly.","message":"In version 1.3.0, `jinxed.win32.get_term()` was updated to check if `ENABLE_VIRTUAL_TERMINAL_INPUT` is already enabled in the console before setting it. Previously, it would unconditionally enable it. This can affect Windows applications that relied on Jinxed always setting this mode.","severity":"gotcha","affected_versions":">=1.3.0"},{"fix":"Test existing applications with `jinxed` 1.4.0 to ensure consistent behavior with the faster event loop. Consider leveraging the new mouse and resize event capabilities.","message":"Version 1.4.0 introduced approximately 100x improved response time for keyboard events and added support for mouse and resize events. While this is a significant performance and feature enhancement, applications sensitive to precise timing of keyboard events or that previously worked around the lack of mouse/resize support might need re-evaluation or could inadvertently expose new interaction possibilities.","severity":"gotcha","affected_versions":">=1.4.0"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}