1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:35:08 +00:00

HackStudio: Support multiple editors on screen

This patch adds Editor (subclass of GTextEditor) and EditorWrapper.
An EditorWrapper is a composite widget that adds a little statusbar
above an Editor widget. The statusbar is used for showing the filename
and the current cursor position. More things can definitely be added.

To get to the currently active editor, call current_editor().
You can also get to the current editor's wrapper by calling..
current_editor_wrapper(). Which editor is current is determined by
which was was last focused by the user.
This commit is contained in:
Andreas Kling 2019-10-27 12:55:10 +01:00
parent de2b25e2c1
commit e39b1f11f9
7 changed files with 156 additions and 45 deletions

View file

@ -5,7 +5,7 @@
#include <LibGUI/GListView.h>
#include <LibGUI/GTextBox.h>
extern GTextEditor& main_editor();
extern GTextEditor& current_editor();
extern void open_file(const String&);
extern OwnPtr<Project> g_project;
@ -71,8 +71,8 @@ FindInFilesWidget::FindInFilesWidget(GWidget* parent)
int line_number = parts[1].to_int(ok);
ASSERT(ok);
open_file(parts[0]);
main_editor().set_cursor(line_number - 1, 0);
main_editor().set_focus(true);
current_editor().set_cursor(line_number - 1, 0);
current_editor().set_focus(true);
};
m_button->on_click = [this](auto&) {