mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 17:27: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
|
@ -33,7 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec"));
|
||||
|
||||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-chess"));
|
||||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-chess"sv));
|
||||
|
||||
auto window = TRY(GUI::Window::try_create());
|
||||
auto widget = TRY(window->try_set_main_widget<ChessWidget>());
|
||||
|
@ -42,10 +42,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Core::System::unveil("/bin/ChessEngine", "x"));
|
||||
TRY(Core::System::unveil("/etc/passwd", "r"));
|
||||
TRY(Core::System::unveil("/tmp/portal/launch", "rw"));
|
||||
TRY(Core::System::unveil(Core::StandardPaths::home_directory().characters(), "wcbr"));
|
||||
TRY(Core::System::unveil(Core::StandardPaths::home_directory(), "wcbr"sv));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto size = Config::read_i32("Chess", "Display", "size", 512);
|
||||
auto size = Config::read_i32("Chess"sv, "Display"sv, "size"sv, 512);
|
||||
window->set_title("Chess");
|
||||
window->set_base_size({ 4, 4 });
|
||||
window->set_size_increment({ 8, 8 });
|
||||
|
@ -53,10 +53,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
||||
widget->set_piece_set(Config::read_string("Chess", "Style", "PieceSet", "stelar7"));
|
||||
widget->set_board_theme(Config::read_string("Chess", "Style", "BoardTheme", "Beige"));
|
||||
widget->set_coordinates(Config::read_bool("Chess", "Style", "Coordinates", true));
|
||||
widget->set_show_available_moves(Config::read_bool("Chess", "Style", "ShowAvailableMoves", true));
|
||||
widget->set_piece_set(Config::read_string("Chess"sv, "Style"sv, "PieceSet"sv, "stelar7"sv));
|
||||
widget->set_board_theme(Config::read_string("Chess"sv, "Style"sv, "BoardTheme"sv, "Beige"sv));
|
||||
widget->set_coordinates(Config::read_bool("Chess"sv, "Style"sv, "Coordinates"sv, true));
|
||||
widget->set_show_available_moves(Config::read_bool("Chess"sv, "Style"sv, "ShowAvailableMoves"sv, true));
|
||||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"));
|
||||
|
||||
|
@ -75,7 +75,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return;
|
||||
|
||||
if (!widget->import_pgn(import_path.value())) {
|
||||
GUI::MessageBox::show(window, "Unable to import game.\n", "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window, "Unable to import game.\n"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return;
|
||||
|
||||
if (!widget->export_pgn(export_path.value())) {
|
||||
GUI::MessageBox::show(window, "Unable to export game.\n", "Error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window, "Unable to export game.\n"sv, "Error"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -96,11 +96,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Copy FEN", { Mod_Ctrl, Key_C }, [&](auto&) {
|
||||
GUI::Clipboard::the().set_data(widget->get_fen().bytes());
|
||||
GUI::MessageBox::show(window, "Board state copied to clipboard as FEN.", "Copy FEN", GUI::MessageBox::Type::Information);
|
||||
GUI::MessageBox::show(window, "Board state copied to clipboard as FEN."sv, "Copy FEN"sv, GUI::MessageBox::Type::Information);
|
||||
})));
|
||||
TRY(game_menu->try_add_separator());
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
if (widget->board().game_result() == Chess::Board::Result::NotFinished) {
|
||||
if (widget->resign() < 0)
|
||||
return;
|
||||
|
@ -124,7 +124,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto action = GUI::Action::create_checkable(set, [&](auto& action) {
|
||||
widget->set_piece_set(action.text());
|
||||
widget->update();
|
||||
Config::write_string("Chess", "Style", "PieceSet", action.text());
|
||||
Config::write_string("Chess"sv, "Style"sv, "PieceSet"sv, action.text());
|
||||
});
|
||||
|
||||
piece_set_action_group.add_action(*action);
|
||||
|
@ -136,13 +136,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::ActionGroup board_theme_action_group;
|
||||
board_theme_action_group.set_exclusive(true);
|
||||
auto board_theme_menu = TRY(style_menu->try_add_submenu("Board Theme"));
|
||||
board_theme_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/chess/mini-board.png").release_value_but_fixme_should_propagate_errors());
|
||||
board_theme_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/chess/mini-board.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
for (auto const& theme : { "Beige", "Green", "Blue" }) {
|
||||
auto action = GUI::Action::create_checkable(theme, [&](auto& action) {
|
||||
widget->set_board_theme(action.text());
|
||||
widget->update();
|
||||
Config::write_string("Chess", "Style", "BoardTheme", action.text());
|
||||
Config::write_string("Chess"sv, "Style"sv, "BoardTheme"sv, action.text());
|
||||
});
|
||||
board_theme_action_group.add_action(*action);
|
||||
if (widget->board_theme().name == theme)
|
||||
|
@ -153,7 +153,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto coordinates_action = GUI::Action::create_checkable("Coordinates", [&](auto& action) {
|
||||
widget->set_coordinates(action.is_checked());
|
||||
widget->update();
|
||||
Config::write_bool("Chess", "Style", "Coordinates", action.is_checked());
|
||||
Config::write_bool("Chess"sv, "Style"sv, "Coordinates"sv, action.is_checked());
|
||||
});
|
||||
coordinates_action->set_checked(widget->coordinates());
|
||||
TRY(style_menu->try_add_action(coordinates_action));
|
||||
|
@ -161,7 +161,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto show_available_moves_action = GUI::Action::create_checkable("Show Available Moves", [&](auto& action) {
|
||||
widget->set_show_available_moves(action.is_checked());
|
||||
widget->update();
|
||||
Config::write_bool("Chess", "Style", "ShowAvailableMoves", action.is_checked());
|
||||
Config::write_bool("Chess"sv, "Style"sv, "ShowAvailableMoves"sv, action.is_checked());
|
||||
});
|
||||
show_available_moves_action->set_checked(widget->show_available_moves());
|
||||
TRY(style_menu->try_add_action(show_available_moves_action));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue