CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-asciimatics

tessl install tessl/pypi-asciimatics@1.15.0

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

Agent Success

Agent success rate when using this tile

81%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.33x

Baseline

Agent success rate without this tile

61%

task.mdevals/scenario-2/

Multilingual Message Display Terminal

Create a terminal application that displays multilingual messages with proper text alignment and formatting, supporting Unicode characters including double-width CJK (Chinese, Japanese, Korean) characters.

Requirements

Your application should:

  1. Display text messages in multiple languages at specific positions on the terminal screen
  2. Handle Unicode characters correctly, including proper width calculation for CJK characters
  3. Support right-aligning text that contains mixed ASCII and CJK characters
  4. Display colored text with proper formatting

Functional Requirements

Display Messages

Create a program that displays the following messages on the terminal screen:

  • Display "Welcome" in English at position (10, 5) in white text
  • Display "欢迎" (Welcome in Chinese) at position (10, 7) in green text
  • Display "こんにちは" (Hello in Japanese) at position (10, 9) in cyan text
  • Display "안녕하세요" (Hello in Korean) at position (10, 11) in yellow text
  • Display a mixed message "User: 张伟 (Score: 100)" at position (10, 13) in white text

Text Alignment

Implement a function that right-aligns text within a specified width, properly accounting for double-width CJK characters:

  • Right-align "Hello世界" within 20 characters at position (5, 15)
  • Right-align "テスト123" within 20 characters at position (5, 17)

The application should run for 3 seconds to allow viewing the output, then exit cleanly.

Test Cases

  • The terminal initializes and displays all messages without errors @test
  • CJK characters "欢迎" display correctly at the specified position (10, 7) @test
  • The mixed message "User: 张伟 (Score: 100)" displays correctly with proper character spacing @test
  • Right-aligned text "Hello世界" appears correctly aligned considering double-width characters @test

Implementation

@generates

API

def display_messages(screen):
    """
    Display multilingual messages on the terminal screen.

    Args:
        screen: The terminal screen object for rendering
    """
    pass

def right_align_text(text, width):
    """
    Calculate proper spacing for right-aligning text with CJK characters.

    Args:
        text: The text string containing ASCII and/or CJK characters
        width: The total width to align within

    Returns:
        The number of spaces needed for right alignment
    """
    pass

Dependencies { .dependencies }

asciimatics { .dependency }

Provides terminal control and Unicode text support.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/asciimatics@1.15.x
tile.json