Skip to main content

Simple Python terminal (TUI) multi-line editor

Project description

Features:

  • simple multi-line editor

  • not whole screen but only next N lines

  • status bar (supporting multiple lines): show interactive feedback. e.g. mark edits, show number of edits, show diff in separate plane or so

This is just a simple multi-line editor for the terminal (VT100). It is a bit like input (doc) but supporting multiple lines and behaving more like a simple editor. It is different to other editors and other TUI frameworks in that it will not go full-screen but only use the last N lines of the terminal. It is intended to be simple and flexible and hackable, i.e. the behavior can be changed, typing events can be handled, etc. It takes extra care to handle terminal resizing. It also supports to show a status bar (potential multi-line).

Homepage: https://github.com/albertz/py-tui-editor

Installation

The project is on PyPI: https://pypi.org/project/tui-editor/

Thus you can just do:

pip install tui-editor

Usage

Simple empty editor:

>>> from tui_editor import TuiEditor
>>> editor = TuiEditor()
>>> editor.edit()
>>> editor.get_text()
'Hello World!'

Predefined editable text:

>>> from tui_editor import TuiEditor
>>> editor = TuiEditor()
>>> editor.set_text('Hello World!')
>>> editor.edit()
>>> editor.get_text()
'Hello World!'

See demo-prompt.py and demo-editor.py.

Screenshot

https://raw.githubusercontent.com/albertz/py-tui-editor/master/screenshots/2022-09-02.png?sanitize=true

Screencast

https://img.youtube.com/vi/zIFMyBkYwqg/maxresdefault.jpg

This shows the demo-prompt.py and demo-editor.py.

https://img.youtube.com/vi/4ERr0o9k72Y/maxresdefault.jpg

This uses a very custom small app, which I use to take over annotated PDF edits into my Latex file, where I get the editor, and it shows me the live-diff in the status bar of the editor.

Licence

MIT License

History

2015 Paul Sokolovsky: picotui project seditor.py example. 2022 Albert Zeyer: extend and redesign and package just the text editor as this library.

References

https://en.wikipedia.org/wiki/ANSI_escape_code https://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tui-editor-1.20240813.3421.tar.gz (11.4 kB view details)

Uploaded Source

File details

Details for the file tui-editor-1.20240813.3421.tar.gz.

File metadata

  • Download URL: tui-editor-1.20240813.3421.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for tui-editor-1.20240813.3421.tar.gz
Algorithm Hash digest
SHA256 cdd81f55c6bd37bfca905029a01e3b61f3de8b7679d2c590decb562bf45205d3
MD5 348e9346490254fdacd79b88f558647e
BLAKE2b-256 4bd0bbceae3999c605f0a8c88c42433b03441da847d334432fb08cead854020e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page