Changelog History
Page 5
-
v2.0.3 Changes
June 08, 2018๐ Bug fixes:
- ๐ Fix in 'x' and 'X' Vi key bindings. Correctly handle line endings and args.
- ๐ Fixed off by one error in Vi line selection.
- ๐ Fixed bugs in Vi block selection. Correctly handle lines that the selection doesn't cross.
- ๐ Python 2 bugfix. Handle str/unicode correctly.
- ๐ Handle option+left/right in iTerm.
-
v2.0.2 Changes
June 03, 2018๐ Bug fixes:
- ๐ Python 3.7 support: correctly handle StopIteration in asynchronous generator.
- ๐ Fixed off-by-one bug in Vi visual block mode.
- ๐ Bugfix in TabsProcessor: handle situations when the cursor is at the end of the line.
-
v2.0.1 Changes
June 02, 2018๐ Version 2.0 includes a big refactoring of the internal architecture. This ๐ includes the merge of the CommandLineInterface and the Application object, a rewrite of how user controls are focused, a rewrite of how event loops work and the removal of the buffers dictionary. This introduces many backwards incompatible changes, but the result is a very nice and powerful architecture.
Most architectural changes effect full screen applications. For applications that use
prompt_toolkit.shortcuts
for simple prompts, there are fewer incompatibilities.๐ Changes:
๐ No automatic translation from \r into \n during the input processing. These are two different keys that can be handled independently. This is a big backward-incompatibility, because the
Enter
key isControlM
, notControlJ
. So, now that we stopped translating \r into \n, it could be that custom key bindings forEnter
don't work anymore. Make sure to bindKeys.Enter
instead ofKeys.ControlJ
for handling theEnter
key.๐ The
CommandLineInterface
and theApplication
classes are merged. First,CommandLineInterface
contained all the I/O objects (like the input, output and event loop), while theApplication
contained everything else. There was no practical reason to keep this separation. (CommandLineInterface
was mostly a proxy toApplication
.)
A consequence is that almost all code which used to receive a
CommandLineInterface
, will now use anApplication
. Usually, where we had an attributecli
, we'll now have an attributeapp
.Secondly, the
Application
object is no longer passed around. Theget_app
function can be used at any time to acquire the active application.(For backwards-compatibility, we have aliases to the old names, whenever possible.)
prompt_toolkit no longer depends on Pygments, but it can still use Pygments for its color schemes and lexers. In many places we used Pygments "Tokens", this has been replaced by the concept of class names, somewhat similar to HTML and CSS.
PygmentsStyle
andPygmentsLexer
adaptors are available for plugging in Pygments styles and lexers.- Wherever we had a list of
(Token, text)
tuples, we now have lists of(style_string, text)
tuples. The style string can contain both inline styling as well as refer to a class from the style sheet.PygmentsTokens
is an adaptor that converts a list of Pygments tokens into a list of(style_string, text)
tuples.
๐ Changes in the
Style
classes.style.from_dict
does not exist anymore. Instantiate theStyle
class directory to create a new style.Style.from_dict
can be used to create a style from a dictionary, where the dictionary keys are a space separated list of class names, and the values, style strings (like before).print_tokens
was renamed toprint_formatted_text
.- In many places in the layout, we accept a parameter named
style
. All the styles from the layout hierarchy are combined to decide what style to be used. - The ANSI color names were confusing and inconsistent with common naming conventions. This has been fixed, but aliases for the original names were kept.
The way focusing works is different. Before it was always a
Buffer
that was focused, and because of that, any visibleBufferControl
that contained thisBuffer
would be focused. Now, any user control can be focused. All of this is handled in theApplication.layout
object.The
buffers
dictionary (CommandLineInterface.buffers
) does not exist anymore. Further,buffers
was aBufferMapping
that keeps track of which buffer has the focus. This significantly reduces the freedom for creating complex applications. We wanted to move toward a layout that can be defined as a (hierarchical) collection of user widgets. A user widget does not need to have aBuffer
underneath and any widget should be focusable.layout.Layout
was introduced to contain the root layout widget and keep track of the focus.
๐จ The key bindings were refactored. It became much more flexible to combine sets of key bindings.
Registry
has been renamed toKeyBindings
.- The
add_binding
function has been renamed to simplyadd
. - Every
load_*
function returns oneKeyBindings
objects, instead of populating an existing one, like before. ConditionalKeyBindings
was added. This can be used to enable/disable all the key bindings from a givenRegistry
.- A function named
merge_key_bindings
was added. This takes a list ofKeyBindings
and merges them into one. key_binding.defaults.load_key_bindings
was added to load all the key bindings.KeyBindingManager
has been removed completely.input_processor
was renamed tokey_processor
.
Further:
- The
Key
class does not exist anymore. Every key is a string and it's considered fine to use string literals in the key bindings. This is more readable, but we still have run-time validation. TheKeys
enum still exist (for backwards-compatibility, but also to have an overview of which keys are supported.) 'enter' and 'tab' are key aliases for 'c-m' and 'c-i'.
- ๐ User controls can define key bindings, which are active when the user control is focused.
UIControl
got aget_key_bindings
(abstract) method.- ๐ Changes in the layout engine:
LayoutDimension
was renamed toDimension
.VSplit
andHSplit
now take apadding
argument.VSplit
andHSplit
now take analign
argument. (TOP/CENTER/BOTTOM/JUSTIFY) or (LEFT/CENTER/RIGHT/JUSTIFY).Float
now takesallow_cover_cursor
andattach_to_window
arguments.Window
got anWindowAlign
argument. This can be used for the alignment of the content.TokenListControl
(renamed toFormattedTextControl
) does not have an alignment argument anymore.All container objects, like
Window
, got astyle
argument. The style for parent containers propagate to child containers, but can be overriden. This is in particular useful for setting a background color.FillControl
does not exist anymore. Use thestyle
andchar
arguments of theWindow
class instead.DummyControl
was added.The continuation function of
PromptMargin
now takesline_number
andis_soft_wrap
as input.- ๐ Changes to
BufferControl
:
- ๐ Changes to
The
InputProcessor
class has been refactored. Theapply_transformation
method should now takes aTransformationInput
object as input.The text
(reverse-i-search)
is now displayed through a processor. (See theshortcuts
module for an example of its usage.)- ๐
widgets
anddialogs
modules:
- ๐
A small collection of widgets was added. These are more complex collections of user controls that are ready to embed in a layout. A
shortcuts.dialogs
module was added as a high level API for displaying input, confirmation and message dialogs.Every class that exposes a
__pt_container__
method (which is supposed to return aContainer
instance) is considered a widget. Theto_container
shortcut will call this method in situations where aContainer
object is expected. This avoids inheritance from otherContainer
types, but also having to unpack the container object from the widget, in case we would have used composition.Warning: The API of the widgets module is not considered stable yet, and can change is the future, if needed.
- ๐ Changes to
Buffer
:
- ๐ Changes to
A
Buffer
no longer takes anaccept_action
. BothAcceptAction
andAbortAction
have been removed. Instead it takes anaccept_handler
.- ๐ Changes regarding auto completion:
The left and right arrows now work in the multi-column auto completion menu.
By default, autocompletion is synchronous. The completer needs to be wrapped in
ThreadedCompleter
in order to get asynchronous autocompletion.When the completer runs in a background thread, completions will be displayed as soon as they are generated. This means that we don't have to wait for all the completions to be generated, before displaying the first one. The completion menus are updated as soon as new completions arrive.
- ๐ Changes regarding input validation:
Added the
Validator.from_callable
class method for easy creation of new validators.- ๐ Changes regarding the
History
classes:
- ๐ Changes regarding the
The
History
base class has a different interface. This was needed for asynchronous loading of the history.ThreadedHistory
was added for this.- ๐ Changes related to
shortcuts.prompt
:
- ๐ Changes related to
There is now a class
PromptSession
which also has a methodprompt
. Both the class and the method take about the same arguments. This can be used to create a session. Everyprompt
call of the same instance will reuse all the arguments given to the class itself.The input history is always shared during the entire session.
Of course, it's still possible to call the global
prompt
function. This will create a newPromptSession
every time when it's called.The
prompt
function now takes akey_bindings
argument instead ofkey_bindings_registry
. This should only contain the additional bindings. (The default bindings are always included.)- ๐ Changes to the event loops:
The event loop API is now closer to how asyncio works. A prompt_toolkit
Application
now has aFuture
object. Calling the.run_async()
method creates and returns thatFuture
. An event loop has arun_until_complete
method that takes a future and runs the event loop until the Future is set.The idea is to be able to transition easily to asyncio when Python 2 support can be dropped in the future.
Application
still has a methodrun()
that underneath still runs the event loop until theFuture
is set and returns that result.The asyncio adaptors (like the asyncio event loop integration) now require Python 3.5. (We use the async/await syntax internally.)
The
Input
andOutput
classes have some changes. (Not really important.)Application.run_sub_applications
has been removed. The alternative is to callrun_coroutine_in_terminal
which returns aFuture
.- ๐ Changes to the
filters
module:
- ๐ Changes to the
The
Application
is no longer passed around, so bothCLIFilter
andSimpleFilter
were merged intoFilter
.to_cli_filter
andto_simple_filter
becameto_filter
.All filters have been turned into functions. For instance,
IsDone
becameis_done
andHasCompletions
becamehas_completions
.This was done because almost all classes were called without any arguments in the
__init__
causing additional braces everywhere. This means thatHasCompletions()
has to be replaced byhas_completions
(without parenthesis).The few filters that took arguments as input, became functions, but still have to be called with the given arguments.
For new filters, it is recommended to use the
@Condition
decorator, rather then inheriting fromFilter
.- Other renames:
IncrementalSearchDirection
was renamed toSearchDirection
.The
use_alternate_screen
parameter has been renamed tofull_screen
.Buffer.initial_document
was renamed toBuffer.document
.TokenListControl
has been renamed toFormattedTextControl
.Application.set_return_value
has been renamed toApplication.set_result
.- Other new features:
DummyAutoSuggest
andDynamicAutoSuggest
were added.DummyClipboard
andDynamicClipboard
were added.DummyCompleter
andDynamicCompleter
were added.DummyHistory
andDynamicHistory
was added.to_container
andto_window
utilities were added.
-
v1.0.18
October 03, 2019 -
v1.0.17
October 03, 2019 -
v1.0.16
April 12, 2019 -
v1.0.9 Changes
November 07, 2016๐ Fixes:
- ๐ Fixed a bug in the
cooked_mode
context manager. This caused a bug in ptpython where executinginput()
would display M instead of accepting the input. - ๐ Handle race condition in eventloop/posix.py
- โก๏ธ Updated ANSI color names for vt100. (High and low intensity colors were swapped.)
๐ New features:
- โ Added yank-nth-arg and yank-last-arg readline commands + Emacs bindings.
- ๐ Allow searching in Vi selection mode.
- Made text objects of the Vi 'n' and 'N' search bindings. This adds for instance the following bindings: cn, cN, dn, dN, yn, yN
- ๐ Fixed a bug in the
-
v1.0.8 Changes
October 16, 2016๐ Fixes:
- In 'shortcuts': complete_while_typing was a SimpleFilter, not a CLIFilter.
- Always reset color attributes after rendering.
- ๐ Handle bug in Windows when '$TERM' is not defined.
- Ignore errors when calling tcgetattr/tcsetattr. (This handles the "Inappropriate ioctl for device" crash in some scenarios.)
- ๐ Fix for Windows. Correctly recognize all Chinese and Lithuanian characters.
๐ New features:
- โ Added shift+left/up/down/right keys.
- ๐ Small performance optimization in the renderer.
- Small optimization in the posix event loop. Don't call time.time() if we don't have an inputhook. (Less syscalls.)
- Turned the _max_postpone_until argument of call_from_executor into a float.
(As returned by
time.time
.) This will do less system calls. It's backwards-incompatible, but this is still a private API, used only by pymux.) - โ Added Shift-I/A commands in Vi block selection mode for inserting text at the beginning of each line of the block.
- ๐จ Refactoring of the 'selectors' module for the posix event loop. (Reuse the same selector object in one loop, don't recreate it for each select.)
-
v1.0.7 Changes
August 21, 2016๐ 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.
-
v1.0.6 Changes
August 15, 2016๐ Fixes:
- Go to the start of the line in Vi navigation 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 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 inVt100_Output
andshortcuts.create_output
.