Files
saphir/Saphir/KeyDev.HC
Alec Murphy 1e379a1053 Refactor everything
We now hijack existing system functions to integrate with `WinMgr`,
instead of `Spawn`ing our own `SaphirTask`.

Also, you can now use `Saphir(Bool)` to toggle enable/disable the
features.

There is a global var `saphir` which values are set by `Defaults.HC` for
colors and other behaviors; these values can be changed at any time.
2026-04-25 18:25:56 -04:00

71 lines
1.4 KiB
HolyC

saphir.kd.sys_cbs = keydev.fp_ctrl_alt_cbs;
saphir.kd.null_cbs = CAlloc(0xd0);
I64 saphir_get_char()
{
I64 sc = NULL;
I64 ch = NULL;
do {
ch = GetKey(&sc, 0, 0);
if (!ch) {
switch (sc & 0xff) {
case SC_CURSOR_UP:
case SC_CURSOR_DOWN:
case SC_CURSOR_LEFT:
case SC_CURSOR_RIGHT:
return ((sc & 0xff) << 8);
default:
break;
}
}
} while (!ch);
return ch;
}
U0 saphir_handle_prefix_cmd()
{
I64 ch = saphir_get_char;
switch (ch >> 8) {
case SC_CURSOR_UP:
case SC_CURSOR_DOWN:
case SC_CURSOR_LEFT:
case SC_CURSOR_RIGHT:
saphir_win_select(ch >> 8);
return;
default:
break;
}
switch (ch & 0xff) {
case '%':
saphir_split_col;
return;
case '"':
saphir_split_row;
return;
default:
break;
}
}
Bool saphir_MyPutKey(I64 ch, I64 sc)
{
switch (ch) {
case CH_CTRLB:
saphir_handle_prefix_cmd;
return TRUE;
}
return FALSE;
}
U0 saphir_keydev(Bool enable)
{
fn_patch(&MyPutKey, &saphir_MyPutKey, enable);
switch (enable) {
case 0:
keydev.fp_ctrl_alt_cbs = saphir.kd.sys_cbs;
return;
default:
keydev.fp_ctrl_alt_cbs = saphir.kd.null_cbs;
return;
}
}