Skip to content
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

custom ctrl-KEY mappings #13

Open
sgbeal opened this issue Apr 2, 2010 · 1 comment
Open

custom ctrl-KEY mappings #13

sgbeal opened this issue Apr 2, 2010 · 1 comment
Labels

Comments

@sgbeal
Copy link

sgbeal commented Apr 2, 2010

An addition for cli.js, in keypress():

if (this.sticky.keys.ctrl) {
  if( this.sticky.keymap && this.sticky.keymap.ctrl )  {
    if( letter in this.sticky.keymap.ctrl ) {
        this.sticky.keymap.ctrl[letter]( this );
    }
  }
  else  {
    if (letter == 'w') {
        this.deleteWord();
    } else if (letter == 'h') {
        this.deleteCharacter(false);
    } else if (letter == 'l') {
        this.clear();
    } else if (letter == 'a') {
        this.setPos(0);
    } else if (letter == 'e') {
        this.setPos(this.buffer.length);
    } else if (letter == 'd') {
        this.runCommand('logout');
    }
  }
}

The keymap can then be configured like:

Terminal.sticky.keymap =
{
ctrl:{
w:function(term) { term.deleteWord(); },
h:function(term){ term.deleteCharacter(false);},
l:function(term){ term.clear(); },
a:function(term){ term.setPos(0); },
e:function(term){ term.setPos(term.buffer.length); },
d:function(term){ term.runCommand('logout'); },
}
};

with that in place, we can remove the "else" block above.

@sgbeal
Copy link
Author

sgbeal commented Apr 3, 2010

good thing i pasted that here, because i lost the code during the forking/merging process. it's been committed to my fork:

http://github.com/sgbeal/xkcdfools/commit/445e94089f7eba6a5a0ad6ad419dcc3db1bb0038

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant