Skip to content

Commit a29ed27

Browse files
committed
cargo fmt
1 parent 67d5686 commit a29ed27

9 files changed

+63
-67
lines changed

examples/arrow.rs

+23-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate termfest;
22

3-
use termfest::{Event, Termfest, Cell};
3+
use termfest::{Cell, Event, Termfest};
44
use termfest::key::*;
55

66
use std::cmp;
@@ -15,35 +15,33 @@ fn main() {
1515
match ev {
1616
Event::Char('q') | Event::Key(ESC) => break,
1717
Event::Char(ch) => screen.put_cell(cursor_x, cursor_y, Cell::new(ch)),
18-
Event::Key(key) => {
19-
match key {
20-
ArrowUp | CtrlP => {
21-
if cursor_y > 0 {
22-
cursor_y -= 1;
23-
}
24-
screen.move_cursor(cursor_x, cursor_y);
18+
Event::Key(key) => match key {
19+
ArrowUp | CtrlP => {
20+
if cursor_y > 0 {
21+
cursor_y -= 1;
2522
}
26-
ArrowDown | CtrlN => {
27-
if cursor_y < height - 1 {
28-
cursor_y += 1;
29-
}
30-
screen.move_cursor(cursor_x, cursor_y);
23+
screen.move_cursor(cursor_x, cursor_y);
24+
}
25+
ArrowDown | CtrlN => {
26+
if cursor_y < height - 1 {
27+
cursor_y += 1;
3128
}
32-
ArrowLeft | CtrlB => {
33-
if cursor_x > 0 {
34-
cursor_x -= 1;
35-
}
36-
screen.move_cursor(cursor_x, cursor_y);
29+
screen.move_cursor(cursor_x, cursor_y);
30+
}
31+
ArrowLeft | CtrlB => {
32+
if cursor_x > 0 {
33+
cursor_x -= 1;
3734
}
38-
ArrowRight | CtrlF => {
39-
if cursor_x < width - 1 {
40-
cursor_x += 1;
41-
}
42-
screen.move_cursor(cursor_x, cursor_y);
35+
screen.move_cursor(cursor_x, cursor_y);
36+
}
37+
ArrowRight | CtrlF => {
38+
if cursor_x < width - 1 {
39+
cursor_x += 1;
4340
}
44-
_ => {}
41+
screen.move_cursor(cursor_x, cursor_y);
4542
}
46-
}
43+
_ => {}
44+
},
4745
Event::Resize {
4846
width: w,
4947
height: h,

examples/attributes.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ fn main() {
4242
i += 1;
4343
}
4444

45-
let effects = [Effect::BOLD, Effect::DIM, Effect::UNDERLINE, Effect::BLINK, Effect::REVERSE];
45+
let effects = [
46+
Effect::BOLD,
47+
Effect::DIM,
48+
Effect::UNDERLINE,
49+
Effect::BLINK,
50+
Effect::REVERSE,
51+
];
4652
for e in effects.iter() {
4753
screen.print(
4854
0,

examples/color256.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ fn main() {
2020
..Attribute::default()
2121
},
2222
);
23-
2423
}
2524
}
2625
screen.flush().unwrap();

examples/edit.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extern crate termfest;
22
extern crate unicode_width;
33

4-
use termfest::{Termfest, Event, DisplayWidth};
4+
use termfest::{DisplayWidth, Event, Termfest};
55
use termfest::key::*;
66
use termfest::attr::Attribute;
77

@@ -61,15 +61,13 @@ fn main() {
6161
Event::Char(ch) => {
6262
editor.insert(ch);
6363
}
64-
Event::Key(key) => {
65-
match key {
66-
ArrowLeft | CtrlB => editor.move_left(),
67-
ArrowRight | CtrlF => editor.move_right(),
68-
CtrlH | Backspace => editor.backspace(),
69-
ESC => break,
70-
_ => {}
71-
}
72-
}
64+
Event::Key(key) => match key {
65+
ArrowLeft | CtrlB => editor.move_left(),
66+
ArrowRight | CtrlF => editor.move_right(),
67+
CtrlH | Backspace => editor.backspace(),
68+
ESC => break,
69+
_ => {}
70+
},
7371
_ => {}
7472
}
7573
editor.show(&fest);

examples/finder.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern crate termfest;
44
use std::io::BufRead;
55
use std::rc::Rc;
66

7-
use termfest::{Termfest, Event, ScreenLock, DisplayWidth, Cell};
7+
use termfest::{Cell, DisplayWidth, Event, ScreenLock, Termfest};
88
use termfest::key::*;
99
use termfest::attr::*;
1010

@@ -166,20 +166,16 @@ fn main() {
166166
Event::Key(Backspace) => {
167167
finder.backspace();
168168
}
169-
Event::Key(ArrowLeft) |
170-
Event::Key(CtrlB) => {
169+
Event::Key(ArrowLeft) | Event::Key(CtrlB) => {
171170
finder.left();
172171
}
173-
Event::Key(ArrowRight) |
174-
Event::Key(CtrlF) => {
172+
Event::Key(ArrowRight) | Event::Key(CtrlF) => {
175173
finder.right();
176174
}
177-
Event::Key(ArrowUp) |
178-
Event::Key(CtrlP) => {
175+
Event::Key(ArrowUp) | Event::Key(CtrlP) => {
179176
finder.up();
180177
}
181-
Event::Key(ArrowDown) |
182-
Event::Key(CtrlN) => {
178+
Event::Key(ArrowDown) | Event::Key(CtrlN) => {
183179
finder.down();
184180
}
185181
Event::Key(ENTER) => {

examples/true_color.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extern crate termfest;
22

33
use termfest::attr::*;
4-
use termfest::{Termfest, Cell};
4+
use termfest::{Cell, Termfest};
55

66
fn main() {
77
let (fest, rx) = Termfest::hold().unwrap();

src/event.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ pub enum Event {
1111
Key(Key),
1212
/// `Char` is an event that notify the input byte sequence is a non-special character.
1313
Char(char),
14-
Resize { width: usize, height: usize },
14+
Resize {
15+
width: usize,
16+
height: usize,
17+
},
1518
}
1619

1720
/// Parse event from buffer.

src/lib.rs

+14-18
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@
4141
//! }
4242
//! ```
4343
44-
extern crate term;
45-
extern crate libc;
46-
extern crate signal_notify;
47-
extern crate unicode_width;
4844
#[macro_use]
49-
extern crate num_derive;
45+
extern crate bitflags;
46+
extern crate libc;
5047
extern crate num;
5148
#[macro_use]
52-
extern crate bitflags;
49+
extern crate num_derive;
50+
extern crate signal_notify;
51+
extern crate term;
52+
extern crate unicode_width;
5353

5454
use std::io::prelude::*;
5555
use std::io::{self, BufWriter};
5656
use std::fs::{File, OpenOptions};
5757
use std::ops::Drop;
5858
use std::sync::{mpsc, Arc, Mutex, MutexGuard};
5959

60-
use std::os::unix::io::{RawFd, AsRawFd};
60+
use std::os::unix::io::{AsRawFd, RawFd};
6161

6262
use signal_notify::{notify, Signal};
63-
use unicode_width::{UnicodeWidthStr, UnicodeWidthChar};
63+
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
6464

6565
pub mod key;
6666
mod event;
@@ -253,9 +253,8 @@ fn setup_tios(fd: ::libc::c_int) -> io::Result<libc::termios> {
253253
return Err(io::Error::last_os_error());
254254
}
255255
let mut tios = orig_tios;
256-
tios.c_iflag &= !(libc::IGNBRK | libc::BRKINT | libc::PARMRK | libc::ISTRIP |
257-
libc::INLCR | libc::IGNCR | libc::ICRNL |
258-
libc::IXON);
256+
tios.c_iflag &= !(libc::IGNBRK | libc::BRKINT | libc::PARMRK | libc::ISTRIP | libc::INLCR
257+
| libc::IGNCR | libc::ICRNL | libc::IXON);
259258
tios.c_lflag &= !(libc::ECHO | libc::ECHONL | libc::ICANON | libc::ISIG | libc::IEXTEN);
260259
tios.c_cflag &= !(libc::CSIZE | libc::PARENB);
261260
tios.c_cflag |= libc::CS8;
@@ -299,13 +298,10 @@ fn spawn_ttyin_reader(tx: mpsc::Sender<Event>, term: Arc<Terminal>) -> io::Resul
299298
let mut tmpbuf = [0; 64];
300299
match ttyin.read(&mut tmpbuf) {
301300
Ok(n) => buf.extend(&tmpbuf[..n]),
302-
Err(e) => {
303-
match e.kind() {
304-
io::ErrorKind::WouldBlock |
305-
io::ErrorKind::InvalidInput => continue,
306-
_ => panic!("failed to read from tty: {}", e),
307-
}
308-
}
301+
Err(e) => match e.kind() {
302+
io::ErrorKind::WouldBlock | io::ErrorKind::InvalidInput => continue,
303+
_ => panic!("failed to read from tty: {}", e),
304+
},
309305
};
310306
let mut from = 0;
311307
loop {

src/screen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::default::Default;
22

33
use terminal::Command;
4-
use attr::{Color, Attribute, Effect};
4+
use attr::{Attribute, Color, Effect};
55
use super::DisplayWidth;
66

77
/// `Cell` is a cell of the terminal.

0 commit comments

Comments
 (0)