#text #linux #terminal #io #unicode

bin+lib term-basics-linux

A simple crate with basic functionality for terminal applications

20 releases

0.5.6 Mar 21, 2021
0.5.5 Nov 5, 2020
0.5.4 Nov 15, 2019
0.2.0 Jul 12, 2019

#85 in Command-line interface

Download history 37/week @ 2021-02-09 58/week @ 2021-02-16 4/week @ 2021-02-23 3/week @ 2021-03-02 2/week @ 2021-03-09 14/week @ 2021-03-16 62/week @ 2021-03-23 60/week @ 2021-03-30 25/week @ 2021-04-06 42/week @ 2021-04-13 30/week @ 2021-04-20 5/week @ 2021-04-27 20/week @ 2021-05-04 40/week @ 2021-05-18 1/week @ 2021-05-25

108 downloads per month

MIT license

844 lines

Crate API


Rust crate libary that provides simple and basic terminal functionality for linux. (Work In Progress!)


As the name is quite long, you can do something like this: use term_basics_linux as tbl; After that you can use the crate: let name = tbl::prompt("type your name: "); It is recommended to use the tbl:: notation or similar, just like you would not use using namespace std; in c++.


The main feature of this crate is the input field, supporting editing your input text with function keys like backspace, delete, home, end, arrows. tbl::println(tbl::input_field());

let name = tbl::prompt("type your name: ");
tbl::print("Your name: ");

It also supports simple user defined colours and text styles: tbl::print_cols_style("very nice", tbl::UserColour::Yellow, tbl::UserColour::Cyan, tbl::TextStyle::Bold); Another feature is getch() which returns the characters from stdin with out the user having to press enter. It can be very useful and is not available by default in rust.


This crate is very simple by design, as it does simple things the code should not be complicated. It is made for linux, as it is a crate for terminal applications. With MacOS being a unix based OS and windows having a linux kernel build in, it should be kind of portable-ish. The crate only supports user defined colours by design. First of all it keeps this crate simple. Secondly i think you should only use user defined colours. If you use them you application will match with the enviroment and other applications. The user chose there colours for a reason and nobody likes inconsistent colours across applications. With all the fuss lately around GTK and distro's breaking themes for applications, this problem is easy to avoid with terminal applications by using the user's colours.


You can always create issues and pull requests on github. You can also mail to codybloemhard@gmail.com


Sometimes different terminal emulators use different codes for certain keys like delete or end. For example, backspace is 127 on both suckless simple terminal (ST) and the build in terminal emulator in vscode. But delete is 27-91-80 on ST and 27-91-51-126 on vscode. End is 27-91-52-126 on ST and 27-91-70 on vscode. If you encounter a non-supported key code, please open an issue on github with the function key(delete,end,etc) and what platform(terminal emulator) you run. The test_chars function can help look up what key code it is on your platform. It is helpfull to to supply that information. Ofcourse you can also make a pull request.


term-basics-linux is tested on the following terminals (emulators):

Platform Tested
ST (suckless simple terminal, zsh) Always
vscode (build in terminal emulator, zsh) Always
tty (arch linux, zsh) Todo


This readme is used on multiple sites so some links might be redundant.


~46K SLoC