Add SmartNewline command with tests and editor integration

- Introduced `CommandId::SmartNewline` for auto-indented newlines, enhancing text editing workflows.
- Added `cmd_smart_newline` to implement indentation-aware newline logic.
- Integrated SmartNewline with keymaps, mouse/keyboard input handlers, and terminal/editor commands.
- Wrote comprehensive tests in `test_smart_newline.cc` to validate behavior for spaces, tabs, and no-indentation cases.
- Updated `Command.h` and `CMakeLists.txt` to register and build the new command.
This commit is contained in:
2026-02-26 13:08:56 -08:00
parent 690c51b0f3
commit bc3433e988
8 changed files with 206 additions and 38 deletions

View File

@@ -125,7 +125,11 @@ map_key(const SDL_Keycode key,
case SDLK_KP_ENTER:
k_prefix = false;
k_ctrl_pending = false;
out = {true, CommandId::Newline, "", 0};
if (mod & KMOD_SHIFT) {
out = {true, CommandId::SmartNewline, "", 0};
} else {
out = {true, CommandId::Newline, "", 0};
}
return true;
case SDLK_ESCAPE:
k_prefix = false;
@@ -439,12 +443,14 @@ ImGuiInputHandler::ProcessSDLEvent(const SDL_Event &e)
}
// If editor universal argument is active, consume digit TEXTINPUT
if (ed_ && ed_
if (ed_ &&ed_
->
UArg() != 0
) {
->
UArg() != 0
)
{
const char *txt = e.text.text;
if (txt && *txt) {
unsigned char c0 = static_cast<unsigned char>(txt[0]);
@@ -606,4 +612,4 @@ ImGuiInputHandler::Poll(MappedInput &out)
out = q_.front();
q_.pop();
return true;
}
}