mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:47:43 +00:00
HackStudio: Unbreak jumping to a search result
I broke this when factoring out the find-in-files widget into its own class. This patch adds a main_editor() global getter for grabbing at the main GTextEditor from wherever you are.
This commit is contained in:
parent
558c63a6f9
commit
f256c55e8d
2 changed files with 10 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <LibGUI/GListView.h>
|
#include <LibGUI/GListView.h>
|
||||||
#include <LibGUI/GTextBox.h>
|
#include <LibGUI/GTextBox.h>
|
||||||
|
|
||||||
|
extern GTextEditor& main_editor();
|
||||||
extern void open_file(const String&);
|
extern void open_file(const String&);
|
||||||
extern OwnPtr<Project> g_project;
|
extern OwnPtr<Project> g_project;
|
||||||
|
|
||||||
|
@ -70,8 +71,8 @@ FindInFilesWidget::FindInFilesWidget(GWidget* parent)
|
||||||
int line_number = parts[1].to_int(ok);
|
int line_number = parts[1].to_int(ok);
|
||||||
ASSERT(ok);
|
ASSERT(ok);
|
||||||
open_file(parts[0]);
|
open_file(parts[0]);
|
||||||
m_textbox->set_cursor(line_number - 1, 0);
|
main_editor().set_cursor(line_number - 1, 0);
|
||||||
m_textbox->set_focus(true);
|
main_editor().set_focus(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_button->on_click = [this](auto&) {
|
m_button->on_click = [this](auto&) {
|
||||||
|
|
|
@ -29,6 +29,12 @@ RefPtr<GWindow> g_window;
|
||||||
RefPtr<GListView> g_project_list_view;
|
RefPtr<GListView> g_project_list_view;
|
||||||
RefPtr<GTextEditor> g_text_editor;
|
RefPtr<GTextEditor> g_text_editor;
|
||||||
|
|
||||||
|
GTextEditor& main_editor()
|
||||||
|
{
|
||||||
|
ASSERT(g_text_editor);
|
||||||
|
return *g_text_editor;
|
||||||
|
}
|
||||||
|
|
||||||
static void build(TerminalWrapper&);
|
static void build(TerminalWrapper&);
|
||||||
static void run(TerminalWrapper&);
|
static void run(TerminalWrapper&);
|
||||||
void open_file(const String&);
|
void open_file(const String&);
|
||||||
|
@ -109,7 +115,7 @@ int main(int argc, char** argv)
|
||||||
auto statusbar = GStatusBar::construct(widget);
|
auto statusbar = GStatusBar::construct(widget);
|
||||||
|
|
||||||
g_text_editor->on_cursor_change = [&] {
|
g_text_editor->on_cursor_change = [&] {
|
||||||
statusbar->set_text(String::format("Line: %d, Column: %d", g_text_editor->cursor().line(), g_text_editor->cursor().column()));
|
statusbar->set_text(String::format("Line: %d, Column: %d", g_text_editor->cursor().line() + 1, g_text_editor->cursor().column()));
|
||||||
};
|
};
|
||||||
|
|
||||||
g_text_editor->add_custom_context_menu_action(GAction::create(
|
g_text_editor->add_custom_context_menu_action(GAction::create(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue