Skip to content

Commit

Permalink
Accept some emacs control keys in vi normal mode, from Alexis
Browse files Browse the repository at this point in the history
Hildebrandt in GitHub issue 2922.
  • Loading branch information
nicm committed Oct 26, 2021
1 parent 5745bd2 commit 9695114
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions status.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ status_redraw(struct client *c)
screen_write_cursormove(&ctx, 0, i, 0);

status_free_ranges(&sle->ranges);
format_draw(&ctx, &gc, width, expanded, &sle->ranges);
format_draw(&ctx, &gc, width, expanded, &sle->ranges,
0);

free(sle->expanded);
sle->expanded = expanded;
Expand Down Expand Up @@ -562,7 +563,7 @@ status_message_redraw(struct client *c)
if (c->message_ignore_styles)
screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
else
format_draw(&ctx, &gc, c->tty.sx, c->message_string, NULL);
format_draw(&ctx, &gc, c->tty.sx, c->message_string, NULL, 0);
screen_write_stop(&ctx);

if (grid_compare(sl->active->grid, old_screen.grid) == 0) {
Expand Down Expand Up @@ -809,14 +810,23 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
{
if (c->prompt_mode == PROMPT_ENTRY) {
switch (key) {
case '\001': /* C-a */
case '\003': /* C-c */
case '\005': /* C-e */
case '\007': /* C-g */
case '\010': /* C-h */
case '\011': /* Tab */
case '\013': /* C-k */
case '\016': /* C-n */
case '\020': /* C-p */
case '\024': /* C-t */
case '\025': /* C-u */
case '\027': /* C-w */
case '\031': /* C-y */
case '\n':
case '\r':
case KEYC_LEFT|KEYC_CTRL:
case KEYC_RIGHT|KEYC_CTRL:
case KEYC_BSPACE:
case KEYC_DC:
case KEYC_DOWN:
Expand All @@ -837,6 +847,9 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
}

switch (key) {
case KEYC_BSPACE:
*new_key = KEYC_LEFT;
return (1);
case 'A':
case 'I':
case 'C':
Expand Down Expand Up @@ -882,7 +895,7 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
*new_key = 'B'|KEYC_VI;
return (1);
case 'd':
*new_key = '\025';
*new_key = '\025'; /* C-u */
return (1);
case 'e':
*new_key = 'e'|KEYC_VI;
Expand Down

0 comments on commit 9695114

Please sign in to comment.