Escape quits, return inserts a new line.

This commit is contained in:
Nathan Vegdahl 2014-12-14 23:11:13 -08:00
parent b78501f983
commit 3154d626ff
2 changed files with 20 additions and 19 deletions

View File

@ -12,7 +12,7 @@ mod buffer;
// Usage documentation string // Usage documentation string
static USAGE: &'static str = " static USAGE: &'static str = "
Usage: led <file> Usage: led [<file>]
led --help led --help
Options: Options:
@ -23,7 +23,7 @@ Options:
// Struct for storing command-line arguments // Struct for storing command-line arguments
#[deriving(Decodable, Show)] #[deriving(Decodable, Show)]
struct Args { struct Args {
arg_file: String, arg_file: Option<String>,
flag_help: bool, flag_help: bool,
} }
@ -54,7 +54,7 @@ fn main() {
column = 0; column = 0;
continue; continue;
} }
rustbox::print(column, line, Style::Bold, Color::White, Color::Black, c.to_string()); rustbox::print(column, line, Style::Normal, Color::White, Color::Black, c.to_string());
column += 1; column += 1;
} }
else { else {
@ -76,21 +76,20 @@ fn main() {
// Handle events // Handle events
match rustbox::poll_event() { match rustbox::poll_event() {
rustbox::Event::KeyEvent(_, _, ch) => { rustbox::Event::KeyEvent(modifier, key, character) => {
match char::from_u32(ch) { // Return
Some('q') => { break; }, if key == 13 {
let p = tb.len();
Some('w') => { tb.insert_text("\n", p);
let p = tb.len(); }
tb.insert_text("\n", p); // Esc
}, else if key == 27 {
break;
Some(c) => { }
let p = tb.len(); // Some key
tb.insert_text(c.to_string().as_slice(), p); else if let Option::Some(c) = char::from_u32(character) {
}, let p = tb.len();
tb.insert_text(c.to_string().as_slice(), p);
_ => {}
} }
}, },

View File

@ -1 +1,3 @@
- Implement useful iterators for the Text Rope. - "Editor" class that has cursors.
- Some way of scrolling the view...?
- File loading.