Commit 51f2f7e3 authored by stratact's avatar stratact

Merge branch 'prompt-sp' into 'master'

Implement PROMPT_SP fix

See merge request !6
parents 5b895f5f f3bb8949
......@@ -17,7 +17,7 @@ name = "liner"
[dependencies]
bytecount = "0.3.1"
termion = "1.4.0"
termion = { git = "https://gitlab.redox-os.org/redox-os/termion" }
unicode-width = "0.1.*"
[dev-dependencies]
......
......@@ -65,7 +65,7 @@ impl<'a> From<&'a str> for Buffer {
impl fmt::Display for Buffer {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for &c in &self.data {
try!(f.write_char(c));
f.write_char(c)?;
}
Ok(())
}
......@@ -256,9 +256,7 @@ impl Buffer {
where W: Write
{
let string: String = self.data.iter().cloned().collect();
try!(out.write(string.as_bytes()));
Ok(())
out.write_all(string.as_bytes())
}
pub fn as_bytes(&self) -> Vec<u8> {
......@@ -274,7 +272,7 @@ impl Buffer {
where W: Write
{
let string: String = self.data.iter().skip(after).cloned().collect();
out.write(string.as_bytes())?;
out.write_all(string.as_bytes())?;
Ok(string.len())
}
......
......@@ -97,7 +97,7 @@ impl Context {
buffer: B,
) -> io::Result<String> {
let res = {
let stdout = stdout().into_raw_mode()?;
let mut stdout = stdout().into_raw_mode()?;
let ed = Editor::new_with_init_buffer(stdout, prompt, f, self, buffer)?;
match self.key_bindings {
KeyBindings::Emacs => Self::handle_keys(keymap::Emacs::new(ed), handler),
......@@ -117,8 +117,9 @@ impl Context {
String: From<M>,
{
let stdin = stdin();
let stdin = stdin.lock();
for c in stdin.keys() {
if try!(keymap.handle_key(c.unwrap(), handler)) {
if keymap.handle_key(c.unwrap(), handler)? {
break;
}
}
......
This diff is collapsed.
......@@ -36,7 +36,7 @@ impl<'a, W: Write> Emacs<'a, W> {
'k' => self.ed.delete_all_after_cursor(),
'w' => self.ed.delete_word_before_cursor(true),
'x' => {
try!(self.ed.undo());
self.ed.undo()?;
Ok(())
}
_ => Ok(()),
......@@ -51,7 +51,7 @@ impl<'a, W: Write> Emacs<'a, W> {
'f' => emacs_move_word(&mut self.ed, EmacsMoveDir::Right),
'b' => emacs_move_word(&mut self.ed, EmacsMoveDir::Left),
'r' => {
try!(self.ed.revert());
self.ed.revert()?;
Ok(())
}
'.' => self.handle_last_arg_fetch(),
......
......@@ -22,34 +22,34 @@ pub trait KeyMap<'a, W: Write, T>: From<T> {
match key {
Key::Ctrl('c') => {
try!(self.editor_mut().handle_newline());
self.editor_mut().handle_newline()?;
return Err(io::Error::new(ErrorKind::Interrupted, "ctrl-c"));
}
// if the current buffer is empty, treat ctrl-d as eof
Key::Ctrl('d') if is_empty => {
try!(self.editor_mut().handle_newline());
self.editor_mut().handle_newline()?;
return Err(io::Error::new(ErrorKind::UnexpectedEof, "ctrl-d"));
}
Key::Char('\t') => try!(self.editor_mut().complete(handler)),
Key::Char('\t') => self.editor_mut().complete(handler)?,
Key::Char('\n') => {
done = try!(self.editor_mut().handle_newline());
done = self.editor_mut().handle_newline()?;
}
Key::Ctrl('f') if self.editor().is_currently_showing_autosuggestion() => {
try!(self.editor_mut().accept_autosuggestion());
self.editor_mut().accept_autosuggestion()?;
}
Key::Right if self.editor().is_currently_showing_autosuggestion() &&
self.editor().cursor_is_at_end_of_line() => {
try!(self.editor_mut().accept_autosuggestion());
self.editor_mut().accept_autosuggestion()?;
}
_ => {
try!(self.handle_key_core(key));
self.handle_key_core(key)?;
self.editor_mut().skip_completions_hint();
}
};
handler(Event::new(self.editor_mut(), EventKind::AfterKey(key)));
try!(self.editor_mut().flush());
self.editor_mut().flush()?;
Ok(done)
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment