mirror of
https://git.checksum.fail/alec/saphir.git
synced 2026-05-01 18:09:42 +03:00
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.
This commit is contained in:
71
Saphir/KeyDev.HC
Normal file
71
Saphir/KeyDev.HC
Normal file
@@ -0,0 +1,71 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user