|  | 
| 6 | 6 | from functools import partial | 
| 7 | 7 | from prompt_toolkit.application import Application | 
| 8 | 8 | from prompt_toolkit.buffer import Buffer | 
|  | 9 | +from prompt_toolkit.contrib.completers import WordCompleter | 
| 9 | 10 | from prompt_toolkit.document import Document | 
|  | 11 | +from prompt_toolkit.eventloop.base import EventLoop | 
| 10 | 12 | from prompt_toolkit.eventloop.defaults import create_event_loop | 
|  | 13 | +from prompt_toolkit.filters import Condition, has_focus | 
|  | 14 | +from prompt_toolkit.key_binding.bindings.focus import focus_next, focus_previous | 
| 11 | 15 | from prompt_toolkit.key_binding.defaults import load_key_bindings | 
| 12 | 16 | from prompt_toolkit.key_binding.key_bindings import KeyBindings, merge_key_bindings | 
| 13 | 17 | from prompt_toolkit.keys import Keys | 
| 14 | 18 | from prompt_toolkit.layout.containers import VSplit, HSplit, Window, Align, to_window, FloatContainer, Float, Container, ConditionalContainer | 
| 15 | 19 | from prompt_toolkit.layout.controls import BufferControl, TokenListControl, UIControlKeyBindings | 
| 16 | 20 | from prompt_toolkit.layout.dimension import Dimension as D | 
| 17 | 21 | from prompt_toolkit.layout.layout import Layout | 
| 18 |  | -from prompt_toolkit.layout.processors import PasswordProcessor | 
| 19 | 22 | from prompt_toolkit.layout.lexers import PygmentsLexer | 
|  | 23 | +from prompt_toolkit.layout.processors import PasswordProcessor | 
| 20 | 24 | from prompt_toolkit.styles.from_pygments import style_from_pygments | 
| 21 | 25 | from prompt_toolkit.token import Token | 
| 22 |  | -from prompt_toolkit.filters import Condition, has_focus | 
| 23 | 26 | from prompt_toolkit.utils import get_cwidth | 
| 24 |  | -from prompt_toolkit.eventloop.base import EventLoop | 
| 25 | 27 | from pygments.lexers import HtmlLexer | 
| 26 |  | -from prompt_toolkit.contrib.completers import WordCompleter | 
| 27 | 28 | 
 | 
| 28 | 29 | loop = create_event_loop() | 
| 29 | 30 | 
 | 
| @@ -242,35 +243,9 @@ def accept_no(app): | 
| 242 | 243 | ]) | 
| 243 | 244 | 
 | 
| 244 | 245 | # Global key bindings. | 
| 245 |  | - | 
| 246 | 246 | bindings = KeyBindings() | 
| 247 |  | - | 
| 248 |  | -@bindings.add(Keys.Tab) | 
| 249 |  | -def _(event): | 
| 250 |  | - windows = event.app.focussable_windows | 
| 251 |  | - if len(windows) > 0: | 
| 252 |  | - try: | 
| 253 |  | - index = windows.index(event.app.layout.current_window) | 
| 254 |  | - except ValueError: | 
| 255 |  | - index = 0 | 
| 256 |  | - else: | 
| 257 |  | - index = (index + 1) % len(windows) | 
| 258 |  | - | 
| 259 |  | - event.app.layout.focus(windows[index]) | 
| 260 |  | - | 
| 261 |  | - | 
| 262 |  | -@bindings.add(Keys.BackTab) | 
| 263 |  | -def _(event): | 
| 264 |  | - windows = event.app.focussable_windows | 
| 265 |  | - if len(windows) > 0: | 
| 266 |  | - try: | 
| 267 |  | - index = windows.index(event.app.layout.current_window) | 
| 268 |  | - except ValueError: | 
| 269 |  | - index = 0 | 
| 270 |  | - else: | 
| 271 |  | - index = (index - 1) % len(windows) | 
| 272 |  | - | 
| 273 |  | - event.app.layout.focus(windows[index]) | 
|  | 247 | +bindings.add(Keys.Tab)(focus_next) | 
|  | 248 | +bindings.add(Keys.BackTab)(focus_previous) | 
| 274 | 249 | 
 | 
| 275 | 250 | 
 | 
| 276 | 251 | style = style_from_pygments(style_dict={ | 
|  | 
0 commit comments