패키지, 저장소 및 앱 카테고리 검색

패키지 상세v5.1.2

dart_console

표준 라이브러리가 제공하는 것보다 입력/출력에 대해 더 많은 제어가 필요한 명령줄 애플리케이션을 위한 보조 라이브러리입니다.

macOSWindowsLinux
30일 다운로드
46.9만
좋아요
147
Pub 점수
160

패키지 설치

flutter pub add dart_console

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

dart_console은 표준 라이브러리가 제공하는 기능을 넘어서는 고급 입력 및 출력 제어를 제공함으로써 명령줄 애플리케이션 개발을 향상시키기 위해 설계된 Dart 라이브러리입니다. 커서 조작, 색상 텍스트, 실시간 입력 처리와 같은 기능을 통해 상호작용 가능한 CLI 경험을 만들 수 있습니다. 풍부한 터미널 상호작용이 필요한 도구에 적합하며, macOS, Windows, Linux에서 크로스플랫폼 작동을 지원합니다. 이 라이브러리는 복잡한 콘솔 작업을 간소화하여 사용자 친화적인 명령줄 인터페이스 구축을 더 쉽게 만듭니다.

사용 사례

  • 인터랙티브 CLI 도구 만들기
  • 색상 있는 터미널 출력 만들기
  • 실시간 사용자 입력 처리 구현
  • 명령줄 대시보드 개발
  • 터미널 커서 위치 관리
  • 개발 도구에서 터미널 UX 향상

주요 기능

  • 고급 입력/출력 제어
  • 크로스 플랫폼 호환성
  • 색상 및 스타일 지원
  • 커서 위치 조정 및 조작
  • 실시간 입력 처리
  • 터미널 상호작용을 위한 간단한 API

적합한 대상

  • 더 풍부한 터미널 제어를 원하는 CLI 개발자
  • 인터랙티브 사용자 입력이 필요한 도구
  • 시각적 피드백이 있는 콘솔 기반 애플리케이션
  • Dart 개발자가 개발 도구를 구축하고 있습니다
  • 터미널 스타일링 및 포맷팅이 필요한 프로젝트

고려 사항

  • 터미널 환경이 필요합니다(웹 아님)
  • 콘솔 기반 애플리케이션에 제한됨
  • 플랫폼에 따라 특이한 점이 있을 수 있습니다
  • 웹 또는 모바일 앱에 적합하지 않습니다
  • 기본 터미널 기능에 따라 다름

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

A Dart library for building console applications.

pub package Language Build codecov

This library contains a variety of useful functions for console application development, including:

  • Reading the current window dimensions (height, width)
  • Reading and setting the cursor location
  • Setting foreground and background colors
  • Manipulating the console into "raw mode", which allows more advanced keyboard input processing than the default dart:io library.
  • Reading keys and control sequences from the keyboard
  • Writing aligned text to the screen
  • Tabular data display, including month calendar

The library has been used to implement a Dart version of the Kilo text editor; when compiled with Dart it results in a self-contained kilo executable. The library is sufficient for a reasonably complete set of usage, including readline-style CLI and basic text games.

The library assumes a terminal that recognizes and implements common ANSI escape sequences. The package has been tested on macOS, Linux and Windows 10. Note that Windows did not support ANSI escape sequences in earlier versions.

The library uses the win32 package for accessing the Win32 API through FFI. That package contains many examples of using Dart FFI for more complex examples.

Usage

A simple example for the dart_console package:

import 'package:dart_console/dart_console.dart';

main() {
  final console = Console();

  console.clearScreen();
  console.resetCursorPosition();

  console.writeLine(
    'Console size is ${console.windowWidth} cols and ${console.windowHeight} rows.',
    TextAlignment.center,
  );

  console.writeLine();

  return 0;
}

More comprehensive demos of the Console class are provided, as follows:

Example Description
demo.dart Suite of test demos that showcase various capabilities
main.dart Basic demo of how to get started with the dart_console
keys.dart Demonstrates how dart_console processes control characters
readline.dart Sample command-line interface / REPL
kilo.dart Rudimentary text editor
life.dart Game of Life
table.dart Demonstrates tabular data display
calendar.dart Prints a monthly calendar on the screen

Acknowledgements

Special thanks to Matt Sullivan (@mjohnsullivan) and Samir Jindel (@sjindel-google) for their help in explaining FFI to me when it was first introduced and still undocumented.

Thanks to @erf for contributing the Game of Life example.

Features and bugs

Please file feature requests and bugs at the issue tracker.

카테고리

의존성

의존성 목록 4 개

소스 저장소

이 패키지를 사용하는 프로젝트

순위