mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 18:55:07 +00:00
HackStudio: Add header navigation
This commit is contained in:
parent
d8a73dd979
commit
879bf3e97b
4 changed files with 95 additions and 4 deletions
|
@ -66,6 +66,7 @@
|
|||
|
||||
NonnullRefPtrVector<EditorWrapper> g_all_editor_wrappers;
|
||||
RefPtr<EditorWrapper> g_current_editor_wrapper;
|
||||
Function<void(String)> g_open_file;
|
||||
|
||||
String g_currently_open_file;
|
||||
OwnPtr<Project> g_project;
|
||||
|
@ -529,6 +530,8 @@ int main(int argc, char** argv)
|
|||
remove_current_editor_action->set_enabled(g_all_editor_wrappers.size() > 1);
|
||||
};
|
||||
|
||||
g_open_file = open_file;
|
||||
|
||||
open_file("main.cpp");
|
||||
|
||||
update_actions();
|
||||
|
@ -547,8 +550,15 @@ void run(TerminalWrapper& wrapper)
|
|||
|
||||
void open_file(const String& filename)
|
||||
{
|
||||
auto file = g_project->get_file(filename);
|
||||
current_editor().set_document(const_cast<GUI::TextDocument&>(file->document()));
|
||||
auto project_file = g_project->get_file(filename);
|
||||
if (project_file) {
|
||||
current_editor().set_document(const_cast<GUI::TextDocument&>(project_file->document()));
|
||||
current_editor().set_readonly(false);
|
||||
} else {
|
||||
auto external_file = ProjectFile::construct_with_name(filename);
|
||||
current_editor().set_document(const_cast<GUI::TextDocument&>(external_file->document()));
|
||||
current_editor().set_readonly(true);
|
||||
}
|
||||
|
||||
if (filename.ends_with(".cpp") || filename.ends_with(".h"))
|
||||
current_editor().set_syntax_highlighter(make<GUI::CppSyntaxHighlighter>());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue