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