diff --git a/README.md b/README.md index 196a23b..f19aadc 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Investigating many vessels or companies through the Equasis website is slow and equasis-cli turns it into scriptable commands that produce tables, JSON, JSON Lines, or CSV, handle batches of hundreds of vessels, and summarize the signals researchers look for. -![Screenshot of the equasis-cli interactive shell](https://github.com/user-attachments/assets/d8efd954-438b-4e91-b000-8391b2f0321f) +![The equasis-cli interactive shell showing the profile of EVER GIVEN](https://raw.githubusercontent.com/rhinonix/equasis-cli/main/docs/images/interactive-shell.png) ## Features diff --git a/docs/images/interactive-shell.png b/docs/images/interactive-shell.png new file mode 100644 index 0000000..84b8f84 Binary files /dev/null and b/docs/images/interactive-shell.png differ diff --git a/src/equasis_cli/tui/app.py b/src/equasis_cli/tui/app.py index 26ed1b0..1d20381 100644 --- a/src/equasis_cli/tui/app.py +++ b/src/equasis_cli/tui/app.py @@ -190,6 +190,7 @@ def _append(self, text: str) -> None: lines = combined.split("\n") if len(lines) > MAX_OUTPUT_LINES: combined = "\n".join(lines[-MAX_OUTPUT_LINES:]) + self._forget_banner() scrolling = self.app.layout.has_focus(self.output_buffer) position = ( min(self.output_buffer.cursor_position, len(combined)) if scrolling else len(combined) @@ -199,6 +200,12 @@ def _append(self, text: str) -> None: def clear(self) -> None: self.output_buffer.set_document(Document("", 0), bypass_readonly=True) + self._forget_banner() + + def _forget_banner(self) -> None: + """Stop styling the first lines as the banner once it is no longer there.""" + self.lexer.banner_lines = 0 + self.lexer.art_lines = 0 def _invalidate(self) -> None: if self.app.is_running: diff --git a/tests/test_tui_app.py b/tests/test_tui_app.py index 03d3045..c167b91 100644 --- a/tests/test_tui_app.py +++ b/tests/test_tui_app.py @@ -116,6 +116,18 @@ def test_output_is_capped(shell: InteractiveShell) -> None: assert len(shell.output_buffer.text.split("\n")) <= MAX_OUTPUT_LINES +def test_banner_styling_ends_when_the_banner_is_cleared(shell: InteractiveShell) -> None: + styles = shell.lexer.lex_document(shell.output_buffer.document) + assert styles(0)[0][0] == "class:banner-art" + + shell.clear() + shell.write(f"{PROMPT}vessel /imo 9811000\nEVER GIVEN (IMO 9811000)") + + styles = shell.lexer.lex_document(shell.output_buffer.document) + assert styles(0)[0][0] == "class:echo" + assert styles(1)[0][0] == "" + + def test_lexer_highlights_messages() -> None: lexer = OutputLexer(banner_lines=0, art_lines=0) document = Document(