[Python-modules-commits] [prompt-toolkit] 01/04: Import prompt-toolkit_0.57.orig.tar.gz
Scott Kitterman
kitterman at moszumanska.debian.org
Sun Jan 10 09:12:56 UTC 2016
This is an automated email from the git hooks/post-receive script.
kitterman pushed a commit to branch master
in repository prompt-toolkit.
commit bf27329a4e483cdf3894b4d0d31726bd3007a746
Author: Scott Kitterman <scott at kitterman.com>
Date: Sun Jan 10 04:08:53 2016 -0500
Import prompt-toolkit_0.57.orig.tar.gz
---
CHANGELOG | 92 +++++
MANIFEST.in | 1 +
PKG-INFO | 18 +-
README.rst | 16 +-
TODO.rst | 39 ++
...ncio-prompt.py => asyncio-prompt-simplified.py} | 28 +-
examples/asyncio-prompt.py | 34 +-
examples/autocompletion-enter.py | 39 ++
examples/bottom-toolbar.py | 10 +-
examples/clock-input.py | 2 +-
examples/colored-prompt.py | 29 +-
examples/regular-language.py | 17 +-
examples/switch-between-vi-emacs.py | 32 ++
examples/system-autocompletion.py | 17 +
examples/system-prompt.py | 3 +-
examples/up-arrow-partial-string-matching.py | 3 +-
prompt_toolkit.egg-info/PKG-INFO | 18 +-
prompt_toolkit.egg-info/SOURCES.txt | 21 +-
prompt_toolkit.egg-info/pbr.json | 1 -
prompt_toolkit/__init__.py | 3 +
prompt_toolkit/application.py | 33 +-
prompt_toolkit/buffer.py | 57 +--
prompt_toolkit/buffer_mapping.py | 92 +++++
prompt_toolkit/clipboard/base.py | 2 +-
prompt_toolkit/contrib/completers/base.py | 20 +-
prompt_toolkit/contrib/completers/filesystem.py | 15 +
prompt_toolkit/contrib/completers/system.py | 10 +-
.../contrib/regular_languages/__init__.py | 2 +-
.../contrib/regular_languages/compiler.py | 2 +-
prompt_toolkit/contrib/regular_languages/lexer.py | 1 +
prompt_toolkit/contrib/telnet/server.py | 6 +-
prompt_toolkit/document.py | 149 +++++++-
prompt_toolkit/enums.py | 2 +-
prompt_toolkit/eventloop/asyncio_posix.py | 2 +-
prompt_toolkit/eventloop/asyncio_win32.py | 2 +-
prompt_toolkit/eventloop/base.py | 7 +-
prompt_toolkit/eventloop/posix.py | 130 ++++---
prompt_toolkit/eventloop/posix_utils.py | 8 +-
prompt_toolkit/eventloop/win32.py | 2 +-
prompt_toolkit/filters/cli.py | 4 +-
prompt_toolkit/focus_stack.py | 60 ---
prompt_toolkit/input.py | 3 +
prompt_toolkit/interface.py | 160 +++++---
prompt_toolkit/key_binding/bindings/basic.py | 11 +-
prompt_toolkit/key_binding/bindings/emacs.py | 47 +--
prompt_toolkit/key_binding/bindings/scroll.py | 6 +-
prompt_toolkit/key_binding/bindings/vi.py | 218 +++++++----
prompt_toolkit/key_binding/manager.py | 37 +-
prompt_toolkit/key_binding/registry.py | 29 +-
prompt_toolkit/keys.py | 1 +
prompt_toolkit/layout/containers.py | 403 +++++++++++++++-----
prompt_toolkit/layout/controls.py | 419 +++++++++++++++------
prompt_toolkit/layout/dimension.py | 13 +-
prompt_toolkit/layout/highlighters.py | 209 ++++++++++
prompt_toolkit/layout/processors.py | 18 +-
prompt_toolkit/layout/screen.py | 21 +-
prompt_toolkit/layout/toolbars.py | 2 +-
prompt_toolkit/layout/utils.py | 56 ++-
prompt_toolkit/mouse_events.py | 3 +
prompt_toolkit/output.py | 13 +
prompt_toolkit/renderer.py | 97 +++--
prompt_toolkit/selection.py | 2 +-
prompt_toolkit/shortcuts.py | 105 +++---
prompt_toolkit/styles.py | 134 ++++---
prompt_toolkit/terminal/vt100_input.py | 54 ++-
prompt_toolkit/terminal/vt100_output.py | 219 ++++++++---
prompt_toolkit/terminal/win32_input.py | 9 +-
prompt_toolkit/terminal/win32_output.py | 66 +++-
prompt_toolkit/utils.py | 72 ++++
setup.cfg | 4 +-
setup.py | 4 +-
tests/buffer_tests/__init__.py | 102 +++++
tests/contrib_tests.py | 249 ++++++++++++
tests/document_tests/__init__.py | 65 ++++
tests/inputstream_tests/__init__.py | 125 ++++++
tests/key_binding_tests/__init__.py | 71 ++++
tests/layout_tests/__init__.py | 29 ++
tests/regular_languages_tests/__init__.py | 102 +++++
tests/run_tests.py | 59 +++
tests/screen_tests/__init__.py | 96 +++++
tests/utils_tests/__init__.py | 41 ++
81 files changed, 3484 insertions(+), 919 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3409e77..de2d7f6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,98 @@
CHANGELOG
=========
+About the version numbering:
+ As long as the version number starts with a zero, we allow backwards
+ incompatible changes between each release. This is required order to move
+ forward. However, we do our best to keep it to a minimum and ensure
+ backwards-compatibility in the most used public APIs.
+ When the library stabilizes, which is hopefully very soon, we will switch
+ to a <breaking>.<feature>.<fix> style of numbering.
+
+
+0.57: 2016-01-04
+----------------
+
+Fixes:
+- Made `max_render_postpone_time` configurable. The current default was bad.
+ (We should probably always draw the UI once every cycle of the event loop.)
+
+
+0.56: 2016-01-03
+----------------
+
+Fixes:
+- Fix in bracketed paste. It was not correctly enabled for each prompt.
+
+
+0.55: 2016-01-03
+----------------
+
+New features:
+- Implemented bracketed paste mode. (This allows much faster pasting, as well
+ as pasting without going into paste mode. This makes sure that indentation in
+ ptpython for instance is kept correctly.)
+- Added support for italic output and blink. (For terminals that support it.)
+- Added get_horizontal_scroll, get_vertical_scroll and always_hide_cursor
+ parameters to Window.
+- Refactoring of the posix event loop. Better scheduling of all tasks/FDs to
+ avoid starvation. (Everything should feel more responsive in high CPU
+ situations.)
+- Added get_default_char function to TokenListControl.
+- AppendAutoSuggestion now accepts a token parameter.
+- Support for ansi color names in styles.
+- Accept get_width/get_height parameters in Float.
+- Added Output.write_raw and accept 'raw' parameter in
+ CommandLineInterface.stdout_proxy.
+- Better caching of tokens in TokenListControl.
+- Add mouse support to TokenListControl.
+- Display "Window too small" when the window becomes too small.
+- Added 'bell' function to Output.
+- Accept weights in HSplit/VSplit.
+- Added Registry.remove_binding method to dynamically remove key bindings.
+- Added focus_on_click parameter to BufferControl.
+- Introduced BufferMapping class as a wrapper around the buffers dictionary.
+ This one also contains the focus stack.
+- Improved 'v' and 'V' key bindings. Allow switching between line and character
+ selection modes.
+- Added layout.highlighters. A new, much faster way to do selection and search
+ highlighting.
+- Make search_state dynamic for key bindings.
+- Added 'sentence' option to WordCompleter.
+- Cache Document.lines for better performance.
+- Implementation of BLOCK selections. (Cut, copy, paste.)
+- Accept a 'reserve_space_for_menu' parameter in the shortcuts. (This is an
+ integer.)
+- Support for 24bit true color on vt100 terminals.
+- Added CommandLineInterface.on_invalidate event.
+- Added __version__ to __init__.py.
+
+Fixes:
+- Always show cursor in the 'done' state.
+- Allow HSplit to have zero children.
+- Bugfix for handling of backslash on Windows with some non-us keyboards.
+ (Ptpython issue #28.)
+- Never render characters outside the visible screen region.
+- Fix in WordCompleter. When case insensitive and input contained uppercase.
+- Highlight search match when the cursor is at any position on the match. (not
+ just the beginning.)
+
+Backwards-incompatible changes:
+(Most changes will probably not have an impact on external applications.)
+- Change in the `Style` API. This allows caching of Attrs in renderer and
+ faster rendering. (Style now has a get_attrs_for_token instead of a
+ get_token_to_attributes_dict method.)
+- Removed DefaultStyle. Created PygmentsStyle.from_defaults class method instead.
+- Removed AbortAction.IGNORE. This was ambiguous.
+- Accept 'cli' parameter in 'walk' and 'find_window_for_buffer_name'.
+- The focus stack is now stored in BufferMapping.
+- ViStateFilter and KeyBindingManager now accept a get_vi_state callable
+ instead of vi_state itself. (This way a key bindings registry becomes
+ stateless.)
+- HighlightSearchProcessor and HighlightSelectionProcessor became deprecated.
+ (Use highlighters instead.)
+
+
0.54: 2015-10-29
----------------
diff --git a/MANIFEST.in b/MANIFEST.in
index b010432..20c6caa 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,3 +1,4 @@
include *rst LICENSE CHANGELOG MANIFEST.in
recursive-include examples *.py
+recursive-include tests *.py
prune examples/sample?/build
diff --git a/PKG-INFO b/PKG-INFO
index 9dd9ece..bb1c0c3 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: prompt_toolkit
-Version: 0.54
+Version: 0.57
Summary: Library for building powerful interactive command lines in Python
Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
Author: Jonathan Slenders
@@ -45,6 +45,7 @@ Description: Python Prompt Toolkit
- Runs on all Python versions from 2.6 up to 3.4.
- Works well with Unicode double width characters. (Chinese input.)
- Selecting text for copy/paste. (Both Emacs and Vi style.)
+ - Support for `bracketed paste <https://cirw.in/blog/bracketed-paste>`_.
- Mouse support for cursor positioning and scrolling.
- Auto suggestions. (Like `fish shell <http://fishshell.com/>`_.)
- Multiple input buffers.
@@ -81,6 +82,12 @@ Description: Python Prompt Toolkit
pip install prompt-toolkit
+ For Conda, do:
+
+ ::
+
+ conda install -c https://conda.anaconda.org/conda-forge prompt_toolkit
+
Getting started
***************
@@ -107,17 +114,24 @@ Description: Python Prompt Toolkit
Projects using prompt-toolkit
*****************************
+ Shells:
+
- `ptpython <http://github.com/jonathanslenders/ptpython/>`_: Python REPL
- `ptpdb <http://github.com/jonathanslenders/ptpdb/>`_: Python debugger (pdb replacement)
- `pgcli <http://pgcli.com/>`_: Postgres client.
- `mycli <http://mycli.net>`_: MySql client.
- - `pyvim <http://github.com/jonathanslenders/pyvim/>`_: A Vim clone in pure Python
- `wharfee <http://wharfee.com/>`_: A Docker command line.
- `xonsh <http://xonsh.org/>`_: A Python-ish, BASHwards-compatible shell.
- `saws <https://github.com/donnemartin/saws>`_: A Supercharged AWS Command Line Interface.
- `cycli <https://github.com/nicolewhite/cycli>`_: A Command Line Interface for Cypher.
- `crash <https://github.com/crate/crash>`_: Crate command line client.
+ - `vcli <https://github.com/dbcli/vcli>`_: Vertica client.
+ - `aws-shell <https://github.com/awslabs/aws-shell>`_: An integrated shell for working with the AWS CLI.
+
+ Full screen applications:
+ - `pymux <http://github.com/jonathanslenders/pymux/>`_: A terminal multiplexer (like tmux) in pure Python.
+ - `pyvim <http://github.com/jonathanslenders/pyvim/>`_: A Vim clone in pure Python.
(Want your own project to be listed here? Please create a GitHub issue.)
diff --git a/README.rst b/README.rst
index 77294e2..3a7e95e 100644
--- a/README.rst
+++ b/README.rst
@@ -37,6 +37,7 @@ Some features:
- Runs on all Python versions from 2.6 up to 3.4.
- Works well with Unicode double width characters. (Chinese input.)
- Selecting text for copy/paste. (Both Emacs and Vi style.)
+- Support for `bracketed paste <https://cirw.in/blog/bracketed-paste>`_.
- Mouse support for cursor positioning and scrolling.
- Auto suggestions. (Like `fish shell <http://fishshell.com/>`_.)
- Multiple input buffers.
@@ -73,6 +74,12 @@ Installation
pip install prompt-toolkit
+For Conda, do:
+
+::
+
+ conda install -c https://conda.anaconda.org/conda-forge prompt_toolkit
+
Getting started
***************
@@ -99,17 +106,24 @@ to the above example. All strings are expected to be unicode strings.
Projects using prompt-toolkit
*****************************
+Shells:
+
- `ptpython <http://github.com/jonathanslenders/ptpython/>`_: Python REPL
- `ptpdb <http://github.com/jonathanslenders/ptpdb/>`_: Python debugger (pdb replacement)
- `pgcli <http://pgcli.com/>`_: Postgres client.
- `mycli <http://mycli.net>`_: MySql client.
-- `pyvim <http://github.com/jonathanslenders/pyvim/>`_: A Vim clone in pure Python
- `wharfee <http://wharfee.com/>`_: A Docker command line.
- `xonsh <http://xonsh.org/>`_: A Python-ish, BASHwards-compatible shell.
- `saws <https://github.com/donnemartin/saws>`_: A Supercharged AWS Command Line Interface.
- `cycli <https://github.com/nicolewhite/cycli>`_: A Command Line Interface for Cypher.
- `crash <https://github.com/crate/crash>`_: Crate command line client.
+- `vcli <https://github.com/dbcli/vcli>`_: Vertica client.
+- `aws-shell <https://github.com/awslabs/aws-shell>`_: An integrated shell for working with the AWS CLI.
+
+Full screen applications:
+- `pymux <http://github.com/jonathanslenders/pymux/>`_: A terminal multiplexer (like tmux) in pure Python.
+- `pyvim <http://github.com/jonathanslenders/pyvim/>`_: A Vim clone in pure Python.
(Want your own project to be listed here? Please create a GitHub issue.)
diff --git a/TODO.rst b/TODO.rst
new file mode 100644
index 0000000..e80bc0c
--- /dev/null
+++ b/TODO.rst
@@ -0,0 +1,39 @@
+
+
+- Focus stack needs to accept values other than `None`. This way we can better give the sidebar and exit message focus in ptpython, and it doesn't break focus in unpredictable ways in ptpdb.
+
+- Margins in BufferControl needs to be rendered independently. That way we can clean up code in the Screen class (which should not be responsible for calling margins.) The Screen class should however keep a mapping of the line numbers to input lines. This will also make it possible to invalidate margins independently of the main content. (Probably it's not worth having invalidation on the margins -- it's not heavy to calculate.)
+
+- Find a way to support backgrounds. A.k.a: find a way to eleminate Pygments.
+
+- support editing of larger buffers.
+
+
+Eleminate pygments
+------------------
+
+We need two things:
+- Tokens to identify chunks of text.
+- A stylesheet.
+For both, we still want to be able to use Pygments, by wrapping them, without loosing any performance.
+
+
+Pygments limitations:
+- Tokens have just one class, unlike CSS. A <span> in HTML can have several classes, where each class contributes to a part of the styling. (E.g. the background.)
+
+Token.History.Something
+
+
+Editing of larger buffers
+-------------------------
+
+We need two things:
+- A way to incrementally edit text of large buffers. (Keeping history.)
+- A way to incrementally lex the result of such a large buffer.
+
+
+Renames:
+-------
+
+WindowRenderInfo.rendered_height -> window_height
+WindowRenderInfo.input_line_to_screen_line -> should become property.
diff --git a/examples/asyncio-prompt.py b/examples/asyncio-prompt-simplified.py
similarity index 64%
copy from examples/asyncio-prompt.py
copy to examples/asyncio-prompt-simplified.py
index edc6dd4..84dad4c 100755
--- a/examples/asyncio-prompt.py
+++ b/examples/asyncio-prompt-simplified.py
@@ -19,7 +19,7 @@ possible. ::
"""
from __future__ import unicode_literals
from prompt_toolkit.interface import CommandLineInterface
-from prompt_toolkit.shortcuts import create_prompt_application, create_asyncio_eventloop
+from prompt_toolkit.shortcuts import prompt_async
import asyncio
import sys
@@ -28,8 +28,7 @@ import sys
loop = asyncio.get_event_loop()
- at asyncio.coroutine
-def print_counter():
+async def print_counter():
"""
Coroutine that prints counters.
"""
@@ -37,32 +36,19 @@ def print_counter():
while True:
print('Counter: %i' % i)
i += 1
- yield from asyncio.sleep(3)
+ await asyncio.sleep(3)
- at asyncio.coroutine
-def interactive_shell():
+async def interactive_shell():
"""
Coroutine that shows the interactive command line.
"""
- # Create an asyncio `EventLoop` object. This is a wrapper around the
- # asyncio loop that can be passed into prompt_toolkit.
- eventloop = create_asyncio_eventloop()
-
- # Create interface.
- cli = CommandLineInterface(
- application=create_prompt_application('Say something inside the event loop: '),
- eventloop=eventloop)
-
- # Patch stdout in something that will always print *above* the prompt when
- # something is written to stdout.
- sys.stdout = cli.stdout_proxy()
-
# Run echo loop. Read text from stdin, and reply it back.
while True:
try:
- result = yield from cli.run_async()
- print('You said: "%s"\n' % result.text)
+ result = await prompt_async('Say something inside the event loop: ',
+ patch_stdout=True)
+ print('You said: "%s"\n' % result)
except (EOFError, KeyboardInterrupt):
loop.stop()
print('Qutting event loop. Bye.')
diff --git a/examples/asyncio-prompt.py b/examples/asyncio-prompt.py
index edc6dd4..0fa4cf4 100755
--- a/examples/asyncio-prompt.py
+++ b/examples/asyncio-prompt.py
@@ -1,35 +1,29 @@
#!/usr/bin/env python
"""
-(Python >3.3)
-
+(Python >= 3.5)
This is an example of how to embed a CommandLineInterface inside an application
that uses the asyncio eventloop. The ``prompt_toolkit`` library will make sure
that when other coroutines are writing to stdout, they write above the prompt,
not destroying the input line.
-
This example does several things:
1. It starts a simple coroutine, printing a counter to stdout every second.
2. It starts a simple input/echo cli loop which reads from stdin.
-
Very important is the following patch. If you are passing stdin by reference to
other parts of the code, make sure that this patch is applied as early as
possible. ::
-
sys.stdout = cli.stdout_proxy()
"""
-from __future__ import unicode_literals
+
from prompt_toolkit.interface import CommandLineInterface
from prompt_toolkit.shortcuts import create_prompt_application, create_asyncio_eventloop
import asyncio
import sys
-
loop = asyncio.get_event_loop()
- at asyncio.coroutine
-def print_counter():
+async def print_counter():
"""
Coroutine that prints counters.
"""
@@ -37,11 +31,10 @@ def print_counter():
while True:
print('Counter: %i' % i)
i += 1
- yield from asyncio.sleep(3)
+ await asyncio.sleep(3)
- at asyncio.coroutine
-def interactive_shell():
+async def interactive_shell():
"""
Coroutine that shows the interactive command line.
"""
@@ -61,19 +54,22 @@ def interactive_shell():
# Run echo loop. Read text from stdin, and reply it back.
while True:
try:
- result = yield from cli.run_async()
- print('You said: "%s"\n' % result.text)
+ result = await cli.run_async()
+ print('You said: "{0}"'.format(result.text))
except (EOFError, KeyboardInterrupt):
- loop.stop()
- print('Qutting event loop. Bye.')
return
def main():
- asyncio.async(print_counter())
- asyncio.async(interactive_shell())
+ shell_task = loop.create_task(interactive_shell())
+
+ # Gather all the async calls, so they can be cancelled at once
+ background_task = asyncio.gather(print_counter(), return_exceptions=True)
- loop.run_forever()
+ loop.run_until_complete(shell_task)
+ background_task.cancel()
+ loop.run_until_complete(background_task)
+ print('Qutting event loop. Bye.')
loop.close()
diff --git a/examples/autocompletion-enter.py b/examples/autocompletion-enter.py
new file mode 100755
index 0000000..b39d919
--- /dev/null
+++ b/examples/autocompletion-enter.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+"""
+Example of a prompt with autocompletion, where pressing the Enter key accepts
+the completion.
+"""
+from __future__ import unicode_literals
+
+from prompt_toolkit import prompt
+from prompt_toolkit.contrib.completers import WordCompleter
+from prompt_toolkit.filters import HasCompletions
+from prompt_toolkit.key_binding.manager import KeyBindingManager
+from prompt_toolkit.keys import Keys
+
+
+animal_completer = WordCompleter([
+ 'alligator', 'ant', 'ape', 'bat', 'bear', 'beaver', 'bee', 'bison',
+ 'butterfly', 'cat', 'chicken', 'crocodile', 'dinosaur', 'dog', 'dolphine',
+ 'dove', 'duck', 'eagle', 'elephant', 'fish', 'goat', 'gorilla', 'kangoroo',
+ 'leopard', 'lion', 'mouse', 'rabbit', 'rat', 'snake', 'spider', 'turkey',
+ 'turtle',
+], ignore_case=True)
+
+
+def main():
+ key_bindings_manager = KeyBindingManager.for_prompt()
+
+ @key_bindings_manager.registry.add_binding(Keys.ControlJ, filter=HasCompletions())
+ def _(event):
+ event.current_buffer.complete_state = None
+
+ text = prompt('Give some animals: ',
+ completer=animal_completer,
+ key_bindings_registry=key_bindings_manager.registry)
+
+ print('You said: %s' % text)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/examples/bottom-toolbar.py b/examples/bottom-toolbar.py
index c3929d7..f5d1e7e 100755
--- a/examples/bottom-toolbar.py
+++ b/examples/bottom-toolbar.py
@@ -5,14 +5,12 @@ Simple example showing a bottom toolbar.
from __future__ import unicode_literals
from prompt_toolkit import prompt
from prompt_toolkit.styles import PygmentsStyle
-from pygments.style import Style
from pygments.token import Token
-class TestStyle(Style):
- styles = {
- Token.Toolbar: '#ffffff bg:#333333',
- }
+test_style = PygmentsStyle.from_defaults({
+ Token.Toolbar: '#ffffff bg:#333333',
+})
def main():
@@ -21,7 +19,7 @@ def main():
text = prompt('Say something: ',
get_bottom_toolbar_tokens=get_bottom_toolbar_tokens,
- style=PygmentsStyle(TestStyle))
+ style=test_style)
print('You said: %s' % text)
diff --git a/examples/clock-input.py b/examples/clock-input.py
index 85b063a..afd978d 100755
--- a/examples/clock-input.py
+++ b/examples/clock-input.py
@@ -8,7 +8,6 @@ from prompt_toolkit.application import Application
from prompt_toolkit.layout import Window
from prompt_toolkit.layout.controls import BufferControl
from prompt_toolkit.layout.processors import BeforeInput
-from prompt_toolkit.layout.utils import token_list_len
from prompt_toolkit.shortcuts import create_eventloop
from prompt_toolkit.utils import Callback
from pygments.token import Token
@@ -16,6 +15,7 @@ from pygments.token import Token
import datetime
import time
+
def _clock_tokens(cli):
" Tokens to be shown before the prompt. "
now = datetime.datetime.now()
diff --git a/examples/colored-prompt.py b/examples/colored-prompt.py
index aaa1ff4..2d64e7c 100755
--- a/examples/colored-prompt.py
+++ b/examples/colored-prompt.py
@@ -5,27 +5,22 @@ Example of a colored prompt.
from __future__ import unicode_literals
from prompt_toolkit import prompt
-from pygments.style import Style
from prompt_toolkit.styles import PygmentsStyle
-from pygments.styles.default import DefaultStyle
from pygments.token import Token
-class ExampleStyle(Style):
- styles = DefaultStyle.styles.copy()
+example_style = PygmentsStyle.from_defaults(style_dict={
+ # User input.
+ Token: '#ff0066',
- styles.update({
- # User input.
- Token: '#ff0066',
-
- # Prompt.
- Token.Username: '#884444',
- Token.At: '#00aa00',
- Token.Colon: '#00aa00',
- Token.Pound: '#00aa00',
- Token.Host: '#000088 bg:#aaaaff',
- Token.Path: '#884444 underline',
- })
+ # Prompt.
+ Token.Username: '#884444 italic',
+ Token.At: '#00aa00',
+ Token.Colon: '#00aa00',
+ Token.Pound: '#00aa00',
+ Token.Host: '#000088 bg:#aaaaff',
+ Token.Path: '#884444 underline',
+})
def get_prompt_tokens(cli):
@@ -40,5 +35,5 @@ def get_prompt_tokens(cli):
if __name__ == '__main__':
- answer = prompt(get_prompt_tokens=get_prompt_tokens, style=PygmentsStyle(ExampleStyle))
+ answer = prompt(get_prompt_tokens=get_prompt_tokens, style=example_style)
print('You said: %s' % answer)
diff --git a/examples/regular-language.py b/examples/regular-language.py
index 140de9a..e56d678 100755
--- a/examples/regular-language.py
+++ b/examples/regular-language.py
@@ -20,7 +20,7 @@ from prompt_toolkit.contrib.regular_languages.compiler import compile
from prompt_toolkit.contrib.regular_languages.completion import GrammarCompleter
from prompt_toolkit.contrib.regular_languages.lexer import GrammarLexer
from prompt_toolkit.layout.lexers import SimpleLexer
-from prompt_toolkit.styles import DefaultStyle, PygmentsStyle
+from prompt_toolkit.styles import PygmentsStyle
from pygments.token import Token
@@ -38,15 +38,12 @@ def create_grammar():
""")
-class ExampleStyle(DefaultStyle):
- styles = {}
- styles.update(DefaultStyle.styles)
- styles.update({
- Token.Operator: '#33aa33 bold',
- Token.Number: '#aa3333 bold',
+example_style = PygmentsStyle.from_defaults({
+ Token.Operator: '#33aa33 bold',
+ Token.Number: '#aa3333 bold',
- Token.TrailingInput: 'bg:#662222 #ffffff',
- })
+ Token.TrailingInput: 'bg:#662222 #ffffff',
+})
if __name__ == '__main__':
@@ -70,7 +67,7 @@ if __name__ == '__main__':
while True:
# Read input and parse the result.
text = prompt('Calculate: ', lexer=lexer, completer=completer,
- style=PygmentsStyle(ExampleStyle))
+ style=example_style)
m = g.match(text)
if m:
vars = m.variables()
diff --git a/examples/switch-between-vi-emacs.py b/examples/switch-between-vi-emacs.py
new file mode 100644
index 0000000..1ff40e8
--- /dev/null
+++ b/examples/switch-between-vi-emacs.py
@@ -0,0 +1,32 @@
+from prompt_toolkit import prompt
+from prompt_toolkit.filters import Condition
+from prompt_toolkit.key_binding.manager import KeyBindingManager
+from prompt_toolkit.keys import Keys
+from pygments.token import Token
+
+def run():
+ vi_mode_enabled = False
+
+ # Create a set of key bindings that have Vi mode enabled if the
+ # ``vi_mode_enabled`` is True..
+ manager = KeyBindingManager.for_prompt(
+ enable_vi_mode=Condition(lambda cli: vi_mode_enabled))
+
+ # Add an additional key binding for toggling this flag.
+ @manager.registry.add_binding(Keys.F4)
+ def _(event):
+ " Toggle between Emacs and Vi mode. "
+ nonlocal vi_mode_enabled
+ vi_mode_enabled = not vi_mode_enabled
+
+ def get_bottom_toolbar_tokens(cli):
+ " Display the current input mode. "
+ text = 'Vi' if vi_mode_enabled else 'Emacs'
+ return [
+ (Token.Toolbar, ' [F4] %s ' % text)
+ ]
+
+ prompt('> ', key_bindings_registry=manager.registry,
+ get_bottom_toolbar_tokens=get_bottom_toolbar_tokens)
+
+run()
diff --git a/examples/system-autocompletion.py b/examples/system-autocompletion.py
new file mode 100644
index 0000000..f89b9d2
--- /dev/null
+++ b/examples/system-autocompletion.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+"""
+Example of autocompletion using filenames.
+"""
+from __future__ import unicode_literals
+
+from prompt_toolkit.contrib.completers.system import SystemCompleter
+from prompt_toolkit import prompt
+
+
+def main():
+ text = prompt('Shell: ', completer=SystemCompleter())
+ print('You said: %s' % text)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/examples/system-prompt.py b/examples/system-prompt.py
index a43a709..d0e40ed 100755
--- a/examples/system-prompt.py
+++ b/examples/system-prompt.py
@@ -1,10 +1,9 @@
#!/usr/bin/env python
from __future__ import unicode_literals
from prompt_toolkit import prompt
-from prompt_toolkit.filters import Always
if __name__ == '__main__':
print('If you press meta-! or esc-! at the following prompt, you can enter system commands.')
- answer = prompt('Give me some input: ', enable_system_bindings=Always())
+ answer = prompt('Give me some input: ', enable_system_bindings=True)
print('You said: %s' % answer)
diff --git a/examples/up-arrow-partial-string-matching.py b/examples/up-arrow-partial-string-matching.py
index c328355..65be0ef 100755
--- a/examples/up-arrow-partial-string-matching.py
+++ b/examples/up-arrow-partial-string-matching.py
@@ -8,7 +8,6 @@ history on the items starting with the given input text.
from __future__ import unicode_literals, print_function
from prompt_toolkit import prompt
from prompt_toolkit.history import InMemoryHistory
-from prompt_toolkit.filters import Always
from prompt_toolkit.interface import AbortAction
@@ -28,7 +27,7 @@ def main():
print()
text = prompt('Say something: ', history=history,
- enable_history_search=Always(),
+ enable_history_search=True,
on_abort=AbortAction.RETRY)
print('You said: %s' % text)
diff --git a/prompt_toolkit.egg-info/PKG-INFO b/prompt_toolkit.egg-info/PKG-INFO
index 29de500..de7410c 100644
--- a/prompt_toolkit.egg-info/PKG-INFO
+++ b/prompt_toolkit.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: prompt-toolkit
-Version: 0.54
+Version: 0.57
Summary: Library for building powerful interactive command lines in Python
Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
Author: Jonathan Slenders
@@ -45,6 +45,7 @@ Description: Python Prompt Toolkit
- Runs on all Python versions from 2.6 up to 3.4.
- Works well with Unicode double width characters. (Chinese input.)
- Selecting text for copy/paste. (Both Emacs and Vi style.)
+ - Support for `bracketed paste <https://cirw.in/blog/bracketed-paste>`_.
- Mouse support for cursor positioning and scrolling.
- Auto suggestions. (Like `fish shell <http://fishshell.com/>`_.)
- Multiple input buffers.
@@ -81,6 +82,12 @@ Description: Python Prompt Toolkit
pip install prompt-toolkit
+ For Conda, do:
+
+ ::
+
+ conda install -c https://conda.anaconda.org/conda-forge prompt_toolkit
+
Getting started
***************
@@ -107,17 +114,24 @@ Description: Python Prompt Toolkit
Projects using prompt-toolkit
*****************************
+ Shells:
+
- `ptpython <http://github.com/jonathanslenders/ptpython/>`_: Python REPL
- `ptpdb <http://github.com/jonathanslenders/ptpdb/>`_: Python debugger (pdb replacement)
- `pgcli <http://pgcli.com/>`_: Postgres client.
- `mycli <http://mycli.net>`_: MySql client.
- - `pyvim <http://github.com/jonathanslenders/pyvim/>`_: A Vim clone in pure Python
- `wharfee <http://wharfee.com/>`_: A Docker command line.
- `xonsh <http://xonsh.org/>`_: A Python-ish, BASHwards-compatible shell.
- `saws <https://github.com/donnemartin/saws>`_: A Supercharged AWS Command Line Interface.
- `cycli <https://github.com/nicolewhite/cycli>`_: A Command Line Interface for Cypher.
- `crash <https://github.com/crate/crash>`_: Crate command line client.
+ - `vcli <https://github.com/dbcli/vcli>`_: Vertica client.
+ - `aws-shell <https://github.com/awslabs/aws-shell>`_: An integrated shell for working with the AWS CLI.
+
+ Full screen applications:
+ - `pymux <http://github.com/jonathanslenders/pymux/>`_: A terminal multiplexer (like tmux) in pure Python.
+ - `pyvim <http://github.com/jonathanslenders/pyvim/>`_: A Vim clone in pure Python.
(Want your own project to be listed here? Please create a GitHub issue.)
diff --git a/prompt_toolkit.egg-info/SOURCES.txt b/prompt_toolkit.egg-info/SOURCES.txt
index 082c87d..eef38ee 100644
--- a/prompt_toolkit.egg-info/SOURCES.txt
+++ b/prompt_toolkit.egg-info/SOURCES.txt
@@ -3,10 +3,13 @@ CHANGELOG
LICENSE
MANIFEST.in
README.rst
+TODO.rst
setup.py
examples/abortaction.retry.py
+examples/asyncio-prompt-simplified.py
examples/asyncio-prompt.py
examples/auto-suggestion.py
+examples/autocompletion-enter.py
examples/autocompletion.py
examples/autocorrection.py
examples/bottom-toolbar.py
@@ -31,6 +34,8 @@ examples/no-wrapping.py
examples/patch-stdout.py
examples/persistent-history.py
examples/regular-language.py
+examples/switch-between-vi-emacs.py
+examples/system-autocompletion.py
examples/system-clipboard-integration.py
examples/system-prompt.py
examples/telnet.py
@@ -41,10 +46,10 @@ prompt_toolkit/__init__.py
prompt_toolkit/application.py
prompt_toolkit/auto_suggest.py
prompt_toolkit/buffer.py
+prompt_toolkit/buffer_mapping.py
prompt_toolkit/completion.py
prompt_toolkit/document.py
prompt_toolkit/enums.py
-prompt_toolkit/focus_stack.py
prompt_toolkit/history.py
prompt_toolkit/input.py
prompt_toolkit/interface.py
@@ -63,7 +68,6 @@ prompt_toolkit/win32_types.py
prompt_toolkit.egg-info/PKG-INFO
prompt_toolkit.egg-info/SOURCES.txt
prompt_toolkit.egg-info/dependency_links.txt
-prompt_toolkit.egg-info/pbr.json
prompt_toolkit.egg-info/requires.txt
prompt_toolkit.egg-info/top_level.txt
prompt_toolkit/clipboard/__init__.py
@@ -119,6 +123,7 @@ prompt_toolkit/layout/__init__.py
prompt_toolkit/layout/containers.py
prompt_toolkit/layout/controls.py
prompt_toolkit/layout/dimension.py
+prompt_toolkit/layout/highlighters.py
prompt_toolkit/layout/lexers.py
prompt_toolkit/layout/margins.py
prompt_toolkit/layout/menus.py
@@ -133,4 +138,14 @@ prompt_toolkit/terminal/conemu_output.py
prompt_toolkit/terminal/vt100_input.py
prompt_toolkit/terminal/vt100_output.py
prompt_toolkit/terminal/win32_input.py
-prompt_toolkit/terminal/win32_output.py
\ No newline at end of file
+prompt_toolkit/terminal/win32_output.py
+tests/contrib_tests.py
+tests/run_tests.py
+tests/buffer_tests/__init__.py
+tests/document_tests/__init__.py
+tests/inputstream_tests/__init__.py
+tests/key_binding_tests/__init__.py
+tests/layout_tests/__init__.py
+tests/regular_languages_tests/__init__.py
+tests/screen_tests/__init__.py
+tests/utils_tests/__init__.py
\ No newline at end of file
diff --git a/prompt_toolkit.egg-info/pbr.json b/prompt_toolkit.egg-info/pbr.json
deleted file mode 100644
index eeda1aa..0000000
--- a/prompt_toolkit.egg-info/pbr.json
+++ /dev/null
@@ -1 +0,0 @@
-{"is_release": false, "git_version": "0abd440"}
\ No newline at end of file
diff --git a/prompt_toolkit/__init__.py b/prompt_toolkit/__init__.py
index 5534834..840e976 100644
--- a/prompt_toolkit/__init__.py
+++ b/prompt_toolkit/__init__.py
@@ -16,3 +16,6 @@ Probably, to get started, you meight also want to have a look at
from .interface import CommandLineInterface
from .application import AbortAction, Application
from .shortcuts import prompt
+
+
+__version__ = '0.57'
diff --git a/prompt_toolkit/application.py b/prompt_toolkit/application.py
index 5867a06..e8daab4 100644
--- a/prompt_toolkit/application.py
+++ b/prompt_toolkit/application.py
@@ -1,17 +1,17 @@
from __future__ import unicode_literals
from .buffer import Buffer, AcceptAction
+from .buffer_mapping import BufferMapping
from .clipboard import Clipboard, InMemoryClipboard
from .enums import DEFAULT_BUFFER
from .filters import CLIFilter, to_cli_filter
-from .focus_stack import FocusStack
from .key_binding.bindings.basic import load_basic_bindings
from .key_binding.bindings.emacs import load_emacs_bindings
from .key_binding.registry import Registry
from .layout import Window
from .layout.containers import Container
from .layout.controls import BufferControl
-from .styles import DefaultStyle, Style, PygmentsStyle
+from .styles import DEFAULT_STYLE, Style
from .utils import Callback
__all__ = (
@@ -20,16 +20,15 @@ __all__ = (
)
-class AbortAction:
+class AbortAction(object):
"""
Actions to take on an Exit or Abort exception.
"""
- IGNORE = 'ignore'
RETRY = 'retry'
RAISE_EXCEPTION = 'raise-exception'
RETURN_NONE = 'return-none'
- _all = (IGNORE, RETRY, RAISE_EXCEPTION, RETURN_NONE)
+ _all = (RETRY, RAISE_EXCEPTION, RETURN_NONE)
class Application(object):
@@ -71,7 +70,7 @@ class Application(object):
:param on_start: Called when reading input starts.
:param on_stop: Called when reading input ends.
:param on_reset: Called during reset.
- :param on_buffer_changed: Called when another buffer gets the focus.
+ :param on_buffer_changed: Called when the content of a buffer has been changed.
:param on_initialize: Called after the
:class:`~prompt_toolkit.interface.CommandLineInterface` initializes.
"""
@@ -79,9 +78,9 @@ class Application(object):
initial_focussed_buffer=DEFAULT_BUFFER,
style=None,
... 6711 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/prompt-toolkit.git
More information about the Python-modules-commits
mailing list