mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:07:34 +00:00
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -130,7 +130,7 @@ static ClassViewNode& add_child_node(NonnullOwnPtrVector<ClassViewNode>& childre
|
|||
void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
|
||||
{
|
||||
ClassViewNode* parent = nullptr;
|
||||
auto scope_parts = decl.scope.view().split_view("::");
|
||||
auto scope_parts = decl.scope.view().split_view("::"sv);
|
||||
|
||||
if (!scope_parts.is_empty()) {
|
||||
// Traverse declarations tree to the parent of 'decl'
|
||||
|
|
|
@ -24,19 +24,19 @@ namespace HackStudio {
|
|||
|
||||
void DebugInfoWidget::init_toolbar()
|
||||
{
|
||||
m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
|
||||
m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
|
||||
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Continue);
|
||||
});
|
||||
|
||||
m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
|
||||
m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
|
||||
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOver);
|
||||
});
|
||||
|
||||
m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
|
||||
m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
|
||||
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceSingleStep);
|
||||
});
|
||||
|
||||
m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
|
||||
m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
|
||||
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOut);
|
||||
});
|
||||
|
||||
|
@ -106,7 +106,7 @@ RefPtr<GUI::Menu> DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode
|
|||
if (does_variable_support_writing(variable)) {
|
||||
context_menu->add_action(GUI::Action::create("Change value", [&](auto&) {
|
||||
String value;
|
||||
if (GUI::InputBox::show(window(), value, "Enter new value:", "Set variable value") == GUI::InputBox::ExecResult::OK) {
|
||||
if (GUI::InputBox::show(window(), value, "Enter new value:"sv, "Set variable value"sv) == GUI::InputBox::ExecResult::OK) {
|
||||
auto& model = static_cast<VariablesModel&>(*m_variables_view->model());
|
||||
model.set_variable_value(index, value, window());
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ int Debugger::debugger_loop()
|
|||
return Debug::DebugSession::DebugDecision::SingleStep;
|
||||
|
||||
// We currently do no support stepping through assembly source
|
||||
if (source_position.value().file_path.ends_with(".S"))
|
||||
if (source_position.value().file_path.ends_with(".S"sv))
|
||||
return Debug::DebugSession::DebugDecision::SingleStep;
|
||||
|
||||
VERIFY(source_position.has_value());
|
||||
|
|
|
@ -34,7 +34,7 @@ DisassemblyModel::DisassemblyModel(Debug::DebugSession const& debug_session, Ptr
|
|||
auto maybe_kernel_base = Symbolication::kernel_base();
|
||||
|
||||
if (maybe_kernel_base.has_value() && containing_function.value().address_low >= maybe_kernel_base.value()) {
|
||||
auto file_or_error = Core::MappedFile::map("/boot/Kernel.debug");
|
||||
auto file_or_error = Core::MappedFile::map("/boot/Kernel.debug"sv);
|
||||
if (file_or_error.is_error())
|
||||
return;
|
||||
kernel_elf = make<ELF::Image>(file_or_error.value()->bytes());
|
||||
|
|
|
@ -144,7 +144,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView
|
|||
GUI::MessageBox::show(
|
||||
parent_window,
|
||||
String::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name),
|
||||
"Set value failed",
|
||||
"Set value failed"sv,
|
||||
GUI::MessageBox::Type::Error);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ private:
|
|||
, m_regs(regs)
|
||||
, m_inspector(inspector)
|
||||
{
|
||||
m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
|
||||
m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables;
|
||||
PtraceRegisters m_regs;
|
||||
|
|
|
@ -177,20 +177,20 @@ void NewProjectDialog::do_create_project()
|
|||
{
|
||||
auto project_template = selected_template();
|
||||
if (!project_template) {
|
||||
GUI::MessageBox::show_error(this, "Could not create project: no template selected.");
|
||||
GUI::MessageBox::show_error(this, "Could not create project: no template selected."sv);
|
||||
return;
|
||||
}
|
||||
|
||||
auto maybe_project_name = get_available_project_name();
|
||||
auto maybe_project_full_path = get_project_full_path();
|
||||
if (!maybe_project_name.has_value() || !maybe_project_full_path.has_value()) {
|
||||
GUI::MessageBox::show_error(this, "Could not create project: invalid project name or path.");
|
||||
GUI::MessageBox::show_error(this, "Could not create project: invalid project name or path."sv);
|
||||
return;
|
||||
}
|
||||
|
||||
auto create_in = m_create_in_input->text();
|
||||
if (!Core::File::exists(create_in) || !Core::File::is_directory(create_in)) {
|
||||
auto result = GUI::MessageBox::show(this, String::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
|
||||
auto result = GUI::MessageBox::show(this, String::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
|
||||
if (result != GUI::MessageBox::ExecResult::Yes)
|
||||
return;
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ void ProjectTemplatesModel::rescan_templates()
|
|||
|
||||
while (di.has_next()) {
|
||||
auto full_path = LexicalPath(di.next_full_path());
|
||||
if (!full_path.has_extension(".ini"))
|
||||
if (!full_path.has_extension(".ini"sv))
|
||||
continue;
|
||||
|
||||
auto project_template = ProjectTemplate::load_from_manifest(full_path.string());
|
||||
|
|
|
@ -61,7 +61,7 @@ Editor::Editor()
|
|||
if (success) {
|
||||
set_execution_position(cursor().line());
|
||||
} else {
|
||||
GUI::MessageBox::show(window(), "Failed to set execution position", "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), "Failed to set execution position"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -161,13 +161,13 @@ void Editor::paint_event(GUI::PaintEvent& event)
|
|||
if (line < first_visible_line || line > last_visible_line) {
|
||||
continue;
|
||||
}
|
||||
char const* sign = (line_offset < deletions) ? "!" : "+";
|
||||
auto sign = (line_offset < deletions) ? "!"sv : "+"sv;
|
||||
painter.draw_text(gutter_icon_rect(line), sign, font(), Gfx::TextAlignment::Center);
|
||||
}
|
||||
if (additions < deletions) {
|
||||
auto deletions_line = min(finish_line, line_count() - 1);
|
||||
if (deletions_line <= last_visible_line) {
|
||||
painter.draw_text(gutter_icon_rect(deletions_line), "-", font(), Gfx::TextAlignment::Center);
|
||||
painter.draw_text(gutter_icon_rect(deletions_line), "-"sv, font(), Gfx::TextAlignment::Center);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ void Editor::show_documentation_tooltip_if_available(String const& hovered_token
|
|||
// is probably to tweak Markdown::Document::render_to_html() so we can inject styles
|
||||
// into the rendered HTML easily.
|
||||
html.append(man_document->render_to_html());
|
||||
html.append("<style>body { background-color: #dac7b5; }</style>");
|
||||
html.append("<style>body { background-color: #dac7b5; }</style>"sv);
|
||||
m_documentation_page_view->load_html(html.build(), {});
|
||||
|
||||
m_documentation_tooltip_window->move_to(screen_location.translated(4, 4));
|
||||
|
@ -355,7 +355,7 @@ void Editor::drop_event(GUI::DropEvent& event)
|
|||
return;
|
||||
window()->move_to_front();
|
||||
if (urls.size() > 1) {
|
||||
GUI::MessageBox::show(window(), "HackStudio can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), "HackStudio can only open one file at a time!"sv, "One at a time please!"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
set_current_editor_wrapper(static_cast<EditorWrapper*>(parent()));
|
||||
|
@ -433,13 +433,13 @@ void Editor::clear_execution_position()
|
|||
|
||||
Gfx::Bitmap const& Editor::breakpoint_icon_bitmap()
|
||||
{
|
||||
static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png").release_value_but_fixme_should_propagate_errors();
|
||||
static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
return *bitmap;
|
||||
}
|
||||
|
||||
Gfx::Bitmap const& Editor::current_position_icon_bitmap()
|
||||
{
|
||||
static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors();
|
||||
static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
return *bitmap;
|
||||
}
|
||||
|
||||
|
@ -685,17 +685,17 @@ void Editor::handle_function_parameters_hint_request()
|
|||
StringBuilder html;
|
||||
for (size_t i = 0; i < params.size(); ++i) {
|
||||
if (i == argument_index)
|
||||
html.append("<b>");
|
||||
html.append("<b>"sv);
|
||||
|
||||
html.appendff("{}", params[i]);
|
||||
|
||||
if (i == argument_index)
|
||||
html.append("</b>");
|
||||
html.append("</b>"sv);
|
||||
|
||||
if (i < params.size() - 1)
|
||||
html.append(", ");
|
||||
html.append(", "sv);
|
||||
}
|
||||
html.append("<style>body { background-color: #dac7b5; }</style>");
|
||||
html.append("<style>body { background-color: #dac7b5; }</style>"sv);
|
||||
|
||||
m_parameter_hint_page_view->load_html(html.build(), {});
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ void EditorWrapper::set_mode_non_displayable()
|
|||
auto palette = editor().palette();
|
||||
palette.set_color(Gfx::ColorRole::BaseText, Color::from_rgb(0xffffff));
|
||||
editor().set_palette(palette);
|
||||
editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?");
|
||||
editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?"sv);
|
||||
}
|
||||
|
||||
void EditorWrapper::set_filename(String const& filename)
|
||||
|
@ -108,7 +108,7 @@ void EditorWrapper::update_title()
|
|||
title.append(m_filename);
|
||||
|
||||
if (editor().document().is_modified())
|
||||
title.append(" (*)");
|
||||
title.append(" (*)"sv);
|
||||
m_filename_title = title.to_string();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
FindWidget const& find_widget() const { return *m_find_widget; }
|
||||
|
||||
private:
|
||||
static constexpr auto untitled_label = "(Untitled)";
|
||||
static constexpr auto untitled_label = "(Untitled)"sv;
|
||||
|
||||
EditorWrapper();
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ GitWidget::GitWidget(String const& repo_root)
|
|||
unstaged_header.set_layout<GUI::HorizontalBoxLayout>();
|
||||
|
||||
auto& refresh_button = unstaged_header.add<GUI::Button>();
|
||||
refresh_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png").release_value_but_fixme_should_propagate_errors());
|
||||
refresh_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
refresh_button.set_fixed_size(16, 16);
|
||||
refresh_button.set_tooltip("refresh");
|
||||
refresh_button.on_click = [this](int) { refresh(); };
|
||||
|
@ -43,7 +43,7 @@ GitWidget::GitWidget(String const& repo_root)
|
|||
unstaged_header.set_fixed_height(20);
|
||||
m_unstaged_files = unstaged.add<GitFilesView>(
|
||||
[this](auto const& file) { stage_file(file); },
|
||||
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors());
|
||||
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
m_unstaged_files->on_selection_change = [this] {
|
||||
const auto& index = m_unstaged_files->selection().first();
|
||||
if (!index.is_valid())
|
||||
|
@ -60,7 +60,7 @@ GitWidget::GitWidget(String const& repo_root)
|
|||
staged_header.set_layout<GUI::HorizontalBoxLayout>();
|
||||
|
||||
auto& commit_button = staged_header.add<GUI::Button>();
|
||||
commit_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/commit.png").release_value_but_fixme_should_propagate_errors());
|
||||
commit_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/commit.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
commit_button.set_fixed_size(16, 16);
|
||||
commit_button.set_tooltip("commit");
|
||||
commit_button.on_click = [this](int) { commit(); };
|
||||
|
@ -71,7 +71,7 @@ GitWidget::GitWidget(String const& repo_root)
|
|||
staged_header.set_fixed_height(20);
|
||||
m_staged_files = staged.add<GitFilesView>(
|
||||
[this](auto const& file) { unstage_file(file); },
|
||||
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png").release_value_but_fixme_should_propagate_errors());
|
||||
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
||||
bool GitWidget::initialize()
|
||||
|
@ -82,10 +82,10 @@ bool GitWidget::initialize()
|
|||
m_git_repo = result.repo;
|
||||
return true;
|
||||
case GitRepo::CreateResult::Type::GitProgramNotFound:
|
||||
GUI::MessageBox::show(window(), "Please install the Git port", "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), "Please install the Git port"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return false;
|
||||
case GitRepo::CreateResult::Type::NoGitRepo: {
|
||||
auto decision = GUI::MessageBox::show(window(), "Create git repository?", "Git", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
|
||||
auto decision = GUI::MessageBox::show(window(), "Create git repository?"sv, "Git"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
|
||||
if (decision != GUI::Dialog::ExecResult::Yes)
|
||||
return false;
|
||||
m_git_repo = GitRepo::initialize_repository(m_repo_root);
|
||||
|
@ -136,7 +136,7 @@ void GitWidget::unstage_file(String const& file)
|
|||
void GitWidget::commit()
|
||||
{
|
||||
if (m_git_repo.is_null()) {
|
||||
GUI::MessageBox::show(window(), "There is no git repository to commit to!", "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), "There is no git repository to commit to!"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ HackStudioWidget::HackStudioWidget(String path_to_project)
|
|||
m_statusbar = add<GUI::Statusbar>(3);
|
||||
m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Auto);
|
||||
m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed);
|
||||
auto width = font().width("Ln 0000, Col 000") + font().max_glyph_width();
|
||||
auto width = font().width("Ln 0000, Col 000"sv) + font().max_glyph_width();
|
||||
m_statusbar->segment(2).set_fixed_width(width);
|
||||
update_statusbar();
|
||||
|
||||
|
@ -184,7 +184,7 @@ HackStudioWidget::HackStudioWidget(String path_to_project)
|
|||
}
|
||||
|
||||
m_project_builder = make<ProjectBuilder>(*m_terminal_wrapper, *m_project);
|
||||
project().model().set_should_show_dotfiles(Config::read_bool("HackStudio", "Global", "ShowDotfiles", false));
|
||||
project().model().set_should_show_dotfiles(Config::read_bool("HackStudio"sv, "Global"sv, "ShowDotfiles"sv, false));
|
||||
}
|
||||
|
||||
void HackStudioWidget::update_actions()
|
||||
|
@ -215,7 +215,7 @@ void HackStudioWidget::on_action_tab_change()
|
|||
|
||||
Vector<String> HackStudioWidget::read_recent_projects()
|
||||
{
|
||||
auto json = Config::read_string("HackStudio", "Global", "RecentProjects");
|
||||
auto json = Config::read_string("HackStudio"sv, "Global"sv, "RecentProjects"sv);
|
||||
AK::JsonParser parser(json);
|
||||
auto value_or_error = parser.parse();
|
||||
if (value_or_error.is_error())
|
||||
|
@ -279,7 +279,7 @@ void HackStudioWidget::open_project(String const& root_path)
|
|||
if (recent_projects.size() > recent_projects_history_size)
|
||||
recent_projects.shrink(recent_projects_history_size);
|
||||
|
||||
Config::write_string("HackStudio", "Global", "RecentProjects", JsonArray(recent_projects).to_string());
|
||||
Config::write_string("HackStudio"sv, "Global"sv, "RecentProjects"sv, JsonArray(recent_projects).to_string());
|
||||
update_recent_projects_submenu();
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu
|
|||
for (auto& new_file_action : m_new_file_actions) {
|
||||
new_file_submenu.add_action(new_file_action);
|
||||
}
|
||||
new_file_submenu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors());
|
||||
new_file_submenu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
new_file_submenu.add_action(*m_new_plain_file_action);
|
||||
new_file_submenu.add_separator();
|
||||
new_file_submenu.add_action(*m_new_directory_action);
|
||||
|
@ -507,7 +507,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const
|
|||
{
|
||||
return GUI::Action::create(label, Gfx::Bitmap::try_load_from_file(icon).release_value_but_fixme_should_propagate_errors(), [this, extension](const GUI::Action&) {
|
||||
String filename;
|
||||
if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecResult::OK)
|
||||
if (GUI::InputBox::show(window(), filename, "Enter name of new file:"sv, "Add new file to project"sv) != GUI::InputBox::ExecResult::OK)
|
||||
return;
|
||||
|
||||
if (!extension.is_empty() && !filename.ends_with(String::formatted(".{}", extension))) {
|
||||
|
@ -537,7 +537,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const
|
|||
|
||||
auto file = Core::File::construct(filepath);
|
||||
if (!file->open((Core::OpenMode)(Core::OpenMode::WriteOnly | Core::OpenMode::MustBeNew))) {
|
||||
GUI::MessageBox::show(window(), String::formatted("Failed to create '{}'", filepath), "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), String::formatted("Failed to create '{}'", filepath), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
open_file(filepath);
|
||||
|
@ -546,9 +546,9 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action()
|
||||
{
|
||||
return GUI::Action::create("&Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
|
||||
return GUI::Action::create("&Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
|
||||
String directory_name;
|
||||
if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecResult::OK)
|
||||
if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:"sv, "Add new folder to project"sv) != GUI::InputBox::ExecResult::OK)
|
||||
return;
|
||||
|
||||
auto path_to_selected = selected_file_paths();
|
||||
|
@ -569,7 +569,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action()
|
|||
auto formatted_dir_name = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_project->model().root_path(), directory_name));
|
||||
int rc = mkdir(formatted_dir_name.characters(), 0755);
|
||||
if (rc < 0) {
|
||||
GUI::MessageBox::show(window(), "Failed to create new directory", "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), "Failed to create new directory"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
@ -582,7 +582,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_selected_action()
|
|||
for (auto& file : files)
|
||||
open_file(file);
|
||||
});
|
||||
open_selected_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors());
|
||||
open_selected_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
open_selected_action->set_enabled(true);
|
||||
return open_selected_action;
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_selected_in_new_tab_act
|
|||
open_file(file);
|
||||
}
|
||||
});
|
||||
open_selected_in_new_tab_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors());
|
||||
open_selected_in_new_tab_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
open_selected_in_new_tab_action->set_enabled(true);
|
||||
return open_selected_in_new_tab_action;
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_show_in_file_manager_action(
|
|||
Desktop::Launcher::open(URL::create_with_file_protocol(m_project->root_path(), file));
|
||||
});
|
||||
show_in_file_manager_action->set_enabled(true);
|
||||
show_in_file_manager_action->set_icon(GUI::Icon::default_icon("app-file-manager").bitmap_for_size(16));
|
||||
show_in_file_manager_action->set_icon(GUI::Icon::default_icon("app-file-manager"sv).bitmap_for_size(16));
|
||||
|
||||
return show_in_file_manager_action;
|
||||
}
|
||||
|
@ -623,7 +623,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_relative_path_action()
|
|||
GUI::Clipboard::the().set_plain_text(paths_string);
|
||||
});
|
||||
copy_relative_path_action->set_enabled(true);
|
||||
copy_relative_path_action->set_icon(GUI::Icon::default_icon("hard-disk").bitmap_for_size(16));
|
||||
copy_relative_path_action->set_icon(GUI::Icon::default_icon("hard-disk"sv).bitmap_for_size(16));
|
||||
|
||||
return copy_relative_path_action;
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_full_path_action()
|
|||
GUI::Clipboard::the().set_plain_text(paths_string);
|
||||
});
|
||||
copy_full_path_action->set_enabled(true);
|
||||
copy_full_path_action->set_icon(GUI::Icon::default_icon("hard-disk").bitmap_for_size(16));
|
||||
copy_full_path_action->set_icon(GUI::Icon::default_icon("hard-disk"sv).bitmap_for_size(16));
|
||||
|
||||
return copy_full_path_action;
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
|
|||
|
||||
auto result = GUI::MessageBox::show(window(),
|
||||
message,
|
||||
"Confirm deletion",
|
||||
"Confirm deletion"sv,
|
||||
GUI::MessageBox::Type::Warning,
|
||||
GUI::MessageBox::InputType::OKCancel);
|
||||
if (result == GUI::MessageBox::ExecResult::Cancel)
|
||||
|
@ -673,7 +673,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
|
|||
if (lstat(file.characters(), &st) < 0) {
|
||||
GUI::MessageBox::show(window(),
|
||||
String::formatted("lstat ({}) failed: {}", file, strerror(errno)),
|
||||
"Removal failed",
|
||||
"Removal failed"sv,
|
||||
GUI::MessageBox::Type::Error);
|
||||
break;
|
||||
}
|
||||
|
@ -684,12 +684,12 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
|
|||
if (is_directory) {
|
||||
GUI::MessageBox::show(window(),
|
||||
String::formatted("Removing directory {} from the project failed: {}", error.file, static_cast<Error const&>(error)),
|
||||
"Removal failed",
|
||||
"Removal failed"sv,
|
||||
GUI::MessageBox::Type::Error);
|
||||
} else {
|
||||
GUI::MessageBox::show(window(),
|
||||
String::formatted("Removing file {} from the project failed: {}", error.file, static_cast<Error const&>(error)),
|
||||
"Removal failed",
|
||||
"Removal failed"sv,
|
||||
GUI::MessageBox::Type::Error);
|
||||
}
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_project_action()
|
||||
{
|
||||
return GUI::Action::create("&Project...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hackstudio-project.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
|
||||
return GUI::Action::create("&Project...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hackstudio-project.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
|
||||
auto dialog = NewProjectDialog::construct(window());
|
||||
dialog->set_icon(window()->icon());
|
||||
auto result = dialog->exec();
|
||||
|
@ -848,7 +848,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_switch_to_previous_editor_ac
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_editor_action()
|
||||
{
|
||||
return GUI::Action::create("&Remove Current Editor", { Mod_Alt | Mod_Shift, Key_E }, Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/remove-editor.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
return GUI::Action::create("&Remove Current Editor", { Mod_Alt | Mod_Shift, Key_E }, Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/remove-editor.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
if (m_all_editor_wrappers.size() <= 1)
|
||||
return;
|
||||
auto tab_widget = m_current_editor_tab_widget;
|
||||
|
@ -861,7 +861,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_editor_action
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_action()
|
||||
{
|
||||
return GUI::Action::create("&Open Project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
return GUI::Action::create("&Open Project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
auto open_path = GUI::FilePicker::get_open_filepath(window(), "Open project", m_project->root_path(), true);
|
||||
if (!open_path.has_value())
|
||||
return;
|
||||
|
@ -892,8 +892,8 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
|
|||
LexicalPath const old_path(old_filename);
|
||||
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window(),
|
||||
old_filename.is_null() ? "Untitled" : old_path.title(),
|
||||
old_filename.is_null() ? "txt" : old_path.extension(),
|
||||
old_filename.is_null() ? "Untitled"sv : old_path.title(),
|
||||
old_filename.is_null() ? "txt"sv : old_path.extension(),
|
||||
Core::File::absolute_path(old_path.dirname()));
|
||||
if (!save_path.has_value()) {
|
||||
return;
|
||||
|
@ -927,7 +927,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_terminal_action()
|
||||
{
|
||||
return GUI::Action::create("Remove &Current Terminal", { Mod_Alt | Mod_Shift, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/remove-terminal.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
return GUI::Action::create("Remove &Current Terminal", { Mod_Alt | Mod_Shift, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/remove-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
auto widget = m_action_tab_widget->active_widget();
|
||||
if (!widget)
|
||||
return;
|
||||
|
@ -953,7 +953,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_tab_widget_action
|
|||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_action()
|
||||
{
|
||||
return GUI::Action::create("Add New &Editor", { Mod_Ctrl | Mod_Alt, Key_E },
|
||||
Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/add-editor.png").release_value_but_fixme_should_propagate_errors(),
|
||||
Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/add-editor.png"sv).release_value_but_fixme_should_propagate_errors(),
|
||||
[this](auto&) {
|
||||
add_new_editor(*m_current_editor_tab_widget);
|
||||
update_actions();
|
||||
|
@ -963,7 +963,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_action()
|
|||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_terminal_action()
|
||||
{
|
||||
return GUI::Action::create("Add New &Terminal", { Mod_Ctrl | Mod_Alt, Key_T },
|
||||
Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/add-terminal.png").release_value_but_fixme_should_propagate_errors(),
|
||||
Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/add-terminal.png"sv).release_value_but_fixme_should_propagate_errors(),
|
||||
[this](auto&) {
|
||||
auto& terminal_wrapper = m_action_tab_widget->add_tab<TerminalWrapper>("Terminal");
|
||||
terminal_wrapper.on_command_exit = [&]() {
|
||||
|
@ -986,13 +986,13 @@ void HackStudioWidget::reveal_action_tab(GUI::Widget& widget)
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action()
|
||||
{
|
||||
return GUI::Action::create("&Debug", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-run.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
return GUI::Action::create("&Debug", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-run.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
if (!Core::File::exists(get_project_executable_path())) {
|
||||
GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
if (Debugger::the().session()) {
|
||||
GUI::MessageBox::show(window(), "Debugger is already running", "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), "Debugger is already running"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1073,7 @@ void HackStudioWidget::initialize_debugger()
|
|||
}
|
||||
|
||||
HackStudioWidget::hide_action_tabs();
|
||||
GUI::MessageBox::show(window(), "Program Exited", "Debugger", GUI::MessageBox::Type::Information);
|
||||
GUI::MessageBox::show(window(), "Program Exited"sv, "Debugger"sv, GUI::MessageBox::Type::Information);
|
||||
});
|
||||
Core::EventLoop::wake_current();
|
||||
});
|
||||
|
@ -1096,7 +1096,7 @@ String HackStudioWidget::get_absolute_path(String const& path) const
|
|||
{
|
||||
// TODO: We can probably do a more specific condition here, something like
|
||||
// "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))"
|
||||
if (path.starts_with("..")) {
|
||||
if (path.starts_with(".."sv)) {
|
||||
return get_full_path_of_serenity_source(path);
|
||||
}
|
||||
return m_project->to_absolute_path(path);
|
||||
|
@ -1106,7 +1106,7 @@ RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(String const& filenam
|
|||
{
|
||||
String file_path = filename;
|
||||
|
||||
if (filename.starts_with("../")) {
|
||||
if (filename.starts_with("../"sv)) {
|
||||
file_path = get_full_path_of_serenity_source(filename);
|
||||
}
|
||||
|
||||
|
@ -1127,7 +1127,7 @@ void HackStudioWidget::build()
|
|||
{
|
||||
auto result = m_project_builder->build(active_file());
|
||||
if (result.is_error()) {
|
||||
GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Build failed", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Build failed"sv, GUI::MessageBox::Type::Error);
|
||||
m_build_action->set_enabled(true);
|
||||
m_stop_action->set_enabled(false);
|
||||
} else {
|
||||
|
@ -1139,7 +1139,7 @@ void HackStudioWidget::run()
|
|||
{
|
||||
auto result = m_project_builder->run(active_file());
|
||||
if (result.is_error()) {
|
||||
GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Run failed", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Run failed"sv, GUI::MessageBox::Type::Error);
|
||||
m_run_action->set_enabled(true);
|
||||
m_stop_action->set_enabled(false);
|
||||
} else {
|
||||
|
@ -1279,7 +1279,7 @@ void HackStudioWidget::create_toolbar(GUI::Widget& parent)
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_build_action()
|
||||
{
|
||||
return GUI::Action::create("&Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/build.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
return GUI::Action::create("&Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/build.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
if (warn_unsaved_changes("There are unsaved changes, do you want to save before building?") == ContinueDecision::No)
|
||||
return;
|
||||
|
||||
|
@ -1290,7 +1290,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_build_action()
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_run_action()
|
||||
{
|
||||
return GUI::Action::create("&Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-run.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
return GUI::Action::create("&Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-run.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
reveal_action_tab(*m_terminal_wrapper);
|
||||
run();
|
||||
});
|
||||
|
@ -1388,14 +1388,14 @@ void HackStudioWidget::create_file_menu(GUI::Window& window)
|
|||
for (auto& new_file_action : m_new_file_actions) {
|
||||
new_submenu.add_action(new_file_action);
|
||||
}
|
||||
new_submenu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors());
|
||||
new_submenu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
new_submenu.add_action(*m_new_plain_file_action);
|
||||
new_submenu.add_separator();
|
||||
new_submenu.add_action(*m_new_directory_action);
|
||||
|
||||
file_menu.add_action(*m_open_action);
|
||||
m_recent_projects_submenu = &file_menu.add_submenu("Open &Recent");
|
||||
m_recent_projects_submenu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-recent.png").release_value_but_fixme_should_propagate_errors());
|
||||
m_recent_projects_submenu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-recent.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
update_recent_projects_submenu();
|
||||
file_menu.add_action(*m_save_action);
|
||||
file_menu.add_action(*m_save_as_action);
|
||||
|
@ -1408,7 +1408,7 @@ void HackStudioWidget::create_file_menu(GUI::Window& window)
|
|||
void HackStudioWidget::create_edit_menu(GUI::Window& window)
|
||||
{
|
||||
auto& edit_menu = window.add_menu("&Edit");
|
||||
edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
reveal_action_tab(*m_find_in_files_widget);
|
||||
m_find_in_files_widget->focus_textbox_and_select_all();
|
||||
}));
|
||||
|
@ -1452,9 +1452,9 @@ void HackStudioWidget::create_view_menu(GUI::Window& window)
|
|||
});
|
||||
auto show_dotfiles_action = GUI::Action::create_checkable("S&how Dotfiles", { Mod_Ctrl, Key_H }, [&](auto& checked) {
|
||||
project().model().set_should_show_dotfiles(checked.is_checked());
|
||||
Config::write_bool("HackStudio", "Global", "ShowDotfiles", checked.is_checked());
|
||||
Config::write_bool("HackStudio"sv, "Global"sv, "ShowDotfiles"sv, checked.is_checked());
|
||||
});
|
||||
show_dotfiles_action->set_checked(Config::read_bool("HackStudio", "Global", "ShowDotfiles", false));
|
||||
show_dotfiles_action->set_checked(Config::read_bool("HackStudio"sv, "Global"sv, "ShowDotfiles"sv, false));
|
||||
|
||||
auto& view_menu = window.add_menu("&View");
|
||||
view_menu.add_action(hide_action_tabs_action);
|
||||
|
@ -1489,7 +1489,7 @@ void HackStudioWidget::create_view_menu(GUI::Window& window)
|
|||
|
||||
m_no_wrapping_action->set_checked(true);
|
||||
|
||||
m_editor_font_action = GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(),
|
||||
m_editor_font_action = GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"sv).release_value_but_fixme_should_propagate_errors(),
|
||||
[&](auto&) {
|
||||
auto picker = GUI::FontPicker::construct(&window, m_editor_font, false);
|
||||
if (picker->exec() == GUI::Dialog::ExecResult::OK) {
|
||||
|
@ -1520,12 +1520,12 @@ void HackStudioWidget::create_view_menu(GUI::Window& window)
|
|||
void HackStudioWidget::create_help_menu(GUI::Window& window)
|
||||
{
|
||||
auto& help_menu = window.add_menu("&Help");
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Hack Studio", GUI::Icon::default_icon("app-hack-studio"), &window));
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Hack Studio", GUI::Icon::default_icon("app-hack-studio"sv), &window));
|
||||
}
|
||||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_stop_action()
|
||||
{
|
||||
auto action = GUI::Action::create("&Stop", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-stop.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
auto action = GUI::Action::create("&Stop", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-stop.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
if (!Debugger::the().session()) {
|
||||
if (auto result = m_terminal_wrapper->kill_running_command(); result.is_error())
|
||||
warnln("{}", result.error());
|
||||
|
@ -1605,7 +1605,7 @@ HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(String
|
|||
if (!any_document_is_dirty())
|
||||
return ContinueDecision::Yes;
|
||||
|
||||
auto result = GUI::MessageBox::show(window(), prompt, "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
|
||||
auto result = GUI::MessageBox::show(window(), prompt, "Unsaved changes"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
|
||||
|
||||
if (result == GUI::MessageBox::ExecResult::Cancel)
|
||||
return ContinueDecision::No;
|
||||
|
@ -1630,7 +1630,7 @@ bool HackStudioWidget::any_document_is_dirty() const
|
|||
|
||||
void HackStudioWidget::update_gml_preview()
|
||||
{
|
||||
auto gml_content = current_editor_wrapper().filename().ends_with(".gml") ? current_editor_wrapper().editor().text() : "";
|
||||
auto gml_content = current_editor_wrapper().filename().ends_with(".gml"sv) ? current_editor_wrapper().editor().text().view() : ""sv;
|
||||
m_gml_preview_widget->load_gml(gml_content);
|
||||
}
|
||||
|
||||
|
@ -1685,7 +1685,7 @@ void HackStudioWidget::on_cursor_change()
|
|||
|
||||
void HackStudioWidget::create_location_history_actions()
|
||||
{
|
||||
m_locations_history_back_action = GUI::Action::create("Go Back", { Mod_Alt | Mod_Shift, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
m_locations_history_back_action = GUI::Action::create("Go Back", { Mod_Alt | Mod_Shift, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
if (m_locations_history_end_index <= 1)
|
||||
return;
|
||||
|
||||
|
@ -1699,7 +1699,7 @@ void HackStudioWidget::create_location_history_actions()
|
|||
update_history_actions();
|
||||
});
|
||||
|
||||
m_locations_history_forward_action = GUI::Action::create("Go Forward", { Mod_Alt | Mod_Shift, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
m_locations_history_forward_action = GUI::Action::create("Go Forward", { Mod_Alt | Mod_Shift, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
if (m_locations_history_end_index == m_locations_history.size())
|
||||
return;
|
||||
|
||||
|
@ -1717,7 +1717,7 @@ void HackStudioWidget::create_location_history_actions()
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_project_configuration_action()
|
||||
{
|
||||
return GUI::Action::create("Project Configuration", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png").release_value(), [&](auto&) {
|
||||
return GUI::Action::create("Project Configuration", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv).release_value(), [&](auto&) {
|
||||
auto parent_directory = LexicalPath::dirname(Project::config_file_path);
|
||||
auto absolute_config_file_path = LexicalPath::absolute_path(m_project->root_path(), Project::config_file_path);
|
||||
|
||||
|
@ -1734,7 +1734,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_project_configuration_a
|
|||
"{\n"
|
||||
" \"build_command\": \"your build command here\",\n"
|
||||
" \"run_command\": \"your run command here\"\n"
|
||||
"}\n");
|
||||
"}\n"sv);
|
||||
file.value()->close();
|
||||
}
|
||||
|
||||
|
@ -1762,9 +1762,9 @@ void HackStudioWidget::update_history_actions()
|
|||
|
||||
RefPtr<Gfx::Font> HackStudioWidget::read_editor_font_from_config()
|
||||
{
|
||||
auto font_family = Config::read_string("HackStudio", "EditorFont", "Family", "Csilla");
|
||||
auto font_variant = Config::read_string("HackStudio", "EditorFont", "Variant", "Regular");
|
||||
auto font_size = Config::read_i32("HackStudio", "EditorFont", "Size", 10);
|
||||
auto font_family = Config::read_string("HackStudio"sv, "EditorFont"sv, "Family"sv, "Csilla"sv);
|
||||
auto font_variant = Config::read_string("HackStudio"sv, "EditorFont"sv, "Variant"sv, "Regular"sv);
|
||||
auto font_size = Config::read_i32("HackStudio"sv, "EditorFont"sv, "Size"sv, 10);
|
||||
|
||||
auto font = Gfx::FontDatabase::the().get(font_family, font_variant, font_size);
|
||||
if (font.is_null())
|
||||
|
@ -1780,9 +1780,9 @@ void HackStudioWidget::change_editor_font(RefPtr<Gfx::Font> font)
|
|||
editor_wrapper.editor().set_font(*m_editor_font);
|
||||
}
|
||||
|
||||
Config::write_string("HackStudio", "EditorFont", "Family", m_editor_font->family());
|
||||
Config::write_string("HackStudio", "EditorFont", "Variant", m_editor_font->variant());
|
||||
Config::write_i32("HackStudio", "EditorFont", "Size", m_editor_font->presentation_size());
|
||||
Config::write_string("HackStudio"sv, "EditorFont"sv, "Family"sv, m_editor_font->family());
|
||||
Config::write_string("HackStudio"sv, "EditorFont"sv, "Variant"sv, m_editor_font->variant());
|
||||
Config::write_i32("HackStudio"sv, "EditorFont"sv, "Size"sv, m_editor_font->presentation_size());
|
||||
}
|
||||
|
||||
void HackStudioWidget::open_coredump(String const& coredump_path)
|
||||
|
@ -1810,7 +1810,7 @@ void HackStudioWidget::for_each_open_file(Function<void(ProjectFile const&)> fun
|
|||
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_toggle_syntax_highlighting_mode_action()
|
||||
{
|
||||
auto action = GUI::Action::create_checkable("&Semantic Highlighting", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-cplusplus.png").release_value_but_fixme_should_propagate_errors(), [this](auto& action) {
|
||||
auto action = GUI::Action::create_checkable("&Semantic Highlighting", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-cplusplus.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto& action) {
|
||||
for (auto& editor_wrapper : m_all_editor_wrappers)
|
||||
editor_wrapper.editor().set_semantic_syntax_highlighting(action.is_checked());
|
||||
});
|
||||
|
|
|
@ -209,7 +209,7 @@ void ConnectionToServerWrapper::on_crash()
|
|||
void ConnectionToServerWrapper::show_frequent_crashes_notification() const
|
||||
{
|
||||
auto notification = GUI::Notification::construct();
|
||||
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors());
|
||||
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
notification->set_title("LanguageServer Crashes too much!");
|
||||
notification->set_text("LanguageServer aided features will not be available in this session");
|
||||
notification->show();
|
||||
|
@ -217,7 +217,7 @@ void ConnectionToServerWrapper::show_frequent_crashes_notification() const
|
|||
void ConnectionToServerWrapper::show_crash_notification() const
|
||||
{
|
||||
auto notification = GUI::Notification::construct();
|
||||
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors());
|
||||
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
notification->set_title("Oops!");
|
||||
notification->set_text(String::formatted("LanguageServer has crashed"));
|
||||
notification->show();
|
||||
|
|
|
@ -63,7 +63,7 @@ bool Project::project_is_serenity() const
|
|||
{
|
||||
// FIXME: Improve this heuristic
|
||||
// Running "Meta/serenity.sh copy-src" installs the serenity repository at this path in the home directory
|
||||
return m_root_path.ends_with("Source/serenity");
|
||||
return m_root_path.ends_with("Source/serenity"sv);
|
||||
}
|
||||
|
||||
NonnullOwnPtr<ProjectConfig> Project::config() const
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
String to_absolute_path(String const&) const;
|
||||
bool project_is_serenity() const;
|
||||
|
||||
static constexpr StringView config_file_path = ".hackstudio/config.json";
|
||||
static constexpr auto config_file_path = ".hackstudio/config.json"sv;
|
||||
NonnullOwnPtr<ProjectConfig> config() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -34,7 +34,7 @@ ErrorOr<void> ProjectBuilder::build(StringView active_file)
|
|||
if (active_file.is_null())
|
||||
return Error::from_string_literal("no active file");
|
||||
|
||||
if (active_file.ends_with(".js")) {
|
||||
if (active_file.ends_with(".js"sv)) {
|
||||
TRY(m_terminal->run_command(String::formatted("js -A {}", active_file)));
|
||||
return {};
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ ErrorOr<void> ProjectBuilder::run(StringView active_file)
|
|||
if (active_file.is_null())
|
||||
return Error::from_string_literal("no active file");
|
||||
|
||||
if (active_file.ends_with(".js")) {
|
||||
if (active_file.ends_with(".js"sv)) {
|
||||
TRY(m_terminal->run_command(String::formatted("js {}", active_file)));
|
||||
return {};
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ ErrorOr<void> ProjectBuilder::initialize_build_directory()
|
|||
}
|
||||
}
|
||||
|
||||
auto cmake_file_path = LexicalPath::join(build_directory(), "CMakeLists.txt").string();
|
||||
auto cmake_file_path = LexicalPath::join(build_directory(), "CMakeLists.txt"sv).string();
|
||||
if (Core::File::exists(cmake_file_path))
|
||||
MUST(Core::File::remove(cmake_file_path, Core::File::RecursionMode::Disallowed, false));
|
||||
|
||||
|
@ -148,7 +148,7 @@ Optional<String> ProjectBuilder::find_cmake_file_for(StringView file_path) const
|
|||
{
|
||||
auto directory = LexicalPath::dirname(file_path);
|
||||
while (!directory.is_empty()) {
|
||||
auto cmake_path = LexicalPath::join(m_project_root, directory, "CMakeLists.txt");
|
||||
auto cmake_path = LexicalPath::join(m_project_root, directory, "CMakeLists.txt"sv);
|
||||
if (Core::File::exists(cmake_path.string()))
|
||||
return cmake_path.string();
|
||||
directory = LexicalPath::dirname(directory);
|
||||
|
|
|
@ -20,13 +20,13 @@ void HackStudio::ProjectDeclarations::set_declared_symbols(String const& filenam
|
|||
|
||||
Optional<GUI::Icon> HackStudio::ProjectDeclarations::get_icon_for(CodeComprehension::DeclarationType type)
|
||||
{
|
||||
static GUI::Icon struct_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Struct.png").release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon class_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Class.png").release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon function_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Function.png").release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon variable_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Variable.png").release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon preprocessor_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Preprocessor.png").release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon member_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Member.png").release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon namespace_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Namespace.png").release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon struct_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Struct.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon class_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Class.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon function_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Function.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon variable_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Variable.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon preprocessor_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Preprocessor.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon member_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Member.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
static GUI::Icon namespace_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Namespace.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
switch (type) {
|
||||
case CodeComprehension::DeclarationType::Struct:
|
||||
return struct_icon;
|
||||
|
|
|
@ -48,7 +48,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(String const& manife
|
|||
|
||||
// Attempt to read in the template icons
|
||||
// Fallback to a generic executable icon if one isn't found
|
||||
auto icon = GUI::Icon::default_icon("filetype-executable");
|
||||
auto icon = GUI::Icon::default_icon("filetype-executable"sv);
|
||||
|
||||
auto bitmap_path_32 = String::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
|
||||
|
||||
|
@ -94,7 +94,7 @@ Result<void, String> ProjectTemplate::create_project(String const& name, String
|
|||
dbgln("Running post-create script '{}'", postcreate_script_path);
|
||||
|
||||
// Generate a namespace-safe project name (replace hyphens with underscores)
|
||||
auto namespace_safe = name.replace("-", "_", ReplaceMode::All);
|
||||
auto namespace_safe = name.replace("-"sv, "_"sv, ReplaceMode::All);
|
||||
|
||||
pid_t child_pid;
|
||||
char const* argv[] = { postcreate_script_path.characters(), name.characters(), path.characters(), namespace_safe.characters(), nullptr };
|
||||
|
|
|
@ -28,8 +28,8 @@ ErrorOr<void> TerminalWrapper::run_command(String const& command, Optional<Strin
|
|||
{
|
||||
if (m_pid != -1) {
|
||||
GUI::MessageBox::show(window(),
|
||||
"A command is already running in this TerminalWrapper",
|
||||
"Can't run command",
|
||||
"A command is already running in this TerminalWrapper"sv,
|
||||
"Can't run command"sv,
|
||||
GUI::MessageBox::Type::Error);
|
||||
return {};
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ ErrorOr<int> TerminalWrapper::setup_master_pseudoterminal(WaitForChildOnExit wai
|
|||
if (WIFEXITED(wstatus)) {
|
||||
m_terminal_widget->inject_string(String::formatted("\033[{};1m(Command exited with code {})\033[0m\r\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus)));
|
||||
} else if (WIFSTOPPED(wstatus)) {
|
||||
m_terminal_widget->inject_string("\033[34;1m(Command stopped!)\033[0m\r\n");
|
||||
m_terminal_widget->inject_string("\033[34;1m(Command stopped!)\033[0m\r\n"sv);
|
||||
} else if (WIFSIGNALED(wstatus)) {
|
||||
m_terminal_widget->inject_string(String::formatted("\033[34;1m(Command signaled with {}!)\033[0m\r\n", strsignal(WTERMSIG(wstatus))));
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto window = GUI::Window::construct();
|
||||
window->resize(840, 600);
|
||||
window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png").release_value_but_fixme_should_propagate_errors());
|
||||
window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
update_path_environment_variable();
|
||||
|
||||
|
@ -112,7 +112,7 @@ static bool make_is_available()
|
|||
static void notify_make_not_available()
|
||||
{
|
||||
auto notification = GUI::Notification::construct();
|
||||
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors());
|
||||
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
notification->set_title("'make' Not Available");
|
||||
notification->set_text("You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository");
|
||||
notification->show();
|
||||
|
@ -128,7 +128,7 @@ static void update_path_environment_variable()
|
|||
|
||||
if (path.length())
|
||||
path.append(":");
|
||||
path.append("/usr/local/sbin:/usr/local/bin:/usr/bin:/bin");
|
||||
path.append("/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv);
|
||||
setenv("PATH", path.to_string().characters(), true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue