1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 20:55:07 +00:00

HackStudio: Rethink the "project" concept to be about a directory

Instead of having .hsp files that determine which files are members
of a project, a project is now an entire directory tree instead.

This feels a lot less cumbersome to work with, and removes a fair
amount of busywork that would otherwise be expected from the user.

This patch refactors large parts of HackStudio to implement the new
way of thinking. I've probably missed some details here and there,
but generally I think it's pretty OK.
This commit is contained in:
Andreas Kling 2020-12-10 18:59:03 +01:00
parent 5d0fda3d39
commit dd3e6451ac
6 changed files with 86 additions and 468 deletions

View file

@ -54,8 +54,6 @@ static RefPtr<HackStudioWidget> s_hack_studio_widget;
static bool make_is_available();
static void update_path_environment_variable();
static String path_to_project(const String& path_argument_absolute_path);
static void open_default_project_file(const String& project_path);
int main(int argc, char** argv)
{
@ -73,7 +71,6 @@ int main(int argc, char** argv)
s_window = GUI::Window::construct();
s_window->resize(840, 600);
s_window->set_title("HackStudio");
s_window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"));
update_path_environment_variable();
@ -88,16 +85,20 @@ int main(int argc, char** argv)
auto argument_absolute_path = Core::File::real_path_for(path_argument);
auto menubar = GUI::MenuBar::construct();
auto project_path = path_to_project(argument_absolute_path);
auto project_path = argument_absolute_path;
if (argument_absolute_path.is_null())
project_path = Core::File::real_path_for(".");
s_hack_studio_widget = s_window->set_main_widget<HackStudioWidget>(project_path);
s_window->set_title(String::formatted("{} - HackStudio", s_hack_studio_widget->project().name()));
auto menubar = GUI::MenuBar::construct();
s_hack_studio_widget->initialize_menubar(menubar);
app->set_menubar(menubar);
s_window->show();
open_default_project_file(argument_absolute_path);
s_hack_studio_widget->update_actions();
return app->exec();
@ -131,22 +132,6 @@ static void update_path_environment_variable()
setenv("PATH", path.to_string().characters(), true);
}
static String path_to_project(const String& path_argument_absolute_path)
{
if (path_argument_absolute_path.ends_with(".hsp"))
return path_argument_absolute_path;
else
return "/home/anon/Source/little/little.hsp";
}
static void open_default_project_file(const String& project_path)
{
if (!project_path.is_empty() && !project_path.ends_with(".hsp"))
open_file(project_path);
else
open_file(s_hack_studio_widget->project().default_file());
}
namespace HackStudio {
GUI::TextEditor& current_editor()