def __init__(self, key_bindings: KeyBindingsBase) -> None: self._bindings = key_bindings self.before_key_press = Event(self) self.after_key_press = Event(self) self._flush_wait_task: Optional[Task[None]] = None self.reset()
def __init__(self, key_bindings: KeyBindingsBase) -> None: self._bindings = key_bindings self.before_key_press = Event(self) self.after_key_press = Event(self) self._keys_pressed = 0 # Monotonically increasing counter. self.reset()
def __init__(self, key_bindings): assert isinstance(key_bindings, KeyBindingsBase) self._bindings = key_bindings self.before_key_press = Event(self) self.after_key_press = Event(self) self._keys_pressed = 0 # Monotonically increasing counter. self.reset()
def __init__(self, key_bindings): assert isinstance(key_bindings, KeyBindingsBase) self._bindings = key_bindings self.before_key_press = Event(self) self.after_key_press = Event(self) # Simple macro recording. (Like readline does.) self.record_macro = False self.macro = [] self.reset()
def __init__(self, registry, cli_ref): self._registry = registry self._cli_ref = cli_ref self.beforeKeyPress = Event(self) self.afterKeyPress = Event(self) # The queue of keys not yet send to our _process generator/state machine. self.input_queue = deque() # The key buffer that is matched in the generator state machine. # (This is at at most the amount of keys that make up for one key binding.) self.key_buffer = [] self.reset()
def __init__(self, command=['/bin/bash'], done_callback=None, before_exec_func=None, bell_func=None): assert isinstance(command, list) assert done_callback is None or callable(done_callback) assert before_exec_func is None or callable(before_exec_func) assert bell_func is None or callable(bell_func) def has_priority(): # Give priority to the processing of this terminal output, if this # user control has the focus. try: app = get_app(raise_exception=True) except NoRunningApplicationError: # The application has terminated before this process ended. return False else: return app.layout.has_focus(self) self.process = Process(lambda: self.on_content_changed.fire(), command=command, before_exec_func=before_exec_func, done_callback=done_callback, bell_func=bell_func, has_priority=has_priority) self.on_content_changed = Event(self) self._running = False
def __init__(self, command=['/bin/bash'], done_callback=None, before_exec_func=None, bell_func=None, sim_prompt=False): assert isinstance(command, list) assert done_callback is None or callable(done_callback) assert before_exec_func is None or callable(before_exec_func) assert bell_func is None or callable(bell_func) def has_priority(): # Give priority to the processing of this terminal output, if this # user control has the focus. return get_app().layout.has_focus(self) self.process = Process(lambda: self.on_content_changed.fire(), command=command, before_exec_func=before_exec_func, done_callback=done_callback, bell_func=bell_func, has_priority=has_priority, sim_prompt=sim_prompt) self.on_content_changed = Event(self) self._running = False self._sim = sim_prompt
def __init__(self, registry, cli_ref): assert isinstance(registry, BaseRegistry) self._registry = registry self._cli_ref = cli_ref self.beforeKeyPress = Event(self) self.afterKeyPress = Event(self) # The queue of keys not yet send to our _process generator/state machine. self.input_queue = deque() # The key buffer that is matched in the generator state machine. # (This is at at most the amount of keys that make up for one key binding.) self.key_buffer = [] # Simple macro recording. (Like readline does.) self.record_macro = False self.macro = [] self.reset()
def __init__(self, address, auth): self._address = address self._uri = "bolt://{}".format(self.address) self._auth = auth self._driver = None self._running = False self._invalidated = False self._refresh_period = 1.0 self._refresh_thread = Thread(target=self.loop) self._on_fresh_data = Event(self) self._edition = self.work( lambda tx: tx.run("CALL dbms.components").value("edition")[0])
def __init__(self, key_bindings): assert isinstance(key_bindings, KeyBindingsBase) self._bindings = key_bindings self.before_key_press = Event(self) self.after_key_press = Event(self) # Timeout, like Vim's timeoutlen option. # For instance, suppose that we have a key binding AB and a second key # binding A. If the uses presses A and then waits, we don't handle this # binding yet (unless it was marked 'eager'), because we don't know # what will follow. This timeout is the maximum amount of time that we # wait until we call the handlers anyway. self.timeout = 1.0 # seconds self._keys_pressed = 0 # Monotonically increasing counter. # Simple macro recording. (Like readline does.) self.record_macro = False self.macro = [] self.reset()
def __init__(self, loop=None, command=['/bin/bash']): self.loop = loop or get_event_loop() def done_callback(*a, **kw): sys.exit(0) # TODO pass self.process = Process.from_command( self.loop, lambda: self.on_content_changed.fire(), command, done_callback, bell_func=None, before_exec_func=None, has_priority=None) self.process.start() self.on_content_changed = Event(self)
def __init__( self, layout: Optional[Layout] = None, style: Optional[BaseStyle] = None, include_default_pygments_style: FilterOrBool = True, style_transformation: Optional[StyleTransformation] = None, key_bindings: Optional[KeyBindingsBase] = None, clipboard: Optional[Clipboard] = None, full_screen: bool = False, color_depth: Union[ColorDepth, Callable[[], Union[ColorDepth, None]], None] = None, mouse_support: FilterOrBool = False, enable_page_navigation_bindings: Optional[ FilterOrBool] = None, # Can be None, True or False. paste_mode: FilterOrBool = False, editing_mode: EditingMode = EditingMode.EMACS, erase_when_done: bool = False, reverse_vi_search_direction: FilterOrBool = False, min_redraw_interval: Union[float, int, None] = None, max_render_postpone_time: Union[float, int, None] = 0.01, refresh_interval: Optional[float] = None, on_reset: Optional[ApplicationEventHandler] = None, on_invalidate: Optional[ApplicationEventHandler] = None, before_render: Optional[ApplicationEventHandler] = None, after_render: Optional[ApplicationEventHandler] = None, # I/O. input: Optional[Input] = None, output: Optional[Output] = None, ): # If `enable_page_navigation_bindings` is not specified, enable it in # case of full screen applications only. This can be overridden by the user. if enable_page_navigation_bindings is None: enable_page_navigation_bindings = Condition( lambda: self.full_screen) paste_mode = to_filter(paste_mode) mouse_support = to_filter(mouse_support) reverse_vi_search_direction = to_filter(reverse_vi_search_direction) enable_page_navigation_bindings = to_filter( enable_page_navigation_bindings) include_default_pygments_style = to_filter( include_default_pygments_style) if layout is None: layout = create_dummy_layout() if style_transformation is None: style_transformation = DummyStyleTransformation() self.style = style self.style_transformation = style_transformation # Key bindings. self.key_bindings = key_bindings self._default_bindings = load_key_bindings() self._page_navigation_bindings = load_page_navigation_bindings() self.layout = layout self.clipboard = clipboard or InMemoryClipboard() self.full_screen: bool = full_screen self._color_depth = color_depth self.mouse_support = mouse_support self.paste_mode = paste_mode self.editing_mode = editing_mode self.erase_when_done = erase_when_done self.reverse_vi_search_direction = reverse_vi_search_direction self.enable_page_navigation_bindings = enable_page_navigation_bindings self.min_redraw_interval = min_redraw_interval self.max_render_postpone_time = max_render_postpone_time self.refresh_interval = refresh_interval # Events. self.on_invalidate = Event(self, on_invalidate) self.on_reset = Event(self, on_reset) self.before_render = Event(self, before_render) self.after_render = Event(self, after_render) # I/O. session = get_app_session() self.output = output or session.output self.input = input or session.input # List of 'extra' functions to execute before a Application.run. self.pre_run_callables: List[Callable[[], None]] = [] self._is_running = False self.future: Optional[Future[_AppResult]] = None self.loop: Optional[AbstractEventLoop] = None self.context: Optional[contextvars.Context] = None #: Quoted insert. This flag is set if we go into quoted insert mode. self.quoted_insert = False #: Vi state. (For Vi key bindings.) self.vi_state = ViState() self.emacs_state = EmacsState() #: When to flush the input (For flushing escape keys.) This is important #: on terminals that use vt100 input. We can't distinguish the escape #: key from for instance the left-arrow key, if we don't know what follows #: after "\x1b". This little timer will consider "\x1b" to be escape if #: nothing did follow in this time span. #: This seems to work like the `ttimeoutlen` option in Vim. self.ttimeoutlen = 0.5 # Seconds. #: Like Vim's `timeoutlen` option. This can be `None` or a float. For #: instance, suppose that we have a key binding AB and a second key #: binding A. If the uses presses A and then waits, we don't handle #: this binding yet (unless it was marked 'eager'), because we don't #: know what will follow. This timeout is the maximum amount of time #: that we wait until we call the handlers anyway. Pass `None` to #: disable this timeout. self.timeoutlen = 1.0 #: The `Renderer` instance. # Make sure that the same stdout is used, when a custom renderer has been passed. self._merged_style = self._create_merged_style( include_default_pygments_style) self.renderer = Renderer( self._merged_style, self.output, self.input, full_screen=full_screen, mouse_support=mouse_support, cpr_not_supported_callback=self.cpr_not_supported_callback, ) #: Render counter. This one is increased every time the UI is rendered. #: It can be used as a key for caching certain information during one #: rendering. self.render_counter = 0 # Invalidate flag. When 'True', a repaint has been scheduled. self._invalidated = False self._invalidate_events: List[Event[object]] = [ ] # Collection of 'invalidate' Event objects. self._last_redraw_time = 0.0 # Unix timestamp of last redraw. Used when # `min_redraw_interval` is given. #: The `InputProcessor` instance. self.key_processor = KeyProcessor(_CombinedRegistry(self)) # If `run_in_terminal` was called. This will point to a `Future` what will be # set at the point when the previous run finishes. self._running_in_terminal = False self._running_in_terminal_f: Optional[Future[None]] = None # Trigger initialize callback. self.reset()
state.cursor_line = buffer.document.cursor_position_row if args.no_dynamic_title == False: setCommandWindowTitle() #pods window podListArea = TextArea(text="", multiline=True, wrap_lines=False, scrollbar=enableScrollbar, lexer=lexer.ResourceWindowLexer(), read_only=True) #add listener to cursor position changed podListArea.buffer.on_cursor_position_changed = Event(podListArea.buffer, podListCursorChanged) podListArea.buffer.name = WindowName.resource podListArea.window.cursorline = to_filter(True) podListAreaFrame = Frame(podListArea, title="Pods", width=podListWindowSize) left_container = HSplit([ upper_left_container, #HorizontalLine(), #Window(height=1, char='-'), podListAreaFrame ]) #print(namespaceWindow.current_value) #output area to output debug etc stuff outputArea = TextArea(text="", multiline=True,
def __init__( self, layout=None, style=None, key_bindings=None, clipboard=None, full_screen=False, mouse_support=False, enable_page_navigation_bindings=False, paste_mode=False, editing_mode=EditingMode.EMACS, erase_when_done=False, reverse_vi_search_direction=False, min_redraw_interval=None, max_render_postpone_time=0, on_reset=None, on_render=None, on_invalidate=None, # I/O. input=None, output=None): paste_mode = to_filter(paste_mode) mouse_support = to_filter(mouse_support) reverse_vi_search_direction = to_filter(reverse_vi_search_direction) enable_page_navigation_bindings = to_filter( enable_page_navigation_bindings) assert layout is None or isinstance(layout, Layout) assert key_bindings is None or isinstance(key_bindings, KeyBindingsBase) assert clipboard is None or isinstance(clipboard, Clipboard) assert isinstance(full_screen, bool) assert isinstance(editing_mode, six.string_types) assert style is None or isinstance(style, BaseStyle) assert isinstance(erase_when_done, bool) assert min_redraw_interval is None or isinstance( min_redraw_interval, (float, int)) assert max_render_postpone_time is None or isinstance( max_render_postpone_time, (float, int)) assert on_reset is None or callable(on_reset) assert on_render is None or callable(on_render) assert on_invalidate is None or callable(on_invalidate) assert output is None or isinstance(output, Output) assert input is None or isinstance(input, Input) self.style = style if layout is None: layout = create_dummy_layout() # Key bindings. self.key_bindings = key_bindings self._default_bindings = load_key_bindings() self._page_navigation_bindings = load_page_navigation_bindings() self.layout = layout self.clipboard = clipboard or InMemoryClipboard() self.full_screen = full_screen self.mouse_support = mouse_support self.paste_mode = paste_mode self.editing_mode = editing_mode self.erase_when_done = erase_when_done self.reverse_vi_search_direction = reverse_vi_search_direction self.enable_page_navigation_bindings = enable_page_navigation_bindings self.min_redraw_interval = min_redraw_interval self.max_render_postpone_time = max_render_postpone_time # Events. self.on_invalidate = Event(self, on_invalidate) self.on_render = Event(self, on_render) self.on_reset = Event(self, on_reset) # I/O. self.output = output or get_default_output() self.input = input or get_default_input() # List of 'extra' functions to execute before a Application.run. self.pre_run_callables = [] self._is_running = False self.future = None #: Quoted insert. This flag is set if we go into quoted insert mode. self.quoted_insert = False #: Vi state. (For Vi key bindings.) self.vi_state = ViState() #: When to flush the input (For flushing escape keys.) This is important #: on terminals that use vt100 input. We can't distinguish the escape #: key from for instance the left-arrow key, if we don't know what follows #: after "\x1b". This little timer will consider "\x1b" to be escape if #: nothing did follow in this time span. #: This seems to work like the `ttimeoutlen` option in Vim. self.input_timeout = .5 #: The `Renderer` instance. # Make sure that the same stdout is used, when a custom renderer has been passed. self._merged_style = merge_styles([ default_style(), DynamicStyle(lambda: self.style), ]) self.renderer = Renderer( self._merged_style, self.output, full_screen=full_screen, mouse_support=mouse_support, cpr_not_supported_callback=self.cpr_not_supported_callback) #: Render counter. This one is increased every time the UI is rendered. #: It can be used as a key for caching certain information during one #: rendering. self.render_counter = 0 # Invalidate flag. When 'True', a repaint has been scheduled. self._invalidated = False self._invalidate_events = [ ] # Collection of 'invalidate' Event objects. self._last_redraw_time = 0 # Unix timestamp of last redraw. Used when # `min_redraw_interval` is given. #: The `InputProcessor` instance. self.key_processor = KeyProcessor(_CombinedRegistry(self)) # If `run_in_terminal` was called. This will point to a `Future` what will be # set at the point whene the previous run finishes. self._running_in_terminal = False self._running_in_terminal_f = None # Trigger initialize callback. self.reset()
def __init__(self, process, has_focus): self.process = process self.has_focus = to_cli_filter(has_focus) self.invalidate = Event(self)
def __init__(self, layout=None, style=None, include_default_pygments_style=True, key_bindings=None, clipboard=None, full_screen=False, color_depth=None, mouse_support=False, enable_page_navigation_bindings=None, # Can be None, True or False. paste_mode=False, editing_mode=EditingMode.EMACS, erase_when_done=False, reverse_vi_search_direction=False, min_redraw_interval=None, max_render_postpone_time=0, on_reset=None, on_invalidate=None, before_render=None, after_render=None, # I/O. input=None, output=None): # If `enable_page_navigation_bindings` is not specified, enable it in # case of full screen applications only. This can be overridden by the user. if enable_page_navigation_bindings is None: enable_page_navigation_bindings = Condition(lambda: self.full_screen) paste_mode = to_filter(paste_mode) mouse_support = to_filter(mouse_support) reverse_vi_search_direction = to_filter(reverse_vi_search_direction) enable_page_navigation_bindings = to_filter(enable_page_navigation_bindings) include_default_pygments_style = to_filter(include_default_pygments_style) assert layout is None or isinstance(layout, Layout), 'Got layout: %r' % (layout, ) assert key_bindings is None or isinstance(key_bindings, KeyBindingsBase) assert clipboard is None or isinstance(clipboard, Clipboard) assert isinstance(full_screen, bool) assert (color_depth is None or callable(color_depth) or color_depth in ColorDepth._ALL), 'Got color_depth: %r' % (color_depth, ) assert isinstance(editing_mode, six.string_types) assert style is None or isinstance(style, BaseStyle) assert isinstance(erase_when_done, bool) assert min_redraw_interval is None or isinstance(min_redraw_interval, (float, int)) assert max_render_postpone_time is None or isinstance(max_render_postpone_time, (float, int)) assert on_reset is None or callable(on_reset) assert on_invalidate is None or callable(on_invalidate) assert before_render is None or callable(before_render) assert after_render is None or callable(after_render) assert output is None or isinstance(output, Output) assert input is None or isinstance(input, Input) self.style = style if layout is None: layout = create_dummy_layout() # Key bindings. self.key_bindings = key_bindings self._default_bindings = load_key_bindings() self._page_navigation_bindings = load_page_navigation_bindings() self.layout = layout self.clipboard = clipboard or InMemoryClipboard() self.full_screen = full_screen self._color_depth = color_depth self.mouse_support = mouse_support self.paste_mode = paste_mode self.editing_mode = editing_mode self.erase_when_done = erase_when_done self.reverse_vi_search_direction = reverse_vi_search_direction self.enable_page_navigation_bindings = enable_page_navigation_bindings self.min_redraw_interval = min_redraw_interval self.max_render_postpone_time = max_render_postpone_time # Events. self.on_invalidate = Event(self, on_invalidate) self.on_reset = Event(self, on_reset) self.before_render = Event(self, before_render) self.after_render = Event(self, after_render) # I/O. self.output = output or get_default_output() self.input = input or get_default_input() # List of 'extra' functions to execute before a Application.run. self.pre_run_callables = [] self._is_running = False self.future = None #: Quoted insert. This flag is set if we go into quoted insert mode. self.quoted_insert = False #: Vi state. (For Vi key bindings.) self.vi_state = ViState() self.emacs_state = EmacsState() #: When to flush the input (For flushing escape keys.) This is important #: on terminals that use vt100 input. We can't distinguish the escape #: key from for instance the left-arrow key, if we don't know what follows #: after "\x1b". This little timer will consider "\x1b" to be escape if #: nothing did follow in this time span. #: This seems to work like the `ttimeoutlen` option in Vim. self.ttimeoutlen = .5 # Seconds. #: Like Vim's `timeoutlen` option. This can be `None` or a float. For #: instance, suppose that we have a key binding AB and a second key #: binding A. If the uses presses A and then waits, we don't handle #: this binding yet (unless it was marked 'eager'), because we don't #: know what will follow. This timeout is the maximum amount of time #: that we wait until we call the handlers anyway. Pass `None` to #: disable this timeout. self.timeoutlen = 1.0 #: The `Renderer` instance. # Make sure that the same stdout is used, when a custom renderer has been passed. self._merged_style = self._create_merged_style(include_default_pygments_style) self.renderer = Renderer( self._merged_style, self.output, full_screen=full_screen, mouse_support=mouse_support, cpr_not_supported_callback=self.cpr_not_supported_callback) #: Render counter. This one is increased every time the UI is rendered. #: It can be used as a key for caching certain information during one #: rendering. self.render_counter = 0 # Invalidate flag. When 'True', a repaint has been scheduled. self._invalidated = False self._invalidate_events = [] # Collection of 'invalidate' Event objects. self._last_redraw_time = 0 # Unix timestamp of last redraw. Used when # `min_redraw_interval` is given. #: The `InputProcessor` instance. self.key_processor = KeyProcessor(_CombinedRegistry(self)) # If `run_in_terminal` was called. This will point to a `Future` what will be # set at the point when the previous run finishes. self._running_in_terminal = False self._running_in_terminal_f = None # Trigger initialize callback. self.reset()
def __init__(self, address, auth, prefer_routing=False, key_bindings=None): self.address = address self.monitor = ServerMonitor(address, auth, prefer_routing=prefer_routing, on_error=self.on_error) self.key_bindings = key_bindings self.invalidate = Event(self)