[Python-modules-commits] [prompt-toolkit] 01/04: Import prompt-toolkit_1.0.2.orig.tar.gz

Scott Kitterman kitterman at moszumanska.debian.org
Sat Jun 18 22:55:32 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 977d4868cc4ebaf522a7c7272421e22e59402d62
Author: Scott Kitterman <scott at kitterman.com>
Date:   Sat Jun 18 18:44:22 2016 -0400

    Import prompt-toolkit_1.0.2.orig.tar.gz
---
 CHANGELOG                                          |  74 ++++++
 PKG-INFO                                           |   7 +-
 README.rst                                         |   5 +-
 TODO.rst                                           |  39 ----
 examples/asyncio-prompt-simplified.py              |  67 ------
 examples/asyncio-prompt.py                         |   4 +-
 ...on-enter.py => autocompletion-like-readline.py} |  24 +-
 examples/chinese-prompt.py                         |   8 +
 examples/clock-input.py                            |  46 +---
 examples/complete-test.py                          |  83 +++++++
 examples/confirmation-prompt.py                    |  11 +
 examples/custom-key-binding.py                     |   8 +-
 examples/finalterm-shell-integration.py            |  36 +++
 examples/pager.py                                  |  85 +++++++
 examples/system-autocompletion.py                  |  17 --
 prompt_toolkit.egg-info/PKG-INFO                   |   7 +-
 prompt_toolkit.egg-info/SOURCES.txt                |  38 ++--
 prompt_toolkit.egg-info/pbr.json                   |   1 +
 prompt_toolkit/__init__.py                         |   2 +-
 prompt_toolkit/benchmark.py                        |  20 ++
 prompt_toolkit/buffer.py                           |  23 +-
 prompt_toolkit/cache.py                            |   5 +
 prompt_toolkit/completion.py                       |   9 +-
 prompt_toolkit/contrib/completers/filesystem.py    |   8 +-
 .../contrib/regular_languages/validation.py        |   2 +-
 prompt_toolkit/contrib/telnet/server.py            |   2 +-
 prompt_toolkit/contrib/validators/base.py          |   3 +-
 prompt_toolkit/document.py                         |  26 ++-
 prompt_toolkit/eventloop/posix_utils.py            |  10 +-
 prompt_toolkit/eventloop/win32.py                  |   7 +-
 prompt_toolkit/filters/cli.py                      |   1 +
 prompt_toolkit/interface.py                        |  43 +++-
 prompt_toolkit/key_binding/bindings/basic.py       |  32 +--
 prompt_toolkit/key_binding/bindings/completion.py  | 163 +++++++++++++
 prompt_toolkit/key_binding/bindings/emacs.py       |   4 +-
 prompt_toolkit/key_binding/bindings/utils.py       |  22 +-
 prompt_toolkit/key_binding/bindings/vi.py          | 111 ++++++---
 prompt_toolkit/key_binding/input_processor.py      | 113 +++++----
 prompt_toolkit/key_binding/registry.py             |  94 +++++---
 prompt_toolkit/layout/containers.py                |  40 +++-
 prompt_toolkit/layout/controls.py                  |  44 +++-
 prompt_toolkit/layout/focus.py                     |  86 +++++++
 prompt_toolkit/layout/margins.py                   |   3 +-
 prompt_toolkit/layout/processors.py                |  51 ++++-
 prompt_toolkit/layout/screen.py                    |   3 +
 prompt_toolkit/layout/utils.py                     |  19 +-
 prompt_toolkit/output.py                           |  12 +
 prompt_toolkit/renderer.py                         |  27 ++-
 prompt_toolkit/shortcuts.py                        | 140 ++++++++++--
 prompt_toolkit/styles/defaults.py                  |   4 +-
 prompt_toolkit/terminal/vt100_output.py            |  22 +-
 prompt_toolkit/terminal/win32_input.py             |  83 +++++--
 prompt_toolkit/terminal/win32_output.py            |   4 +
 prompt_toolkit/token.py                            |   9 +
 prompt_toolkit/utils.py                            |  14 +-
 setup.cfg                                          |   2 +-
 tests/buffer_tests/__init__.py                     | 102 ---------
 tests/cli_tests.py                                 | 183 ---------------
 tests/contrib_tests.py                             | 249 --------------------
 tests/document_tests/__init__.py                   |  65 ------
 tests/filter_tests.py                              | 153 -------------
 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                                 |  61 -----
 tests/style_tests.py                               |  41 ----
 tests/test_buffer.py                               | 111 +++++++++
 tests/test_cli.py                                  | 216 ++++++++++++++++++
 tests/test_contrib.py                              | 253 +++++++++++++++++++++
 tests/test_document.py                             |  74 ++++++
 tests/test_filter.py                               | 168 ++++++++++++++
 tests/test_inputstream.py                          | 142 ++++++++++++
 tests/test_key_binding.py                          |  98 ++++++++
 tests/test_layout.py                               |  60 +++++
 tests/test_regular_languages.py                    | 110 +++++++++
 tests/test_shortcuts.py                            |  51 +++++
 tests/test_style.py                                |  40 ++++
 tests/test_utils.py                                |  39 ++++
 tests/utils_tests/__init__.py                      |  41 ----
 80 files changed, 2728 insertions(+), 1679 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index dcde93e..432e2de 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,80 @@
 CHANGELOG
 =========
 
+1.0.2: 2016-06-16
+-----------------
+
+Fixes:
+- Don't select the first completion when `complete_while_typing` is False.
+  (Restore the old behaviour.)
+
+
+1.0.1: 2016-06-15
+-----------------
+
+Fixes:
+- Bugfix in GrammarValidator and SentenceValidator.
+- Don't leave the alternate screen on resize events.
+- Use errors=surrogateescape, in order to handle mouse events in some
+  terminals.
+- Ignore key presses in _InterfaceEventLoopCallbacks.feed_key when the CLI is in the done state.
+- Bugfix in get_common_complete_suffix. Don't return any suffix when there are
+  completions that change whatever is before the cursor.
+- Bugfix for Win32/Python2: use unicode literals: This crashed arrow navigation
+  on Windows.
+- Bugfix in InputProcessor: handling of more complex key bindings.
+- Fix: don't apply completions, if there is only one completion which doesn't
+  have any effect.
+- Fix: correctly handle prompts starting with a newline in
+  prompt_toolkit.shortcuts.
+- Fix: thread safety in autocomplete code.
+- Improve styling for matching brackets. (Allow individual styling for the
+  bracket under the cursor and the other.)
+- Fix in ShowLeadingWhiteSpaceProcessor/ShowTrailingWhiteSpaceProcessor: take
+  output encoding into account. (The signature had to change a little for
+  this.)
+- Bug fix in key bindings: only activate Emacs system/open-in-editor bindings
+  if editing_mode is emacs.
+- Added write_binary parameter to Vt100_Output. This fixes a bug in some cases
+  where we expect it to write non-encoded strings.
+- Fix key bindings for Vi mode registers.
+
+New features (**):
+- Added shortcuts.confirm/create_confirm_application function.
+- Emulate bracketed paste on Windows. (When the input stream contains multiple
+  key presses among which a newline and at least one other character, consider
+  this a paste event, and handle as bracketed paste on Unix.
+- Added key handler for displaying completions, just like readline does.
+- Implemented Vi guu,gUU,g~~ key bindings.
+- Implemented Vi 'gJ' key binding.
+- Implemented Vi ab,ib,aB,iB text objects.
+- Support for ZeroWidthEscape tokens in prompt and token lists. Used to support
+  final shell integration.
+- Fix: Make document.text/cursor_position/selection read-only. (Changing these
+  would break the caching causing bigger issues.)
+- Using pytest for unit tests.
+- Allow key bindings to have Keys.Any at any possible position. (Not just the
+  end.) This made it significantly easier to write the named register Vi
+  bindings, resulting in an approved start-up time.)
+- Better feedback when entering multi-key key bindings in insert mode. (E.g.
+  when 'jj' would be mapped to escape.)
+- Small improvement in key processor: allow key bindings to generate new key
+  presses.
+- Handle ControlUp and ControlDown by default: move to the previous/next record
+  in the history.
+- Accept 'char'/'get_char' parameters in FillControl.
+- Added refresh_interval method to prompt() function.
+
+Performance improvements:
+- Improve the performance of test_callable_args: this should significantly
+  increase the start-up time.
+- Start-up time for creating the Vi bindings has been improved significantly.
+
+(**) Some small backwards-compatible features were allowed for this minor
+     release. After evaluating the impact/risk/work involved we concluded that
+     we could ship these in a minor release.
+
+
 1.0.0: 2016-05-05
 -----------------
 
diff --git a/PKG-INFO b/PKG-INFO
index 5bd2723..1e57db0 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: prompt_toolkit
-Version: 1.0.0
+Version: 1.0.2
 Summary: Library for building powerful interactive command lines in Python
 Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
 Author: Jonathan Slenders
@@ -41,6 +41,7 @@ Description: Python Prompt Toolkit
         - Multi-line input editing.
         - Advanced code completion.
         - Both Emacs and Vi key bindings. (Similar to readline.)
+        - Even some advanced Vi functionality, like named registers and digraphs.
         - Reverse and forward incremental search.
         - Runs on all Python versions from 2.6 up to 3.5.
         - Works well with Unicode double width characters. (Chinese input.)
@@ -51,7 +52,7 @@ Description: Python Prompt Toolkit
         - Multiple input buffers.
         - No global state.
         - Lightweight, the only dependencies are Pygments, six and wcwidth.
-        - Runs on Linux, OS X, OpenBSD and Windows systems.
+        - Runs on Linux, OS X, FreeBSD, OpenBSD and Windows systems.
         - And much more...
         
         Feel free to create tickets for bugs and feature requests, and create pull
@@ -132,6 +133,8 @@ Description: Python Prompt Toolkit
         - `ipython <http://github.com/ipython/ipython/>`_: The IPython REPL
         - `click-repl <https://github.com/click-contrib/click-repl>`_: Subcommand REPL for click apps.
         - `haxor-news <https://github.com/donnemartin/haxor-news>`_: A Hacker News CLI.
+        - `gitsome <https://github.com/donnemartin/gitsome>`_: A Git/Shell Autocompleter with GitHub Integration.
+        - `http-prompt <https://github.com/eliangcs/http-prompt>`_: An interactive command-line HTTP client.
         
         Full screen applications:
         
diff --git a/README.rst b/README.rst
index d6a797b..2a261e6 100644
--- a/README.rst
+++ b/README.rst
@@ -33,6 +33,7 @@ Some features:
 - Multi-line input editing.
 - Advanced code completion.
 - Both Emacs and Vi key bindings. (Similar to readline.)
+- Even some advanced Vi functionality, like named registers and digraphs.
 - Reverse and forward incremental search.
 - Runs on all Python versions from 2.6 up to 3.5.
 - Works well with Unicode double width characters. (Chinese input.)
@@ -43,7 +44,7 @@ Some features:
 - Multiple input buffers.
 - No global state.
 - Lightweight, the only dependencies are Pygments, six and wcwidth.
-- Runs on Linux, OS X, OpenBSD and Windows systems.
+- Runs on Linux, OS X, FreeBSD, OpenBSD and Windows systems.
 - And much more...
 
 Feel free to create tickets for bugs and feature requests, and create pull
@@ -124,6 +125,8 @@ Shells:
 - `ipython <http://github.com/ipython/ipython/>`_: The IPython REPL
 - `click-repl <https://github.com/click-contrib/click-repl>`_: Subcommand REPL for click apps.
 - `haxor-news <https://github.com/donnemartin/haxor-news>`_: A Hacker News CLI.
+- `gitsome <https://github.com/donnemartin/gitsome>`_: A Git/Shell Autocompleter with GitHub Integration.
+- `http-prompt <https://github.com/eliangcs/http-prompt>`_: An interactive command-line HTTP client.
 
 Full screen applications:
 
diff --git a/TODO.rst b/TODO.rst
deleted file mode 100644
index e80bc0c..0000000
--- a/TODO.rst
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-- 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-simplified.py b/examples/asyncio-prompt-simplified.py
deleted file mode 100755
index 84dad4c..0000000
--- a/examples/asyncio-prompt-simplified.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-"""
-(Python >3.3)
-
-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 prompt_async
-
-import asyncio
-import sys
-
-
-loop = asyncio.get_event_loop()
-
-
-async def print_counter():
-    """
-    Coroutine that prints counters.
-    """
-    i = 0
-    while True:
-        print('Counter: %i' % i)
-        i += 1
-        await asyncio.sleep(3)
-
-
-async def interactive_shell():
-    """
-    Coroutine that shows the interactive command line.
-    """
-    # Run echo loop. Read text from stdin, and reply it back.
-    while True:
-        try:
-            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.')
-            return
-
-
-def main():
-    asyncio.async(print_counter())
-    asyncio.async(interactive_shell())
-
-    loop.run_forever()
-    loop.close()
-
-
-if __name__ == '__main__':
-    main()
diff --git a/examples/asyncio-prompt.py b/examples/asyncio-prompt.py
index 0fa4cf4..7bdb79e 100755
--- a/examples/asyncio-prompt.py
+++ b/examples/asyncio-prompt.py
@@ -15,7 +15,7 @@ possible. ::
 """
 
 from prompt_toolkit.interface import CommandLineInterface
-from prompt_toolkit.shortcuts import create_prompt_application, create_asyncio_eventloop
+from prompt_toolkit.shortcuts import create_prompt_application, create_asyncio_eventloop, prompt_async
 
 import asyncio
 import sys
@@ -36,7 +36,7 @@ async def print_counter():
 
 async def interactive_shell():
     """
-    Coroutine that shows the interactive command line.
+    Like `interactive_shell`, but doing things manual.
     """
     # Create an asyncio `EventLoop` object. This is a wrapper around the
     # asyncio loop that can be passed into prompt_toolkit.
diff --git a/examples/autocompletion-enter.py b/examples/autocompletion-like-readline.py
similarity index 52%
rename from examples/autocompletion-enter.py
rename to examples/autocompletion-like-readline.py
index b39d919..e262558 100755
--- a/examples/autocompletion-enter.py
+++ b/examples/autocompletion-like-readline.py
@@ -1,13 +1,13 @@
 #!/usr/bin/env python
 """
-Example of a prompt with autocompletion, where pressing the Enter key accepts
-the completion.
+Autocompletion example that displays the autocompletions like readline does by
+binding a custom handler to the Tab key.
 """
 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.bindings.completion import display_completions_like_readline
 from prompt_toolkit.key_binding.manager import KeyBindingManager
 from prompt_toolkit.keys import Keys
 
@@ -20,18 +20,18 @@ animal_completer = WordCompleter([
     'turtle',
 ], ignore_case=True)
 
+# Create key bindings registry with a custom binding for the Tab key that
+# displays completions like GNU readline.
+key_bindings_manager = KeyBindingManager.for_prompt()
+key_bindings_manager.registry.add_binding(Keys.ControlI)(display_completions_like_readline)
 
 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)
+    text = prompt('Give some animals: ', completer=animal_completer,
+                  key_bindings_registry=key_bindings_manager.registry,
 
+                  # Important: for this to work: `complete_while_typing` needs
+                  #            to be False.
+                  complete_while_typing=False)
     print('You said: %s' % text)
 
 
diff --git a/examples/chinese-prompt.py b/examples/chinese-prompt.py
new file mode 100755
index 0000000..0687f7b
--- /dev/null
+++ b/examples/chinese-prompt.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+from __future__ import unicode_literals
+from prompt_toolkit import prompt
+
+
+if __name__ == '__main__':
+    answer = prompt('你好: ')
+    print('You said: %s' % answer)
diff --git a/examples/clock-input.py b/examples/clock-input.py
index 33e826b..041652f 100755
--- a/examples/clock-input.py
+++ b/examples/clock-input.py
@@ -3,19 +3,12 @@
 Example of a 'dynamic' prompt. On that shows the current time in the prompt.
 """
 from __future__ import unicode_literals
-from prompt_toolkit.application import Application
-from prompt_toolkit.interface import CommandLineInterface
-from prompt_toolkit.layout import Window
-from prompt_toolkit.layout.controls import BufferControl
-from prompt_toolkit.layout.processors import BeforeInput
-from prompt_toolkit.shortcuts import create_eventloop
+from prompt_toolkit.shortcuts import prompt
 from prompt_toolkit.token import Token
-
 import datetime
-import time
 
 
-def _clock_tokens(cli):
+def get_prompt_tokens(cli):
     " Tokens to be shown before the prompt. "
     now = datetime.datetime.now()
     return [
@@ -25,39 +18,8 @@ def _clock_tokens(cli):
 
 
 def main():
-    eventloop = create_eventloop()
-    done = [False]  # Non local
-
-    def on_read_start(cli):
-        """
-        This function is called when we start reading at the input.
-        (Actually the start of the read-input event loop.)
-        """
-        # Following function should be run in the background.
-        # We do it by using an executor thread from the `CommandLineInterface`
-        # instance.
-        def run():
-            # Send every second a redraw request.
-            while not done[0]:
-                time.sleep(1)
-                cli.request_redraw()
-
-        cli.eventloop.run_in_executor(run)
-
-    def on_read_stop(cli):
-        done[0] = True
-
-    app = Application(
-        layout=Window(BufferControl(input_processors=[BeforeInput(_clock_tokens)])),
-        on_start=on_read_start,
-        on_stop=on_read_stop)
-
-    cli = CommandLineInterface(application=app, eventloop=eventloop)
-
-    code_obj = cli.run()
-    print('You said: %s' % code_obj.text)
-
-    eventloop.close()
+    result = prompt(get_prompt_tokens=get_prompt_tokens, refresh_interval=.5)
+    print('You said: %s' % result)
 
 
 if __name__ == '__main__':
diff --git a/examples/complete-test.py b/examples/complete-test.py
new file mode 100755
index 0000000..3ca37e5
--- /dev/null
+++ b/examples/complete-test.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+"""
+get_password function that displays asterisks instead of the actual characters.
+With the addition of a ControlT shortcut to hide/show the input.
+"""
+from __future__ import unicode_literals
+from prompt_toolkit import prompt
+from prompt_toolkit.key_binding.manager import KeyBindingManager
+from prompt_toolkit.keys import Keys
+from prompt_toolkit.filters import Condition
+from prompt_toolkit.contrib.completers import WordCompleter
+
+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():
+    complete_wt = [False]
+
+    def complete_while_typing():
+        return complete_wt[0]
+
+    key_bindings_manager = KeyBindingManager()
+
+    @key_bindings_manager.registry.add_binding(Keys.ControlI)
+    def _(event):
+        complete_wt[0] = True
+
+        b = event.current_buffer
+
+        def second_tab():
+            if b.complete_state:
+                b.complete_next()
+            else:
+                event.cli.start_completion(select_first=True)
+
+        # On the second tab-press, or when already navigating through
+        # completions.
+        if event.is_repeat or b.complete_state:
+            second_tab()
+        else:
+            event.cli.start_completion(insert_common_part=True)
+
+    prompt('Password: ',
+           complete_while_typing=Condition(complete_while_typing),
+           key_bindings_registry=key_bindings_manager.registry,
+           completer=animal_completer)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/examples/confirmation-prompt.py b/examples/confirmation-prompt.py
new file mode 100755
index 0000000..44d37aa
--- /dev/null
+++ b/examples/confirmation-prompt.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+"""
+Example of a confirmation prompt.
+"""
+from __future__ import unicode_literals
+
+from prompt_toolkit.shortcuts import confirm
+
+if __name__ == '__main__':
+    answer = confirm('Should we do that? (y/n) ')
+    print('You said: %s' % answer)
diff --git a/examples/custom-key-binding.py b/examples/custom-key-binding.py
index 80eb902..5da6aaf 100755
--- a/examples/custom-key-binding.py
+++ b/examples/custom-key-binding.py
@@ -29,10 +29,16 @@ def main():
 
         Note that when you type for instance 'xa', the insertion of 'x' is
         postponed until the 'a' is typed. because we don't know earlier whether
-        or not a 'y' will follow.
+        or not a 'y' will follow. However, prompt-toolkit should already give
+        some visual feedback of the typed character.
         """
         event.cli.current_buffer.insert_text('z')
 
+    @key_bindings_manager.registry.add_binding('a', 'b', 'c')
+    def _(event):
+        " Typing 'abc' should insert 'd'. "
+        event.cli.current_buffer.insert_text('d')
+
     @key_bindings_manager.registry.add_binding(Keys.ControlT)
     def _(event):
         """
diff --git a/examples/finalterm-shell-integration.py b/examples/finalterm-shell-integration.py
new file mode 100755
index 0000000..f7265d7
--- /dev/null
+++ b/examples/finalterm-shell-integration.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+"""
+Mark the start and end of the prompt with Final term (iterm2) escape sequences.
+See: https://iterm2.com/finalterm.html
+"""
+from __future__ import unicode_literals
+
+from prompt_toolkit import prompt
+from prompt_toolkit.token import Token
+import sys
+
+
+BEFORE_PROMPT = '\033]133;A\a'
+AFTER_PROMPT = '\033]133;B\a'
+BEFORE_OUTPUT = '\033]133;C\a'
+AFTER_OUTPUT = '\033]133;D;{command_status}\a' # command_status is the command status, 0-255
+
+
+def get_prompt_tokens(cli):
+    # Generate the tokens for the prompt.
+    # Important: use the `ZeroWidthEscape` token only if you are sure that
+    #            writing this as raw text to the output will not introduce any
+    #            cursor movements.
+    return [
+        (Token.ZeroWidthEscape, BEFORE_PROMPT),
+        (Token, 'Say something: # '),
+        (Token.ZeroWidthEscape, AFTER_PROMPT),
+    ]
+
+
+if __name__ == '__main__':
+    answer = prompt(get_prompt_tokens=get_prompt_tokens)
+
+    sys.stdout.write(BEFORE_OUTPUT)
+    print('You said: %s' % answer)
+    sys.stdout.write(AFTER_OUTPUT.format(command_status=0))
diff --git a/examples/pager.py b/examples/pager.py
new file mode 100755
index 0000000..0dcd7ec
--- /dev/null
+++ b/examples/pager.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+"""
+"""
+from __future__ import unicode_literals
+
+from prompt_toolkit.application import Application
+from prompt_toolkit.buffer import Buffer
+from prompt_toolkit.document import Document
+from prompt_toolkit.enums import DEFAULT_BUFFER
+from prompt_toolkit.interface import CommandLineInterface
+from prompt_toolkit.key_binding.manager import KeyBindingManager
+from prompt_toolkit.layout.containers import HSplit, Window
+from prompt_toolkit.layout.controls import BufferControl, TokenListControl
+from prompt_toolkit.layout.dimension import LayoutDimension as D
+from prompt_toolkit.layout.processors import HighlightSearchProcessor
+from prompt_toolkit.layout.screen import Char
+from prompt_toolkit.layout.toolbars import SearchToolbar
+from prompt_toolkit.shortcuts import create_eventloop
+from prompt_toolkit.styles import PygmentsStyle
+
+from pygments.token import Token
+
+def get_statusbar_tokens(cli):
+    b = cli.buffers[DEFAULT_BUFFER]
+    return [
+        (Token.Status, '%s' % (b.document.cursor_position_row + 1)),
+    ]
+
+
+layout = HSplit([
+    Window(content=TokenListControl(get_statusbar_tokens, align_right=True,
+                                    default_char=Char(token=Token.Status)),
+           height=D.exact(1)),
+
+    # The main content.
+    Window(
+        content=BufferControl(buffer_name=DEFAULT_BUFFER,
+                              input_processors=[HighlightSearchProcessor(preview_search=True)]),
+#        always_hide_cursor=True
+        ),
+
+    SearchToolbar(),
+])
+
+# Key bindings.
+manager = KeyBindingManager(enable_search=True, enable_extra_page_navigation=True)
+
+ at manager.registry.add_binding('q')
+def _(event):
+    " Quit. "
+    event.cli.set_return_value(None)
+
+text = open('./pager.py', 'rb').read().decode('utf-8')
+
+style = PygmentsStyle.from_defaults({
+    Token.Status: 'bg:#444444 #ffffff',
+})
+
+# create application.
+application = Application(
+    layout=layout,
+    buffer=Buffer(initial_document=Document(text=text, cursor_position=0), read_only=True),
+    key_bindings_registry=manager.registry,
+
+    # Let's add mouse support!
+    mouse_support=True,
+    style=style,
+
+    # Using an alternate screen buffer means as much as: "run full screen".
+    # It switches the terminal to an alternate screen.
+    use_alternate_screen=True)
+
+
+def run():
+    eventloop = create_eventloop()
+
+    try:
+        cli = CommandLineInterface(application=application, eventloop=eventloop)
+        cli.run(reset_current_buffer=False)
+
+    finally:
+        eventloop.close()
+
+if __name__ == '__main__':
+    run()
diff --git a/examples/system-autocompletion.py b/examples/system-autocompletion.py
deleted file mode 100644
index f89b9d2..0000000
--- a/examples/system-autocompletion.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/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/prompt_toolkit.egg-info/PKG-INFO b/prompt_toolkit.egg-info/PKG-INFO
index bd517f6..9635de2 100644
--- a/prompt_toolkit.egg-info/PKG-INFO
+++ b/prompt_toolkit.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: prompt-toolkit
-Version: 1.0.0
+Version: 1.0.2
 Summary: Library for building powerful interactive command lines in Python
 Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
 Author: Jonathan Slenders
@@ -41,6 +41,7 @@ Description: Python Prompt Toolkit
         - Multi-line input editing.
         - Advanced code completion.
         - Both Emacs and Vi key bindings. (Similar to readline.)
+        - Even some advanced Vi functionality, like named registers and digraphs.
         - Reverse and forward incremental search.
         - Runs on all Python versions from 2.6 up to 3.5.
         - Works well with Unicode double width characters. (Chinese input.)
@@ -51,7 +52,7 @@ Description: Python Prompt Toolkit
         - Multiple input buffers.
         - No global state.
         - Lightweight, the only dependencies are Pygments, six and wcwidth.
-        - Runs on Linux, OS X, OpenBSD and Windows systems.
+        - Runs on Linux, OS X, FreeBSD, OpenBSD and Windows systems.
         - And much more...
         
         Feel free to create tickets for bugs and feature requests, and create pull
@@ -132,6 +133,8 @@ Description: Python Prompt Toolkit
         - `ipython <http://github.com/ipython/ipython/>`_: The IPython REPL
         - `click-repl <https://github.com/click-contrib/click-repl>`_: Subcommand REPL for click apps.
         - `haxor-news <https://github.com/donnemartin/haxor-news>`_: A Hacker News CLI.
+        - `gitsome <https://github.com/donnemartin/gitsome>`_: A Git/Shell Autocompleter with GitHub Integration.
+        - `http-prompt <https://github.com/eliangcs/http-prompt>`_: An interactive command-line HTTP client.
         
         Full screen applications:
         
diff --git a/prompt_toolkit.egg-info/SOURCES.txt b/prompt_toolkit.egg-info/SOURCES.txt
index 0c45d30..4a67f0d 100644
--- a/prompt_toolkit.egg-info/SOURCES.txt
+++ b/prompt_toolkit.egg-info/SOURCES.txt
@@ -3,19 +3,21 @@ 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-like-readline.py
 examples/autocompletion.py
 examples/autocorrection.py
 examples/bottom-toolbar.py
+examples/chinese-prompt.py
 examples/clock-input.py
 examples/colored-prompt.py
+examples/complete-test.py
+examples/confirmation-prompt.py
 examples/custom-key-binding.py
+examples/finalterm-shell-integration.py
 examples/full-screen-layout.py
 examples/get-input-vi-mode.py
 examples/get-input-with-default.py
@@ -31,13 +33,13 @@ examples/multi-column-autocompletion-with-meta.py
 examples/multi-column-autocompletion.py
 examples/multiline-prompt.py
 examples/no-wrapping.py
+examples/pager.py
 examples/patch-stdout.py
 examples/persistent-history.py
 examples/print-tokens.py
 examples/regular-language.py
 examples/rprompt.py
 examples/switch-between-vi-emacs.py
-examples/system-autocompletion.py
 examples/system-clipboard-integration.py
 examples/system-prompt.py
 examples/telnet.py
@@ -47,6 +49,7 @@ examples/tutorial/sqlite-cli.py
 prompt_toolkit/__init__.py
 prompt_toolkit/application.py
 prompt_toolkit/auto_suggest.py
+prompt_toolkit/benchmark.py
 prompt_toolkit/buffer.py
 prompt_toolkit/buffer_mapping.py
 prompt_toolkit/cache.py
@@ -71,6 +74,7 @@ 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/key_binding/registry.py
 prompt_toolkit/key_binding/vi_state.py
 prompt_toolkit/key_binding/bindings/__init__.py
 prompt_toolkit/key_binding/bindings/basic.py
+prompt_toolkit/key_binding/bindings/completion.py
 prompt_toolkit/key_binding/bindings/emacs.py
 prompt_toolkit/key_binding/bindings/scroll.py
 prompt_toolkit/key_binding/bindings/utils.py
@@ -127,6 +132,7 @@ prompt_toolkit/layout/__init__.py
 prompt_toolkit/layout/containers.py
 prompt_toolkit/layout/controls.py
 prompt_toolkit/layout/dimension.py
+prompt_toolkit/layout/focus.py
 prompt_toolkit/layout/lexers.py
 prompt_toolkit/layout/margins.py
 prompt_toolkit/layout/menus.py
@@ -148,15 +154,15 @@ prompt_toolkit/terminal/vt100_input.py
 prompt_toolkit/terminal/vt100_output.py
 prompt_toolkit/terminal/win32_input.py
 prompt_toolkit/terminal/win32_output.py
-tests/cli_tests.py
-tests/contrib_tests.py
-tests/filter_tests.py
-tests/run_tests.py
-tests/style_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/utils_tests/__init__.py
\ No newline at end of file
+tests/test_buffer.py
+tests/test_cli.py
+tests/test_contrib.py
+tests/test_document.py
+tests/test_filter.py
+tests/test_inputstream.py
+tests/test_key_binding.py
+tests/test_layout.py
+tests/test_regular_languages.py
+tests/test_shortcuts.py
+tests/test_style.py
+tests/test_utils.py
\ No newline at end of file
diff --git a/prompt_toolkit.egg-info/pbr.json b/prompt_toolkit.egg-info/pbr.json
new file mode 100644
index 0000000..92dc09a
--- /dev/null
+++ b/prompt_toolkit.egg-info/pbr.json
@@ -0,0 +1 @@
+{"is_release": false, "git_version": "3e5f60f"}
\ No newline at end of file
diff --git a/prompt_toolkit/__init__.py b/prompt_toolkit/__init__.py
index 04c1450..25ae04a 100644
--- a/prompt_toolkit/__init__.py
+++ b/prompt_toolkit/__init__.py
@@ -19,4 +19,4 @@ from .shortcuts import prompt
 
 
 # Don't forget to update in `docs/conf.py`!
-__version__ = '1.0.0'
+__version__ = '1.0.2'
diff --git a/prompt_toolkit/benchmark.py b/prompt_toolkit/benchmark.py
new file mode 100644
index 0000000..8c1cd31
--- /dev/null
+++ b/prompt_toolkit/benchmark.py
@@ -0,0 +1,20 @@
+
+
+#real_property = property
+#
+#def property(func):
+#    name = '_cache_' + func.__name__
+#    def wrapper(self, *a, **kw):
+#        if hasattr(self, name):
+#            value = getattr(self, name) + 1
+#        else:
+#            value = 1
+#        setattr(self, name, value)
+#
+#        if True:#value > 1:
+#            with open('/tmp/log', 'a') as f:
+#                f.write('accessed %r %i times\n' % (func.__name__, value))
+#
+#        return func(self, *a, **kw)
+#
+#    return real_property(wrapper)
diff --git a/prompt_toolkit/buffer.py b/prompt_toolkit/buffer.py
index 29dac07..739486a 100644
--- a/prompt_toolkit/buffer.py
+++ b/prompt_toolkit/buffer.py
@@ -482,6 +482,20 @@ class Buffer(object):
 
         return '\n'.join(lines)
 
+    def transform_current_line(self, transform_callback):
+        """
+        Apply the given transformation function to the current line.
+
+        :param transform_callback: callable that takes a string and return a new string.
... 5151 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