|
@@ -8,22 +8,19 @@
|
|
|
#include "MainWidget.h"
|
|
|
#include <LibConfig/Client.h>
|
|
|
#include <LibCore/ArgsParser.h>
|
|
|
-#include <LibCore/File.h>
|
|
|
-#include <LibCore/StandardPaths.h>
|
|
|
+#include <LibCore/System.h>
|
|
|
#include <LibFileSystemAccessClient/Client.h>
|
|
|
#include <LibGUI/Menubar.h>
|
|
|
#include <LibGUI/MessageBox.h>
|
|
|
+#include <LibMain/Main.h>
|
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
-int main(int argc, char** argv)
|
|
|
+ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
|
{
|
|
|
- if (pledge("stdio recvfd sendfd thread rpath cpath wpath unix", nullptr) < 0) {
|
|
|
- perror("pledge");
|
|
|
- return 1;
|
|
|
- }
|
|
|
+ TRY(Core::System::pledge("stdio recvfd sendfd thread rpath cpath wpath unix", nullptr));
|
|
|
|
|
|
- auto app = GUI::Application::construct(argc, argv);
|
|
|
+ auto app = TRY(GUI::Application::try_create(arguments));
|
|
|
|
|
|
Config::pledge_domains("TextEditor");
|
|
|
|
|
@@ -32,36 +29,19 @@ int main(int argc, char** argv)
|
|
|
Core::ArgsParser parser;
|
|
|
parser.add_option(preview_mode, "Preview mode, one of 'none', 'html', 'markdown', 'auto'", "preview-mode", '\0', "mode");
|
|
|
parser.add_positional_argument(file_to_edit, "File to edit, with optional starting line and column number", "file[:line[:column]]", Core::ArgsParser::Required::No);
|
|
|
+ parser.parse(arguments);
|
|
|
|
|
|
- parser.parse(argc, argv);
|
|
|
-
|
|
|
- if (unveil("/res", "r") < 0) {
|
|
|
- perror("unveil");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- if (unveil("/tmp/portal/launch", "rw") < 0) {
|
|
|
- perror("unveil");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- if (unveil("/tmp/portal/webcontent", "rw") < 0) {
|
|
|
- perror("unveil");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- if (unveil("/tmp/portal/filesystemaccess", "rw") < 0) {
|
|
|
- perror("unveil");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- unveil(nullptr, nullptr);
|
|
|
+ TRY(Core::System::unveil("/res", "r"));
|
|
|
+ TRY(Core::System::unveil("/tmp/portal/launch", "rw"));
|
|
|
+ TRY(Core::System::unveil("/tmp/portal/webcontent", "rw"));
|
|
|
+ TRY(Core::System::unveil("/tmp/portal/filesystemaccess", "rw"));
|
|
|
+ TRY(Core::System::unveil(nullptr, nullptr));
|
|
|
|
|
|
StringView preview_mode_view = preview_mode;
|
|
|
|
|
|
auto app_icon = GUI::Icon::default_icon("app-text-editor");
|
|
|
|
|
|
- auto window = GUI::Window::construct();
|
|
|
+ auto window = TRY(GUI::Window::try_create());
|
|
|
window->resize(640, 400);
|
|
|
|
|
|
auto& text_widget = window->set_main_widget<MainWidget>();
|