mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 03:05:07 +00:00
HackStudio: Support opening the same file in both editors
Hey, it actually works! You can now edit the same file in both editors and even the C++ highlighting updates correctly in both of them. :^)
This commit is contained in:
parent
9b13a3905b
commit
e2d7f585da
5 changed files with 26 additions and 7 deletions
|
@ -305,13 +305,8 @@ static void rehighlight()
|
|||
|
||||
void open_file(const String& filename)
|
||||
{
|
||||
auto file = CFile::construct(filename);
|
||||
if (!file->open(CFile::ReadOnly)) {
|
||||
GMessageBox::show("Could not open!", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window);
|
||||
return;
|
||||
}
|
||||
auto contents = file->read_all();
|
||||
current_editor().set_text(contents);
|
||||
auto file = g_project->get_file(filename);
|
||||
current_editor().set_document(const_cast<GTextDocument&>(file->document()));
|
||||
|
||||
if (filename.ends_with(".cpp")) {
|
||||
current_editor().on_change = [] { rehighlight(); };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue