././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1633747340.7410862 curtsies-0.3.10/0000755000076500000240000000000000000000000012261 5ustar00tombstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1632589505.0 curtsies-0.3.10/LICENSE0000644000076500000240000000207300000000000013270 0ustar00tombstaffThe MIT License (MIT) Copyright (c) 2014 Thomas Ballinger 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=1632595191.0 curtsies-0.3.10/MANIFEST.in0000644000076500000240000000012300000000000014013 0ustar00tombstaffinclude LICENSE include tests/*.py include examples/*.py include curtsies/py.typed ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1633747340.7415361 curtsies-0.3.10/PKG-INFO0000644000076500000240000001020000000000000013347 0ustar00tombstaffMetadata-Version: 2.1 Name: curtsies Version: 0.3.10 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 Platform: UNKNOWN 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.6 Description-Content-Type: text/markdown License-File: LICENSE [![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=1632595191.0 curtsies-0.3.10/README.md0000644000076500000240000000677000000000000013552 0ustar00tombstaff[![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=1633747340.7095947 curtsies-0.3.10/curtsies/0000755000076500000240000000000000000000000014122 5ustar00tombstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1633747160.0 curtsies-0.3.10/curtsies/__init__.py0000644000076500000240000000043200000000000016232 0ustar00tombstaff"""Terminal-formatted strings""" __version__ = "0.3.10" 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=1632595191.0 curtsies-0.3.10/curtsies/configfile_keynames.py0000644000076500000240000000175700000000000020507 0ustar00tombstaff"""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=1632595191.0 curtsies-0.3.10/curtsies/curtsieskeys.py0000644000076500000240000001101200000000000017224 0ustar00tombstaff"""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~": '', # not fixing for back compat. # (b"\x1b[4~": u'