aboutsummaryrefslogtreecommitdiffstats
path: root/src/keys.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-07-07 00:53:09 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-07-07 21:27:01 +0200
commit69345edd77b3ff98a99b36de8063f9e5febad3eb (patch)
treebd2d3fc7d4db2a597d209a37f1d1500a5efbe45c /src/keys.c
parentdd059ca8129a97dfde79101bdcf5d3f7bcec0a90 (diff)
downloadcalcurse-69345edd77b3ff98a99b36de8063f9e5febad3eb.tar.gz
calcurse-69345edd77b3ff98a99b36de8063f9e5febad3eb.zip
Add support for copy/paste registers
This adds support for vim-style copy/paste registers which allows cutting and copying multiple items without having to overwrite the copy/paste buffer. Registers can be specified using the quote key ('"'). To access a register, type '"x' before a command where "x" is the name of a register. If you want to copy the currently selected item into register 1, type '"1c'. Valid registers are 0-9, a-z, "-" and "_". Note that the latter is the so-called black hole register, which works similar to the black hole register in vim. The register prefix key is currently hardcoded and cannot be configured. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/keys.c')
-rw-r--r--src/keys.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/keys.c b/src/keys.c
index 579ddc8..38b6780 100644
--- a/src/keys.c
+++ b/src/keys.c
@@ -180,12 +180,13 @@ enum key keys_get_action(int pressed)
return actions[pressed];
}
-enum key keys_getch(WINDOW * win, int *count)
+enum key keys_getch(WINDOW * win, int *count, int *reg)
{
int ch = '0';
- if (count) {
+ if (count && reg) {
*count = 0;
+ *reg = 0;
do {
*count = *count * 10 + ch - '0';
ch = wgetch(win);
@@ -194,8 +195,23 @@ enum key keys_getch(WINDOW * win, int *count)
if (*count == 0)
*count = 1;
- } else
+
+ if (ch == '"') {
+ ch = wgetch(win);
+ if (ch >= '1' && ch <= '9') {
+ *reg = ch - '1' + 1;
+ }
+ else if (ch >= 'a' && ch <= 'z') {
+ *reg = ch - 'a' + 10;
+ }
+ else if (ch == '_') {
+ *reg = REG_BLACK_HOLE;
+ }
+ ch = wgetch(win);
+ }
+ } else {
ch = wgetch(win);
+ }
switch (ch) {
case KEY_RESIZE:
@@ -524,7 +540,7 @@ void keys_popup_info(enum key key)
#define WINCOL (col - 4)
infowin = popup(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2,
keydef[key].label, info[key], 1);
- keys_getch(infowin, NULL);
+ keys_getch(infowin, NULL, NULL);
delwin(infowin);
#undef WINROW
#undef WINCOL