[Python-modules-commits] [prompt-toolkit] 01/04: Imported Upstream version 1.0.15

Scott Kitterman kitterman at moszumanska.debian.org
Mon Jan 8 21:51:38 UTC 2018


This is an automated email from the git hooks/post-receive script.

kitterman pushed a commit to branch debian/master
in repository prompt-toolkit.

commit 17a720df9d286d9cdb890e7441e97a77dcc4ed16
Author: Scott Kitterman <scott at kitterman.com>
Date:   Mon Jan 8 16:42:04 2018 -0500

    Imported Upstream version 1.0.15
---
 CHANGELOG                                    | 15 +++++++++++++++
 PKG-INFO                                     |  3 ++-
 README.rst                                   |  1 +
 prompt_toolkit.egg-info/PKG-INFO             |  3 ++-
 prompt_toolkit/__init__.py                   |  2 +-
 prompt_toolkit/buffer.py                     |  2 +-
 prompt_toolkit/eventloop/posix.py            |  5 -----
 prompt_toolkit/interface.py                  |  9 +++++++--
 prompt_toolkit/key_binding/bindings/emacs.py |  1 +
 prompt_toolkit/key_binding/bindings/vi.py    |  2 +-
 prompt_toolkit/renderer.py                   | 17 +++++++++++++----
 11 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 1666226..c81a177 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,21 @@
 CHANGELOG
 =========
 
+1.0.15: 2017-07-27
+------------------
+
+Fixes:
+- Don't shuffle tasks in the event loop. This fixes an issue where lines
+  printed from background threads were printed in a different order if
+  `patch_stdout=True`.
+- Only consider the text before the cursor when activating history search.
+- Pressing escape should accept the search, this is closer to how readline works.
+- Enable autowrap again when required.
+
+New features:
+- Add run_in_terminal option to disable cooked mode.
+
+
 1.0.14: 2017-03-26
 ------------------
 
diff --git a/PKG-INFO b/PKG-INFO
index 6aeb2d2..8b98df5 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: prompt_toolkit
-Version: 1.0.14
+Version: 1.0.15
 Summary: Library for building powerful interactive command lines in Python
 Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
 Author: Jonathan Slenders
@@ -137,6 +137,7 @@ Description: Python Prompt Toolkit
         - `http-prompt <https://github.com/eliangcs/http-prompt>`_: An interactive command-line HTTP client.
         - `coconut <http://coconut-lang.org/>`_: Functional programming in Python.
         - `Ergonomica <https://ergonomica.github.io/>`_: A Bash alternative written in Python.
+        - `Kube-shell <https://github.com/cloudnativelabs/kube-shell>`_: Kubernetes shell: An integrated shell for working with the Kubernetes CLI
         
         Full screen applications:
         
diff --git a/README.rst b/README.rst
index ba7c983..35b1745 100644
--- a/README.rst
+++ b/README.rst
@@ -129,6 +129,7 @@ Shells:
 - `http-prompt <https://github.com/eliangcs/http-prompt>`_: An interactive command-line HTTP client.
 - `coconut <http://coconut-lang.org/>`_: Functional programming in Python.
 - `Ergonomica <https://ergonomica.github.io/>`_: A Bash alternative written in Python.
+- `Kube-shell <https://github.com/cloudnativelabs/kube-shell>`_: Kubernetes shell: An integrated shell for working with the Kubernetes CLI
 
 Full screen applications:
 
diff --git a/prompt_toolkit.egg-info/PKG-INFO b/prompt_toolkit.egg-info/PKG-INFO
index c5685cc..e63fa27 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.14
+Version: 1.0.15
 Summary: Library for building powerful interactive command lines in Python
 Home-page: https://github.com/jonathanslenders/python-prompt-toolkit
 Author: Jonathan Slenders
@@ -137,6 +137,7 @@ Description: Python Prompt Toolkit
         - `http-prompt <https://github.com/eliangcs/http-prompt>`_: An interactive command-line HTTP client.
         - `coconut <http://coconut-lang.org/>`_: Functional programming in Python.
         - `Ergonomica <https://ergonomica.github.io/>`_: A Bash alternative written in Python.
+        - `Kube-shell <https://github.com/cloudnativelabs/kube-shell>`_: Kubernetes shell: An integrated shell for working with the Kubernetes CLI
         
         Full screen applications:
         
diff --git a/prompt_toolkit/__init__.py b/prompt_toolkit/__init__.py
index eb80a15..1f679f0 100644
--- a/prompt_toolkit/__init__.py
+++ b/prompt_toolkit/__init__.py
@@ -19,4 +19,4 @@ from .shortcuts import prompt, prompt_async
 
 
 # Don't forget to update in `docs/conf.py`!
-__version__ = '1.0.14'
+__version__ = '1.0.15'
diff --git a/prompt_toolkit/buffer.py b/prompt_toolkit/buffer.py
index 92bab8f..f5df289 100644
--- a/prompt_toolkit/buffer.py
+++ b/prompt_toolkit/buffer.py
@@ -849,7 +849,7 @@ class Buffer(object):
         """ Set `history_search_text`. """
         if self.enable_history_search():
             if self.history_search_text is None:
-                self.history_search_text = self.text
+                self.history_search_text = self.document.text_before_cursor
         else:
             self.history_search_text = None
 
diff --git a/prompt_toolkit/eventloop/posix.py b/prompt_toolkit/eventloop/posix.py
index 9ca3fc9..f631dbd 100644
--- a/prompt_toolkit/eventloop/posix.py
+++ b/prompt_toolkit/eventloop/posix.py
@@ -1,7 +1,6 @@
 from __future__ import unicode_literals
 import fcntl
 import os
-import random
 import signal
 import threading
 import time
@@ -153,10 +152,6 @@ class PosixEventLoop(EventLoop):
                             if handler:
                                 tasks.append(handler)
 
-                    # Handle everything in random order. (To avoid starvation.)
-                    random.shuffle(tasks)
-                    random.shuffle(low_priority_tasks)
-
                     # When there are high priority tasks, run all these.
                     # Schedule low priority tasks for the next iteration.
                     if tasks:
diff --git a/prompt_toolkit/interface.py b/prompt_toolkit/interface.py
index 898ac0e..e1e0e56 100644
--- a/prompt_toolkit/interface.py
+++ b/prompt_toolkit/interface.py
@@ -611,7 +611,7 @@ class CommandLineInterface(object):
         if self.eventloop:
             self.eventloop.stop()
 
-    def run_in_terminal(self, func, render_cli_done=False):
+    def run_in_terminal(self, func, render_cli_done=False, cooked_mode=True):
         """
         Run function on the terminal above the prompt.
 
@@ -624,6 +624,8 @@ class CommandLineInterface(object):
         :param render_cli_done: When True, render the interface in the
                 'Done' state first, then execute the function. If False,
                 erase the interface first.
+        :param cooked_mode: When True (the default), switch the input to
+                cooked mode while executing the function.
 
         :returns: the result of `func`.
         """
@@ -637,7 +639,10 @@ class CommandLineInterface(object):
         self._return_value = None
 
         # Run system command.
-        with self.input.cooked_mode():
+        if cooked_mode:
+            with self.input.cooked_mode():
+                result = func()
+        else:
             result = func()
 
         # Redraw interface again.
diff --git a/prompt_toolkit/key_binding/bindings/emacs.py b/prompt_toolkit/key_binding/bindings/emacs.py
index efd8df6..bccdb04 100644
--- a/prompt_toolkit/key_binding/bindings/emacs.py
+++ b/prompt_toolkit/key_binding/bindings/emacs.py
@@ -375,6 +375,7 @@ def load_emacs_search_bindings(get_search_state=None):
         event.cli.pop_focus()
 
     @handle(Keys.ControlJ, filter=has_focus)
+    @handle(Keys.Escape, filter=has_focus, eager=True)
     def _(event):
         """
         When enter pressed in isearch, quit isearch mode. (Multiline
diff --git a/prompt_toolkit/key_binding/bindings/vi.py b/prompt_toolkit/key_binding/bindings/vi.py
index 1455100..72568ee 100644
--- a/prompt_toolkit/key_binding/bindings/vi.py
+++ b/prompt_toolkit/key_binding/bindings/vi.py
@@ -1808,6 +1808,7 @@ def load_vi_search_bindings(get_search_state=None,
         event.cli.vi_state.input_mode = InputMode.INSERT
 
     @handle(Keys.ControlJ, filter=has_focus)
+    @handle(Keys.Escape, filter=has_focus)
     def _(event):
         """
         Apply the search. (At the / or ? prompt.)
@@ -1857,7 +1858,6 @@ def load_vi_search_bindings(get_search_state=None,
         """ Returns True when the search buffer is empty. """
         return cli.buffers[search_buffer_name].text == ''
 
-    @handle(Keys.Escape, filter=has_focus)
     @handle(Keys.ControlC, filter=has_focus)
     @handle(Keys.ControlH, filter=has_focus & Condition(search_buffer_is_empty))
     @handle(Keys.Backspace, filter=has_focus & Condition(search_buffer_is_empty))
diff --git a/prompt_toolkit/renderer.py b/prompt_toolkit/renderer.py
index b4c4a71..7a8fde5 100644
--- a/prompt_toolkit/renderer.py
+++ b/prompt_toolkit/renderer.py
@@ -21,7 +21,8 @@ __all__ = (
 
 
 def _output_screen_diff(output, screen, current_pos, previous_screen=None, last_token=None,
-                        is_done=False, attrs_for_token=None, size=None, previous_width=0):  # XXX: drop is_done
+                        is_done=False, use_alternate_screen=False, attrs_for_token=None, size=None,
+                        previous_width=0):  # XXX: drop is_done
     """
     Render the diff between this screen and the previous screen.
 
@@ -108,11 +109,17 @@ def _output_screen_diff(output, screen, current_pos, previous_screen=None, last_
             write(char.char)
             last_token[0] = char.token
 
-    # Disable autowrap
+    # Render for the first time: reset styling.
     if not previous_screen:
-        output.disable_autowrap()
         reset_attributes()
 
+    # Disable autowrap. (When entering a the alternate screen, or anytime when
+    # we have a prompt. - In the case of a REPL, like IPython, people can have
+    # background threads, and it's hard for debugging if their output is not
+    # wrapped.)
+    if not previous_screen or not use_alternate_screen:
+        output.disable_autowrap()
+
     # When the previous screen has a different size, redraw everything anyway.
     # Also when we are done. (We meight take up less rows, so clearing is important.)
     if is_done or not previous_screen or previous_width != width:  # XXX: also consider height??
@@ -187,7 +194,7 @@ def _output_screen_diff(output, screen, current_pos, previous_screen=None, last_
     else:
         current_pos = move_cursor(screen.cursor_position)
 
-    if is_done:
+    if is_done or not use_alternate_screen:
         output.enable_autowrap()
 
     # Always reset the color attributes. This is important because a background
@@ -437,6 +444,7 @@ class Renderer(object):
         self._cursor_pos, self._last_token = _output_screen_diff(
             output, screen, self._cursor_pos,
             self._last_screen, self._last_token, is_done,
+            use_alternate_screen=self.use_alternate_screen,
             attrs_for_token=self._attrs_for_token,
             size=size,
             previous_width=(self._last_size.columns if self._last_size else 0))
@@ -472,6 +480,7 @@ class Renderer(object):
         output.cursor_up(self._cursor_pos.y)
         output.erase_down()
         output.reset_attributes()
+        output.enable_autowrap()
         output.flush()
 
         # Erase title.

-- 
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