Add multi-window support to GUI with shared buffer list and improved input handling

- Introduced support for multiple windows, sharing the primary editor's buffer list.
- Added `GUIFrontend::OpenNewWindow_` for creating secondary windows with independent dimensions and input handlers.
- Redesigned `WindowState` to encapsulate per-window attributes (dimensions, renderer, input, etc.).
- Updated input processing and command execution to route events based on active window, preserving window-level states.
- Enhanced SDL2 and ImGui integration for proper context management across multiple windows.
- Increased robustness by handling window closing, resizing, and cleanup of secondary windows without affecting the primary editor.
- Updated documentation and key bindings for multi-window operations (e.g., Cmd+N / Ctrl+Shift+N).
- Version updated to 1.8.0 to reflect the major GUI enhancement.
This commit is contained in:
2026-03-15 13:19:04 -07:00
parent 11c523ad52
commit d768e56727
8 changed files with 429 additions and 194 deletions

View File

@@ -115,6 +115,14 @@ ensure_cursor_visible(const Editor &ed, Buffer &buf)
}
static bool
cmd_new_window(CommandContext &ctx)
{
ctx.editor.SetNewWindowRequested(true);
return true;
}
static bool
cmd_center_on_cursor(CommandContext &ctx)
{
@@ -2254,10 +2262,8 @@ cmd_show_help(CommandContext &ctx)
};
auto populate_from_text = [](Buffer &b, const std::string &text) {
// Clear existing rows
while (b.Nrows() > 0) {
b.delete_row(0);
}
// Clear existing content
b.replace_all_bytes("");
// Parse text and insert rows
std::string line;
line.reserve(128);
@@ -5002,6 +5008,11 @@ InstallDefaultCommands()
CommandId::CenterOnCursor, "center-on-cursor", "Center viewport on current line", cmd_center_on_cursor,
false, false
});
// GUI: new window
CommandRegistry::Register({
CommandId::NewWindow, "new-window", "Open a new editor window (GUI only)", cmd_new_window,
false, false
});
}