Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added docs/images/interactive-shell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/equasis_cli/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_tui_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down