Skip to content

Commit

Permalink
Update orbclient
Browse files Browse the repository at this point in the history
Add exit key
  • Loading branch information
jackpot51 committed May 4, 2017
1 parent e160513 commit 86fc766
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ Sodium: A modern vi-like editor
"""

[dependencies]
orbclient = "0.1.12"
orbclient = "0.3"

[features]
default = ["orbital"]
orbital = []
ansi = []
5 changes: 5 additions & 0 deletions src/core/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ impl Editor {
self.prompt = String::new();
self.cursor_mut().mode = Mode::Command(CommandMode::Normal);
}
(Primitive(Insert(_)), Escape) => {
let left = self.left(1);
self.goto(left);
self.cursor_mut().mode = Mode::Command(CommandMode::Normal);
},
(Primitive(Insert(_)), Char(' ')) if self.key_state.shift => {
let left = self.left(1);
self.goto(left);
Expand Down
2 changes: 1 addition & 1 deletion src/io/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use state::editor::Editor;
use state::mode::{Mode, PrimitiveMode};

#[cfg(feature = "orbital")]
use orbclient::Color;
use orbclient::{Color, Renderer};

#[cfg(feature = "orbital")]
impl Editor {
Expand Down
32 changes: 16 additions & 16 deletions src/io/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ impl Key {
/// Convern an Orbital key event to a `Key`.
#[cfg(feature = "orbital")]
pub fn from_event(k: KeyEvent) -> Key {
match k.character {
'\0' => match k.scancode {
s if k.pressed => match s {
K_BKSP => Key::Backspace,
K_LEFT => Key::Left,
K_RIGHT => Key::Right,
K_UP => Key::Up,
K_DOWN => Key::Down,
K_TAB => Key::Tab,
K_ESC => Key::Escape,
_ => Key::Unknown(s),

},
_ => Key::Null,
},
c => Key::Char(c),
if k.pressed {
match k.scancode {
K_BKSP => Key::Backspace,
K_LEFT => Key::Left,
K_RIGHT => Key::Right,
K_UP => Key::Up,
K_DOWN => Key::Down,
K_TAB => Key::Tab,
K_ESC => Key::Escape,
s => match k.character {
'\0' => Key::Unknown(s),
c => Key::Char(c),
}
}
} else {
Key::Null
}
}

Expand Down

0 comments on commit 86fc766

Please sign in to comment.