equal
deleted
inserted
replaced
2018 ungetch(ks[i]); |
2018 ungetch(ks[i]); |
2019 } |
2019 } |
2020 return; |
2020 return; |
2021 } |
2021 } |
2022 |
2022 |
|
2023 static int bindcommand(keycode kcode) { |
|
2024 gchar asciikey[16]; |
|
2025 const gchar *boundcmd; |
|
2026 |
|
2027 if (!kcode.mcode || kcode.mcode == MKEY_EQUIV) |
|
2028 g_snprintf(asciikey, 15, "%d", kcode.value); |
|
2029 else if (kcode.mcode == MKEY_META) |
|
2030 g_snprintf(asciikey, 15, "M%d", kcode.value); |
|
2031 else |
|
2032 g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
|
2033 |
|
2034 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
|
2035 |
|
2036 if (boundcmd) { |
|
2037 gchar *cmd = g_strdup_printf("/%s", boundcmd); |
|
2038 scr_CheckAutoAway(TRUE); |
|
2039 if (process_command(cmd)) |
|
2040 return 255; // Quit |
|
2041 g_free(cmd); |
|
2042 return 0; |
|
2043 } |
|
2044 |
|
2045 scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); |
|
2046 if (utf8_mode) |
|
2047 scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!"); |
|
2048 return -1; |
|
2049 } |
|
2050 |
2023 // process_key(key) |
2051 // process_key(key) |
2024 // Handle the pressed key, in the command line (bottom). |
2052 // Handle the pressed key, in the command line (bottom). |
2025 int process_key(keycode kcode) |
2053 int process_key(keycode kcode) |
2026 { |
2054 { |
2027 int key = kcode.value; |
2055 int key = kcode.value; |
2037 switch (kcode.value) { |
2065 switch (kcode.value) { |
2038 case 27: |
2066 case 27: |
2039 key = 27; |
2067 key = 27; |
2040 break; |
2068 break; |
2041 default: |
2069 default: |
2042 scr_LogPrint(LPRINT_NORMAL, "Unknown key=M%d", kcode.value); |
2070 if (bindcommand(kcode) == 255) |
|
2071 return 255; |
2043 } |
2072 } |
2044 break; |
2073 break; |
2045 default: |
2074 default: |
2046 scr_LogPrint(LPRINT_NORMAL, "Unknown mkeycode! (%d)", kcode.mcode); |
2075 if (bindcommand(kcode) == 255) |
2047 key = ERR; |
2076 return 255; |
|
2077 key = ERR; // Do not process any further |
2048 } |
2078 } |
2049 |
2079 |
2050 switch (key) { |
2080 switch (key) { |
2051 case 0: |
2081 case 0: |
2052 case ERR: |
2082 case ERR: |
2209 strcpy(tmpLine, ptr_inputline); |
2239 strcpy(tmpLine, ptr_inputline); |
2210 *ptr_inputline++ = key; |
2240 *ptr_inputline++ = key; |
2211 strcpy(ptr_inputline, tmpLine); |
2241 strcpy(ptr_inputline, tmpLine); |
2212 check_offset(1); |
2242 check_offset(1); |
2213 } else { |
2243 } else { |
2214 const gchar *boundcmd = isbound(key); |
2244 // Look for a key binding. |
2215 if (boundcmd) { |
2245 if (bindcommand(kcode) == 255) |
2216 gchar *cmd = g_strdup_printf("/%s", boundcmd); |
2246 return 255; |
2217 scr_CheckAutoAway(TRUE); |
|
2218 if (process_command(cmd)) |
|
2219 return 255; |
|
2220 g_free(cmd); |
|
2221 } else { |
|
2222 scr_LogPrint(LPRINT_NORMAL, "Unknown key=%d", key); |
|
2223 if (utf8_mode) |
|
2224 scr_LogPrint(LPRINT_NORMAL, |
|
2225 "WARNING: UTF-8 not yet supported!"); |
|
2226 } |
|
2227 } |
2247 } |
2228 } |
2248 } |
2229 |
2249 |
2230 if (completion_started && key != 9 && key != KEY_RESIZE) |
2250 if (completion_started && key != 9 && key != KEY_RESIZE) |
2231 scr_end_current_completion(); |
2251 scr_end_current_completion(); |