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 (150)
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
...@@ -4,7 +4,11 @@ rust: ...@@ -4,7 +4,11 @@ rust:
- stable - stable
- beta - beta
- nightly - nightly
os:
- linux
- osx
script: script:
- cargo build --verbose - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then FAKETTY="script -q /dev/null"; fi
- cargo test --verbose - $FAKETTY cargo build --verbose
- cargo test --release --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 # 1.0.0
Termion 1.0.0 is out! This release is breaking, which is also the reason for the semver bump. Termion 1.0.0 is out! This release is breaking, which is also the reason for the semver bump.
......
[package] [package]
name = "termion" name = "termion"
version = "1.1.4" version = "4.0.4"
authors = ["ticki <Ticki@users.noreply.github.com>", "gycos <alexandre.bury@gmail.com>"] 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." description = "A bindless library for manipulating terminals."
repository = "https://github.com/ticki/termion" repository = "https://gitlab.redox-os.org/redox-os/termion"
documentation = "https://docs.rs/termion" documentation = "https://docs.rs/termion"
license = "MIT" license = "MIT"
keywords = ["tty", "color", "terminal", "password", "tui"] keywords = ["tty", "color", "terminal", "password", "tui"]
exclude = ["target", "CHANGELOG.md", "image.png", "Cargo.lock"] 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] [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"
}
}
}
<p align="center"> <p align="center">
<img alt="Termion logo" src="https://rawgit.com/ticki/termion/master/logo.svg" /> <img alt="Termion logo" src="https://rawgit.com/redox-os/termion/master/logo.svg" />
</p> </p>
[![Build Status](https://travis-ci.org/ticki/termion.svg?branch=master)](https://travis-ci.org/ticki/termion) [![Latest Version](https://img.shields.io/crates/v/termion.svg)](https://crates.io/crates/termion) &emsp; | [Documentation](https://docs.rs/termion) | [Examples](https://github.com/Ticki/termion/tree/master/examples) | [Changelog](https://github.com/Ticki/termion/tree/master/CHANGELOG.md) | [Tutorial](http://ticki.github.io/blog/making-terminal-applications-in-rust-with-termion/) [![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/)
|----|----|----|----|---- |----|----|----|----|----
...@@ -32,9 +32,28 @@ This crate is stable. ...@@ -32,9 +32,28 @@ This crate is stable.
```toml ```toml
[dependencies] [dependencies]
termion = "1.0" 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 ## 0.1.0 to 1.0.0 guide
This sample table gives an idea of how to go about converting to the new major This sample table gives an idea of how to go about converting to the new major
...@@ -154,16 +173,16 @@ fn main() { ...@@ -154,16 +173,16 @@ fn main() {
let stdin = stdin(); let stdin = stdin();
let mut stdin = stdin.lock(); let mut stdin = stdin.lock();
stdout.write(b"password: ").unwrap(); stdout.write_all(b"password: ").unwrap();
stdout.flush().unwrap(); stdout.flush().unwrap();
let pass = stdin.read_passwd(&mut stdout); let pass = stdin.read_passwd(&mut stdout);
if let Ok(Some(pass)) = pass { if let Ok(Some(pass)) = pass {
stdout.write(pass.as_bytes()).unwrap(); stdout.write_all(pass.as_bytes()).unwrap();
stdout.write(b"\n").unwrap(); stdout.write_all(b"\n").unwrap();
} else { } 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; extern crate termion;
use termion::raw::IntoRawMode; use std::io::{stdout, Read, Write};
use termion::async_stdin;
use std::io::{Read, Write, stdout};
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use termion::async_stdin;
use termion::raw::IntoRawMode;
fn main() { fn main() {
let stdout = stdout(); let stdout = stdout();
let mut stdout = stdout.lock().into_raw_mode().unwrap(); let mut stdout = stdout.lock().into_raw_mode().unwrap();
let mut stdin = async_stdin().bytes(); 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 { loop {
write!(stdout, "{}", termion::clear::CurrentLine).unwrap(); write!(stdout, "{}", termion::clear::CurrentLine).unwrap();
...@@ -25,10 +31,10 @@ fn main() { ...@@ -25,10 +31,10 @@ fn main() {
stdout.flush().unwrap(); stdout.flush().unwrap();
thread::sleep(Duration::from_millis(50)); thread::sleep(Duration::from_millis(50));
stdout.write(b"# ").unwrap(); stdout.write_all(b"# ").unwrap();
stdout.flush().unwrap(); stdout.flush().unwrap();
thread::sleep(Duration::from_millis(50)); 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(); write!(stdout, "{}", termion::cursor::Goto(1, 1)).unwrap();
stdout.flush().unwrap(); stdout.flush().unwrap();
} }
......
extern crate termion; extern crate termion;
use termion::event::{Key, Event, MouseEvent}; use std::io::{stdin, stdout, Write};
use termion::input::{TermRead, MouseTerminal}; use termion::event::{Event, Key, MouseEvent};
use termion::input::{MouseTerminal, TermRead};
use termion::raw::IntoRawMode; use termion::raw::IntoRawMode;
use std::io::{Write, stdout, stdin};
fn main() { fn main() {
let stdin = stdin(); let stdin = stdin();
let mut stdout = MouseTerminal::from(stdout().into_raw_mode().unwrap()); 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(); stdout.flush().unwrap();
for c in stdin.events() { for c in stdin.events() {
let evt = c.unwrap(); let evt = c.unwrap();
match evt { match evt {
Event::Key(Key::Char('q')) => break, Event::Key(Key::Char('q')) => break,
Event::Mouse(me) => { Event::Mouse(me) => match me {
match me { MouseEvent::Press(_, x, y) => {
MouseEvent::Press(_, x, y) => { write!(stdout, "{}x", termion::cursor::Goto(x, y)).unwrap();
write!(stdout, "{}x", termion::cursor::Goto(x, y)).unwrap();
},
_ => (),
} }
} _ => (),
},
_ => {} _ => {}
} }
stdout.flush().unwrap(); stdout.flush().unwrap();
......
...@@ -3,8 +3,9 @@ extern crate termion; ...@@ -3,8 +3,9 @@ extern crate termion;
use termion::{color, style}; use termion::{color, style};
fn main() { fn main() {
println!("{}Gray background", color::Bg(color::LightBlack));
println!("{}Red", color::Fg(color::Red)); println!("{}Red", color::Fg(color::Red));
println!("{}Blue", color::Fg(color::Blue)); println!("{}Blue", color::Fg(color::Blue));
println!("{}Blue'n'Bold{}", style::Bold, style::Reset); 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 termion::{clear, color, cursor};
use std::{time, thread};
const COMMUNISM: &'static str = r#"
!######### #
!########! ##!
!########! ###
!########## ####
######### ##### ######
!###! !####! ######
! ##### ######!
!####! #######
##### #######
!####! #######!
####!########
## ##########
,######! !#############
,#### ########################!####!
,####' ##################!' #####
,####' ####### !####!
####' #####
~## ##~
"#;
fn main() {
let mut state = 0;
println!("\n{}{}{}{}{}{}", cursor::Hide, clear::All, cursor::Goto(1, 1), color::Fg(color::Black), color::Bg(color::Red), COMMUNISM);
loop {
println!("{}{} ☭ GAY ☭ SPACE ☭ COMMUNISM ☭ ", cursor::Goto(1, 1), color::Bg(color::AnsiValue(state)));
println!("{}{} WILL PREVAIL, COMRADES! ", cursor::Goto(1, 20), color::Bg(color::AnsiValue(state)));
state += 1;
state %= 8;
thread::sleep(time::Duration::from_millis(90));
}
}
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!();
}
extern crate termion; extern crate termion;
use std::io::{stdin, stdout, Write};
use termion::event::Key; use termion::event::Key;
use termion::input::TermRead; use termion::input::TermRead;
use termion::raw::IntoRawMode; use termion::raw::IntoRawMode;
use std::io::{Write, stdout, stdin};
fn main() { fn main() {
let stdin = stdin(); let stdin = stdin();
let mut stdout = stdout().into_raw_mode().unwrap(); let mut stdout = stdout().into_raw_mode().unwrap();
write!(stdout, "{}{}q to exit. Type stuff, use alt, and so on.{}", write!(
termion::clear::All, stdout,
termion::cursor::Goto(1, 1), "{}{}q to exit. Type stuff, use alt, and so on.{}",
termion::cursor::Hide).unwrap(); termion::clear::All,
termion::cursor::Goto(1, 1),
termion::cursor::Hide
)
.unwrap();
stdout.flush().unwrap(); stdout.flush().unwrap();
for c in stdin.keys() { for k in stdin.keys() {
write!(stdout, "{}{}", termion::cursor::Goto(1, 1), termion::clear::CurrentLine).unwrap(); 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('q') => break,
Key::Char(c) => println!("{}", c), Key::Char(c) => println!("{}", c),
Key::Alt(c) => println!("^{}", c), Key::Alt(c) => println!("^{}", c),
...@@ -29,7 +39,9 @@ fn main() { ...@@ -29,7 +39,9 @@ fn main() {
Key::Up => println!("↑"), Key::Up => println!("↑"),
Key::Down => println!("↓"), Key::Down => println!("↓"),
Key::Backspace => println!("×"), Key::Backspace => println!("×"),
_ => {}, _ => {
println!("{:?}", k)
}
} }
stdout.flush().unwrap(); stdout.flush().unwrap();
} }
......
extern crate termion; extern crate termion;
use std::io::{self, Write};
use termion::cursor::{self, DetectCursorPos};
use termion::event::*; use termion::event::*;
use termion::cursor; use termion::input::{MouseTerminal, TermRead};
use termion::input::{TermRead, MouseTerminal};
use termion::raw::IntoRawMode; use termion::raw::IntoRawMode;
use std::io::{self, Write};
fn main() { fn main() {
let stdin = io::stdin(); let stdin = io::stdin();
let mut stdout = MouseTerminal::from(io::stdout().into_raw_mode().unwrap()); let mut stdout = MouseTerminal::from(io::stdout().into_raw_mode().unwrap());
writeln!(stdout, writeln!(
"{}{}q to exit. Type stuff, use alt, click around...", stdout,
termion::clear::All, "{}{}q to exit. Type stuff, use alt, click around...",
termion::cursor::Goto(1, 1)) termion::clear::All,
.unwrap(); termion::cursor::Goto(1, 1)
)
.unwrap();
for c in stdin.events() { for c in stdin.events() {
let evt = c.unwrap(); let evt = c.unwrap();
match evt { match evt {
Event::Key(Key::Char('q')) => break, Event::Key(Key::Char('q')) => break,
Event::Mouse(me) => { Event::Mouse(me) => match me {
match me { MouseEvent::Press(_, a, b) | MouseEvent::Release(a, b) | MouseEvent::Hold(a, b) => {
MouseEvent::Press(_, a, b) | write!(stdout, "{}", cursor::Goto(a, b)).unwrap();
MouseEvent::Release(a, b) | let (x, y) = stdout.cursor_pos().unwrap();
MouseEvent::Hold(a, b) => { write!(
write!(stdout, "{}", cursor::Goto(a, b)).unwrap(); stdout,
} "{}{}Cursor is at: ({},{}){}",
cursor::Goto(5, 5),
termion::clear::UntilNewline,
x,
y,
cursor::Goto(a, b)
)
.unwrap();
} }
} },
_ => {} _ => {}
} }
......
extern crate termion; extern crate termion;
use std::io::{stdin, stdout, Write};
use termion::event::Key; use termion::event::Key;
use termion::input::TermRead; use termion::input::TermRead;
use termion::raw::IntoRawMode; use termion::raw::IntoRawMode;
use std::io::{Write, stdout, stdin};
fn rainbow<W: Write>(stdout: &mut W, blue: u8) { 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..32 { for red in 0..32 {
let red = red * 8; let red = red * 8;
for green in 0..64 { for green in 0..64 {
let green = green * 4; let green = green * 4;
write!(stdout, "{} ", termion::color::Bg(termion::color::Rgb(red, green, blue))).unwrap(); write!(
stdout,
"{} ",
termion::color::Bg(termion::color::Rgb(red, green, blue))
)
.unwrap();
} }
write!(stdout, "\n\r").unwrap(); write!(stdout, "\n\r").unwrap();
} }
...@@ -24,10 +35,14 @@ fn main() { ...@@ -24,10 +35,14 @@ fn main() {
let stdin = stdin(); let stdin = stdin();
let mut stdout = stdout().into_raw_mode().unwrap(); let mut stdout = stdout().into_raw_mode().unwrap();
writeln!(stdout, "{}{}{}Use the up/down arrow keys to change the blue in the rainbow.", writeln!(
termion::clear::All, stdout,
termion::cursor::Goto(1, 1), "{}{}{}Use the up/down arrow keys to change the blue in the rainbow.",
termion::cursor::Hide).unwrap(); termion::clear::All,
termion::cursor::Goto(1, 1),
termion::cursor::Hide
)
.unwrap();
let mut blue = 172u8; let mut blue = 172u8;
...@@ -36,13 +51,13 @@ fn main() { ...@@ -36,13 +51,13 @@ fn main() {
Key::Up => { Key::Up => {
blue = blue.saturating_add(4); blue = blue.saturating_add(4);
rainbow(&mut stdout, blue); rainbow(&mut stdout, blue);
}, }
Key::Down => { Key::Down => {
blue = blue.saturating_sub(4); blue = blue.saturating_sub(4);
rainbow(&mut stdout, blue); rainbow(&mut stdout, blue);
}, }
Key::Char('q') => break, Key::Char('q') => break,
_ => {}, _ => {}
} }
stdout.flush().unwrap(); stdout.flush().unwrap();
} }
......
extern crate termion; extern crate termion;
use std::io::{stdin, stdout, Write};
use termion::input::TermRead; use termion::input::TermRead;
use std::io::{Write, stdout, stdin};
fn main() { fn main() {
let stdout = stdout(); let stdout = stdout();
...@@ -9,15 +9,15 @@ fn main() { ...@@ -9,15 +9,15 @@ fn main() {
let stdin = stdin(); let stdin = stdin();
let mut stdin = stdin.lock(); let mut stdin = stdin.lock();
stdout.write(b"password: ").unwrap(); stdout.write_all(b"password: ").unwrap();
stdout.flush().unwrap(); stdout.flush().unwrap();
let pass = stdin.read_passwd(&mut stdout); let pass = stdin.read_passwd(&mut stdout);
if let Ok(Some(pass)) = pass { if let Ok(Some(pass)) = pass {
stdout.write(pass.as_bytes()).unwrap(); stdout.write_all(pass.as_bytes()).unwrap();
stdout.write(b"\n").unwrap(); stdout.write_all(b"\n").unwrap();
} else { } else {
stdout.write(b"Error\n").unwrap(); stdout.write_all(b"Error\n").unwrap();
} }
} }
...@@ -12,13 +12,13 @@ fn main() { ...@@ -12,13 +12,13 @@ fn main() {
{line_num_fg}{line_num_bg}84 {reset} }};\n\ {line_num_fg}{line_num_bg}84 {reset} }};\n\
{line_num_fg}{line_num_bg}85 {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", {line_num_fg}{line_num_bg}{info_line}{reset} {red}^{reset} {error_fg}borrow from first closure ends here",
lighgreen=color::Fg(color::LightGreen), lighgreen = color::Fg(color::LightGreen),
red=color::Fg(color::Red), red = color::Fg(color::Red),
bold=style::Bold, bold = style::Bold,
reset=style::Reset, reset = style::Reset,
magenta=color::Fg(color::Magenta), magenta = color::Fg(color::Magenta),
line_num_bg=color::Bg(color::AnsiValue::grayscale(3)), line_num_bg = color::Bg(color::AnsiValue::grayscale(3)),
line_num_fg=color::Fg(color::AnsiValue::grayscale(18)), line_num_fg = color::Fg(color::AnsiValue::grayscale(18)),
info_line="| ", info_line = "| ",
error_fg=color::Fg(color::AnsiValue::grayscale(17))) error_fg = color::Fg(color::AnsiValue::grayscale(17)))
} }
extern crate termion; extern crate termion;
use std::io::{stdin, stdout, Read, Write};
use termion::color; use termion::color;
use termion::raw::IntoRawMode; use termion::raw::IntoRawMode;
use std::io::{Read, Write, stdout, stdin};
fn main() { fn main() {
// Initialize 'em all. // Initialize 'em all.
...@@ -11,8 +11,16 @@ fn main() { ...@@ -11,8 +11,16 @@ fn main() {
let stdin = stdin(); let stdin = stdin();
let stdin = stdin.lock(); let stdin = stdin.lock();
write!(stdout, "{}{}{}yo, 'q' will exit.{}{}", termion::clear::All, termion::cursor::Goto(5, 5), write!(
termion::style::Bold, termion::style::Reset, termion::cursor::Goto(20, 10)).unwrap(); 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(); stdout.flush().unwrap();
let mut bytes = stdin.bytes(); let mut bytes = stdin.bytes();
...@@ -25,10 +33,11 @@ fn main() { ...@@ -25,10 +33,11 @@ fn main() {
// Clear the screen // Clear the screen
b'c' => write!(stdout, "{}", termion::clear::All), b'c' => write!(stdout, "{}", termion::clear::All),
// Set red color // 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. // Write it to stdout.
a => write!(stdout, "{}", a), a => write!(stdout, "{}", a),
}.unwrap(); }
.unwrap();
stdout.flush().unwrap(); stdout.flush().unwrap();
} }
......
extern crate termion; extern crate termion;
use termion::{color, cursor, clear};
use std::{thread, time}; use std::{thread, time};
use termion::{clear, color, cursor};
fn main() { fn main() {
for r in 0..255 { for r in 0..255 {
......