MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / main

Function main

Applications/TextEdit/main.cpp:146–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146int main(int argc, char** argv){
147 window = new Lemon::GUI::Window("Text Editor", {512, 256}, WINDOW_FLAGS_RESIZABLE, Lemon::GUI::WindowType::GUI);
148 window->CreateMenuBar();
149
150 fileMenu.first = "File";
151 fileMenu.second.push_back({.id = TEXTEDIT_OPEN, .name = std::string("Open...")});
152 fileMenu.second.push_back({.id = TEXTEDIT_SAVEAS, .name = std::string("Save As...")});
153 fileMenu.second.push_back({.id = TEXTEDIT_SAVE, .name = std::string("Save...")});
154
155 window->menuBar->items.push_back(fileMenu);
156
157 window->OnMenuCmd = OnWindowCmd;
158 window->OnPaint = OnWindowPaint;
159
160 textBox = new ExtendedTextBox({{0, 0}, {0, 20}});
161 window->AddWidget(textBox);
162 textBox->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::WidgetAlignment::WAlignLeft);
163
164 textBox->font = Lemon::Graphics::LoadFont("/initrd/sourcecodepro.ttf", "monospace", 12);
165 textBox->multiline = true;
166 textBox->editable = true;
167
168 if(argc > 1){
169 LoadFile(argv[1]);
170 }
171
172 while(!window->closed){
173 Lemon::LemonEvent ev;
174 while(window->PollEvent(ev)){
175 window->GUIHandleEvent(ev);
176 }
177
178 window->Paint();
179 }
180
181 delete window;
182 return 0;
183}

Callers

nothing calls this directly

Calls 8

LoadFontFunction · 0.85
LoadFileFunction · 0.85
CreateMenuBarMethod · 0.80
SetLayoutMethod · 0.80
PollEventMethod · 0.80
GUIHandleEventMethod · 0.80
AddWidgetMethod · 0.45
PaintMethod · 0.45

Tested by

no test coverage detected