mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
keymap: Port to LibMain :^)
This commit is contained in:
parent
8b5c0e8e71
commit
120168203e
Notes:
sideshowbarker
2024-07-18 00:47:46 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/120168203e9
2 changed files with 13 additions and 35 deletions
|
@ -71,7 +71,7 @@ target_link_libraries(gunzip LibCompress)
|
|||
target_link_libraries(gzip LibCompress)
|
||||
target_link_libraries(id LibMain)
|
||||
target_link_libraries(js LibJS LibLine LibMain)
|
||||
target_link_libraries(keymap LibKeyboard)
|
||||
target_link_libraries(keymap LibKeyboard LibMain)
|
||||
target_link_libraries(lspci LibPCIDB)
|
||||
target_link_libraries(lsusb LibUSBDB)
|
||||
target_link_libraries(man LibMarkdown)
|
||||
|
|
|
@ -6,52 +6,30 @@
|
|||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibKeyboard/CharacterMap.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio setkeymap getkeymap rpath wpath cpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/res/keymaps", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/etc/Keyboard.ini", "rwc") < 0) {
|
||||
perror("unveil /etc/Keyboard.ini");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio setkeymap getkeymap rpath wpath cpath", nullptr));
|
||||
TRY(Core::System::unveil("/res/keymaps", "r"));
|
||||
TRY(Core::System::unveil("/etc/Keyboard.ini", "rwc"));
|
||||
|
||||
const char* path = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(path, "The mapping file to be used", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
if (path && path[0] == '/') {
|
||||
if (unveil(path, "r") < 0) {
|
||||
perror("unveil path");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (path && path[0] == '/')
|
||||
TRY(Core::System::unveil(path, "r"));
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
if (!path) {
|
||||
auto keymap = Keyboard::CharacterMap::fetch_system_map();
|
||||
if (keymap.is_error()) {
|
||||
warnln("getkeymap: {}", keymap.error());
|
||||
return 1;
|
||||
}
|
||||
|
||||
outln("{}", keymap.value().character_map_name());
|
||||
auto keymap = TRY(Keyboard::CharacterMap::fetch_system_map());
|
||||
outln("{}", keymap.character_map_name());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue