CHANGELOG
=========
2.0.0: ...
-----------------
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 is `ControlM`, not
`ControlJ`. So, now that we stopped translating \r into \n, it could be that
custom key bindings for `Enter` don't work anymore. Make sure to bind
`Keys.Enter` instead of `Keys.ControlJ` for handling the `Enter` key.
- The `CommandLineInterface` and the `Application` classes are merged. First,
`CommandLineInterface` contained all the I/O objects (like the input, output
and event loop), while the `Application` contained everything else. There was
no practical reason to keep this separation. (`CommandLineInterface` was
mostly a proxy to `Application`.)
A consequence is that all almost code which used to received a
`CommandLineInterface`, will now use an `Application`. Usually, where we
had an attribute `cli`, we'll now have an attribute `app`.
Secondly, the `Application` object is no longer passed around. The `get_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` and `PygmentsLexer` 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 the ``Style`` 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 to `print_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 visible `BufferControl` that contained
this `Buffer` would be focused. Now, any user control can be focused. All
of this is handled in the `Application.layout` object.
- The `buffers` dictionary (`CommandLineInterface.buffers`) does not exist
anymore. Further, `buffers` was a `BufferMapping` 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 a `Buffer` 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 to `KeyBindings`.
* The `add_binding` function has been renamed to simply `add`.
* Every `load_*` function returns one `KeyBindings` 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 given `Registry`.
* A function named `merge_key_bindings` was added. This takes a list of
`KeyBindings` 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 to `key_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. The `Keys` 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 a `get_key_bindings` (abstract) method.
- Changes in the layout engine:
* `LayoutDimension` was renamed to `Dimension`.
* `VSplit` and `HSplit` now take a `padding` argument.
* `VSplit` and `HSplit` now take an `align` argument.
(TOP/CENTER/BOTTOM/JUSTIFY) or (LEFT/CENTER/RIGHT/JUSTIFY).
* `Float` now takes `allow_cover_cursor` and `attach_to_window` arguments.
* `Window` got an `Align` argument. This can be used for the alignment of the
content. `TokenListControl` does not have an alignment argument anymore.
* `Window` got a `token` and `get_token` argument. This is used to fill the
window's background using the given `Token`. That way, a window can for
instance be given a background color.
* `FillControl` does not exist anymore. Use the `token` and `char` arguments
of the `Window` class instead.
* `DummyControl` was added.
* `VSplit` and `HSplit` classes also take a `token` as argument, these are
passed to the `Window` class and applied to the content as well.
* Alignment of the content is now done in the `Window` class, not in the
user control.
* The continuation function of `PromptMargin` now takes `line_number` and
* `is_soft_wrap` as input.
- Changes to `BufferControl`:
* `BufferControl` now takes a `input_processor` as argument. (Singular
instead of plural). If you want to combine multiple, they have to be merged
together using `merge_input_processors`. (Similar to `merge_key_bindings`.)
* The `InputProcessor` class has been refactored. The `apply_transformation`
method should now takes a `TransformationInput` object as input.
* The text `(reverse-i-search)` is now displayed through a processor. (See
the `shortcuts` module for an example of the usage.)
- `widgets` and `dialogs` 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 with shortcuts for displaying input, confirmation and
message dialogs.
* Every class that exposes a ``__pt_container__`` method (which is supposed
to return a ``Container`` instance) is considered a widget. The
``to_container`` shortcut will call this method in situations where a
``Container`` object is expected. This avoids inheritance from other
``Container`` types, but also having to unpack the container object