Opens `$EDITOR` to get multi-line input as a list of Unicode strings, just like what `git commit` does.
Project description
get-unicode-multiline-input-with-editor
Opens $EDITOR to get multi-line input as a list of Unicode strings, just like what git commit does.
- Determines
$EDITOReither manually or via the Git-flavored heuristics inget-unicode-arguments-to-launch-editor - Supports optional initial content and comment lines
- Opens a temporary file in the editor to get multi-line input
- Ignores comment lines and blank lines in the result
- Works with Python 2+
Installation
pip install get-unicode-multiline-input-with-editor
Usage
# coding=utf-8
from __future__ import print_function
from get_unicode_multiline_input_with_editor import get_unicode_multiline_input_with_editor
result = get_unicode_multiline_input_with_editor(
unicode_initial_input_lines=[
u'Write something here...',
u'# Enter your text above.',
u'# Lines starting with # will be ignored.'
],
unicode_line_comments_start_with=u'#', # specify `None` to not skip over any line
editor=None # or specify e.g. 'vim'
)
print(result)
Assuming nano is the default editor, the user will see something like this:
GNU nano 7.2 /tmp/tmp9khfi5es.txt
Write something here...
# Enter your text above.
# Lines starting with # will be ignored.
^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute ^C Location M-U Undo M-A Set Mark
^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify ^_ Go To Line M-E Redo M-6 Copy
Afterward, if the user enters some text, print(result) basically prints whatever the user entered, minus the comments.
Contributing
Contributions welcome! Please open issues or pull requests on GitHub.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file get_unicode_multiline_input_with_editor-0.1.0a1.tar.gz.
File metadata
- Download URL: get_unicode_multiline_input_with_editor-0.1.0a1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03dafda3e865b23d877410529e6441a6880c760d1aa5cde0d5b00cfbf639d7e8
|
|
| MD5 |
0ecabf27c3dcb0adfb5db7469b2bbd8c
|
|
| BLAKE2b-256 |
2e3681a9b80901f9fc5489f212ad4b7252abe135c3fa7e32528622b39cdc7c1a
|
File details
Details for the file get_unicode_multiline_input_with_editor-0.1.0a1-py2.py3-none-any.whl.
File metadata
- Download URL: get_unicode_multiline_input_with_editor-0.1.0a1-py2.py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0c0abf65823665f975a7fa7db63675d5726c14afd39d0aaddef9e60d4ee77f8
|
|
| MD5 |
3e896aefccd7fc7991a0f0a41388e859
|
|
| BLAKE2b-256 |
cfd7d7557d7694aa7edf7dd8fbe45eb84efbbd8f0eaf4d915bc2d6a8648314c1
|