| 482 | |
| 483 | |
| 484 | class InteractiveUI(BaseLiveTailUI): |
| 485 | EXIT_SESSION = "Esc: Exit" |
| 486 | EXIT_HIGHLIGHT = "Esc: Exit Highlight" |
| 487 | EXIT_CLEAR = "Ecs: Exit Clear" |
| 488 | INSTRUCTIONS = "h: Highlight Terms (MAX 5) c: Clear Highlighted Terms t: Toggle Formatting ({}/{}) up/down: Scroll ctrl+u/ctrl+d: Fast Scroll" |
| 489 | HIGHLIGHT_INSTRUCTIONS = "Type Term and press ENTER" |
| 490 | _MAX_LINE_COUNT = 1000 |
| 491 | |
| 492 | def __init__( |
| 493 | self, |
| 494 | log_events, |
| 495 | session_metadata: LiveTailSessionMetadata, |
| 496 | app_output=None, |
| 497 | app_input=None, |
| 498 | ) -> None: |
| 499 | self._log_events = log_events |
| 500 | self._session_metadata = session_metadata |
| 501 | self._keywords_to_highlight = {} |
| 502 | self._output = LiveTailBuffer() |
| 503 | self._is_scroll_active = False |
| 504 | self._log_events_printer = InteractivePrinter( |
| 505 | self, |
| 506 | self._output, |
| 507 | self._log_events, |
| 508 | self._session_metadata, |
| 509 | self._keywords_to_highlight, |
| 510 | ) |
| 511 | self._create_ui(app_output, app_input) |
| 512 | |
| 513 | def _create_ui(self, app_output, app_input): |
| 514 | prompt_buffer = Buffer() |
| 515 | self._prompt_buffer_control = BufferControl(prompt_buffer) |
| 516 | prompt_buffer_window = Window(self._prompt_buffer_control) |
| 517 | prompt_text_window = Window( |
| 518 | FormattedTextControl(">"), dont_extend_width=True, width=1 |
| 519 | ) |
| 520 | self._key_bindings = LiveTailKeyBindings( |
| 521 | self, prompt_buffer, self._output, self._keywords_to_highlight |
| 522 | ) |
| 523 | |
| 524 | output_buffer_control = BufferControl( |
| 525 | self._output, input_processors=[BufferControlColorProcessor()] |
| 526 | ) |
| 527 | log_output_container = Window(output_buffer_control, wrap_lines=True) |
| 528 | |
| 529 | dashed_line_container = Window(height=1, char="-") |
| 530 | metadata_container = self._create_metadata() |
| 531 | bottom_toolbar_container = self._create_bottom_toolbar() |
| 532 | |
| 533 | containers = HSplit( |
| 534 | [ |
| 535 | log_output_container, |
| 536 | dashed_line_container, |
| 537 | VSplit( |
| 538 | [ |
| 539 | prompt_text_window, |
| 540 | prompt_buffer_window, |
| 541 | ], |