Skip to main content

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 $EDITOR either manually or via the Git-flavored heuristics in get-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


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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file get_unicode_multiline_input_with_editor-0.1.0a1.tar.gz.

File metadata

File hashes

Hashes for get_unicode_multiline_input_with_editor-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 03dafda3e865b23d877410529e6441a6880c760d1aa5cde0d5b00cfbf639d7e8
MD5 0ecabf27c3dcb0adfb5db7469b2bbd8c
BLAKE2b-256 2e3681a9b80901f9fc5489f212ad4b7252abe135c3fa7e32528622b39cdc7c1a

See more details on using hashes here.

File details

Details for the file get_unicode_multiline_input_with_editor-0.1.0a1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for get_unicode_multiline_input_with_editor-0.1.0a1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c0c0abf65823665f975a7fa7db63675d5726c14afd39d0aaddef9e60d4ee77f8
MD5 3e896aefccd7fc7991a0f0a41388e859
BLAKE2b-256 cfd7d7557d7694aa7edf7dd8fbe45eb84efbbd8f0eaf4d915bc2d6a8648314c1

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