Commit ca651de5 authored by Matthew Nicholson's avatar Matthew Nicholson Committed by MovingtoMars
Browse files

add KeyMap implementation for emacs bindings

Right now this is just a simple passthrough to Editor, but this will
parent dab133c3
use std::io::{self, Write};
use termion::event::Key;
use KeyMap;
use Editor;
use event::EventHandler;
pub struct Emacs<'a, W: Write> {
ed: Editor<'a, W>,
impl<'a, W: Write> Emacs<'a, W> {
pub fn new(ed: Editor<'a, W>) -> Self {
Emacs {
ed: ed,
impl<'a, W: Write> KeyMap<'a, W, Emacs<'a, W>> for Emacs<'a, W> {
fn handle_key(&mut self, key: Key, handler: &mut EventHandler<W>) -> io::Result<bool> {
self.ed.handle_key(key, handler)
fn editor(&mut self) -> &mut Editor<'a, W> {
&mut self.ed
impl<'a, W: Write> From<Emacs<'a, W>> for String {
fn from(emacs: Emacs<'a, W>) -> String {
......@@ -7,3 +7,6 @@ pub trait KeyMap<'a, W: Write, T> : From<T> {
fn handle_key(&mut self, key: Key, handler: &mut EventHandler<W>) -> io::Result<bool>;
fn editor(&mut self) -> &mut Editor<'a, W>;
pub mod emacs;
pub use emacs::Emacs;
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