Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • redox-os/termion
  • NateDogg1232/termion
  • lemarcuspoilus/termion
  • nixpulvis/termion
  • Jezza/termion
  • mneumann/termion
  • ParadoxSpiral/termion
  • mdevlamynck/termion
  • jocutajar/termion
  • d-e-s-o/termion
  • karliss/termion
  • scauligi/termion
  • mwilbur/termion
  • curious/termion
  • xPMo/termion
  • lovasoa/termion
  • stillinbeta/termion
  • mjbshaw/termion
  • rabite0/termion
  • akitsu-sanae/termion
  • joshhansen/termion
  • lilydjwg/termion
  • kivimango/termion
  • gintsp/termion
  • 4lDO2/termion
  • denis/termion
  • needle/termion
  • rw_van/termion
  • nfachan2/termion
  • FuchsiaFrog/termion-horizontal-scroll
  • haraguroicha/termion
  • bugnano/termion
  • nolan1299/termion
  • zethra/termion
  • proehlen/termion
  • kankri/termion
  • ridcully/termion
  • TheLostLambda/termion
  • khs26/termion
  • lassipulkkinen/termion
  • amigo-rich/termion
  • nbdd0121/termion
  • jean-airoldie/termion
  • andreasblum/termion
  • luqmana/termion
  • orhun/termion
  • joshka/termion
  • nicholasdower/termion
48 results
Show changes
Commits on Source (203)
image: "redoxos/redoxer"
stages:
- build
- test
variables:
REDOXER_USE_FUSE: no
before_script:
cargo install redoxer --git "https://gitlab.redox-os.org/redox-os/redoxer.git"
cache:
paths:
- target/
build:linux:stable:
stage: build
script:
- rustup update stable
- cargo +stable build --verbose
build:linux:
stage: build
script: cargo +nightly build --verbose
build:redox:
stage: build
script: redoxer build --verbose
test:linux:stable:
stage: test
dependencies:
- build:linux:stable
script:
- rustup update stable
- script -c "cargo +stable test --verbose"
test:linux:
stage: test
dependencies:
- build:linux
script: script -c "cargo +nightly test --verbose"
test:redox:
stage: test
dependencies:
- build:redox
script: redoxer test --verbose
language: rust
cache: cargo
rust:
- stable
- beta
- nightly
os:
- linux
- osx
script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then FAKETTY="script -q /dev/null"; fi
- $FAKETTY cargo build --verbose
- $FAKETTY cargo test --verbose
- $FAKETTY cargo test --release --verbose
# 4.0.4
- Remove debug printing when parsing CSI sequences
- Support NO\_COLOR environment variable
# 4.0.3
Remove unused code and update dependencies.
# 4.0.2
Fixes an error check in Ctrl-Arrow code, no difference in behavior. Cleaned up examples.
# 4.0.1
Fixes a regression in function keys F5 and above.
# 4.0.0
4.0.0 adds support for horizontal scrolling when working with `MouseTerminal`.
## 3.0.0 to 4.0.0 guide
A change is only necessary if you were matching on all variants of the `MouseEvent` enum without a wildcard.
In this case, you need to either handle the two new variants, `MouseLeft` and `MouseRight`, or add a wildcard.
# 3.0.0
v3 release improves `raw` terminal API and enables support of any TTY target.
## 2.0.0 to 3.0.0 guide
Changes are only required if you were using `IntoRawMode` on generic terminals `W: Write`. Now, terminal
is also required to implement [`AsFd` trait][AsFd-trait]. So replacing generic bounds with `W: Write + AsFd`
should be sufficient.
[AsFd-trait]: https://doc.rust-lang.org/std/os/fd/trait.AsFd.html
# 1.0.0
Termion 1.0.0 is out! This release is breaking, which is also the reason for the semver bump.
......
[package]
name = "termion"
version = "1.0.3"
authors = ["Ticki <Ticki@users.noreply.github.com>"]
version = "4.0.4"
authors = [
"ticki <Ticki@users.noreply.github.com>",
"gycos <alexandre.bury@gmail.com>",
"IGI-111 <igi-111@protonmail.com>",
"Jeremy Soller <jackpot51@gmail.com>",
]
description = "A bindless library for manipulating terminals."
repository = "https://github.com/ticki/termion"
documentation = "http://ticki.github.io/termion/"
repository = "https://gitlab.redox-os.org/redox-os/termion"
documentation = "https://docs.rs/termion"
license = "MIT"
keywords = ["tty", "color", "terminal", "password", "tui"]
exclude = ["target", "CHANGELOG.md", "image.png", "Cargo.lock"]
[dependencies]
numtoa = { version = "0.2.4"}
serde = { version = "1.0", features = ["derive"], optional = true }
[target.'cfg(not(target_os = "redox"))'.dependencies]
libc = "0.2.8"
libc = "0.2"
[target.'cfg(target_os = "redox")'.dependencies]
redox_termios = "0.1.3"
libredox = "0.1.3"
{
"drips": {
"ethereum": {
"ownedBy": "0x083e29156955A4c0f7eAA406e1167Bd1bE88933E"
}
}
}
# Termion
<p align="center">
<img alt="Termion logo" src="https://rawgit.com/redox-os/termion/master/logo.svg" />
</p>
Termion is a pure Rust, bindless library for low-level handling, manipulating
[![Build Status](https://travis-ci.org/redox-os/termion.svg?branch=master)](https://travis-ci.org/redox-os/termion) [![Latest Version](https://img.shields.io/crates/v/termion.svg)](https://crates.io/crates/termion) | [Documentation](https://docs.rs/termion) | [Examples](https://github.com/redox-os/termion/tree/master/examples) | [Changelog](https://github.com/redox-os/termion/tree/master/CHANGELOG.md) | [Tutorial](http://ticki.github.io/blog/making-terminal-applications-in-rust-with-termion/)
|----|----|----|----|----
**Termion** is a pure Rust, bindless library for low-level handling, manipulating
and reading information about terminals. This provides a full-featured
alternative to Termbox.
......@@ -8,9 +14,9 @@ Termion aims to be simple and yet expressive. It is bindless, meaning that it
is not a front-end to some other library (e.g., ncurses or termbox), but a
standalone library directly talking to the TTY.
Termion is quite convinient, due to its complete coverage of essential TTY
Termion is quite convenient, due to its complete coverage of essential TTY
features, providing one consistent API. Termion is rather low-level containing
only abstraction aligned with what actually happens behind the scenes, for
only abstraction aligned with what actually happens behind the scenes. For
something more high-level, refer to inquirer-rs, which uses Termion as backend.
Termion generates escapes and API calls for the user. This makes it a whole lot
......@@ -18,23 +24,39 @@ cleaner to use escapes.
Supports Redox, Mac OS X, BSD, and Linux (or, in general, ANSI terminals).
[Documentation.](http://ticki.github.io/termion/) | [Examples.](https://github.com/Ticki/termion/tree/master/examples) | [Changelog.](https://github.com/Ticki/termion/tree/master/CHANGELOG.md)
## A note on stability
Although small breaking changes might happen, I will try my best to avoid them,
and this crate can generally be considered stable.
This crate is stable.
## Cargo.toml
```toml
[dependencies]
termion = "1.0.3"
termion = "*"
```
## 3.0.0 to 4.0.0 guide
A change is only necessary if you were matching on all variants of the `MouseEvent` enum without a wildcard.
In this case, you need to either handle the two new variants, `MouseLeft` and `MouseRight`, or add a wildcard.
## 2.0.0 to 3.0.0 guide
Changes are only required if you were using `IntoRawMode` on generic terminals `W: Write`. Now, terminal
is also required to implement [`AsFd` trait][AsFd-trait]. So replacing generic bounds with `W: Write + AsFd`
should be sufficient.
[AsFd-trait]: https://doc.rust-lang.org/std/os/fd/trait.AsFd.html
## 1.0.0 to 2.0.0 guide
| 1.0.0 | 2.0.0
|--------------------------------|---------------------------
| `AlternativeScreen::from(x)` | `x.into_alternative_screen()`
## 0.1.0 to 1.0.0 guide
This sample table gives an idea of how to go bu converting to the new major
This sample table gives an idea of how to go about converting to the new major
version of Termion.
| 0.1.0 | 1.0.0
......@@ -55,6 +77,7 @@ version of Termion.
- Cursor movement.
- Text formatting.
- Console size.
- TTY-only stream.
- Control sequences.
- Termios control.
- Password input.
......@@ -64,8 +87,9 @@ version of Termion.
- Special keys events (modifiers, special keys, etc.).
- Allocation-free.
- Asynchronous key events.
- Mouse input
- Mouse input.
- Carefully tested.
- Detailed documentation on every item.
and much more.
......@@ -149,16 +173,16 @@ fn main() {
let stdin = stdin();
let mut stdin = stdin.lock();
stdout.write(b"password: ").unwrap();
stdout.write_all(b"password: ").unwrap();
stdout.flush().unwrap();
let pass = stdin.read_passwd(&mut stdout);
if let Ok(Some(pass)) = pass {
stdout.write(pass.as_bytes()).unwrap();
stdout.write(b"\n").unwrap();
stdout.write_all(pass.as_bytes()).unwrap();
stdout.write_all(b"\n").unwrap();
} else {
stdout.write(b"Error\n").unwrap();
stdout.write_all(b"Error\n").unwrap();
}
}
```
......
extern crate termion;
use std::io::{stdout, Write};
use std::{thread, time};
use termion::screen::IntoAlternateScreen;
fn main() {
{
let mut screen = stdout().into_alternate_screen().unwrap();
write!(screen, "Welcome to the alternate screen.\n\nPlease wait patiently until we arrive back at the main screen in a about three seconds.").unwrap();
screen.flush().unwrap();
thread::sleep(time::Duration::from_secs(3));
}
println!("Phew! We are back.");
}
extern crate termion;
use std::io::{stdin, stdout, Write};
use termion::event::Key;
use termion::input::TermRead;
use termion::raw::IntoRawMode;
use termion::screen::{IntoAlternateScreen, ToAlternateScreen, ToMainScreen};
fn write_alt_screen_msg<W: Write>(screen: &mut W) {
write!(screen, "{}{}Welcome to the alternate screen.{}Press '1' to switch to the main screen or '2' to switch to the alternate screen.{}Press 'q' to exit (and switch back to the main screen).",
termion::clear::All,
termion::cursor::Goto(1, 1),
termion::cursor::Goto(1, 3),
termion::cursor::Goto(1, 4)).unwrap();
}
fn main() {
let stdin = stdin();
let mut screen = stdout()
.into_raw_mode()
.unwrap()
.into_alternate_screen()
.unwrap();
write!(screen, "{}", termion::cursor::Hide).unwrap();
write_alt_screen_msg(&mut screen);
screen.flush().unwrap();
for c in stdin.keys() {
match c.unwrap() {
Key::Char('q') => break,
Key::Char('1') => {
write!(screen, "{}", ToMainScreen).unwrap();
}
Key::Char('2') => {
write!(screen, "{}", ToAlternateScreen).unwrap();
write_alt_screen_msg(&mut screen);
}
_ => {}
}
screen.flush().unwrap();
}
write!(screen, "{}", termion::cursor::Show).unwrap();
}
extern crate termion;
use termion::raw::IntoRawMode;
use termion::async_stdin;
use std::io::{Read, Write, stdout, stdin};
use std::io::{stdout, Read, Write};
use std::thread;
use std::time::Duration;
use termion::async_stdin;
use termion::raw::IntoRawMode;
fn main() {
let stdout = stdout();
let mut stdout = stdout.lock().into_raw_mode().unwrap();
let mut stdin = async_stdin().bytes();
write!(stdout, "{}{}", termion::clear::All, termion::cursor::Goto(1, 1)).unwrap();
write!(
stdout,
"{}{}",
termion::clear::All,
termion::cursor::Goto(1, 1)
)
.unwrap();
loop {
write!(stdout, "{}", termion::clear::CurrentLine).unwrap();
......@@ -25,10 +31,10 @@ fn main() {
stdout.flush().unwrap();
thread::sleep(Duration::from_millis(50));
stdout.write(b"# ").unwrap();
stdout.write_all(b"# ").unwrap();
stdout.flush().unwrap();
thread::sleep(Duration::from_millis(50));
stdout.write(b"\r #").unwrap();
stdout.write_all(b"\r #").unwrap();
write!(stdout, "{}", termion::cursor::Goto(1, 1)).unwrap();
stdout.flush().unwrap();
}
......
extern crate termion;
use termion::event::{Key, Event, MouseEvent};
use termion::input::{TermRead, MouseTerminal};
use std::io::{stdin, stdout, Write};
use termion::event::{Event, Key, MouseEvent};
use termion::input::{MouseTerminal, TermRead};
use termion::raw::IntoRawMode;
use std::io::{Write, stdout, stdin};
fn main() {
let stdin = stdin();
let mut stdout = MouseTerminal::from(stdout().into_raw_mode().unwrap());
write!(stdout, "{}{}q to exit. Click, click, click!", termion::clear::All, termion::cursor::Goto(1, 1)).unwrap();
write!(
stdout,
"{}{}q to exit. Click, click, click!",
termion::clear::All,
termion::cursor::Goto(1, 1)
)
.unwrap();
stdout.flush().unwrap();
for c in stdin.events() {
let evt = c.unwrap();
match evt {
Event::Key(Key::Char('q')) => break,
Event::Mouse(me) => {
match me {
MouseEvent::Press(_, x, y) => {
write!(stdout, "{}x", termion::cursor::Goto(x, y)).unwrap();
},
_ => (),
Event::Mouse(me) => match me {
MouseEvent::Press(_, x, y) => {
write!(stdout, "{}x", termion::cursor::Goto(x, y)).unwrap();
}
}
_ => (),
},
_ => {}
}
stdout.flush().unwrap();
......
......@@ -3,8 +3,9 @@ extern crate termion;
use termion::{color, style};
fn main() {
println!("{}Gray background", color::Bg(color::LightBlack));
println!("{}Red", color::Fg(color::Red));
println!("{}Blue", color::Fg(color::Blue));
println!("{}Blue'n'Bold{}", style::Bold, style::Reset);
println!("{}Just plain italic", style::Italic);
println!("{}Just plain italic{}", style::Italic, style::Reset);
}
extern crate termion;
use std::io::stdout;
use termion::color::{AnsiValue, Bg, DetectColors};
use termion::raw::IntoRawMode;
fn main() {
let count;
{
let mut term = stdout().into_raw_mode().unwrap();
count = term.available_colors().unwrap();
}
println!("This terminal supports {} colors.", count);
for i in 0..count {
print!("{} {}", Bg(AnsiValue(i as u8)), Bg(AnsiValue(0)));
}
println!();
}
......@@ -3,7 +3,7 @@ extern crate termion;
use std::fs;
fn main() {
if termion::is_tty(fs::File::create("/dev/stdout").unwrap()) {
if termion::is_tty(&fs::File::create("/dev/stdout").unwrap()) {
println!("This is a TTY!");
} else {
println!("This is not a TTY :(");
......
extern crate termion;
use std::io::{stdin, stdout, Write};
use termion::event::Key;
use termion::input::TermRead;
use termion::raw::IntoRawMode;
use std::io::{Write, stdout, stdin};
fn main() {
let stdin = stdin();
let mut stdout = stdout().into_raw_mode().unwrap();
write!(stdout, "{}{}q to exit. Type stuff, use alt, and so on.{}",
termion::clear::All,
termion::cursor::Goto(1, 1),
termion::cursor::Hide).unwrap();
write!(
stdout,
"{}{}q to exit. Type stuff, use alt, and so on.{}",
termion::clear::All,
termion::cursor::Goto(1, 1),
termion::cursor::Hide
)
.unwrap();
stdout.flush().unwrap();
for c in stdin.keys() {
write!(stdout, "{}{}", termion::cursor::Goto(1, 1), termion::clear::CurrentLine).unwrap();
for k in stdin.keys() {
write!(
stdout,
"{}{}",
termion::cursor::Goto(1, 1),
termion::clear::CurrentLine
)
.unwrap();
match c.unwrap() {
match k.as_ref().unwrap() {
Key::Char('q') => break,
Key::Char(c) => println!("{}", c),
Key::Alt(c) => println!("^{}", c),
Key::Ctrl(c) => println!("*{}", c),
Key::Esc => println!("ESC"),
Key::Left => println!("←"),
Key::Right => println!("→"),
Key::Up => println!("↑"),
Key::Down => println!("↓"),
Key::Backspace => println!("×"),
_ => {},
_ => {
println!("{:?}", k)
}
}
stdout.flush().unwrap();
}
......
extern crate termion;
use termion::event::{Key, Event, MouseEvent};
use termion::input::{TermRead, MouseTerminal};
use std::io::{self, Write};
use termion::cursor::{self, DetectCursorPos};
use termion::event::*;
use termion::input::{MouseTerminal, TermRead};
use termion::raw::IntoRawMode;
use std::io::{Write, stdout, stdin};
fn main() {
let stdin = stdin();
let mut stdout = MouseTerminal::from(stdout().into_raw_mode().unwrap());
let stdin = io::stdin();
let mut stdout = MouseTerminal::from(io::stdout().into_raw_mode().unwrap());
write!(stdout, "{}{}q to exit. Type stuff, use alt, click around...", termion::clear::All, termion::cursor::Goto(1, 1)).unwrap();
let mut x = 1;
let mut y = 1;
writeln!(
stdout,
"{}{}q to exit. Type stuff, use alt, click around...",
termion::clear::All,
termion::cursor::Goto(1, 1)
)
.unwrap();
for c in stdin.events() {
let evt = c.unwrap();
writeln!(stdout, "{:?}{}{}", evt, termion::cursor::Goto(5, 5), termion::clear::CurrentLine).unwrap();
match evt {
Event::Key(Key::Char('q')) => break,
Event::Mouse(me) => {
match me {
MouseEvent::Press(_, a, b) |
MouseEvent::Release(a, b) => {
x = a;
y = b;
}
Event::Mouse(me) => match me {
MouseEvent::Press(_, a, b) | MouseEvent::Release(a, b) | MouseEvent::Hold(a, b) => {
write!(stdout, "{}", cursor::Goto(a, b)).unwrap();
let (x, y) = stdout.cursor_pos().unwrap();
write!(
stdout,
"{}{}Cursor is at: ({},{}){}",
cursor::Goto(5, 5),
termion::clear::UntilNewline,
x,
y,
cursor::Goto(a, b)
)
.unwrap();
}
}
},
_ => {}
}
writeln!(stdout, "{:?}{}", evt, termion::cursor::Goto(x, y)).unwrap();
stdout.flush().unwrap();
}
write!(stdout, "{}", termion::cursor::Show).unwrap();
}
#![feature(step_by)]
extern crate termion;
use std::io::{stdin, stdout, Write};
use termion::event::Key;
use termion::input::TermRead;
use termion::raw::IntoRawMode;
use std::io::{Write, stdout, stdin};
fn rainbow<W: Write>(stdout: &mut W, blue: u8) {
write!(stdout, "{}{}", termion::cursor::Goto(1, 1), termion::clear::All).unwrap();
write!(
stdout,
"{}{}",
termion::cursor::Goto(1, 1),
termion::clear::All
)
.unwrap();
for red in (0..255).step_by(8 as u8) {
for green in (0..255).step_by(4) {
write!(stdout, "{} ", termion::color::Bg(termion::color::Rgb(red, green, blue))).unwrap();
for red in 0..32 {
let red = red * 8;
for green in 0..64 {
let green = green * 4;
write!(
stdout,
"{} ",
termion::color::Bg(termion::color::Rgb(red, green, blue))
)
.unwrap();
}
write!(stdout, "\n\r").unwrap();
}
......@@ -24,10 +35,14 @@ fn main() {
let stdin = stdin();
let mut stdout = stdout().into_raw_mode().unwrap();
writeln!(stdout, "{}{}{}Use the arrow keys to change the blue in the rainbow.",
termion::clear::All,
termion::cursor::Goto(1, 1),
termion::cursor::Hide).unwrap();
writeln!(
stdout,
"{}{}{}Use the up/down arrow keys to change the blue in the rainbow.",
termion::clear::All,
termion::cursor::Goto(1, 1),
termion::cursor::Hide
)
.unwrap();
let mut blue = 172u8;
......@@ -36,13 +51,13 @@ fn main() {
Key::Up => {
blue = blue.saturating_add(4);
rainbow(&mut stdout, blue);
},
}
Key::Down => {
blue = blue.saturating_sub(4);
rainbow(&mut stdout, blue);
},
}
Key::Char('q') => break,
_ => {},
_ => {}
}
stdout.flush().unwrap();
}
......
extern crate termion;
use std::io::{stdin, stdout, Write};
use termion::input::TermRead;
use std::io::{Write, stdout, stdin};
fn main() {
let stdout = stdout();
......@@ -9,15 +9,15 @@ fn main() {
let stdin = stdin();
let mut stdin = stdin.lock();
stdout.write(b"password: ").unwrap();
stdout.write_all(b"password: ").unwrap();
stdout.flush().unwrap();
let pass = stdin.read_passwd(&mut stdout);
if let Ok(Some(pass)) = pass {
stdout.write(pass.as_bytes()).unwrap();
stdout.write(b"\n").unwrap();
stdout.write_all(pass.as_bytes()).unwrap();
stdout.write_all(b"\n").unwrap();
} else {
stdout.write(b"Error\n").unwrap();
stdout.write_all(b"Error\n").unwrap();
}
}
......@@ -12,13 +12,13 @@ fn main() {
{line_num_fg}{line_num_bg}84 {reset} }};\n\
{line_num_fg}{line_num_bg}85 {reset} }}\n\
{line_num_fg}{line_num_bg}{info_line}{reset} {red}^{reset} {error_fg}borrow from first closure ends here",
lighgreen=color::Fg(color::LightGreen),
red=color::Fg(color::Red),
bold=style::Bold,
reset=style::Reset,
magenta=color::Fg(color::Magenta),
line_num_bg=color::Bg(color::AnsiValue::grayscale(3)),
line_num_fg=color::Fg(color::AnsiValue::grayscale(18)),
info_line="| ",
error_fg=color::Fg(color::AnsiValue::grayscale(17)))
lighgreen = color::Fg(color::LightGreen),
red = color::Fg(color::Red),
bold = style::Bold,
reset = style::Reset,
magenta = color::Fg(color::Magenta),
line_num_bg = color::Bg(color::AnsiValue::grayscale(3)),
line_num_fg = color::Fg(color::AnsiValue::grayscale(18)),
info_line = "| ",
error_fg = color::Fg(color::AnsiValue::grayscale(17)))
}
extern crate termion;
use std::io::{stdin, stdout, Read, Write};
use termion::color;
use termion::raw::IntoRawMode;
use std::io::{Read, Write, stdout, stdin};
fn main() {
// Initialize 'em all.
......@@ -11,8 +11,16 @@ fn main() {
let stdin = stdin();
let stdin = stdin.lock();
write!(stdout, "{}{}{}yo, 'q' will exit.{}{}", termion::clear::All, termion::cursor::Goto(5, 5),
termion::style::Bold, termion::style::Reset, termion::cursor::Goto(20, 10)).unwrap();
write!(
stdout,
"{}{}{}yo, 'q' will exit.{}{}",
termion::clear::All,
termion::cursor::Goto(5, 5),
termion::style::Bold,
termion::style::Reset,
termion::cursor::Goto(20, 10)
)
.unwrap();
stdout.flush().unwrap();
let mut bytes = stdin.bytes();
......@@ -25,10 +33,11 @@ fn main() {
// Clear the screen
b'c' => write!(stdout, "{}", termion::clear::All),
// Set red color
b'r' => write!(stdout, "{}", color::Fg(color::Rgb(5, 0, 0))),
b'r' => write!(stdout, "{}", color::Fg(color::Rgb(255, 0, 0))),
// Write it to stdout.
a => write!(stdout, "{}", a),
}.unwrap();
}
.unwrap();
stdout.flush().unwrap();
}
......
extern crate termion;
use termion::{color, cursor, clear};
use std::{thread, time};
use termion::{clear, color, cursor};
fn main() {
for r in 0..255 {
......