mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 18:17:41 +00:00
HackStudio: Optionally pass line & column to open_file
This makes it easier to open a file at a specific location.
This commit is contained in:
parent
5cd030568f
commit
8fc9ec942e
3 changed files with 5 additions and 4 deletions
|
@ -236,7 +236,7 @@ Vector<String> HackStudioWidget::selected_file_paths() const
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HackStudioWidget::open_file(const String& full_filename)
|
bool HackStudioWidget::open_file(const String& full_filename, size_t line, size_t column)
|
||||||
{
|
{
|
||||||
String filename = full_filename;
|
String filename = full_filename;
|
||||||
if (full_filename.starts_with(project().root_path())) {
|
if (full_filename.starts_with(project().root_path())) {
|
||||||
|
@ -298,6 +298,7 @@ bool HackStudioWidget::open_file(const String& full_filename)
|
||||||
|
|
||||||
current_editor().on_cursor_change = [this] { update_statusbar(); };
|
current_editor().on_cursor_change = [this] { update_statusbar(); };
|
||||||
current_editor_wrapper().on_change = [this] { update_gml_preview(); };
|
current_editor_wrapper().on_change = [this] { update_gml_preview(); };
|
||||||
|
current_editor().set_cursor(line, column);
|
||||||
update_gml_preview();
|
update_gml_preview();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -34,7 +34,8 @@ class HackStudioWidget : public GUI::Widget {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~HackStudioWidget() override;
|
virtual ~HackStudioWidget() override;
|
||||||
bool open_file(const String& filename);
|
|
||||||
|
bool open_file(String const& filename, size_t line = 0, size_t column = 0);
|
||||||
void close_file_in_all_editors(String const& filename);
|
void close_file_in_all_editors(String const& filename);
|
||||||
|
|
||||||
void update_actions();
|
void update_actions();
|
||||||
|
|
|
@ -132,8 +132,7 @@ void open_file(const String& filename)
|
||||||
|
|
||||||
void open_file(const String& filename, size_t line, size_t column)
|
void open_file(const String& filename, size_t line, size_t column)
|
||||||
{
|
{
|
||||||
s_hack_studio_widget->open_file(filename);
|
s_hack_studio_widget->open_file(filename, line, column);
|
||||||
s_hack_studio_widget->current_editor_wrapper().editor().set_cursor({ line, column });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<EditorWrapper> current_editor_wrapper()
|
RefPtr<EditorWrapper> current_editor_wrapper()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue