aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--boxes.c55
-rw-r--r--dumbsh.c3
-rw-r--r--handlekeys.c35
-rw-r--r--handlekeys.h3
4 files changed, 38 insertions, 58 deletions
diff --git a/boxes.c b/boxes.c
index 0923cab..c2bc226 100644
--- a/boxes.c
+++ b/boxes.c
@@ -1737,9 +1737,10 @@ struct keyCommand simpleCommandKeys[] =
1737 {"F10", "quit"}, 1737 {"F10", "quit"},
1738 {"Home", "startOfLine"}, 1738 {"Home", "startOfLine"},
1739 {"Left", "leftChar"}, 1739 {"Left", "leftChar"},
1740 {"Enter", "executeLine"},
1740 {"Return", "executeLine"}, 1741 {"Return", "executeLine"},
1741 {"Right", "rightChar"}, 1742 {"Right", "rightChar"},
1742 {"^[", "switchMode"}, 1743 {"Esc", "switchMode"},
1743 {"Up", "upLine"}, 1744 {"Up", "upLine"},
1744 {NULL, NULL} 1745 {NULL, NULL}
1745}; 1746};
@@ -1782,6 +1783,7 @@ struct function simpleEmacsCommands[] =
1782// The key to command mappings. 1783// The key to command mappings.
1783struct keyCommand simpleEmacsKeys[] = 1784struct keyCommand simpleEmacsKeys[] =
1784{ 1785{
1786 {"BS", "delete-backward-char"},
1785 {"Del", "delete-backward-char"}, 1787 {"Del", "delete-backward-char"},
1786 {"^D", "delete-char"}, 1788 {"^D", "delete-char"},
1787 {"Down", "next-line"}, 1789 {"Down", "next-line"},
@@ -1797,15 +1799,15 @@ struct keyCommand simpleEmacsKeys[] =
1797 {"PgDn", "scroll-up"}, 1799 {"PgDn", "scroll-up"},
1798 {"^V", "scroll-up"}, 1800 {"^V", "scroll-up"},
1799 {"PgUp", "scroll-down"}, 1801 {"PgUp", "scroll-down"},
1800 {"^[v", "scroll-down"}, // M-v 1802 {"Escv", "scroll-down"}, // M-v
1803 {"Enter", "newline"},
1801 {"Return", "newline"}, 1804 {"Return", "newline"},
1802 {"Right", "forward-char"}, 1805 {"Right", "forward-char"},
1803 {"^F", "forward-char"}, 1806 {"^F", "forward-char"},
1804 {"^[x", "execute-extended-command"}, // M-x 1807 {"Escx", "execute-extended-command"}, // M-x
1805 {"^X2", "split-window-vertically"}, 1808 {"^X2", "split-window-vertically"},
1806 {"^X3", "split-window-horizontally"}, // TODO - Just making this up for now. 1809 {"^X3", "split-window-horizontally"}, // TODO - Just making this up for now.
1807 {"^XP", "other-window"}, 1810 {"^XP", "other-window"},
1808 {"^XP", "other-window"},
1809 {"^X0", "delete-window"}, 1811 {"^X0", "delete-window"},
1810 {"Up", "previous-line"}, 1812 {"Up", "previous-line"},
1811 {"^P", "previous-line"}, 1813 {"^P", "previous-line"},
@@ -1816,7 +1818,6 @@ struct keyCommand simpleEmacsCommandKeys[] =
1816{ 1818{
1817 {"Del", "delete-backwards-char"}, 1819 {"Del", "delete-backwards-char"},
1818 {"^D", "delete-char"}, 1820 {"^D", "delete-char"},
1819 {"^D", "delete-char"},
1820 {"Down", "next-line"}, 1821 {"Down", "next-line"},
1821 {"^N", "next-line"}, 1822 {"^N", "next-line"},
1822 {"End", "end-of-line"}, 1823 {"End", "end-of-line"},
@@ -1827,8 +1828,9 @@ struct keyCommand simpleEmacsCommandKeys[] =
1827 {"^B", "backward-char"}, 1828 {"^B", "backward-char"},
1828 {"Up", "previous-line"}, 1829 {"Up", "previous-line"},
1829 {"^P", "previous-line"}, 1830 {"^P", "previous-line"},
1831 {"Enter", "accept-line"},
1830 {"Return", "accept-line"}, 1832 {"Return", "accept-line"},
1831 {"^[x", "execute-extended-command"}, 1833 {"Escx", "execute-extended-command"},
1832 {NULL, NULL} 1834 {NULL, NULL}
1833}; 1835};
1834 1836
@@ -1901,11 +1903,12 @@ struct keyCommand simpleJoeKeys[] =
1901 {"^B", "ltarw"}, 1903 {"^B", "ltarw"},
1902 {"^V", "pgdn"}, // Actually half a page. 1904 {"^V", "pgdn"}, // Actually half a page.
1903 {"^U", "pgup"}, // Actually half a page. 1905 {"^U", "pgup"}, // Actually half a page.
1906 {"Enter", "open"},
1904 {"Return", "open"}, 1907 {"Return", "open"},
1905 {"Right", "rtarw"}, 1908 {"Right", "rtarw"},
1906 {"^F", "rtarw"}, 1909 {"^F", "rtarw"},
1907 {"^[x", "execmd"}, 1910 {"Escx", "execmd"},
1908 {"^[^X", "execmd"}, 1911 {"Esc^X", "execmd"},
1909 {"^Ko", "splitw"}, 1912 {"^Ko", "splitw"},
1910 {"^K^O", "splitw"}, 1913 {"^K^O", "splitw"},
1911 {"^Kn", "nextw"}, 1914 {"^Kn", "nextw"},
@@ -1929,10 +1932,11 @@ struct keyCommand simpleJoeCommandKeys[] =
1929 {"^B", "ltarw"}, 1932 {"^B", "ltarw"},
1930 {"Right", "rtarw"}, 1933 {"Right", "rtarw"},
1931 {"^F", "rtarw"}, 1934 {"^F", "rtarw"},
1932 {"^[x", "execmd"}, 1935 {"Escx", "execmd"},
1933 {"^[^X", "execmd"}, 1936 {"Esc^X", "execmd"},
1934 {"Up", "uparw"}, 1937 {"Up", "uparw"},
1935 {"^P", "uparw"}, 1938 {"^P", "uparw"},
1939 {"Enter", "executeLine"},
1936 {"Return", "executeLine"}, 1940 {"Return", "executeLine"},
1937 {NULL, NULL} 1941 {NULL, NULL}
1938}; 1942};
@@ -1959,19 +1963,17 @@ struct context simpleJoe =
1959// No cursor movement, just scrolling. 1963// No cursor movement, just scrolling.
1960// TODO - Put content into read only mode. 1964// TODO - Put content into read only mode.
1961// TODO - actually implement read only mode where up and down one line do actual scrolling instead of cursor movement. 1965// TODO - actually implement read only mode where up and down one line do actual scrolling instead of cursor movement.
1962// TODO - maybe I can support the ZZ command in one of two ways -
1963// Just have a Z command do the quit.
1964// Have the first Z go into a special mode, where anything other than a Z restores the original mode.
1965 1966
1966struct keyCommand simpleLessKeys[] = 1967struct keyCommand simpleLessKeys[] =
1967{ 1968{
1968 {"Down", "downLine"}, 1969 {"Down", "downLine"},
1969 {"j", "downLine"}, 1970 {"j", "downLine"},
1971 {"Enter", "downLine"},
1970 {"Return", "downLine"}, 1972 {"Return", "downLine"},
1971 {"End", "endOfLine"}, 1973 {"End", "endOfLine"},
1972 {"q", "quit"}, 1974 {"q", "quit"},
1973 {":q", "quit"}, // TODO - A vi ism, should do ex command stuff instead. 1975 {":q", "quit"}, // TODO - A vi ism, should do ex command stuff instead.
1974 {"ZZ", "quit"}, // The infrastructure here does not support this style of command. 1976 {"ZZ", "quit"},
1975 {"PgDn", "downPage"}, 1977 {"PgDn", "downPage"},
1976 {"f", "downPage"}, 1978 {"f", "downPage"},
1977 {" ", "downPage"}, 1979 {" ", "downPage"},
@@ -2005,10 +2007,11 @@ struct context simpleLess =
2005struct keyCommand simpleMoreKeys[] = 2007struct keyCommand simpleMoreKeys[] =
2006{ 2008{
2007 {"j", "downLine"}, 2009 {"j", "downLine"},
2010 {"Enter", "downLine"},
2008 {"Return", "downLine"}, 2011 {"Return", "downLine"},
2009 {"q", "quit"}, 2012 {"q", "quit"},
2010 {":q", "quit"}, // See comments for "less". 2013 {":q", "quit"}, // See comments for "less".
2011 {"ZZ", "quit"}, // See comments for "less". 2014 {"ZZ", "quit"},
2012 {"f", "downPage"}, 2015 {"f", "downPage"},
2013 {" ", "downPage"}, 2016 {" ", "downPage"},
2014 {"^F", "downPage"}, 2017 {"^F", "downPage"},
@@ -2044,21 +2047,22 @@ struct keyCommand simpleMceditKeys[] =
2044 {"Down", "downLine"}, 2047 {"Down", "downLine"},
2045 {"End", "endOfLine"}, 2048 {"End", "endOfLine"},
2046 {"F10", "quit"}, 2049 {"F10", "quit"},
2047 {"^[0", "quit"}, 2050 {"Esc0", "quit"},
2048 {"F2", "save"}, 2051 {"F2", "save"},
2049 {"^[2", "save"}, 2052 {"Esc2", "save"},
2050 {"Home", "startOfLine"}, 2053 {"Home", "startOfLine"},
2051 {"Left", "leftChar"}, 2054 {"Left", "leftChar"},
2052 {"PgDn", "downPage"}, 2055 {"PgDn", "downPage"},
2053 {"PgUp", "upPage"}, 2056 {"PgUp", "upPage"},
2057 {"Enter", "splitLine"},
2054 {"Return", "splitLine"}, 2058 {"Return", "splitLine"},
2055 {"Right", "rightChar"}, 2059 {"Right", "rightChar"},
2056{"Shift F2", "switchMode"}, // MC doesn't have a command mode. 2060{"Shift F2", "switchMode"}, // MC doesn't have a command mode.
2057 {"^[:", "switchMode"}, // Sorta vi like, and coz tmux is screwing with the shift function keys somehow. 2061 {"Esc:", "switchMode"}, // Sorta vi like, and coz tmux is screwing with the shift function keys somehow.
2058 {"^[|", "splitV"}, // MC doesn't have a split window concept, so make these up to match tmux more or less. 2062 {"Esc|", "splitV"}, // MC doesn't have a split window concept, so make these up to match tmux more or less.
2059 {"^[-", "splitH"}, 2063 {"Esc-", "splitH"},
2060 {"^[o", "switchBoxes"}, 2064 {"Esco", "switchBoxes"},
2061 {"^[x", "deleteBox"}, 2065 {"Escx", "deleteBox"},
2062 {"Up", "upLine"}, 2066 {"Up", "upLine"},
2063 {NULL, NULL} 2067 {NULL, NULL}
2064}; 2068};
@@ -2128,6 +2132,7 @@ struct keyCommand simpleNanoKeys[] =
2128 {"PgDn", "downPage"}, 2132 {"PgDn", "downPage"},
2129 {"^Y", "upPage"}, // ? 2133 {"^Y", "upPage"}, // ?
2130 {"PgUp", "upPage"}, 2134 {"PgUp", "upPage"},
2135 {"Enter", "enter"}, // TODO - Not sure if this is correct.
2131 {"Return", "enter"}, // TODO - Not sure if this is correct. 2136 {"Return", "enter"}, // TODO - Not sure if this is correct.
2132 {"^F", "right"}, 2137 {"^F", "right"},
2133 {"Right", "right"}, 2138 {"Right", "right"},
@@ -2264,6 +2269,7 @@ struct keyCommand simpleViNormalKeys[] =
2264 {"^F", "downPage"}, 2269 {"^F", "downPage"},
2265 {"PgUp", "upPage"}, 2270 {"PgUp", "upPage"},
2266 {"^B", "upPage"}, 2271 {"^B", "upPage"},
2272 {"Enter", "startOfNextLine"},
2267 {"Return", "startOfNextLine"}, 2273 {"Return", "startOfNextLine"},
2268 {"Right", "rightChar"}, 2274 {"Right", "rightChar"},
2269 {"l", "rightChar"}, 2275 {"l", "rightChar"},
@@ -2289,7 +2295,7 @@ struct keyCommand simpleViInsertKeys[] =
2289 {"BS", "backSpaceChar"}, 2295 {"BS", "backSpaceChar"},
2290 {"Del", "deleteChar"}, 2296 {"Del", "deleteChar"},
2291 {"Return", "splitLine"}, 2297 {"Return", "splitLine"},
2292 {"^[", "visual"}, 2298 {"Esc", "visual"},
2293 {"^C", "visual"}, 2299 {"^C", "visual"},
2294 {NULL, NULL} 2300 {NULL, NULL}
2295}; 2301};
@@ -2302,9 +2308,10 @@ struct keyCommand simpleExKeys[] =
2302 {"End", "endOfLine"}, 2308 {"End", "endOfLine"},
2303 {"Home", "startOfLine"}, 2309 {"Home", "startOfLine"},
2304 {"Left", "leftChar"}, 2310 {"Left", "leftChar"},
2311 {"Enter", "executeLine"},
2305 {"Return", "executeLine"}, 2312 {"Return", "executeLine"},
2306 {"Right", "rightChar"}, 2313 {"Right", "rightChar"},
2307 {"^[", "visual"}, 2314 {"Esc", "visual"},
2308 {"Up", "upLine"}, 2315 {"Up", "upLine"},
2309 {NULL, NULL} 2316 {NULL, NULL}
2310}; 2317};
diff --git a/dumbsh.c b/dumbsh.c
index a282caf..875614b 100644
--- a/dumbsh.c
+++ b/dumbsh.c
@@ -170,8 +170,7 @@ static struct keyCommand simpleEmacsKeys[] =
170 {"Del", deleteChar}, 170 {"Del", deleteChar},
171 {"^D", deleteChar}, 171 {"^D", deleteChar},
172 {"Return", doCommand}, 172 {"Return", doCommand},
173 {"^J", doCommand}, 173 {"Enter", doCommand},
174 {"^M", doCommand},
175 {"Down", nextHistory}, 174 {"Down", nextHistory},
176 {"^N", nextHistory}, 175 {"^N", nextHistory},
177 {"End", endOfLine}, 176 {"End", endOfLine},
diff --git a/handlekeys.c b/handlekeys.c
index 322d41e..030c933 100644
--- a/handlekeys.c
+++ b/handlekeys.c
@@ -18,8 +18,7 @@ struct key
18 char *name; 18 char *name;
19}; 19};
20 20
21// This table includes some variations I have found on some terminals, 21// This table includes some variations I have found on some terminals.
22// and the MC "Esc digit" versions.
23// http://rtfm.etla.org/xterm/ctlseq.html has a useful guide. 22// http://rtfm.etla.org/xterm/ctlseq.html has a useful guide.
24// TODO - Don't think I got all the linux console variations. 23// TODO - Don't think I got all the linux console variations.
25// TODO - Add more shift variations, plus Ctrl & Alt variations when needed. 24// TODO - Add more shift variations, plus Ctrl & Alt variations when needed.
@@ -44,10 +43,10 @@ static struct key keys[] =
44 {"\x07", "^G"}, // BEL 43 {"\x07", "^G"}, // BEL
45 {"\x08", "Del"}, // BS Delete key, usually. 44 {"\x08", "Del"}, // BS Delete key, usually.
46 {"\x09", "Tab"}, // HT 45 {"\x09", "Tab"}, // HT
47 {"\x0A", "Return"}, // LF Roxterm translates Ctrl-M to this. 46 {"\x0A", "Enter"}, // LF Roxterm translates Ctrl-M to this.
48 {"\x0B", "^K"}, // VT 47 {"\x0B", "^K"}, // VT
49 {"\x0C", "^L"}, // FF 48 {"\x0C", "^L"}, // FF
50 {"\x0D", "^M"}, // CR Other Return key, usually. 49 {"\x0D", "Return"}, // CR Other Enter/Return key, usually.
51 {"\x0E", "^N"}, // SO 50 {"\x0E", "^N"}, // SO
52 {"\x0F", "^O"}, // SI DISCARD 51 {"\x0F", "^O"}, // SI DISCARD
53 {"\x10", "^P"}, // DLE 52 {"\x10", "^P"}, // DLE
@@ -63,7 +62,7 @@ static struct key keys[] =
63 {"\x1A", "^Z"}, // SUB SIGTSTP 62 {"\x1A", "^Z"}, // SUB SIGTSTP
64 // Commented out coz it's the ANSI start byte in the below multibyte keys. 63 // Commented out coz it's the ANSI start byte in the below multibyte keys.
65 // Handled in the code with a timeout. 64 // Handled in the code with a timeout.
66 //{"\x1B", "^["}, // ESC Esc key. 65 //{"\x1B", "Esc"}, // ESC Esc key.
67 {"\x1C", "^\\"}, // FS SIGQUIT 66 {"\x1C", "^\\"}, // FS SIGQUIT
68 {"\x1D", "^]"}, // GS 67 {"\x1D", "^]"}, // GS
69 {"\x1E", "^^"}, // RS 68 {"\x1E", "^^"}, // RS
@@ -167,25 +166,6 @@ static struct key keys[] =
167 {"\x1BO1;2Q", "Shift F2"}, 166 {"\x1BO1;2Q", "Shift F2"},
168 {"\x1BO1;2R", "Shift F3"}, 167 {"\x1BO1;2R", "Shift F3"},
169 {"\x1BO1;2S", "Shift F4"}, 168 {"\x1BO1;2S", "Shift F4"},
170
171 // MC "Esc digit" specials.
172 // NOTE - The MC Esc variations might not be such a good idea, other programs
173 // want the Esc key for other things.
174 // Notably seems that "Esc somekey" is used in place of "Alt somekey"
175 // AKA "Meta somekey" coz apparently some OSes swallow those.
176 // Conversely, some terminals send "Esc somekey" when you do
177 // "Alt somekey".
178 // MC Esc variants might be used on Macs for other things?
179 {"\x1B\x31", "F1"},
180 {"\x1B\x32", "F2"},
181 {"\x1B\x33", "F3"},
182 {"\x1B\x34", "F4"},
183 {"\x1B\x35", "F5"},
184 {"\x1B\x36", "F6"},
185 {"\x1B\x37", "F7"},
186 {"\x1B\x38", "F8"},
187 {"\x1B\x39", "F9"},
188 {"\x1B\x30", "F10"}
189}; 169};
190 170
191static volatile sig_atomic_t sigWinch; 171static volatile sig_atomic_t sigWinch;
@@ -196,9 +176,6 @@ static void handleSIGWINCH(int signalNumber)
196 sigWinch = 1; 176 sigWinch = 1;
197} 177}
198 178
199// TODO - Unhandled complications -
200// Less and more have the "ZZ" command, but nothing else seems to have
201// multi ordinary character commands.
202void handle_keys(long extra, 179void handle_keys(long extra,
203 int (*handle_sequence)(long extra, char *sequence), 180 int (*handle_sequence)(long extra, char *sequence),
204 void (*handle_CSI)(long extra, char *command, int *params, int count)) 181 void (*handle_CSI)(long extra, char *command, int *params, int count))
@@ -268,9 +245,7 @@ void handle_keys(long extra,
268 { 245 {
269 // After a short delay to check, this is a real Escape key, 246 // After a short delay to check, this is a real Escape key,
270 // not part of an escape sequence, so deal with it. 247 // not part of an escape sequence, so deal with it.
271 // TODO - So far the only uses of this have the escape at the start, 248 strcat(sequence, "Esc");
272 // but maybe a strcat is needed instead later?
273 strcpy(sequence, "^[");
274 buffer[0] = buffIndex = 0; 249 buffer[0] = buffIndex = 0;
275 } 250 }
276 // TODO - Call some sort of timer tick callback. This wont be 251 // TODO - Call some sort of timer tick callback. This wont be
diff --git a/handlekeys.h b/handlekeys.h
index 00e6e93..192d96c 100644
--- a/handlekeys.h
+++ b/handlekeys.h
@@ -9,8 +9,7 @@
9 * See the keys[] array at the top of handlekeys.c for what byte sequences get 9 * See the keys[] array at the top of handlekeys.c for what byte sequences get
10 * translated into what key names. See dumbsh.c for an example of usage. 10 * translated into what key names. See dumbsh.c for an example of usage.
11 * A 0.1 second delay is used to detect the Esc key being pressed, and not Esc 11 * A 0.1 second delay is used to detect the Esc key being pressed, and not Esc
12 * being part of a raw keystroke. As a bonus, Midnight Commander style 12 * being part of a raw keystroke.
13 * "Esc digit" sequences are translated to function keys.
14 * 13 *
15 * handle_keys also tries to decode CSI commands that terminals can send. 14 * handle_keys also tries to decode CSI commands that terminals can send.
16 * Some keystrokes are CSI commands, but those are translated as key sequences 15 * Some keystrokes are CSI commands, but those are translated as key sequences