CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-asciimatics

A cross-platform package to replace curses (mouse/keyboard input & text colours/positioning) and create ASCII animations

81

1.32x
Overview
Eval results
Files

task.mdevals/scenario-9/

Terminal Log Viewer

Build a terminal-based log viewer that displays log content larger than the visible screen using a scrolling buffer. The viewer allows users to navigate through content that extends beyond the terminal's physical display area.

Requirements

Initialize Scrolling Buffer

Create a screen buffer with a height larger than the terminal's visible height. This allows content to be rendered beyond what is immediately visible.

Display Log Lines

Print log lines into the buffer and display the visible portion in the terminal window. The buffer should contain all log content while only a subset is shown on screen.

Navigate Content

Support keyboard navigation:

  • Arrow up/down: scroll one line at a time
  • Page up/down: scroll by one screen height
  • Home/End: jump to start or end of content
  • 'q' or 'Q': exit the viewer

Show Position Indicator

Display a status line showing the current viewing position (e.g., "Lines 1-20 of 100").

Implementation

@generates

API

def create_log_viewer(screen, log_lines):
    """
    Create and run a log viewer with scrolling buffer.

    Parameters:
    - screen: Screen instance
    - log_lines (list): List of log line strings to display

    The function should handle user input for scrolling and display
    the appropriate portion of the log based on scroll position.
    """

Test Cases

  • Given 100 log lines and terminal height of 20, the viewer displays lines 1-19 with status "Lines 1-19 of 100" @test
  • Pressing arrow down 5 times scrolls to show lines 6-24 with status "Lines 6-24 of 100" @test
  • Pressing arrow up from position showing lines 10-28 scrolls to show lines 9-27 @test
  • Pressing Home key from any position jumps to show lines 1-19 @test

Dependencies { .dependencies }

asciimatics { .dependency }

Provides terminal control and screen management with scrolling buffer support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-asciimatics

tile.json