https://github.com/bigbuildbench/lotabout_tuikit
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.3%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: BigBuildBench
- License: mit
- Language: Rust
- Default Branch: master
- Size: 274 KB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Tuikit
Tuikit is a TUI library for writing terminal UI applications. Highlights:
- Thread safe.
- Support non-fullscreen mode as well as fullscreen mode.
- Support
Altkeys, mouse events, etc. - Buffering for efficient rendering.
Tuikit is modeld after termbox which views the terminal as a table of fixed-size cells and input being a stream of structured messages.
WARNING: The library is not stable yet, the API might change.
Usage
In your Cargo.toml add the following:
toml
[dependencies]
tuikit = "*"
And if you'd like to use the latest snapshot version:
toml
[dependencies]
tuikit = { git = "https://github.com/lotabout/tuikit.git" }
Here is an example (could also be run by cargo run --example hello-world):
```rust use tuikit::prelude::*; use std::cmp::{min, max};
fn main() { let term: Term<()> = Term::with_height(TermHeight::Percent(30)).unwrap(); let mut row = 1; let mut col = 0;
let _ = term.print(0, 0, "press arrow key to move the text, (q) to quit");
let _ = term.present();
while let Ok(ev) = term.poll_event() {
let _ = term.clear();
let _ = term.print(0, 0, "press arrow key to move the text, (q) to quit");
let (width, height) = term.term_size().unwrap();
match ev {
Event::Key(Key::ESC) | Event::Key(Key::Char('q')) => break,
Event::Key(Key::Up) => row = max(row-1, 1),
Event::Key(Key::Down) => row = min(row+1, height-1),
Event::Key(Key::Left) => col = max(col, 1)-1,
Event::Key(Key::Right) => col = min(col+1, width-1),
_ => {}
}
let attr = Attr{ fg: Color::RED, ..Attr::default() };
let _ = term.print_with_attr(row, col, "Hello World! 你好!今日は。", attr);
let _ = term.set_cursor(row, col);
let _ = term.present();
}
} ```
Layout
tuikit provides HSplit, VSplit and Win for managing layouts:
HSplitallow you to split area horizontally into pieces.VSplitworks just likeHSplitbut splits vertically.Windo not split, it could have margin, padding and border.
For example:
```rust use tuikit::prelude::*;
struct Model(String);
impl Draw for Model { fn draw(&self, canvas: &mut dyn Canvas) -> DrawResult<()> { let (width, height) = canvas.size()?; let messagewidth = self.0.len(); let left = (width - messagewidth) / 2; let top = height / 2; let _ = canvas.print(top, left, &self.0); Ok(()) } }
impl Widget for Model{}
fn main() { let term: Term<()> = Term::withheight(TermHeight::Percent(50)).unwrap(); let model = Model("middle!".tostring());
while let Ok(ev) = term.poll_event() {
if let Event::Key(Key::Char('q')) = ev {
break;
}
let _ = term.print(0, 0, "press 'q' to exit");
let hsplit = HSplit::default()
.split(
VSplit::default()
.basis(Size::Percent(30))
.split(Win::new(&model).border(true).basis(Size::Percent(30)))
.split(Win::new(&model).border(true).basis(Size::Percent(30)))
)
.split(Win::new(&model).border(true));
let _ = term.draw(&hsplit);
let _ = term.present();
}
} ```
The split algorithm is simple:
- Both
HSplitandVSplitwill take severalSplitwhere aSplitwould contains:- basis, the original size
- grow, the factor to grow if there is still enough room
- shrink, the factor to shrink if there is not enough room
HSplit/VSplitwill count the total width/height(basis) of the split items- Judge if the current width/height is enough or not for the split items
- shrink/grow the split items according to their grow/shrink:
factor / sum(factors) - If still not enough room, the last one(s) would be set width/height 0
References
Tuikit borrows ideas from lots of other projects:
- rustyline Readline Implementation in Rust.
- How to enter the raw mode.
- Part of the keycode parsing logic.
- termion A bindless library for controlling terminals/TTY.
- How to parse mouse events.
- How to enter raw mode.
- rustbox and termbox
- The idea of viewing terminal as table of fixed cells.
- termfest Easy TUI library written in Rust
- The buffering idea.
Owner
- Name: BigBuildBench
- Login: BigBuildBench
- Kind: organization
- Repositories: 1
- Profile: https://github.com/BigBuildBench
abbr. B3, benchmarking the repo-level understanding capability of your LLMs by reconstructing project build-file.
GitHub Events
Total
- Create event: 6
Last Year
- Create event: 6
Dependencies
- actions-rs/cargo v1 composite
- actions-rs/toolchain v1 composite
- actions/checkout v2 composite
- actions-rs/cargo v1 composite
- actions-rs/toolchain v1 composite
- actions/checkout v2 composite
- aho-corasick 0.7.18
- atty 0.2.14
- bitflags 1.2.1
- cfg-if 0.1.10
- cfg-if 1.0.0
- dirs-next 2.0.0
- dirs-sys-next 0.1.2
- env_logger 0.6.2
- getrandom 0.2.2
- hermit-abi 0.1.17
- humantime 1.3.0
- lazy_static 1.4.0
- libc 0.2.125
- log 0.4.11
- memchr 2.5.0
- nix 0.24.1
- quick-error 1.2.3
- redox_syscall 0.2.5
- redox_users 0.4.0
- regex 1.5.6
- regex-syntax 0.6.26
- rustversion 1.0.4
- term 0.7.0
- termcolor 1.1.0
- unicode-width 0.1.8
- wasi 0.10.2+wasi-snapshot-preview1
- winapi 0.3.9
- winapi-i686-pc-windows-gnu 0.4.0
- winapi-util 0.1.5
- winapi-x86_64-pc-windows-gnu 0.4.0
- env_logger 0.6.1 development