## libcurses
Framework and tools for multi-threaded, curses(3)-based, terminal applications.
* Write to screen from multiple threads.
* Use `libcurses.wrapper` instead of `curses.wrapper`.
* Use `libcurses.getkey` instead of `curses.getch`.
* Use `libcurses.getline` instead of `curses.getstr`.
* Preserve the cursor with context manager `libcurses.preserve_cursor`.
* Register callbacks with `register_fkey` to handle function-keys pressed
during `getkey` and `getline` processing.
* Register callbacks with `add_mouse_handler` to handle mouse events
during `getkey` and `getline` processing.
* Manage a logger destination, `LogSink`, to write to a curses window.
* A `Grid` framework.
### class Grid
Grid of windows.
A rectangular collection of windows with shared (collapsed) borders that
resize the windows to either side (syncronized shrink/expand) when moused upon.
+-------+---+------+ example `Grid`, 9 windows.
| | | |
+-------+---+------+
| | |
+------+----+------+
| | |
+------+--+--------+
| | |
+---------+--------+
Drag and drop an interior border to resize the windows on either side.
Double-click an interior border to enter Resize Mode:
* scroll-wheel and arrow-keys move the border, and
* click anywhere, Enter and Esc to exit Resize Mode.
Grids also provide a wrapper around `curses.newwin` that takes positioning
parameters that describe the spatial-relationship to other windows on the
screen, instead of (y,x) coordinates:
+--------+ +--------+
| | | ^ |
| |<------ left2r --| | |
| | | | |
|<---------------- left ---| | |
| | | | |
+--------+ +--|-----+
| | | ^
bottom2t | | bottom top | | top2b
v | | |
+-----|--+ +--------+
| | | | |
| | |-- right ---------------->|
| | | | |
| | |-- right2l ----->| |
| v | | |
+--------+ +--------+
For example, this 3x13 grid with three 3x5 boxes may be described at least
three different ways:
+---+---+---+
| a | b | c |
+---+---+---+
grid = Grid(curses.newwin(3, 13))
1) a = grid.box('a', 3, 5)
b = grid.box('b', 3, 5, left2r=a)
c = grid.box('c', 3, 5, left2r=b)
2) c = grid.box('c', 3, 5, right=grid)
b = grid.box('b', 3, 5, right=c)
a = grid.box('a', 3, 5, right=b)
3) a = grid.box('a', 3, 5, left=grid)
c = grid.box('c', 3, 5, right=grid)
b = grid.box('b', 3, 0, left2r=a, right=c)
If two endpoints are given (such as 3b), the length will be calculated to
fill the gap between the endpoints.
### class LogSink
Logger sink to curses window.
The `LogSink` class provides a logger destination that writes log
messages to a curses window, and methods that control various
logging features.
### class MouseEvent
Wrap `curses.getmouse` with additional, convenience-properties.
`MouseEvent` encapsulates the results of `curses.getmouse`,
x x-coordinate.
y y-coordinate.
bstate bitmask describing the type of event.
and provides these additional properties:
button button number (1-5).
nclicks number of clicks (1-3).
is_pressed True if button is pressed.
is_released True if button was just released.
is_alt True if Alt key is held.
is_ctrl True if Ctrl key is held.
is_shift True if Shift key is held.
is_moving True if mouse is moving.
### method add_mouse_handler
Call `func` with `args` when mouse event happens at (y, x).
### method clear_mouse_handlers
Remove all mouse handlers.
### function get_colormap
Return map of `loguru-level-name` to `curses-color/attr`.
Call after creating all custom levels with `logger.level()`.
Map is build once and cached; repeated calls return same map.
### function getkey
Read and return a character from window.
Args:
win: curses window to read from.
no_mouse: ignore mouse events (for internal use).
Return:
-1 when no-input in no-delay mode, or
None on end of file, or
>=0 int character read.
### function getline
Read and return a line of input from window.
A line is terminated with CR, LF or KEY_ENTER.
Backspace deletes the previous character.
NAK (ctrl-U) kills the line.
Mouse events are handled.
### function preserve_cursor
Context manager to save and restore the cursor.
### function register_fkey
Register `func` to be called when `key` is pressed.
Args:
func: callable, to be called on receipt of `key`.
key: the key to be captured, e.g., `curses.KEY_F1`,
or zero (0) for all keys.
`func` is appended to a list for the `key`;
pass func=None to remove list of funcs for `key` from registry.
### function wrapper
Use instead of `curses.wrapper`.
Raw data
{
"_id": null,
"home_page": null,
"name": "rlane-libcurses",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "curses, python, xterm-256color, mouse",
"author": null,
"author_email": "Russel Lane <russel@rlane.com>",
"download_url": "https://files.pythonhosted.org/packages/1c/bc/aaaa120eef2505fe9565396f3ff0df22aa94d1bf5b3a4b0c796f7dc5d97c/rlane_libcurses-1.0.9.tar.gz",
"platform": null,
"description": "## libcurses\n\nFramework and tools for multi-threaded, curses(3)-based, terminal applications.\n\n* Write to screen from multiple threads.\n\n * Use `libcurses.wrapper` instead of `curses.wrapper`.\n * Use `libcurses.getkey` instead of `curses.getch`.\n * Use `libcurses.getline` instead of `curses.getstr`.\n * Preserve the cursor with context manager `libcurses.preserve_cursor`.\n\n* Register callbacks with `register_fkey` to handle function-keys pressed\n during `getkey` and `getline` processing.\n\n* Register callbacks with `add_mouse_handler` to handle mouse events\n during `getkey` and `getline` processing.\n\n* Manage a logger destination, `LogSink`, to write to a curses window.\n\n* A `Grid` framework.\n\n\n### class Grid\n\nGrid of windows.\n\nA rectangular collection of windows with shared (collapsed) borders that\nresize the windows to either side (syncronized shrink/expand) when moused upon.\n\n +-------+---+------+ example `Grid`, 9 windows.\n | | | |\n +-------+---+------+\n | | |\n +------+----+------+\n | | |\n +------+--+--------+\n | | |\n +---------+--------+\n\nDrag and drop an interior border to resize the windows on either side.\n\nDouble-click an interior border to enter Resize Mode:\n * scroll-wheel and arrow-keys move the border, and\n * click anywhere, Enter and Esc to exit Resize Mode.\n\nGrids also provide a wrapper around `curses.newwin` that takes positioning\nparameters that describe the spatial-relationship to other windows on the\nscreen, instead of (y,x) coordinates:\n\n +--------+ +--------+\n | | | ^ |\n | |<------ left2r --| | |\n | | | | |\n |<---------------- left ---| | |\n | | | | |\n +--------+ +--|-----+\n | | | ^\n bottom2t | | bottom top | | top2b\n v | | |\n +-----|--+ +--------+\n | | | | |\n | | |-- right ---------------->|\n | | | | |\n | | |-- right2l ----->| |\n | v | | |\n +--------+ +--------+\n\nFor example, this 3x13 grid with three 3x5 boxes may be described at least\nthree different ways:\n\n +---+---+---+\n | a | b | c |\n +---+---+---+\n\n grid = Grid(curses.newwin(3, 13))\n\n 1) a = grid.box('a', 3, 5)\n b = grid.box('b', 3, 5, left2r=a)\n c = grid.box('c', 3, 5, left2r=b)\n\n 2) c = grid.box('c', 3, 5, right=grid)\n b = grid.box('b', 3, 5, right=c)\n a = grid.box('a', 3, 5, right=b)\n\n 3) a = grid.box('a', 3, 5, left=grid)\n c = grid.box('c', 3, 5, right=grid)\n b = grid.box('b', 3, 0, left2r=a, right=c)\n\nIf two endpoints are given (such as 3b), the length will be calculated to\nfill the gap between the endpoints.\n\n\n### class LogSink\n\nLogger sink to curses window.\n\nThe `LogSink` class provides a logger destination that writes log\nmessages to a curses window, and methods that control various\nlogging features.\n\n\n### class MouseEvent\n\nWrap `curses.getmouse` with additional, convenience-properties.\n\n`MouseEvent` encapsulates the results of `curses.getmouse`,\n\n x x-coordinate.\n y y-coordinate.\n bstate bitmask describing the type of event.\n\nand provides these additional properties:\n\n button button number (1-5).\n nclicks number of clicks (1-3).\n is_pressed True if button is pressed.\n is_released True if button was just released.\n is_alt True if Alt key is held.\n is_ctrl True if Ctrl key is held.\n is_shift True if Shift key is held.\n is_moving True if mouse is moving.\n\n\n### method add_mouse_handler\n\nCall `func` with `args` when mouse event happens at (y, x).\n\n### method clear_mouse_handlers\n\nRemove all mouse handlers.\n\n### function get_colormap\n\nReturn map of `loguru-level-name` to `curses-color/attr`.\n\nCall after creating all custom levels with `logger.level()`.\nMap is build once and cached; repeated calls return same map.\n\n\n### function getkey\n\nRead and return a character from window.\n\nArgs:\n win: curses window to read from.\n no_mouse: ignore mouse events (for internal use).\n\nReturn:\n -1 when no-input in no-delay mode, or\n None on end of file, or\n >=0 int character read.\n\n\n### function getline\n\nRead and return a line of input from window.\n\nA line is terminated with CR, LF or KEY_ENTER.\nBackspace deletes the previous character.\nNAK (ctrl-U) kills the line.\nMouse events are handled.\n\n\n### function preserve_cursor\n\nContext manager to save and restore the cursor.\n\n### function register_fkey\n\nRegister `func` to be called when `key` is pressed.\n\nArgs:\n func: callable, to be called on receipt of `key`.\n key: the key to be captured, e.g., `curses.KEY_F1`,\n or zero (0) for all keys.\n\n`func` is appended to a list for the `key`;\npass func=None to remove list of funcs for `key` from registry.\n\n\n### function wrapper\n\nUse instead of `curses.wrapper`.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Curses based boxes, menus, loggers",
"version": "1.0.9",
"project_urls": {
"Homepage": "https://github.com/russellane/libcurses"
},
"split_keywords": [
"curses",
" python",
" xterm-256color",
" mouse"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "077097fbe8548ea3bb7ab9f3be6402c73c4f42fa40776a4ea10c8b94857258b8",
"md5": "6fb41f88d114fdeccce8a0924f6e47b3",
"sha256": "4f69d420f9ac4c54009f809ab5eede0890a9c0c2af316dd41acdd7addacfae2e"
},
"downloads": -1,
"filename": "rlane_libcurses-1.0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6fb41f88d114fdeccce8a0924f6e47b3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 24428,
"upload_time": "2024-11-16T17:30:15",
"upload_time_iso_8601": "2024-11-16T17:30:15.228499Z",
"url": "https://files.pythonhosted.org/packages/07/70/97fbe8548ea3bb7ab9f3be6402c73c4f42fa40776a4ea10c8b94857258b8/rlane_libcurses-1.0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1cbcaaaa120eef2505fe9565396f3ff0df22aa94d1bf5b3a4b0c796f7dc5d97c",
"md5": "e3e30676e1600aa3c7dc207eb146d1e7",
"sha256": "041a4b7e381b97121db17b3cb65876c911ceffdeb9cd177feeae764a5511f30f"
},
"downloads": -1,
"filename": "rlane_libcurses-1.0.9.tar.gz",
"has_sig": false,
"md5_digest": "e3e30676e1600aa3c7dc207eb146d1e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 27046,
"upload_time": "2024-11-16T17:30:16",
"upload_time_iso_8601": "2024-11-16T17:30:16.945120Z",
"url": "https://files.pythonhosted.org/packages/1c/bc/aaaa120eef2505fe9565396f3ff0df22aa94d1bf5b3a4b0c796f7dc5d97c/rlane_libcurses-1.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-16 17:30:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "russellane",
"github_project": "libcurses",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "rlane-libcurses"
}