Skip to content

Implement Interactive Selection Components #27

@FerdinandSu

Description

@FerdinandSu

Description / 功能描述

English:
Implement interactive UI components similar to MobileSuit .NET v3.0+ to enhance user interaction in console applications. This feature will provide arrow-key navigation, multi-selection support, and confirmation prompts.

中文:
实现类似于 MobileSuit .NET v3.0+ 的交互式UI组件,以增强控制台应用程序中的用户交互。此功能将提供方向键导航、多选支持和确认提示。

Features / 功能特性

English:

  • Single selection prompt with arrow key navigation
  • Multi-selection prompt with space-bar toggle
  • Yes/No confirmation dialogs
  • Range selection parser (e.g., "1-3 5 7-9" → [1,2,3,5,7,8,9])
  • Keyboard event capture for non-buffered input
  • Customizable styling and colors

中文:

  • 带方向键导航的单选提示
  • 带空格键切换的多选提示
  • 是/否确认对话框
  • 范围选择解析器(例如 "1-3 5 7-9" → [1,2,3,5,7,8,9])
  • 非缓冲输入的键盘事件捕获
  • 可自定义的样式和颜色

Tech Stack / 技术栈

  • Python keyboard or readchar library for key capture / 使用 keyboardreadchar 库进行按键捕获
  • ANSI escape codes for cursor control / 使用ANSI转义码进行光标控制
  • Integration with existing IOHub system / 与现有IOHub系统集成

Difficulty & Time / 难度与时间

Difficulty / 难度: 🟢 Easy to Medium / 简单到中等
Estimated Time / 预估时间: 2-4 days / 2-4天

Requirements / 要求

English:

  • MUST follow the API design from MobileSuit .NET (see .claude/MobileSuitFeatures.md Feature Use pyproject.toml instead of setup.py #9)
  • MUST work on Windows, macOS, and Linux
  • MUST handle Ctrl+C gracefully for cancellation
  • PR MUST include:
    • Unit tests for all selection types
    • Screenshots/GIFs demonstrating the interactive components
    • Documentation with usage examples

中文:

  • 必须 遵循MobileSuit .NET的API设计(参见 .claude/MobileSuitFeatures.md 功能 Use pyproject.toml instead of setup.py #9
  • 必须 在Windows、macOS和Linux上运行
  • 必须 优雅地处理Ctrl+C以取消操作
  • PR 必须 包含:
    • 所有选择类型的单元测试
    • 演示交互组件的截图/GIF
    • 带使用示例的文档

Acceptance Criteria / 验收标准

  • Implement IOInteractive.SingleSelection(options, prompt) / 实现单选方法
  • Implement IOInteractive.MultiSelection(options, prompt) / 实现多选方法
  • Implement IOInteractive.Confirm(prompt, default_value) / 实现确认方法
  • Implement range parser: ParseRange("1-3 5 7-9") / 实现范围解析器
  • Support arrow keys (↑↓) for navigation / 支持方向键导航
  • Support space for toggle (multi-select) / 支持空格切换(多选)
  • Support Enter for confirmation / 支持回车确认
  • Handle edge cases (empty list, single item, etc.) / 处理边界情况
  • Add comprehensive unit tests (80%+ coverage) / 添加全面的单元测试(80%以上覆盖率)
  • Cross-platform testing passed / 跨平台测试通过
  • Update documentation in README.md / 更新README.md文档
  • Add example to examples/ directory / 在examples/目录添加示例

Reference / 参考

See .claude/MobileSuitFeatures.md Feature #9 for detailed specification.
详细规格请参见 .claude/MobileSuitFeatures.md 功能 #9

Before Starting / 开始之前

Please comment on this issue to let us know you're working on it!
请在此issue下评论,让我们知道你正在处理!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeature-parityPorting from MobileSuit .NETgood-first-issueGood for newcomersuiUser interface improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions