Skip to content

Commit c63de0d

Browse files
committed
Merge branch 'gui'
2 parents 07453ab + 158d6ac commit c63de0d

8,621 files changed

Lines changed: 22606 additions & 731 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
# Cached files
3535
.cache
36+
<<<<<<< HEAD
3637
cache
3738
build
3839

@@ -41,3 +42,9 @@ bitPresent
4142

4243
# VSCode
4344
.vscode
45+
=======
46+
build
47+
48+
# Binaries
49+
bitPresent
50+
>>>>>>> gui

.vscode/c_cpp_properties.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "include paths",
5+
"includePath": [
6+
"/usr/lib/wx/include/gtk3-unicode-3.0",
7+
"/usr/include/wx-3.0",
8+
"/usr/include/gtk-3.0",
9+
"/usr/include/pango-1.0",
10+
"/usr/include/glib-2.0",
11+
"/usr/lib/glib-2.0/include",
12+
"/usr/include/harfbuzz",
13+
"/usr/include/freetype2",
14+
"/usr/include/libpng16",
15+
"/usr/include/fribidi",
16+
"/usr/include/cairo",
17+
"/usr/include/pixman-1",
18+
"/usr/include/gdk-pixbuf-2.0",
19+
"/usr/include/libmount",
20+
"/usr/include/blkid",
21+
"/usr/include/gio-unix-2.0",
22+
"/usr/include/atk-1.0",
23+
"/usr/include/at-spi2-atk/2.0",
24+
"/usr/include/dbus-1.0",
25+
"/usr/lib/dbus-1.0/include",
26+
"/usr/include/at-spi-2.0"
27+
]
28+
}
29+
],
30+
"version": 4
31+
}

.vscode/settings.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"files.associations": {
3+
"cctype": "cpp",
4+
"clocale": "cpp",
5+
"cmath": "cpp",
6+
"cstdarg": "cpp",
7+
"cstddef": "cpp",
8+
"cstdio": "cpp",
9+
"cstdlib": "cpp",
10+
"cstring": "cpp",
11+
"ctime": "cpp",
12+
"cwchar": "cpp",
13+
"cwctype": "cpp",
14+
"array": "cpp",
15+
"atomic": "cpp",
16+
"hash_map": "cpp",
17+
"strstream": "cpp",
18+
"bit": "cpp",
19+
"*.tcc": "cpp",
20+
"bitset": "cpp",
21+
"chrono": "cpp",
22+
"codecvt": "cpp",
23+
"complex": "cpp",
24+
"condition_variable": "cpp",
25+
"cstdint": "cpp",
26+
"deque": "cpp",
27+
"list": "cpp",
28+
"map": "cpp",
29+
"set": "cpp",
30+
"unordered_map": "cpp",
31+
"unordered_set": "cpp",
32+
"vector": "cpp",
33+
"exception": "cpp",
34+
"algorithm": "cpp",
35+
"functional": "cpp",
36+
"iterator": "cpp",
37+
"memory": "cpp",
38+
"memory_resource": "cpp",
39+
"numeric": "cpp",
40+
"optional": "cpp",
41+
"random": "cpp",
42+
"ratio": "cpp",
43+
"string": "cpp",
44+
"string_view": "cpp",
45+
"system_error": "cpp",
46+
"tuple": "cpp",
47+
"type_traits": "cpp",
48+
"utility": "cpp",
49+
"fstream": "cpp",
50+
"initializer_list": "cpp",
51+
"iomanip": "cpp",
52+
"iosfwd": "cpp",
53+
"iostream": "cpp",
54+
"istream": "cpp",
55+
"limits": "cpp",
56+
"mutex": "cpp",
57+
"new": "cpp",
58+
"ostream": "cpp",
59+
"sstream": "cpp",
60+
"stdexcept": "cpp",
61+
"streambuf": "cpp",
62+
"thread": "cpp",
63+
"cfenv": "cpp",
64+
"cinttypes": "cpp",
65+
"typeindex": "cpp",
66+
"typeinfo": "cpp",
67+
"valarray": "cpp",
68+
"variant": "cpp",
69+
"future": "cpp"
70+
}
71+
72+
}

Linux/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ vpath %.cc src
33
PRODUCT := bitPresent
44

55
CXX := g++
6-
CXXFLAGS := -c -g
7-
CXXLIBS := -lSDL2 -lSDL2_ttf -lSDL2_image -lhpdf
6+
CXXFLAGS := -c -std=c++17 `wx-config-gtk3 --cxxflags`
7+
CXXLIBS := -lSDL2 -lSDL2_ttf -lSDL2_image -lhpdf `wx-config-gtk3 --libs`
88
CXXINCDIRS := -I.
99

1010
SOURCE := $(shell find . -name *.cc)
@@ -43,4 +43,4 @@ run: $(PRODUCT)
4343
debug: $(PRODUCT)
4444
@gdb $<
4545

46-
-include $(DEPFILES)
46+
-include $(DEPFILES)

Linux/dat/BPLogo.png

12.1 KB
Loading

Linux/dat/BTLogo.png

15 KB
Loading

Linux/src/fileParser.cc

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
#include <algorithm>
2+
#include <vector>
3+
#include <fstream>
4+
5+
#include <filesystem>
6+
namespace fs = std::filesystem;
7+
8+
#include "lib/fileParser.hh"
9+
#include "lib/objects.hh"
10+
#include "lib/gui.hh"
11+
#include "lib/globals.hh"
12+
13+
int nDotWarn = 0;
14+
15+
std::vector<std::string> tokenize(std::string path)
16+
{
17+
std::vector<std::string> tokens;
18+
19+
std::ifstream file(path.c_str());
20+
if (file.fail()) return tokens;
21+
22+
std::string line;
23+
std::string buffer;
24+
int cline = 0;
25+
26+
while (std::getline(file, line))
27+
{
28+
cline += 1;
29+
if (line[0] == '.')
30+
{
31+
int index = line.find(" ");
32+
if (index == std::string::npos)
33+
{
34+
gprintf("[WARNING](Line %d): Invalid '.' command statement. Ignoring\n", cline);
35+
nDotWarn++;
36+
continue;
37+
}
38+
else
39+
{
40+
tokens.push_back(line.substr(0, index));
41+
tokens.push_back(line.substr(index + 1, line.length() - 1));
42+
}
43+
}
44+
else
45+
{
46+
tokens.push_back(line);
47+
}
48+
}
49+
50+
if(Global::useGUI) progress();
51+
52+
file.close();
53+
return tokens;
54+
}
55+
56+
void parse(std::vector<std::string> tokens)
57+
{
58+
int cline = nDotWarn;
59+
60+
if(Global::_PRESENT[Global::_CPRESENT] == nullptr)
61+
{
62+
gprintf("[ERROR]: Presentation object does not exist\n");
63+
return;
64+
}
65+
66+
for (int i = 0; i < tokens.size(); i++)
67+
{
68+
cline += 1;
69+
70+
//Skip empty tokens
71+
if (tokens[i] == "") continue;
72+
73+
//Check for commands
74+
if (tokens[i] == ".background")
75+
{
76+
i += 1;
77+
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') gprintf("[WARNING](Line %d): Using instruction(\"%s\") as argument for '.background'\n", cline, tokens[i].c_str());
78+
Global::_BACKGROUND = tokens[i];
79+
continue;
80+
}
81+
82+
if (tokens[i] == ".image")
83+
{
84+
i += 1;
85+
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') gprintf("[WARNING](Line %d): Using instruction(\"%s\") as argument for '.image'\n", cline, tokens[i].c_str());
86+
if (Global::_CSLIDE < 0) gprintf("[WARNING]: '.image' used outside of a slide. Ignoring...\n");
87+
else Global::_PRESENT[Global::_CPRESENT]->slides[Global::_CSLIDE].image = tokens[i];
88+
continue;
89+
}
90+
91+
if (tokens[i] == ".font")
92+
{
93+
i += 1;
94+
if (tokens[i][0] == '<' || tokens[i][0] == '[' || tokens[i][0] == '-') gprintf("[WARNING](Line %d): Using instruction(\"%s\") as argument for '.image'\n", cline, tokens[i].c_str());
95+
96+
if(fs::path(tokens[i]).is_relative())
97+
{
98+
std::string tmp;
99+
tmp = Global::_INPATH + tokens[i];
100+
tokens[i] = tmp;
101+
}
102+
103+
Global::_FONT = { {"title", TTF_OpenFont(tokens[i].c_str(), 68)}, {"subtitle", TTF_OpenFont(tokens[i].c_str(), 50)}, {"normal", TTF_OpenFont(tokens[i].c_str(), 34)} };
104+
if (Global::_FONT["title"] == NULL || Global::_FONT["subtitle"] == NULL || Global::_FONT["normal"] == NULL)
105+
{
106+
gprintf("[ERROR](Line %d): Error loading font. Reverting to default\n", cline);
107+
Global::_FONT = Global::_DEFAULTFONT;
108+
}
109+
continue;
110+
}
111+
112+
if (tokens[i] == ".color")
113+
{
114+
i += 1;
115+
if (tokens[i] == "default") Global::_TEXTCOLOR = Global::_DEFAULTTEXTCOLOR;
116+
else
117+
{
118+
uint8_t r = std::stoi(tokens[i].substr(0, 2), nullptr, 16);
119+
uint8_t g = std::stoi(tokens[i].substr(2, 2), nullptr, 16);
120+
uint8_t b = std::stoi(tokens[i].substr(4, 2), nullptr, 16);
121+
122+
Global::_TEXTCOLOR = new SDL_Color{ r, g, b };
123+
}
124+
continue;
125+
}
126+
127+
//Check for other defining Tokens
128+
if (tokens[i][0] == '<' && tokens[i][tokens[i].length() - 1] == '>')
129+
{
130+
Global::_PRESENT[Global::_CPRESENT]->slides.push_back(Slide());
131+
Global::_CSLIDE = Global::_CSLIDE + 1;
132+
Global::_CPOINT = -1;
133+
134+
Global::_PRESENT[Global::_CPRESENT]->slides[Global::_CSLIDE].titleSlide = true;
135+
136+
std::string tmp = tokens[i].substr(1, tokens[i].length() - 2);
137+
Global::_PRESENT[Global::_CPRESENT]->slides[Global::_CSLIDE].title = tmp;
138+
continue;
139+
}
140+
141+
if (tokens[i][0] == '[' && tokens[i][tokens[i].length() - 1] == ']')
142+
{
143+
Global::_PRESENT[Global::_CPRESENT]->slides.push_back(Slide());
144+
Global::_CSLIDE = Global::_CSLIDE + 1;
145+
Global::_CPOINT = -1;
146+
147+
std::string tmp = tokens[i].substr(1, tokens[i].length() - 2);
148+
Global::_PRESENT[Global::_CPRESENT]->slides[Global::_CSLIDE].title = tmp;
149+
continue;
150+
}
151+
152+
if (tokens[i][0] == '-' && tokens[i][tokens[i].length() - 1] == '-')
153+
{
154+
if (Global::_CSLIDE < 0) gprintf("[WARNING](Line %d): Defined subtitle outside of a slide. Ignoring...\n", cline);
155+
else
156+
{
157+
std::string tmp = tokens[i].substr(1, tokens[i].length() - 2);
158+
Global::_PRESENT[Global::_CPRESENT]->slides[Global::_CSLIDE].subtitle = tmp;
159+
}
160+
continue;
161+
}
162+
163+
if (tokens[i][0] == '*')
164+
{
165+
if (Global::_CSLIDE < 0) gprintf("[WARNING](Line %d): Defined subpoint outside of a slide. Ignoring...\n", cline);
166+
else if (Global::_CPOINT < 0) gprintf("[WARNING](Line %d): Defined subpoint outside of a point. Ignoring...\n", cline);
167+
else
168+
{
169+
int cutoff = 1;
170+
if (tokens[i][1] == ' ') cutoff = 2;
171+
Global::_PRESENT[Global::_CPRESENT]->slides[Global::_CSLIDE].points[Global::_CPOINT].subPoints.push_back(tokens[i].substr(cutoff, tokens[i].length() - 1));
172+
}
173+
continue;
174+
}
175+
176+
//Add non-special strings as points to slides
177+
if (Global::_CSLIDE < 0) gprintf("[WARNING](Line %d): Defined point outside of a slide. Ignoring...\n", cline);
178+
else
179+
{
180+
Global::_PRESENT[Global::_CPRESENT]->slides[Global::_CSLIDE].points.push_back(Point(tokens[i]));
181+
Global::_CPOINT = Global::_CPOINT + 1;
182+
}
183+
}
184+
185+
tokens.clear();
186+
}

0 commit comments

Comments
 (0)