././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1749105192.418394 curtsies-0.4.3/0000755000175100001660000000000015020235050012752 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1749105188.0 curtsies-0.4.3/LICENSE0000644000175100001660000000214615020235044013765 0ustar00runnerdockerThe MIT License (MIT) Copyright (c) 2014 Thomas Ballinger Copyright (c) 2020-2023 Sebastian Ramacher Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1749105188.0 curtsies-0.4.3/MANIFEST.in0000644000175100001660000000012315020235044014507 0ustar00runnerdockerinclude LICENSE include tests/*.py include examples/*.py include curtsies/py.typed ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1749105192.418394 curtsies-0.4.3/PKG-INFO0000644000175100001660000001026615020235050014054 0ustar00runnerdockerMetadata-Version: 2.4 Name: curtsies Version: 0.4.3 Summary: Curses-like terminal wrapper, with colored strings! Home-page: https://github.com/bpython/curtsies Author: Thomas Ballinger Author-email: thomasballinger@gmail.com License: MIT Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: POSIX Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Requires-Python: >=3.10 Description-Content-Type: text/markdown License-File: LICENSE Requires-Dist: blessed>=1.5 Requires-Dist: cwcwidth Dynamic: license-file [![Documentation Status](https://readthedocs.org/projects/curtsies/badge/?version=latest)](https://readthedocs.org/projects/curtsies/?badge=latest) ![Curtsies Logo](http://ballingt.com/assets/curtsiestitle.png) Curtsies is a Python 3.6+ compatible library for interacting with the terminal. This is what using (nearly every feature of) curtsies looks like: ```python import random import sys from curtsies import FullscreenWindow, Input, FSArray from curtsies.fmtfuncs import red, bold, green, on_blue, yellow print(yellow('this prints normally, not to the alternate screen')) with FullscreenWindow() as window: a = FSArray(window.height, window.width) msg = red(on_blue(bold('Press escape to exit, space to clear.'))) a[0:1, 0:msg.width] = [msg] window.render_to_terminal(a) with Input() as input_generator: for c in input_generator: if c == '': break elif c == '': a = FSArray(window.height, window.width) else: s = repr(c) row = random.choice(range(window.height)) column = random.choice(range(window.width-len(s))) color = random.choice([red, green, on_blue, yellow]) a[row, column:column+len(s)] = [color(s)] window.render_to_terminal(a) ``` Paste it in a `something.py` file and try it out! Installation: `pip install curtsies` [Documentation](http://curtsies.readthedocs.org/en/latest/) Primer ------ [FmtStr](http://curtsies.readthedocs.org/en/latest/FmtStr.html) objects are strings formatted with colors and styles displayable in a terminal with [ANSI escape sequences](http://en.wikipedia.org/wiki/ANSI_escape_code>`_). ![](https://i.imgur.com/bRLI134.png) [FSArray](http://curtsies.readthedocs.org/en/latest/FSArray.html) objects contain multiple such strings with each formatted string on its own row, and FSArray objects can be superimposed on each other to build complex grids of colored and styled characters through composition. (the import statement shown below is outdated) ![](http://i.imgur.com/rvTRPv1.png) Such grids of characters can be rendered to the terminal in alternate screen mode (no history, like `Vim`, `top` etc.) by [FullscreenWindow](http://curtsies.readthedocs.org/en/latest/window.html#curtsies.window.FullscreenWindow) objects or normal history-preserving screen by [CursorAwareWindow](http://curtsies.readthedocs.org/en/latest/window.html#curtsies.window.CursorAwareWindow) objects. User keyboard input events like pressing the up arrow key are detected by an [Input](http://curtsies.readthedocs.org/en/latest/input.html) object. Examples -------- * [Tic-Tac-Toe](/examples/tictactoeexample.py) ![](http://i.imgur.com/AucB55B.png) * [Avoid the X's game](/examples/gameexample.py) ![](http://i.imgur.com/nv1RQd3.png) * [Bpython-curtsies uses curtsies](http://ballingt.com/2013/12/21/bpython-curtsies.html) [![](http://i.imgur.com/r7rZiBS.png)](http://www.youtube.com/watch?v=lwbpC4IJlyA) * [More examples](/examples) About ----- * [Curtsies Documentation](http://curtsies.readthedocs.org/en/latest/) * Curtsies was written to for [bpython-curtsies](http://ballingt.com/2013/12/21/bpython-curtsies.html) * `#bpython` on irc is a good place to talk about Curtsies, but feel free to open an issue if you're having a problem! * Thanks to the many contributors! * If all you need are colored strings, consider one of these [other libraries](http://curtsies.readthedocs.io/en/latest/FmtStr.html#fmtstr-rationale)! ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1749105188.0 curtsies-0.4.3/README.md0000644000175100001660000000677015020235044014246 0ustar00runnerdocker[![Documentation Status](https://readthedocs.org/projects/curtsies/badge/?version=latest)](https://readthedocs.org/projects/curtsies/?badge=latest) ![Curtsies Logo](http://ballingt.com/assets/curtsiestitle.png) Curtsies is a Python 3.6+ compatible library for interacting with the terminal. This is what using (nearly every feature of) curtsies looks like: ```python import random import sys from curtsies import FullscreenWindow, Input, FSArray from curtsies.fmtfuncs import red, bold, green, on_blue, yellow print(yellow('this prints normally, not to the alternate screen')) with FullscreenWindow() as window: a = FSArray(window.height, window.width) msg = red(on_blue(bold('Press escape to exit, space to clear.'))) a[0:1, 0:msg.width] = [msg] window.render_to_terminal(a) with Input() as input_generator: for c in input_generator: if c == '': break elif c == '': a = FSArray(window.height, window.width) else: s = repr(c) row = random.choice(range(window.height)) column = random.choice(range(window.width-len(s))) color = random.choice([red, green, on_blue, yellow]) a[row, column:column+len(s)] = [color(s)] window.render_to_terminal(a) ``` Paste it in a `something.py` file and try it out! Installation: `pip install curtsies` [Documentation](http://curtsies.readthedocs.org/en/latest/) Primer ------ [FmtStr](http://curtsies.readthedocs.org/en/latest/FmtStr.html) objects are strings formatted with colors and styles displayable in a terminal with [ANSI escape sequences](http://en.wikipedia.org/wiki/ANSI_escape_code>`_). ![](https://i.imgur.com/bRLI134.png) [FSArray](http://curtsies.readthedocs.org/en/latest/FSArray.html) objects contain multiple such strings with each formatted string on its own row, and FSArray objects can be superimposed on each other to build complex grids of colored and styled characters through composition. (the import statement shown below is outdated) ![](http://i.imgur.com/rvTRPv1.png) Such grids of characters can be rendered to the terminal in alternate screen mode (no history, like `Vim`, `top` etc.) by [FullscreenWindow](http://curtsies.readthedocs.org/en/latest/window.html#curtsies.window.FullscreenWindow) objects or normal history-preserving screen by [CursorAwareWindow](http://curtsies.readthedocs.org/en/latest/window.html#curtsies.window.CursorAwareWindow) objects. User keyboard input events like pressing the up arrow key are detected by an [Input](http://curtsies.readthedocs.org/en/latest/input.html) object. Examples -------- * [Tic-Tac-Toe](/examples/tictactoeexample.py) ![](http://i.imgur.com/AucB55B.png) * [Avoid the X's game](/examples/gameexample.py) ![](http://i.imgur.com/nv1RQd3.png) * [Bpython-curtsies uses curtsies](http://ballingt.com/2013/12/21/bpython-curtsies.html) [![](http://i.imgur.com/r7rZiBS.png)](http://www.youtube.com/watch?v=lwbpC4IJlyA) * [More examples](/examples) About ----- * [Curtsies Documentation](http://curtsies.readthedocs.org/en/latest/) * Curtsies was written to for [bpython-curtsies](http://ballingt.com/2013/12/21/bpython-curtsies.html) * `#bpython` on irc is a good place to talk about Curtsies, but feel free to open an issue if you're having a problem! * Thanks to the many contributors! * If all you need are colored strings, consider one of these [other libraries](http://curtsies.readthedocs.io/en/latest/FmtStr.html#fmtstr-rationale)! ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1749105192.4113941 curtsies-0.4.3/curtsies/0000755000175100001660000000000015020235050014613 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1749105188.0 curtsies-0.4.3/curtsies/__init__.py0000644000175100001660000000043215020235044016726 0ustar00runnerdocker"""Terminal-formatted strings""" __version__ = "0.4.3" from .window import FullscreenWindow, CursorAwareWindow from .input import Input from .termhelpers import Nonblocking, Cbreak, Termmode from .formatstring import FmtStr, fmtstr from .formatstringarray import FSArray, fsarray ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1749105188.0 curtsies-0.4.3/curtsies/configfile_keynames.py0000644000175100001660000000176015020235044021175 0ustar00runnerdocker"""Mapping of config file names of keys to curtsies names In the style of bpython config files and keymap""" from typing import Tuple SPECIALS = { "C-[": "", "C-^": "", "C-_": "", } # TODO make a precalculated version of this class KeyMap: """Maps config file key syntax to Curtsies names""" def __getitem__(self, key: str) -> tuple[str, ...]: if not key: # Unbound key return () elif key in SPECIALS: return (SPECIALS[key],) elif key[1:] and key[:2] == "C-": return ("" % key[2:],) elif key[1:] and key[:2] == "M-": return ( "" % key[2:], "" % key[2:], ) elif key[0] == "F" and key[1:].isdigit(): return ("" % int(key[1:]),) else: raise KeyError( "Configured keymap (%s)" % key + " does not exist in bpython.keys" ) keymap = KeyMap() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1749105188.0 curtsies-0.4.3/curtsies/curtsieskeys.py0000644000175100001660000001115515020235044017730 0ustar00runnerdocker"""All the key sequences""" # If you add a binding, add something about your setup # if you can figure out why it's different # Special names are for multi-character keys, or key names # that would be hard to write in a config file # TODO add PAD keys hack as in bpython.cli # fmt: off CURTSIES_NAMES = { b' ': '', b'\x1b ': '', b'\t': '', b'\x1b[Z': '', b'\x1b[A': '', b'\x1b[B': '', b'\x1b[C': '', b'\x1b[D': '', b'\x1bOA': '', # in issue 92 its shown these should be normal arrows, b'\x1bOB': '', # not ctrl-arrows as we previously had them. b'\x1bOC': '', b'\x1bOD': '', b'\x1b[1;5A': '', b'\x1b[1;5B': '', b'\x1b[1;5C': '', # reported by myint b'\x1b[1;5D': '', # reported by myint b'\x1b[5A': '', # not sure about these, someone wanted them for bpython b'\x1b[5B': '', b'\x1b[5C': '', b'\x1b[5D': '', b'\x1b[1;9A': '', b'\x1b[1;9B': '', b'\x1b[1;9C': '', b'\x1b[1;9D': '', b'\x1b[1;10A': '', b'\x1b[1;10B': '', b'\x1b[1;10C': '', b'\x1b[1;10D': '', b'\x1bOP': '', b'\x1bOQ': '', b'\x1bOR': '', b'\x1bOS': '', # see bpython #626 b'\x1b[11~': '', b'\x1b[12~': '', b'\x1b[13~': '', b'\x1b[14~': '', b'\x1b[15~': '', b'\x1b[17~': '', b'\x1b[18~': '', b'\x1b[19~': '', b'\x1b[20~': '', b'\x1b[21~': '', b'\x1b[23~': '', b'\x1b[24~': '', b'\x00': '', b'\x1c': '', b'\x1d': '', b'\x1e': '', b'\x1f': '', b'\x7f': '', # for some folks this is ctrl-backspace apparently b'\x1b\x7f': '', b'\xff': '', b'\x1b\x1b[A': '', # uncertain about these four b'\x1b\x1b[B': '', b'\x1b\x1b[C': '', b'\x1b\x1b[D': '', b'\x1b': '', b'\x1b[1~': '', b'\x1b[4~': '', b'\x1b\x1b[5~':'', b'\x1b\x1b[6~':'', b'\x1b[H': '', # reported by amorozov in bpython #490 b'\x1b[F': '', # reported by amorozov in bpython #490 b'\x1bOH': '', # reported by mixmastamyk in curtsies #78 b'\x1bOF': '', # reported by mixmastamyk in curtsies #78 # not fixing for back compat. # (b"\x1b[1~": u'', # find b"\x1b[2~": '', # insert (0) b"\x1b[3~": '', # delete (.), "Execute" b"\x1b[3;5~": '', # st (simple terminal) see issue #169 b"\x1b[4h": '', b"\x1b[P": '', # not fixing for back compat. # (b"\x1b[4~": u'