-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sublime-like changes #109
base: master
Are you sure you want to change the base?
Sublime-like changes #109
Changes from 1 commit
d202ae3
83692fd
4f9d809
2d2763e
a4e9f93
386f22b
dfd0781
0699d1c
0bc9269
117299f
702b140
39995fd
1c11099
db5488b
1424a88
2b38760
decb28f
c276d9b
b6472f1
fbd71c2
574c9a9
15ce710
495083c
e31365d
62a601f
6c32c20
0e77c3d
ab35a26
f19eb17
8bfcfa1
694b3b1
88c8b35
3790457
b1f795c
e94e3e9
7e1aea1
75dff11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use crate::core::{Command, RelativeMove, AbsoluteMove}; | ||
use crate::core::{Command, RelativeMove, AbsoluteMove, ExpandLinesDirection}; | ||
use termion::event::{Event, Key}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
@@ -48,6 +48,11 @@ impl KeybindingConfig { | |
let cmd : AbsoluteMove = serde_json::from_value(args)?; | ||
Command::AbsoluteMove(cmd) | ||
}, | ||
"select_lines" => { | ||
let args = binding.args.ok_or("select_lines binding incomplete! Missing \"args\"")?; | ||
let cmd : ExpandLinesDirection = serde_json::from_value(args)?; | ||
Command::CursorExpandLines(cmd) | ||
} | ||
x => match Command::from_str(x) { | ||
Ok(cmd) => cmd, | ||
// unimplemented command for now | ||
|
@@ -62,7 +67,7 @@ impl KeybindingConfig { | |
keymap.insert(binding, cmd.clone()); | ||
found_cmds.push(cmd); | ||
} else { | ||
warn!("Skipping failed binding"); | ||
// warn!("Skipping failed binding"); | ||
continue; | ||
} | ||
} | ||
|
@@ -91,12 +96,22 @@ impl KeybindingConfig { | |
"delete" => Some(Event::Key(Key::Delete)), | ||
"insert" => Some(Event::Key(Key::Insert)), | ||
"escape" => Some(Event::Key(Key::Esc)), | ||
"ctrl+right" => Some(Event::Unsupported(vec![27, 91, 49, 59, 53, 67])), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused: why are these named "ctrl+something" instead of an actual command name like "word-left" or "word-right"? Other question: what are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It looks different on HEAD. There its separated. a bit clearer. But in principle there are two parsers: One is to parse a command name to The other is to parse key-descriptions to
Try typing after doing that :-) It adds a cursor below or above the current cursor, which are unfortunately invisible at the moment. I have some screencasts showing of the features, just have to find a place to upload to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, sorry. I confused Either way, this part is not there to define functionality! Its there so that users can use But for completeness, here are the screencasts I talked about (just "view raw" for each file): "switchcase" is what |
||
"ctrl+left" => Some(Event::Unsupported(vec![27, 91, 49, 59, 53, 68])), | ||
"ctrl+shift+right" => Some(Event::Unsupported(vec![27, 91, 49, 59, 54, 67])), | ||
"ctrl+shift+left" => Some(Event::Unsupported(vec![27, 91, 49, 59, 54, 68])), | ||
"ctrl+shift+up" => Some(Event::Unsupported(vec![27, 91, 49, 59, 54, 65])), | ||
"ctrl+shift+down" => Some(Event::Unsupported(vec![27, 91, 49, 59, 54, 66])), | ||
"alt+shift+up" => Some(Event::Unsupported(vec![27, 91, 49, 59, 52, 65])), | ||
"alt+shift+down" => Some(Event::Unsupported(vec![27, 91, 49, 59, 52, 66])), | ||
// Not yet released | ||
// "shift+tab" => Some(Event::Key(Key::Backtab)), | ||
|
||
x if x.starts_with("f") => { | ||
match x[1..].parse::<u8>() { | ||
Ok(val) => Some(Event::Key(Key::F(val))), | ||
Err(_) => { | ||
warn!("Cannot parse {}", x); | ||
// warn!("Cannot parse {}", x); | ||
None | ||
} | ||
} | ||
|
@@ -109,7 +124,7 @@ impl KeybindingConfig { | |
let character; | ||
// start_length + "shift+x".len() || start_length + "x".len() | ||
if x.len() != start_length + 7 && x.len() != start_length + 1 { | ||
warn!("Cannot parse {}. Length is = {}, which is neither {} nor {} ", x, x.len(), start_length + 1, start_length + 7); | ||
// warn!("Cannot parse {}. Length is = {}, which is neither {} nor {} ", x, x.len(), start_length + 1, start_length + 7); | ||
return None | ||
} else { | ||
if x.len() == start_length + 7 { | ||
|
@@ -128,7 +143,7 @@ impl KeybindingConfig { | |
} | ||
|
||
x => { | ||
warn!("Completely unknown argument {}", x); | ||
// warn!("Completely unknown argument {}", x); | ||
None | ||
}, | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,7 @@ impl Tui { | |
} | ||
return; }, | ||
Command::Quit => { self.exit = true; return; }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting is a bit off here, although it does not matter too much since we can just rustfmt later. |
||
Command::Cancel => { self.prompt = None; return; }, | ||
Command::Cancel if !self.prompt.is_none() => { self.prompt = None; return; }, | ||
_ => {/* Somebody else has to deal with these commands */}, | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should refrain from adding more command aliases. We could discuss modifying the existing ones, but I think it will confusing to have too many commands that do the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I never planned to do a full PR.
I switched to command names used by sublime texts keymap-file, but didn't want to remove the old names just yet.