Skip to content

Commit 9bfa2e7

Browse files
committed
Add simple text editor to view files
1 parent d35ba2f commit 9bfa2e7

File tree

10 files changed

+112
-26
lines changed

10 files changed

+112
-26
lines changed

applications/calculator/src/calculator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2020

2121
#include <calculator.hpp>
22-
#include <libfenster/button.hpp>
23-
#include <libfenster/label.hpp>
24-
#include <libfenster/text_field.hpp>
22+
#include <libfenster/components/button.hpp>
23+
#include <libfenster/components/label.hpp>
24+
#include <libfenster/components/text_field.hpp>
2525
#include <libfenster/application.hpp>
26-
#include <libfenster/window.hpp>
26+
#include <libfenster/components/window.hpp>
2727
#include <libfenster/metrics/rectangle.hpp>
2828

2929
#include <algorithm>

applications/desktop/src/background.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include "item.hpp"
2727
#include "item_organizer.hpp"
2828

29-
#include <libfenster/canvas.hpp>
30-
#include <libfenster/selection.hpp>
29+
#include <libfenster/components/canvas.hpp>
30+
#include <libfenster/components/selection.hpp>
3131
#include <vector>
3232

3333
using namespace fenster;

applications/desktop/src/item.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#ifndef DESKTOP_ITEM
2222
#define DESKTOP_ITEM
2323

24-
#include <libfenster/canvas.hpp>
25-
#include <libfenster/label.hpp>
24+
#include <libfenster/components/canvas.hpp>
25+
#include <libfenster/components/label.hpp>
2626
#include <cairo/cairo.h>
2727

2828
using namespace fenster;

applications/desktop/src/taskbar.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#ifndef DESKTOP_TASKBAR
2222
#define DESKTOP_TASKBAR
2323

24-
#include <libfenster/canvas.hpp>
25-
#include <libfenster/selection.hpp>
26-
#include <libfenster/window.hpp>
24+
#include <libfenster/components/canvas.hpp>
25+
#include <libfenster/components/selection.hpp>
26+
#include <libfenster/components/window.hpp>
2727
#include <libfenster/font/text_layouter.hpp>
2828
#include <vector>
2929

applications/editor/build.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
ROOT="../.."
3+
if [ -f "$ROOT/variables.sh" ]; then
4+
. "$ROOT/variables.sh"
5+
fi
6+
. "$ROOT/ghost.sh"
7+
8+
# Build configuration
9+
ARTIFACT_NAME="editor.bin"
10+
CFLAGS_ADD="-I$SYSROOT_SYSTEM_INCLUDE/freetype2"
11+
LDFLAGS="-lproperties -linput -lfenster -lcairo -lfreetype -lpixman-1 -lpng -lz"
12+
13+
# Include application build tasks
14+
. "../applications.sh"

applications/editor/src/editor.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2+
* *
3+
* Ghost, a micro-kernel based operating system for the x86 architecture *
4+
* Copyright (C) 2025, Max Schlüssel <[email protected]> *
5+
* *
6+
* This program is free software: you can redistribute it and/or modify *
7+
* it under the terms of the GNU General Public License as published by *
8+
* the Free Software Foundation, either version 3 of the License, or *
9+
* (at your option) any later version. *
10+
* *
11+
* This program is distributed in the hope that it will be useful, *
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14+
* GNU General Public License for more details. *
15+
* *
16+
* You should have received a copy of the GNU General Public License *
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
18+
* *
19+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20+
21+
#include <libfenster/components/button.hpp>
22+
#include <libfenster/application.hpp>
23+
#include <libfenster/components/window.hpp>
24+
#include <libfenster/layout/grid_layout.hpp>
25+
#include <libfenster/components/text_area.hpp>
26+
#include <fstream>
27+
#include <string>
28+
#include <iterator>
29+
30+
using namespace fenster;
31+
32+
int main(int argc, char* argv[])
33+
{
34+
if(Application::open() != ApplicationOpenStatus::Success)
35+
{
36+
klog("failed to create UI");
37+
return -1;
38+
}
39+
40+
Window* window = Window::create();
41+
window->setBounds(Rectangle(0, 0, 600, 400));
42+
window->setTitle("Editor");
43+
window->onClose([]() { g_exit(0); });
44+
45+
auto windowLayout = GridLayout::create(window);
46+
47+
auto textArea = TextArea::create();
48+
window->addChild(textArea);
49+
50+
if(argc > 1)
51+
{
52+
std::ifstream file(argv[1], std::ios::binary); // open in binary mode
53+
if(file)
54+
{
55+
textArea->setTitle(std::string(std::istreambuf_iterator<char>(file),
56+
std::istreambuf_iterator<char>()).c_str());
57+
}
58+
}
59+
60+
window->setVisible(true);
61+
window->onClose([]()
62+
{
63+
g_exit(0);
64+
});
65+
66+
for(;;)
67+
g_sleep(9999);
68+
}

applications/fenster

Submodule fenster updated 67 files

applications/navigator/src/navigator.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
* *
1919
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2020

21-
#include <libfenster/button.hpp>
21+
#include <libfenster/components/button.hpp>
2222
#include <libfenster/application.hpp>
23-
#include <libfenster/window.hpp>
23+
#include <libfenster/components/window.hpp>
2424
#include <libfenster/interface.hpp>
25-
#include <libfenster/text_field.hpp>
26-
#include <libfenster/panel.hpp>
27-
#include <libfenster/scrollpane.hpp>
28-
#include <libfenster/label.hpp>
29-
#include <libfenster/image.hpp>
25+
#include <libfenster/components/text_field.hpp>
26+
#include <libfenster/components/panel.hpp>
27+
#include <libfenster/components/scrollpane.hpp>
28+
#include <libfenster/components/label.hpp>
29+
#include <libfenster/components/image.hpp>
3030
#include <libfenster/listener/key_listener.hpp>
3131
#include <libfenster/layout/flex_layout.hpp>
3232
#include <libfenster/layout/grid_layout.hpp>
@@ -280,6 +280,10 @@ void navigatorLoad(bool keepHistory)
280280
{
281281
g_spawn(path.c_str(), "", ".", G_SECURITY_LEVEL_APPLICATION);
282282
}
283+
else
284+
{
285+
g_spawn("/applications/editor.bin", path.c_str(), ".", G_SECURITY_LEVEL_APPLICATION);
286+
}
283287
}
284288
}
285289
else

applications/terminal/src/screen/gui/gui_screen.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
#include <list>
3030
#include <map>
3131

32-
#include <libfenster/button.hpp>
33-
#include <libfenster/canvas.hpp>
32+
#include <libfenster/components/button.hpp>
33+
#include <libfenster/components/canvas.hpp>
3434
#include <libfenster/listener/focus_listener.hpp>
3535
#include <libfenster/listener/key_listener.hpp>
3636
#include <libfenster/application.hpp>
37-
#include <libfenster/window.hpp>
37+
#include <libfenster/components/window.hpp>
3838

3939
class canvas_resize_bounds_listener_t;
4040
class input_key_listener_t;

applications/testprogram/src/tester.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
#include "tester.hpp"
2222

2323
#include <libfenster/application.hpp>
24-
#include <libfenster/window.hpp>
25-
#include <libfenster/panel.hpp>
24+
#include <libfenster/components/window.hpp>
25+
#include <libfenster/components/panel.hpp>
2626
#include <cstdio>
27-
#include <libfenster/checkbox.hpp>
28-
#include <libfenster/label.hpp>
27+
#include <libfenster/components/checkbox.hpp>
28+
#include <libfenster/components/label.hpp>
2929
#include <libfenster/layout/stack_layout.hpp>
3030

3131
int main(int argc, char** argv)

0 commit comments

Comments
 (0)