Web Analytics

AppCUI-rs

⭐ 358 stars Japanese by gdt050579

🌐 言語

AppCUI-rs

`` ⯈ 𝗔𝗽𝗽𝗖𝗨𝗜-𝗿𝘀 🖳

Windows Build Status
Linux Build Status
MacOS Build Status
Code Coverage
License
Crates.io
Docs.rs
Gallery

AppCUI-rsは、高速でクロスプラットフォームなRustライブラリであり、豊富なウィジェット、テーマ、完全なUnicodeサポートを備えたモダンなテキストベースのユーザーインターフェース(TUI)を構築するためのものです。ncursesやその他のターミナルUIフレームワークの代替手段です。

✨ 特徴

  • [x] 多数のすぐに使えるコントロール(ボタン、ラベル、テキストボックス、チェックボックス、ラジオボタン、リストビュー、ツリービュー、コンボボックス、日付/時間ピッカー、カラーピッカー、タブ、アコーディオンなど)。コントロールの完全なリストはこちらから確認できます
  • [x] 絶対座標、相対座標、ドッキング、配置、アンカー、ピボット位置指定などを使用してコントロールを配置できる強力なレイアウトシステム(詳細はこちら
  • [x] メニューとツールバー
  • [x] マルチプラットフォーム対応(WindowsはAPIと仮想端末、Linuxはncurses、MacOSはtermiosを使用)
  • [x] バックグラウンドタスクを可能にするマルチスレッドサポート
  • [x] タイマー
  • [x] マウスサポート
  • [x] クリップボードサポート
  • [x] カラーテーマ
  • [x] Unicode文字のサポート
  • [x] 事前定義されたダイアログ(メッセージボックス、入力ボックス、カラーピッカー、保存&開くダイアログ、フォルダナビゲーターなど)
  • [x] 対応する端末で利用可能な真のカラーサポート(1ピクセルあたり24ビット)

📸 スクリーンショット

👉 すべてのコントロールの完全なデモについてはギャラリーをご覧ください!

🖥️ バックエンド

AppCUIは、使用されるオペレーティングシステムに基づいてさまざまなバックエンドをサポートしています:

  • Windows Console - Win32の低レベルAPIに基づき、従来のWindowsコンソール用に設計
  • Windows VT - ANSIシーケンスに基づき、モダンなWindows仮想端末用に設計
  • NCurses - Linux環境向けのNCurses APIに基づく
  • Termios - ANSIシーケンスおよびMAC OSXの低レベルAPIに基づく
  • Web Terminal - Web実装向けに設計(webglベース)
  • CrossTerm - crosstermクレートに基づくが、機能フラグで有効化
サポートされているバックエンドの詳細はこちらをご覧ください

🚀 クイックスタート

以下を Cargo.toml に追加してください:

toml [dependencies] appcui = "*"

次に、新しいRustプロジェクトを作成し、以下のコードを追加します:
rust use appcui::prelude::*;

fn main() -> Result<(), appcui::system::Error> { let mut app = App::new().build()?; let mut win = Window::new( "Test", LayoutBuilder::new().alignment(Alignment::Center).width(30).height(9).build(), window::Flags::Sizeable, ); win.add(Label::new( "Hello World !", LayoutBuilder::new().alignment(Alignment::Center).width(13).height(1).build(), )); app.add_window(win); app.run(); Ok(()) }

よりコンパクトなバージョンはproc-macrosを使用します:

rs use appcui::prelude::*;

fn main() -> Result<(), appcui::system::Error> { let mut app = App::new().build()?; let mut win = window!("Test,a:c,w:30,h:9"); win.add(label!("'Hello World !',a:c,w:13,h:1")); app.add_window(win); app.run(); Ok(()) }


次に cargo run でプロジェクトを実行します。タイトルが Test で、中央に Hello World ! と表示されたウィンドウが表示されるはずです。

🧪 例

AppCUI-rs には入門用の例がいくつか用意されています。examples フォルダーで見つけることができ、以下を含みます:

🛠️ より複雑な例

ボタンを持つウィンドウを作成し、そのボタンを押すとカウンターが増加する例。

rust use appcui::prelude::*;

// Create a window that handles button events and has a counter #[Window(events = ButtonEvents)] struct CounterWindow { counter: i32 }

impl CounterWindow { fn new() -> Self { let mut w = Self { // set up the window title and position base: window!("'Counter window',a:c,w:30,h:5"), // initial counter is 1 counter: 1 }; // add a single button with the caption "1" (like the counter) w.add(button!("'1',d:b,w:20")); w } } impl ButtonEvents for CounterWindow { // When the button is pressed, this function will be called // with the handle of the button that was pressed // Since we only have one button, we don't need to store its handle // in the struct, as we will receive the handle via the on_pressed method fn on_pressed(&mut self, handle: Handle