cargo fmt
This commit is contained in:
parent
8a110c5b01
commit
f5ea473328
38
src/main.rs
38
src/main.rs
|
@ -20,12 +20,7 @@
|
|||
use std::{
|
||||
env::args,
|
||||
fs::File,
|
||||
io::{
|
||||
Read,
|
||||
stdout,
|
||||
Stdout,
|
||||
Write,
|
||||
},
|
||||
io::{stdout, Read, Stdout, Write},
|
||||
os::fd::FromRawFd,
|
||||
};
|
||||
|
||||
|
@ -35,7 +30,7 @@ use crossterm::{
|
|||
terminal, ExecutableCommand, Result,
|
||||
};
|
||||
use ropey::Rope;
|
||||
use yacexits::{ exit, EX_DATAERR, EX_UNAVAILABLE };
|
||||
use yacexits::{exit, EX_DATAERR, EX_UNAVAILABLE};
|
||||
|
||||
struct Buffer {
|
||||
pub text: Rope,
|
||||
|
@ -288,7 +283,7 @@ impl State {
|
|||
self.mode = Mode::Insert(state);
|
||||
}
|
||||
KeyCode::Char('o') => {
|
||||
let state = InsertState { append: false};
|
||||
let state = InsertState { append: false };
|
||||
self.cursor.line += 1;
|
||||
self.cursor.column = 0;
|
||||
let index = self.buffer.cursor_to_char(self.cursor);
|
||||
|
@ -463,23 +458,22 @@ fn main() -> Result<()> {
|
|||
let stdin = 0; // get stdin as a file descriptor
|
||||
if unsafe { libc::isatty(stdin) } == 0 {
|
||||
unsafe { File::from_raw_fd(stdin) }
|
||||
} else { File::open("/dev/null").unwrap() }
|
||||
},
|
||||
Some(path) => {
|
||||
std::fs::File::open(path).unwrap_or_else(|_| {
|
||||
eprintln!(
|
||||
"{}: {}: No such file or directory.",
|
||||
argv[0],
|
||||
argv[1]
|
||||
);
|
||||
exit(EX_UNAVAILABLE);
|
||||
})
|
||||
},
|
||||
}.read_to_end(&mut buf).unwrap();
|
||||
} else {
|
||||
File::open("/dev/null").unwrap()
|
||||
}
|
||||
}
|
||||
Some(path) => std::fs::File::open(path).unwrap_or_else(|_| {
|
||||
eprintln!("{}: {}: No such file or directory.", argv[0], argv[1]);
|
||||
exit(EX_UNAVAILABLE);
|
||||
}),
|
||||
}
|
||||
.read_to_end(&mut buf)
|
||||
.unwrap();
|
||||
|
||||
let text = String::from_utf8(buf).unwrap_or_else(|_| {
|
||||
eprintln!(
|
||||
"{}: {}: File contents are not valid UTF-8.", argv[0], argv[1]
|
||||
"{}: {}: File contents are not valid UTF-8.",
|
||||
argv[0], argv[1]
|
||||
);
|
||||
exit(EX_DATAERR);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue