improve handling of control key combos, bump version to 0.8.2

This commit is contained in:
cy384 2020-12-12 17:55:52 -05:00
parent 4552bcbf64
commit af285b6e6c
2 changed files with 25 additions and 8 deletions

View File

@ -4,11 +4,11 @@
#define __SSHEVEN_CONSTANTS_R__
/* so many versions */
#define SSHEVEN_VERSION "0.8.1"
#define SSHEVEN_LONG_VERSION "0.8.1 prerelease, by cy384"
#define SSHEVEN_DESCRIPTION "ssheven 0.8.1 by cy384"
#define SSHEVEN_VERSION "0.8.2"
#define SSHEVEN_LONG_VERSION "0.8.2 prerelease, by cy384"
#define SSHEVEN_DESCRIPTION "ssheven 0.8.2 by cy384"
#define SSHEVEN_VERSION_MAJOR 0x00
#define SSHEVEN_VERSION_MINOR 0x81
#define SSHEVEN_VERSION_MINOR 0x82
#define SSHEVEN_VERSION_PRERELEASE 0x01
/* options: development, alpha, beta, release */

View File

@ -23,6 +23,11 @@ struct preferences prefs;
enum { WAIT, READ, EXIT } read_thread_command = WAIT;
enum { UNINTIALIZED, OPEN, CLEANUP, DONE } read_thread_state = UNINTIALIZED;
// TODO: put this somewhere else
// contains a mapping of apple virtual keycode to ascii control code
// currently only for A-Z
const uint8_t virtual_keycode_to_control_ascii[255] = {1, 19, 4, 6, 8, 7, 26, 24, 3, 22, 255, 2, 17, 23, 5, 18, 25, 20, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 21, 255, 9, 16, 255, 12, 10, 255, 11, 255, 255, 255, 255, 14, 13, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255};
void set_terminal_string(void)
{
/*
@ -590,8 +595,9 @@ int handle_keypress(EventRecord* event)
{
unsigned char c = event->message & charCodeMask;
// if we have a key and command and it's not autorepeating
if (c && (event->modifiers & cmdKey) && event->what != autoKey)
// if we have a key and command, and it's not autorepeating
if (c && event->what != autoKey && event->modifiers & cmdKey)
{
switch (c)
{
@ -605,8 +611,20 @@ int handle_keypress(EventRecord* event)
break;
}
}
// if we have a key and control, and it's not autorepeating
else if (c && event->what != autoKey && event->modifiers & controlKey)
{
// check if we know a control code translation for that key
uint8_t control_code = virtual_keycode_to_control_ascii[((event->message & keyCodeMask)>>8)];
if (control_code != 255)
{
ssh_con.send_buffer[0] = control_code;
ssh_write(ssh_con.send_buffer, 1);
}
}
// if it's just a normal key
// note that this is after translation, e.g. shift-f -> 'F', ctrl-a -> 0x01
// note that this is after translation, e.g. shift-f -> 'F'
else if (c)
{
if (key_to_vterm[c] != VTERM_KEY_NONE)
@ -615,7 +633,6 @@ int handle_keypress(EventRecord* event)
}
else
{
if ('\r' == c) c = '\n';
ssh_con.send_buffer[0] = c;
ssh_write(ssh_con.send_buffer, 1);
}