ladybird/Applications/TextEditor/main.cpp
Andreas Kling f813bb52a2 Applications+DevTools+MenuApplets: Drop "unix" pledge when possible
Now that the "unix" pledge is no longer required for socket I/O, we can
drop it after making the connections we need in a program.

In most GUI program cases, once we've connected to the WindowServer by
instantiating a GApplication, we no longer need "unix" :^)
2020-01-12 12:03:57 +01:00

41 lines
1 KiB
C++

#include "TextEditorWidget.h"
#include <LibDraw/PNGLoader.h>
#include <stdio.h>
int main(int argc, char** argv)
{
if (pledge("stdio rpath cpath wpath shared_buffer unix fattr", nullptr) < 0) {
perror("pledge");
return 1;
}
GApplication app(argc, argv);
if (pledge("stdio rpath cpath wpath shared_buffer", nullptr) < 0) {
perror("pledge");
return 1;
}
auto window = GWindow::construct();
window->set_title("Text Editor");
window->set_rect(20, 200, 640, 400);
auto text_widget = TextEditorWidget::construct();
window->set_main_widget(text_widget);
text_widget->editor().set_focus(true);
window->on_close_request = [&]() -> GWindow::CloseRequestDecision {
if (text_widget->request_close())
return GWindow::CloseRequestDecision::Close;
return GWindow::CloseRequestDecision::StayOpen;
};
if (argc >= 2)
text_widget->open_sesame(argv[1]);
window->show();
window->set_icon(load_png("/res/icons/TextEditor16.png"));
return app.exec();
}