Web Analytics

AppCUI-rs

⭐ 376 stars Japanese by gdt050579

🌐 言語

AppCUI-rs

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


Windows ビルドステータス
Linux ビルドステータス
macOS ビルドステータス
コードカバレッジ
ライセンス
Crates.io
Docs.rs
ギャラリー

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] 対応端末でのTrueColor(24bit/pixel)サポート

📸 スクリーンショット

👉 すべてのコントロールの完全なデモはギャラリーをチェック!

🖥️ バックエンド

AppCUIは、OSに応じて様々なバックエンドをサポートしています。

  • Windows Console - Win32の低レベルAPIに基づき、従来のWindowsコンソール向けに設計されています
  • Windows VT - ANSIシーケンスに基づき、最新のWindows仮想端末向けに設計されています
  • NCurses - Linux環境向けにNCurses APIに基づいています
  • Termios - ANSIシーケンスとmacOS用の低レベル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