パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細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開発者が開発ユーティリティを構築しています
  • ターミナルのスタイリングとフォーマットが必要なプロジェクト

注意事項

  • ターミナル環境が必要(Webではない)
  • コンソールベースのアプリケーションに限定
  • プラットフォーム固有の癖がある可能性があります
  • ウェブやモバイルアプリには適していません
  • 下位のターミナル機能に依存します

元の 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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

ランキング