libbe.ui.util.editor

Define editor_string(), a function that invokes an editor to accept user-produced text as a string.

exception libbe.ui.util.editor.CantFindEditor
libbe.ui.util.editor.comment_string(comment)
>>> comment_string('hello') == comment_marker+"hello"
True
libbe.ui.util.editor.editor_string(comment=None, encoding=None)

Invokes the editor, and returns the user-produced text as a string

>>> if "EDITOR" in os.environ:
...     del os.environ["EDITOR"]
>>> if "VISUAL" in os.environ:
...     del os.environ["VISUAL"]
>>> editor_string()
Traceback (most recent call last):
CantFindEditor: Can't find editor to get string from
>>> os.environ["EDITOR"] = "echo bar > "
>>> editor_string()
u'bar\n'
>>> os.environ["VISUAL"] = "echo baz > "
>>> editor_string()
u'baz\n'
>>> os.environ["VISUAL"] = "echo 'baz\n== Anything below this line will be ignored\nHi' > "
>>> editor_string()
u'baz\n'
>>> del os.environ["EDITOR"]
>>> del os.environ["VISUAL"]
libbe.ui.util.editor.trimmed_string(instring)
>>> trimmed_string("hello\n"+comment_marker)
u'hello\n'
>>> trimmed_string("hi!\n" + comment_string('Booga'))
u'hi!\n'

Previous topic

libbe.ui.util

Next topic

libbe.ui.util.pager

This Page