Permalink
Browse files

add FreeBSD home and end keyboard handling

  • Loading branch information...
Gerhard Wiesinger
Gerhard Wiesinger committed Jan 7, 2017
1 parent a089446 commit 6afedd6324b2aa9506622c56ffd59ae594bdea68
Showing with 132 additions and 5 deletions.
  1. +4 −2 0.67_My_PuTTY/config.c
  2. +60 −1 0.67_My_PuTTY/macosx/osxwin.m
  3. +42 −1 0.67_My_PuTTY/unix/gtkwin.c
  4. +26 −1 0.67_My_PuTTY/windows/window.c
@@ -2533,11 +2533,13 @@ void setup_config_box(struct controlbox *b, int midsession,
conf_radiobutton_handler,
I(CONF_bksp_is_delete),
"Control-H", I(0), "Control-? (127)", I(1), NULL);
ctrl_radiobuttons(s, "The Home and End keys", 'e', 2,
ctrl_radiobuttons(s, "The Home and End keys", 'e', 3,
HELPCTX(keyboard_homeend),
conf_radiobutton_handler,
I(CONF_rxvt_homeend),
"Standard", I(0), "rxvt", I(1), NULL);
"Standard", I(0), "rxvt", I(1), "urxvt", I(2),
"xterm", I(3), "FreeBSD1", I(4), "FreeBSD2", I(5),
NULL);
ctrl_radiobuttons(s, "The Function keys and keypad", 'f', 3,
HELPCTX(keyboard_funkeys),
conf_radiobutton_handler,
@@ -703,7 +703,8 @@ - (void)keyDown:(NSEvent *)ev
}
goto done;
}
if (cfg.rxvt_homeend && (code == 1 || code == 4)) {
if ((cfg.rxvt_homeend == 1) && (code == 1 || code == 4)) {
// rxvt
if (code == 1) {
output[end++] = '\033';
output[end++] = '[';
@@ -715,6 +716,64 @@ - (void)keyDown:(NSEvent *)ev
}
goto done;
}
if ((cfg.rxvt_homeend == 2) && (code == 1 || code == 4)) {
// urxvt
if (code == 1) {
output[end++] = '\033';
output[end++] = '[';
output[end++] = '7';
output[end++] = '~';
} else {
output[end++] = '\033';
output[end++] = '[';
output[end++] = '8';
output[end++] = '~';
}
goto done;
}
if ((cfg.rxvt_homeend == 3) && (code == 1 || code == 4)) {
// xterm
if (code == 1) {
output[end++] = '\033';
output[end++] = 'O';
output[end++] = 'H';
} else {
output[end++] = '\033';
output[end++] = 'O';
output[end++] = 'F';
}
goto done;
}
if ((cfg.rxvt_homeend == 4) && (code == 1 || code == 4)) {
// FreeBSD1
if (code == 1) {
output[end++] = '\033';
output[end++] = '[';
output[end++] = 'H';
} else {
output[end++] = '\033';
output[end++] = '[';
output[end++] = 'F';
}
goto done;
}
if ((cfg.rxvt_homeend == 5) && (code == 1 || code == 4)) {
// FreeBSD2
if (code == 1) {
output[end++] = '\033';
output[end++] = 'O';
output[end++] = 'H';
} else {
output[end++] = '\033';
output[end++] = '[';
output[end++] = '?';
output[end++] = '1';
output[end++] = 'l';
output[end++] = '\033';
output[end++] = '>';
}
goto done;
}
if (code) {
char buf[20];
sprintf(buf, "\x1B[%d~", code);
@@ -1568,14 +1568,55 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
goto done;
}
if ((code == 1 || code == 4) &&
conf_get_int(inst->conf, CONF_rxvt_homeend)) {
conf_get_int(inst->conf, CONF_rxvt_homeend) == 1) {
// rxvt
#ifdef KEY_EVENT_DIAGNOSTICS
debug((" - rxvt style Home/End"));
#endif
end = 1 + sprintf(output+1, code == 1 ? "\x1B[H" : "\x1BOw");
use_ucsoutput = FALSE;
goto done;
}
if ((code == 1 || code == 4) &&
conf_get_int(inst->conf, CONF_rxvt_homeend) == 2) {
// rxvt
#ifdef KEY_EVENT_DIAGNOSTICS
debug((" - urxvt style Home/End"));
#endif
end = 1 + sprintf(output+1, code == 1 ? "\x1B[7~" : "\x1B[8~");
use_ucsoutput = FALSE;
goto done;
}
if ((code == 1 || code == 4) &&
conf_get_int(inst->conf, CONF_rxvt_homeend) == 3) {
// rxvt
#ifdef KEY_EVENT_DIAGNOSTICS
debug((" - xterm style Home/End"));
#endif
end = 1 + sprintf(output+1, code == 1 ? "\x1BOH" : "\x1BOF");
use_ucsoutput = FALSE;
goto done;
}
if ((code == 1 || code == 4) &&
conf_get_int(inst->conf, CONF_rxvt_homeend) == 4) {
// FreeBSD
#ifdef KEY_EVENT_DIAGNOSTICS
debug((" - FreeBSD1 style Home/End"));
#endif
end = 1 + sprintf(output+1, code == 1 ? "\x1B[H" : "\x1B[F");
use_ucsoutput = FALSE;
goto done;
}
if ((code == 1 || code == 4) &&
conf_get_int(inst->conf, CONF_rxvt_homeend) == 5) {
// FreeBSD
#ifdef KEY_EVENT_DIAGNOSTICS
debug((" - FreeBSD2 style Home/End"));
#endif
end = 1 + sprintf(output+1, code == 1 ? "\x1BOH" : "\x1B[?1l\x1B>");
use_ucsoutput = FALSE;
goto done;
}
if (code) {
#ifdef KEY_EVENT_DIAGNOSTICS
debug((" - ordinary function key encoding"));
@@ -6744,10 +6744,35 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
return p - output;
}
if ((code == 1 || code == 4) &&
conf_get_int(conf, CONF_rxvt_homeend)) {
conf_get_int(conf, CONF_rxvt_homeend) == 1) {
// rxvt
p += sprintf((char *) p, code == 1 ? "\x1B[H" : "\x1BOw");
return p - output;
}
if ((code == 1 || code == 4) &&
conf_get_int(conf, CONF_rxvt_homeend) == 2) {
// urxvt
p += sprintf((char *) p, code == 1 ? "\x1B[7~" : "\x1B[8~");
return p - output;
}
if ((code == 1 || code == 4) &&
conf_get_int(conf, CONF_rxvt_homeend) == 3) {
// xterm
p += sprintf((char *) p, code == 1 ? "\x1BOH" : "\x1BOF");
return p - output;
}
if ((code == 1 || code == 4) &&
conf_get_int(conf, CONF_rxvt_homeend) == 4) {
// FreeBSD1
p += sprintf((char *) p, code == 1 ? "\x1B[H" : "\x1B[H");
return p - output;
}
if ((code == 1 || code == 4) &&
conf_get_int(conf, CONF_rxvt_homeend) == 5) {
// FreeBSD2
p += sprintf((char *) p, code == 1 ? "\x1BOH" : "\x1B[?1l\x1B>");
return p - output;
}
if (code) {
p += sprintf((char *) p, "\x1B[%d~", code);
return p - output;

0 comments on commit 6afedd6

Please sign in to comment.