[Python-modules-commits] [prompt-toolkit] 01/04: Import prompt-toolkit_1.0.7.orig.tar.gz
Scott Kitterman
kitterman at moszumanska.debian.org
Fri Sep 9 04:42:40 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 f316c4932775b820aea7f4b62af195635c5dec1c
Author: Scott Kitterman <scott at kitterman.com>
Date: Fri Sep 9 00:31:12 2016 -0400
Import prompt-toolkit_1.0.7.orig.tar.gz
---
CHANGELOG | 99 ++++++
PKG-INFO | 12 +-
README.rst | 10 +-
examples/ansi-colors.py | 96 +++++
examples/chinese-prompt.py | 8 -
examples/complete-test.py | 83 -----
examples/gevent-get-input.py | 22 ++
examples/pager.py | 85 -----
prompt_toolkit.egg-info/PKG-INFO | 12 +-
prompt_toolkit.egg-info/SOURCES.txt | 10 +-
prompt_toolkit.egg-info/pbr.json | 1 -
prompt_toolkit/__init__.py | 2 +-
prompt_toolkit/benchmark.py | 20 --
prompt_toolkit/buffer.py | 17 +-
prompt_toolkit/cache.py | 20 ++
prompt_toolkit/clipboard/in_memory.py | 5 +-
prompt_toolkit/completion.py | 24 +-
prompt_toolkit/contrib/validators/base.py | 2 +-
prompt_toolkit/document.py | 18 +
prompt_toolkit/eventloop/inputhook.py | 15 +
prompt_toolkit/eventloop/posix.py | 25 +-
prompt_toolkit/eventloop/select.py | 105 ++++++
prompt_toolkit/filters/base.py | 59 ++--
prompt_toolkit/filters/cli.py | 78 ++++-
prompt_toolkit/filters/types.py | 27 +-
prompt_toolkit/input.py | 16 +
prompt_toolkit/interface.py | 100 ++++--
prompt_toolkit/key_binding/bindings/basic.py | 170 +++------
prompt_toolkit/key_binding/bindings/completion.py | 16 +-
prompt_toolkit/key_binding/bindings/emacs.py | 283 ++++-----------
.../key_binding/bindings/named_commands.py | 385 +++++++++++++++++++++
prompt_toolkit/key_binding/bindings/vi.py | 29 +-
prompt_toolkit/key_binding/input_processor.py | 26 +-
prompt_toolkit/key_binding/registry.py | 9 +-
prompt_toolkit/keys.py | 12 +-
prompt_toolkit/layout/__init__.py | 1 -
prompt_toolkit/layout/focus.py | 86 -----
prompt_toolkit/layout/lexers.py | 14 +-
prompt_toolkit/layout/screen.py | 2 +-
prompt_toolkit/layout/toolbars.py | 6 +-
prompt_toolkit/renderer.py | 7 +
prompt_toolkit/shortcuts.py | 42 ++-
prompt_toolkit/terminal/vt100_input.py | 50 ++-
prompt_toolkit/terminal/vt100_output.py | 183 +++++++---
prompt_toolkit/terminal/win32_output.py | 60 ++--
setup.cfg | 2 +-
tests/test_cli.py | 293 +++++++++++++++-
47 files changed, 1732 insertions(+), 915 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 09f8542..d7c0de5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,105 @@
CHANGELOG
=========
+1.0.7: 2016-08-21
+-----------------
+
+Fixes:
+- Bugfix in completion. When calculating the common completion to be inserted,
+ the new completions were calculated wrong.
+- On Windows, avoid extra vertical scrolling if the cursor is already on screen.
+
+New features:
+- Support negative arguments for next/previous word ending/beginning.
+
+
+1.0.6: 2016-08-15
+-----------------
+
+Fixes:
+- Go to the start of the line in Vi nagivation mode, when 'j' or 'k' have been
+ pressed to navigate to a new history entry.
+- Don't crash when pasting text that contains \r\n characters. (This could
+ happen in iTerm2.)
+- Python 2.6 compatibility fix.
+- Allow pressing <esc> before each -ve argument.
+- Better support for conversion from #ffffff values to ANSI colors in
+ Vt100_Output.
+ * Prefer colors with some saturation, instead of gray colors, if the given
+ color was not gray.
+ * Prefer a different foreground and background color if they were
+ originally not the same. (This avoids concealing text.)
+
+New features:
+- Improved ANSI color support.
+ * If the $PROMPT_TOOLKIT_ANSI_COLORS_ONLY environment variable has been
+ set, use the 16 ANSI colors only.
+ * Take an `ansi_colors_only` parameter in `Vt100_Output` and
+ `shortcuts.create_output`.
+
+
+1.0.5: 2016-08-04
+-----------------
+
+Fixes:
+- Critical fix for running on Windows. The gevent work-around in the inputhook
+ caused 'An operation was attempted on something that is not a socket'.
+
+
+1.0.4: 2016-08-03
+-----------------
+
+Fixes:
+- Key binding fixes:
+ * Improved handling of repeat arguments in Emacs mode. Pressing sequences
+ like 'esc---123' do now work (like GNU Readline):
+ - repetition of the minus sign is ignored.
+ - No esc prefix is required for each digit.
+ * Fix in ControlX-ControlX binding.
+ * Fix in bracketed paste.
+ * Pressing Control-U at the start of the line now deletes the newline.
+ * Pressing Control-K at the end of the line, deletes the newline after
+ the cursor.
+ * Support negative argument for Control-K
+ * Fixed cash when left/right were pressed with a negative argument. (In
+ Emacs mode.)
+ * Fix in ControlUp/ControlDown key bindings.
+ * Distinguish backspace from Control-H. They are not the same.
+ * Delete in front of the cursor when a negative argument has been given
+ to backspace.
+ * Handle arrow keys correctly in emacs-term.
+- Performance optimizations:
+ * Performance optimization in Registry.
+ * Several performance optimization in filters.
+ * Import asyncio inline (only if required).
+- Use the best possible selector in the event loop. This fixes bugs in
+ situations where we have too many open file descriptors.
+- Fix UI freeze when gevent monkey patch has been applied.
+- Fix segmentation fault in Alpine Linux. (Regarding the use of ioctl.)
+- Use the correct colors on Windows. (When the foreground/background colors
+ have been modified.)
+- Display a better error message when running in Idle.
+- Additional flags for vt100 inputs: disable flow control.
+- Also patch stderr in CommandLineInterface.patch_stdout_context.
+
+New features:
+- Allow users to enter Vi digraphs in reverse order.
+- Improved autocompletion behaviour. See IPython issue #9658.
+- Added a 'clear' function in the shortcuts module.
+
+For future compatibility:
+- `Keys.Enter` has been added. This is the key that should be bound for
+ handling the enter key.
+
+ Right now, prompt_toolkit translates \r into \n during the handling of the
+ input; this is not correct and makes it impossible to distinguish between
+ ControlJ and ControlM. Some applications bind ControlJ for custom handling of
+ the enter key, because this equals \n. However, in a future version we will
+ stop replacing \r by \n and at that point, the enter key will be ControlM.
+ So better is to use `Keys.Enter`, which becomes an alias for whatever the
+ enter key translates into.
+
+
1.0.3: 2016-06-20
-----------------
diff --git a/PKG-INFO b/PKG-INFO
index a2d4012..0035cfa 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: prompt_toolkit
-Version: 1.0.3
+Version: 1.0.7
Summary: Library for building powerful interactive command lines in Python
Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
Author: Jonathan Slenders
@@ -15,19 +15,19 @@ Description: Python Prompt Toolkit
and terminal applications in Python.
Read the `documentation on readthedocs
- <http://python-prompt-toolkit.readthedocs.org/en/stable/>`_.
+ <http://python-prompt-toolkit.readthedocs.io/en/stable/>`_.
Ptpython
********
`ptpython <http://github.com/jonathanslenders/ptpython/>`_ is an interactive
- Python Shell, build on top of prompt-toolkit.
+ Python Shell, build on top of prompt_toolkit.
.. image :: https://github.com/jonathanslenders/python-prompt-toolkit/raw/master/docs/images/ptpython.png
- prompt-toolkit features
+ prompt_toolkit features
***********************
``prompt_toolkit`` could be a replacement for `GNU readline
@@ -81,7 +81,7 @@ Description: Python Prompt Toolkit
::
- pip install prompt-toolkit
+ pip install prompt_toolkit
For Conda, do:
@@ -113,7 +113,7 @@ Description: Python Prompt Toolkit
unicode_literals`` at the start of the above example.
- Projects using prompt-toolkit
+ Projects using prompt_toolkit
*****************************
Shells:
diff --git a/README.rst b/README.rst
index 2a261e6..8eea0c5 100644
--- a/README.rst
+++ b/README.rst
@@ -7,19 +7,19 @@ Python Prompt Toolkit
and terminal applications in Python.
Read the `documentation on readthedocs
-<http://python-prompt-toolkit.readthedocs.org/en/stable/>`_.
+<http://python-prompt-toolkit.readthedocs.io/en/stable/>`_.
Ptpython
********
`ptpython <http://github.com/jonathanslenders/ptpython/>`_ is an interactive
-Python Shell, build on top of prompt-toolkit.
+Python Shell, build on top of prompt_toolkit.
.. image :: https://github.com/jonathanslenders/python-prompt-toolkit/raw/master/docs/images/ptpython.png
-prompt-toolkit features
+prompt_toolkit features
***********************
``prompt_toolkit`` could be a replacement for `GNU readline
@@ -73,7 +73,7 @@ Installation
::
- pip install prompt-toolkit
+ pip install prompt_toolkit
For Conda, do:
@@ -105,7 +105,7 @@ put a small ``u`` in front of every string or put ``from __future__ import
unicode_literals`` at the start of the above example.
-Projects using prompt-toolkit
+Projects using prompt_toolkit
*****************************
Shells:
diff --git a/examples/ansi-colors.py b/examples/ansi-colors.py
new file mode 100755
index 0000000..5e12c2a
--- /dev/null
+++ b/examples/ansi-colors.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+"""
+Demonstration of all the ANSI colors.
+"""
+from __future__ import unicode_literals
+from prompt_toolkit.shortcuts import print_tokens
+from prompt_toolkit.styles import style_from_dict
+from prompt_toolkit.token import Token
+
+
+def main():
+ style = style_from_dict({
+ Token.Title: 'underline',
+
+ Token.Black: '#ansiblack',
+ Token.White: '#ansiwhite',
+ Token.Red: '#ansired',
+ Token.Green: '#ansigreen',
+ Token.Yellow: '#ansiyellow',
+ Token.Blue: '#ansiblue',
+ Token.Fuchsia: '#ansifuchsia',
+ Token.Turquoise: '#ansiturquoise',
+ Token.LightGray: '#ansilightgray',
+
+ Token.DarkGray: '#ansidarkgray',
+ Token.DarkRed: '#ansidarkred',
+ Token.DarkGreen: '#ansidarkgreen',
+ Token.Brown: '#ansibrown',
+ Token.DarkBlue: '#ansidarkblue',
+ Token.Purple: '#ansipurple',
+ Token.Teal: '#ansiteal',
+
+ Token.BgBlack: 'bg:#ansiblack',
+ Token.BgWhite: 'bg:#ansiwhite',
+ Token.BgRed: 'bg:#ansired',
+ Token.BgGreen: 'bg:#ansigreen',
+ Token.BgYellow: 'bg:#ansiyellow',
+ Token.BgBlue: 'bg:#ansiblue',
+ Token.BgFuchsia: 'bg:#ansifuchsia',
+ Token.BgTurquoise: 'bg:#ansiturquoise',
+ Token.BgLightGray: 'bg:#ansilightgray',
+
+ Token.BgDarkGray: 'bg:#ansidarkgray',
+ Token.BgDarkRed: 'bg:#ansidarkred',
+ Token.BgDarkGreen: 'bg:#ansidarkgreen',
+ Token.BgBrown: 'bg:#ansibrown',
+ Token.BgDarkBlue: 'bg:#ansidarkblue',
+ Token.BgPurple: 'bg:#ansipurple',
+ Token.BgTeal: 'bg:#ansiteal',
+ })
+ tokens = [
+ (Token.Title, 'Foreground colors'), (Token, '\n'),
+ (Token.Black, '#ansiblack'), (Token, '\n'),
+ (Token.White, '#ansiwhite'), (Token, '\n'),
+ (Token.Red, '#ansired'), (Token, '\n'),
+ (Token.Green, '#ansigreen'), (Token, '\n'),
+ (Token.Yellow, '#ansiyellow'), (Token, '\n'),
+ (Token.Blue, '#ansiblue'), (Token, '\n'),
+ (Token.Fuchsia, '#ansifuchsia'), (Token, '\n'),
+ (Token.Turquoise, '#ansiturquoise'), (Token, '\n'),
+ (Token.LightGray, '#ansilightgray'), (Token, '\n'),
+
+ (Token.DarkGray, '#ansidarkgray'), (Token, '\n'),
+ (Token.DarkRed, '#ansidarkred'), (Token, '\n'),
+ (Token.DarkGreen, '#ansidarkgreen'), (Token, '\n'),
+ (Token.Brown, '#ansibrown'), (Token, '\n'),
+ (Token.DarkBlue, '#ansidarkblue'), (Token, '\n'),
+ (Token.Purple, '#ansipurple'), (Token, '\n'),
+ (Token.Teal, '#ansiteal'), (Token, '\n'),
+
+ (Token.Title, 'Background colors'), (Token, '\n'),
+ (Token.BgBlack, '#ansiblack'), (Token, '\n'),
+ (Token.BgWhite, '#ansiwhite'), (Token, '\n'),
+ (Token.BgRed, '#ansired'), (Token, '\n'),
+ (Token.BgGreen, '#ansigreen'), (Token, '\n'),
+ (Token.BgYellow, '#ansiyellow'), (Token, '\n'),
+ (Token.BgBlue, '#ansiblue'), (Token, '\n'),
+ (Token.BgFuchsia, '#ansifuchsia'), (Token, '\n'),
+ (Token.BgTurquoise, '#ansiturquoise'), (Token, '\n'),
+ (Token.BgLightGray, '#ansilightgray'), (Token, '\n'),
+
+ (Token.BgDarkGray, '#ansidarkgray'), (Token, '\n'),
+ (Token.BgDarkRed, '#ansidarkred'), (Token, '\n'),
+ (Token.BgDarkGreen, '#ansidarkgreen'), (Token, '\n'),
+ (Token.BgBrown, '#ansibrown'), (Token, '\n'),
+ (Token.BgDarkBlue, '#ansidarkblue'), (Token, '\n'),
+ (Token.BgPurple, '#ansipurple'), (Token, '\n'),
+ (Token.BgTeal, '#ansiteal'), (Token, '\n'),
+
+ (Token, '\n'),
+ ]
+ print_tokens(tokens, style=style)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/examples/chinese-prompt.py b/examples/chinese-prompt.py
deleted file mode 100755
index 0687f7b..0000000
--- a/examples/chinese-prompt.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/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/complete-test.py b/examples/complete-test.py
deleted file mode 100755
index 3ca37e5..0000000
--- a/examples/complete-test.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/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/gevent-get-input.py b/examples/gevent-get-input.py
new file mode 100755
index 0000000..8449b54
--- /dev/null
+++ b/examples/gevent-get-input.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+"""
+For testing: test to make sure that everything still works when gevent monkey
+patches are applied.
+"""
+from __future__ import unicode_literals
+from gevent.monkey import patch_all
+from prompt_toolkit.shortcuts import prompt, create_eventloop
+
+
+if __name__ == '__main__':
+ # Apply patches.
+ patch_all()
+
+ # There were some issues in the past when the event loop had an input hook.
+ def dummy_inputhook(*a):
+ pass
+ eventloop = create_eventloop(inputhook=dummy_inputhook)
+
+ # Ask for input.
+ answer = prompt('Give me some input: ', eventloop=eventloop)
+ print('You said: %s' % answer)
diff --git a/examples/pager.py b/examples/pager.py
deleted file mode 100755
index 0dcd7ec..0000000
--- a/examples/pager.py
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/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/prompt_toolkit.egg-info/PKG-INFO b/prompt_toolkit.egg-info/PKG-INFO
index 362a351..8a6d2bb 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.3
+Version: 1.0.7
Summary: Library for building powerful interactive command lines in Python
Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
Author: Jonathan Slenders
@@ -15,19 +15,19 @@ Description: Python Prompt Toolkit
and terminal applications in Python.
Read the `documentation on readthedocs
- <http://python-prompt-toolkit.readthedocs.org/en/stable/>`_.
+ <http://python-prompt-toolkit.readthedocs.io/en/stable/>`_.
Ptpython
********
`ptpython <http://github.com/jonathanslenders/ptpython/>`_ is an interactive
- Python Shell, build on top of prompt-toolkit.
+ Python Shell, build on top of prompt_toolkit.
.. image :: https://github.com/jonathanslenders/python-prompt-toolkit/raw/master/docs/images/ptpython.png
- prompt-toolkit features
+ prompt_toolkit features
***********************
``prompt_toolkit`` could be a replacement for `GNU readline
@@ -81,7 +81,7 @@ Description: Python Prompt Toolkit
::
- pip install prompt-toolkit
+ pip install prompt_toolkit
For Conda, do:
@@ -113,7 +113,7 @@ Description: Python Prompt Toolkit
unicode_literals`` at the start of the above example.
- Projects using prompt-toolkit
+ Projects using prompt_toolkit
*****************************
Shells:
diff --git a/prompt_toolkit.egg-info/SOURCES.txt b/prompt_toolkit.egg-info/SOURCES.txt
index 4a67f0d..8c9079b 100644
--- a/prompt_toolkit.egg-info/SOURCES.txt
+++ b/prompt_toolkit.egg-info/SOURCES.txt
@@ -5,16 +5,15 @@ MANIFEST.in
README.rst
setup.py
examples/abortaction.retry.py
+examples/ansi-colors.py
examples/asyncio-prompt.py
examples/auto-suggestion.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
@@ -25,6 +24,7 @@ examples/get-input.py
examples/get-multiline-input.py
examples/get-password-with-toggle-display-shortcut.py
examples/get-password.py
+examples/gevent-get-input.py
examples/html-input.py
examples/input-validation.py
examples/inputhook.py
@@ -33,7 +33,6 @@ 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
@@ -49,7 +48,6 @@ 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
@@ -74,7 +72,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
@@ -108,6 +105,7 @@ prompt_toolkit/eventloop/callbacks.py
prompt_toolkit/eventloop/inputhook.py
prompt_toolkit/eventloop/posix.py
prompt_toolkit/eventloop/posix_utils.py
+prompt_toolkit/eventloop/select.py
prompt_toolkit/eventloop/utils.py
prompt_toolkit/eventloop/win32.py
prompt_toolkit/filters/__init__.py
@@ -125,6 +123,7 @@ 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/named_commands.py
prompt_toolkit/key_binding/bindings/scroll.py
prompt_toolkit/key_binding/bindings/utils.py
prompt_toolkit/key_binding/bindings/vi.py
@@ -132,7 +131,6 @@ 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
diff --git a/prompt_toolkit.egg-info/pbr.json b/prompt_toolkit.egg-info/pbr.json
deleted file mode 100644
index b41d2b3..0000000
--- a/prompt_toolkit.egg-info/pbr.json
+++ /dev/null
@@ -1 +0,0 @@
-{"is_release": false, "git_version": "a6c27e6"}
\ No newline at end of file
diff --git a/prompt_toolkit/__init__.py b/prompt_toolkit/__init__.py
index 381aad8..b5a76aa 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.3'
+__version__ = '1.0.7'
diff --git a/prompt_toolkit/benchmark.py b/prompt_toolkit/benchmark.py
deleted file mode 100644
index 8c1cd31..0000000
--- a/prompt_toolkit/benchmark.py
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-#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 739486a..2612f8d 100644
--- a/prompt_toolkit/buffer.py
+++ b/prompt_toolkit/buffer.py
@@ -537,7 +537,7 @@ class Buffer(object):
# Remember the original column for the next up/down movement.
self.preferred_column = original_column
- def auto_up(self, count=1):
+ def auto_up(self, count=1, go_to_start_of_line_if_history_changes=False):
"""
If we're not on the first line (of a multiline input) go a line up,
otherwise go back in history. (If nothing is selected.)
@@ -549,7 +549,11 @@ class Buffer(object):
elif not self.selection_state:
self.history_backward(count=count)
- def auto_down(self, count=1):
+ # Go to the start of the line?
+ if go_to_start_of_line_if_history_changes:
+ self.cursor_position += self.document.get_start_of_line_position()
+
+ def auto_down(self, count=1, go_to_start_of_line_if_history_changes=False):
"""
If we're not on the last line (of a multiline input) go a line down,
otherwise go forward in history. (If nothing is selected.)
@@ -561,9 +565,14 @@ class Buffer(object):
elif not self.selection_state:
self.history_forward(count=count)
+ # Go to the start of the line?
+ if go_to_start_of_line_if_history_changes:
+ self.cursor_position += self.document.get_start_of_line_position()
+
def delete_before_cursor(self, count=1):
"""
- Delete character before cursor, return deleted character.
+ Delete specified number of characters before cursor and return the
+ deleted text.
"""
assert count >= 0
deleted = ''
@@ -581,7 +590,7 @@ class Buffer(object):
def delete(self, count=1):
"""
- Delete one character. Return deleted character.
+ Delete specified number of characters and Return the deleted text.
"""
if self.cursor_position < len(self.text):
deleted = self.document.text_after_cursor[:count]
diff --git a/prompt_toolkit/cache.py b/prompt_toolkit/cache.py
index 8edb03e..55c7369 100644
--- a/prompt_toolkit/cache.py
+++ b/prompt_toolkit/cache.py
@@ -1,9 +1,11 @@
from __future__ import unicode_literals
from collections import deque
+from functools import wraps
__all__ = (
'SimpleCache',
'FastDictCache',
+ 'memoized',
)
@@ -89,3 +91,21 @@ class FastDictCache(dict):
self[key] = result
self._keys.append(key)
return result
+
+
+def memoized(maxsize=1024):
+ """
+ Momoization decorator for immutable classes and pure functions.
+ """
+ cache = SimpleCache(maxsize=maxsize)
+
+ def decorator(obj):
+ @wraps(obj)
+ def new_callable(*a, **kw):
+ def create_new():
+ return obj(*a, **kw)
+
+ key = (a, tuple(kw.items()))
+ return cache.get(key, create_new)
+ return new_callable
+ return decorator
diff --git a/prompt_toolkit/clipboard/in_memory.py b/prompt_toolkit/clipboard/in_memory.py
index ea4dec4..e7cd0ef 100644
--- a/prompt_toolkit/clipboard/in_memory.py
+++ b/prompt_toolkit/clipboard/in_memory.py
@@ -10,8 +10,9 @@ class InMemoryClipboard(Clipboard):
Default clipboard implementation.
Just keep the data in memory.
"""
- def __init__(self):
- self._data = None
+ def __init__(self, data=None):
+ assert data is None or isinstance(data, ClipboardData)
+ self._data = data
def set_data(self, data):
assert isinstance(data, ClipboardData)
diff --git a/prompt_toolkit/completion.py b/prompt_toolkit/completion.py
index 056274a..339738a 100644
--- a/prompt_toolkit/completion.py
+++ b/prompt_toolkit/completion.py
@@ -40,8 +40,13 @@ class Completion(object):
assert self.start_position <= 0
def __repr__(self):
- return '%s(text=%r, start_position=%r)' % (
- self.__class__.__name__, self.text, self.start_position)
+ if self.display == self.text:
+ return '%s(text=%r, start_position=%r)' % (
+ self.__class__.__name__, self.text, self.start_position)
+ else:
+ return '%s(text=%r, start_position=%r, display=%r)' % (
+ self.__class__.__name__, self.text, self.start_position,
+ self.display)
def __eq__(self, other):
return (
@@ -66,6 +71,21 @@ class Completion(object):
else:
return ''
+ def new_completion_from_position(self, position):
+ """
+ (Only for internal use!)
+ Get a new completion by splitting this one. Used by
+ `CommandLineInterface` when it needs to have a list of new completions
+ after inserting the common prefix.
+ """
+ assert isinstance(position, int) and position - self.start_position >= 0
+
+ return Completion(
+ text=self.text[position - self.start_position:],
+ display=self.display,
+ display_meta=self._display_meta,
+ get_display_meta=self._get_display_meta)
+
class CompleteEvent(object):
"""
diff --git a/prompt_toolkit/contrib/validators/base.py b/prompt_toolkit/contrib/validators/base.py
index a883bd5..16c1539 100644
--- a/prompt_toolkit/contrib/validators/base.py
+++ b/prompt_toolkit/contrib/validators/base.py
@@ -21,7 +21,7 @@ class SentenceValidator(Validator):
self.move_cursor_to_end = move_cursor_to_end
if ignore_case:
- self.sentences = {s.lower() for s in self.sentences}
+ self.sentences = set([s.lower() for s in self.sentences])
def validate(self, document):
if document.text not in self.sentences:
diff --git a/prompt_toolkit/document.py b/prompt_toolkit/document.py
index ce34820..470ba27 100644
--- a/prompt_toolkit/document.py
+++ b/prompt_toolkit/document.py
@@ -480,6 +480,9 @@ class Document(object):
Return an index relative to the cursor position pointing to the start
of the next word. Return `None` if nothing was found.
"""
+ if count < 0:
+ return self.find_previous_word_beginning(count=-count, WORD=WORD)
+
regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
iterator = regex.finditer(self.text_after_cursor)
@@ -499,6 +502,9 @@ class Document(object):
Return an index relative to the cursor position pointing to the end
of the next word. Return `None` if nothing was found.
"""
+ if count < 0:
+ return self.find_previous_word_ending(count=-count, WORD=WORD)
+
if include_current_position:
text = self.text_after_cursor
else:
@@ -525,6 +531,9 @@ class Document(object):
Return an index relative to the cursor position pointing to the start
of the previous word. Return `None` if nothing was found.
"""
+ if count < 0:
+ return self.find_next_word_beginning(count=-count, WORD=WORD)
+
regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
iterator = regex.finditer(self.text_before_cursor[::-1])
@@ -540,6 +549,9 @@ class Document(object):
Return an index relative to the cursor position pointing to the end
of the previous word. Return `None` if nothing was found.
"""
+ if count < 0:
+ return self.find_next_word_ending(count=-count, WORD=WORD)
+
text_before_cursor = self.text_after_cursor[:1] + self.text_before_cursor[::-1]
regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
@@ -594,12 +606,18 @@ class Document(object):
"""
Relative position for cursor left.
"""
+ if count < 0:
+ return self.get_cursor_right_position(-count)
+
return - min(self.cursor_position_col, count)
def get_cursor_right_position(self, count=1):
"""
Relative position for cursor_right.
"""
+ if count < 0:
+ return self.get_cursor_left_position(-count)
+
return min(count, len(self.current_line_after_cursor))
def get_cursor_up_position(self, count=1, preferred_column=None):
diff --git a/prompt_toolkit/eventloop/inputhook.py b/prompt_toolkit/eventloop/inputhook.py
index 0d2b82e..bab1f4c 100644
--- a/prompt_toolkit/eventloop/inputhook.py
+++ b/prompt_toolkit/eventloop/inputhook.py
@@ -25,6 +25,8 @@ controls everything.
from __future__ import unicode_literals
import os
import threading
+from prompt_toolkit.utils import is_windows
+from .select import select_fds
__all__ = (
'InputHookContext',
@@ -73,6 +75,19 @@ class InputHookContext(object):
... 3184 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