aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/boxes.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--boxes.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/boxes.c b/boxes.c
index c2bc226..c0dcffe 100644
--- a/boxes.c
+++ b/boxes.c
@@ -1662,12 +1662,12 @@ static void handleCSI(long extra, char *command, int *params, int count)
1662 } 1662 }
1663} 1663}
1664 1664
1665 1665// Callback for incoming key sequences from the user.
1666static int handleKeySequence(long extra, char *sequence) 1666static int handleKeySequence(long extra, char *sequence, int isTranslated)
1667{ 1667{
1668 struct _view *view = (struct _view *) extra; // Though we pretty much stomp on this straight away. 1668 struct _view *view = (struct _view *) extra; // Though we pretty much stomp on this straight away.
1669 struct keyCommand *commands = currentBox->view->content->context->modes[currentBox->view->mode].keys; 1669 struct keyCommand *commands = currentBox->view->content->context->modes[currentBox->view->mode].keys;
1670 int j; 1670 int j, l = strlen(sequence);
1671 1671
1672 // Coz things might change out from under us, find the current view. 1672 // Coz things might change out from under us, find the current view.
1673 if (commandMode) view = commandLine; 1673 if (commandMode) view = commandLine;
@@ -1676,14 +1676,23 @@ static int handleKeySequence(long extra, char *sequence)
1676 // Search for a key sequence bound to a command. 1676 // Search for a key sequence bound to a command.
1677 for (j = 0; commands[j].key; j++) 1677 for (j = 0; commands[j].key; j++)
1678 { 1678 {
1679 if (strcmp(commands[j].key, sequence) == 0) 1679 if (strncmp(commands[j].key, sequence, l) == 0)
1680 { 1680 {
1681 doCommand(view, commands[j].command); 1681 // If it's a partial match, keep accumulating them.
1682 return 1; 1682 if (strlen(commands[j].key) != l)
1683 return 0;
1684 else
1685 {
1686 doCommand(view, commands[j].command);
1687 return 1;
1688 }
1683 } 1689 }
1684 } 1690 }
1685 1691
1686 if ((0 == sequence[1]) && isprint(sequence[0])) // See if it's an ordinary key. 1692 // See if it's ordinary keys.
1693 // NOTE - with vi style ordinary keys can be commands,
1694 // but they would be found by the command check above first.
1695 if (!isTranslated)
1687 { 1696 {
1688 // TODO - Should check for tabs to, and insert them. 1697 // TODO - Should check for tabs to, and insert them.
1689 // Though better off having a function for that? 1698 // Though better off having a function for that?
@@ -1691,10 +1700,10 @@ static int handleKeySequence(long extra, char *sequence)
1691 view->oW = formatLine(view, view->line->line, &(view->output)); 1700 view->oW = formatLine(view, view->line->line, &(view->output));
1692 moveCursorRelative(view, strlen(sequence), 0, 0, 0); 1701 moveCursorRelative(view, strlen(sequence), 0, 0, 0);
1693 updateLine(view); 1702 updateLine(view);
1694 return 1;
1695 } 1703 }
1696 1704
1697 return 0; 1705 // Tell handle_keys to drop it, coz we dealt with it, or it's not one of ours.
1706 return 1;
1698} 1707}
1699 1708
1700 1709