Skip to main content

Simple Python terminal (TUI) multi-line editor

Project description

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!'

Screenshot

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

Motivation

Python TUI?

What I want:

  • simple multi-line editor

  • not whole screen but only next N lines

  • show interactive feedback. e.g. mark edits, show number of edits, show diff in separate plane or so

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.20220821.223215.tar.gz (9.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: tui-editor-1.20220821.223215.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for tui-editor-1.20220821.223215.tar.gz
Algorithm Hash digest
SHA256 29e163fa2d029e00652a262a4c937321aaa06f387e60b609fff05458fb1ac0b1
MD5 a7849b769c41069158a00337cf5a941b
BLAKE2b-256 bf1e29084b1d9bf18c52e75030fe56dc52e3de9471bf6be94f82722fd5a62bbb

See more details on using hashes here.

Supported by

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