Files
kte/KKeymap.h
Kyle Isom 45b2b88623 Code quality, safety, stability, and cleanups.
- Replace header include guards with `#pragma once` and perform minor optimizations.
- Replaced traditional include guards with `#pragma once` for simplicity and to reduce boilerplate in all headers.
- Improved CLI line number handling with clamping and error messaging.
- Enhanced `chdir` error handling for macOS GUI builds.
- Removed redundant logic for GUI builds.
- Adjusted font constructor and registry to handle `const` data pointers consistently.
2025-12-03 14:02:54 -08:00

30 lines
1.0 KiB
C

/*
* KKeymap.h - mapping for k-command (C-k prefix) keys to CommandId
*/
#pragma once
#include "Command.h"
// Lookup the command to execute after a C-k prefix.
// Parameters:
// - ascii_key: ASCII code of the key, preferably lowercased if it's a letter.
// - ctrl: whether Control modifier was held for this key (e.g., C-k C-x).
// Returns true and sets out if a mapping exists; false otherwise.
bool KLookupKCommand(int ascii_key, bool ctrl, CommandId &out);
// Lookup direct Control-chord commands (e.g., C-n, C-p, C-f, ...).
// ascii_key should be the lowercase ASCII of the letter (e.g., 'n' for C-n).
bool KLookupCtrlCommand(int ascii_key, CommandId &out);
// Lookup ESC/Meta + key commands (e.g., ESC f/b).
// ascii_key should be the lowercase ASCII of the letter.
bool KLookupEscCommand(int ascii_key, CommandId &out);
// Utility: normalize an int keycode to lowercased ASCII if it's in printable range.
inline int
KLowerAscii(const int key)
{
if (key >= 'A' && key <= 'Z')
return key + ('a' - 'A');
return key;
}