Skip to content

Commit d2932da

Browse files
authored
Merge branch 'main' into main
2 parents cf2a999 + ab398ff commit d2932da

File tree

10 files changed

+234
-177
lines changed

10 files changed

+234
-177
lines changed

src/Core/BetterCode

7.86 MB
Binary file not shown.

src/Core/datatypes.cpp

Lines changed: 68 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -84,53 +84,53 @@ better::Text better::backspace(better::Text text) { //couple of bugs with backsp
8484
}; //Text end
8585
}
8686
return
87-
{
88-
text.textEdit.erase(text.cursor.row),
89-
{text.cursor.row - 1, static_cast<int>(text.textEdit[text.cursor.row - 1].size())},
90-
{
91-
{false,false,false,false},
92-
text.data.isShift,
93-
text.data.isCaps,
94-
text.data.isScroll,
95-
text.data.isCtrl,
96-
text.data.clearHistory,
97-
text.data.switchEditor,
98-
-1,
99-
text.data.menu,
100-
text.data.filename,
101-
text.data.textHeight,
102-
text.data.textWidth
103-
},
104-
text.cursor.row >= text.textEdit.size() - 1 ? text.topLineNumber - 1 : text.topLineNumber,
105-
text.topColumnNumber,
106-
text.highlightStart,
107-
text.highlightEnd
108-
};
87+
{ //Text start
88+
text.textEdit.erase(text.cursor.row), //textEdit
89+
{text.cursor.row - 1, static_cast<int>(text.textEdit[text.cursor.row - 1].size())}, //cursor
90+
{ //data start
91+
{false,false,false,false}, //menusToDraw
92+
text.data.isShift, //isShift
93+
text.data.isCaps, //isCaps
94+
text.data.isScroll, //isScroll
95+
text.data.isCtrl, //isCtrl
96+
text.data.clearHistory, //clearHistory
97+
text.data.switchEditor, //switchEditor
98+
-1, //index
99+
text.data.menu, //menu
100+
text.data.filename, //filename
101+
text.data.textHeight, //textHeight
102+
text.data.textWidth //textWidth
103+
}, //data end
104+
text.cursor.row >= text.textEdit.size() - 1 ? text.topLineNumber - 1 : text.topLineNumber, //topLineNumber
105+
text.topColumnNumber, //topColumnNumber
106+
text.highlightStart, //highlightStart
107+
text.highlightEnd //highlightEnd
108+
}; //Text end
109109
}
110110

111111
return
112-
{
113-
text.textEdit.set(text.cursor.row,newLine),
114-
{text.cursor.row, text.cursor.column - 1},
115-
{
116-
{false,false,false,false},
117-
text.data.isShift,
118-
text.data.isCaps,
119-
text.data.isScroll,
120-
text.data.isCtrl,
121-
text.data.clearHistory,
122-
text.data.switchEditor,
123-
-1,
124-
text.data.menu,
125-
text.data.filename,
126-
text.data.textHeight,
127-
text.data.textWidth
128-
},
129-
text.topLineNumber,
130-
text.topColumnNumber,
131-
text.highlightStart,
132-
text.highlightEnd
133-
};
112+
{ //Text start
113+
text.textEdit.set(text.cursor.row,newLine), //textEdit
114+
{text.cursor.row, text.cursor.column - 1}, //cursor
115+
{ //data start
116+
{false,false,false,false}, //menusToDraw
117+
text.data.isShift, //isShift
118+
text.data.isCaps, //isCaps
119+
text.data.isScroll, //isScroll
120+
text.data.isCtrl, //isCtrl
121+
text.data.clearHistory, //clearHistory
122+
text.data.switchEditor, //switchEditor
123+
-1, //index
124+
text.data.menu, //menu
125+
text.data.filename, //filename
126+
text.data.textHeight, //textHeight
127+
text.data.textWidth //textWidth
128+
}, //data end
129+
text.topLineNumber, //topLineNumber
130+
text.topColumnNumber, //topColumnNumber
131+
text.highlightStart, //highlightStart
132+
text.highlightEnd //hightlightEnd
133+
}; //Text end
134134
}
135135

136136
better::Text better::newLine(better::Text textEdit, bool autoIndent) { //create cases for the following: newline at start of line, newline at end of line, newline in middle of line, newline at end of text
@@ -145,26 +145,26 @@ better::Text better::newLine(better::Text textEdit, bool autoIndent) { //create
145145
better::Text newText
146146
{
147147
endOfText ? textEdit.textEdit.set(textEdit.cursor.row, textEdit.textEdit[textEdit.cursor.row].take(textEdit.cursor.column)).push_back(textEdit.textEdit[textEdit.cursor.row].drop(textEdit.cursor.column)) :
148-
textEdit.textEdit.insert(textEdit.cursor.row + 1, textEdit.textEdit[textEdit.cursor.row].drop(textEdit.cursor.column)).set(textEdit.cursor.row, textEdit.textEdit[textEdit.cursor.row].take(textEdit.cursor.column)),
149-
{textEdit.cursor.row + 1, 0},
150-
{
151-
{false,false,false,false},
152-
textEdit.data.isShift,
153-
textEdit.data.isCaps,
154-
textEdit.data.isScroll,
155-
textEdit.data.isCtrl,
156-
textEdit.data.clearHistory,
157-
textEdit.data.switchEditor,
158-
-1,
159-
textEdit.data.menu,
160-
textEdit.data.filename,
161-
textEdit.data.textHeight,
162-
textEdit.data.textWidth
163-
},
164-
endOfText ? (textSizeRightSize ? textEdit.topLineNumber + 1 : 0) : textEdit.topLineNumber,
165-
0,
166-
textEdit.highlightStart,
167-
textEdit.highlightEnd
148+
textEdit.textEdit.insert(textEdit.cursor.row + 1, textEdit.textEdit[textEdit.cursor.row].drop(textEdit.cursor.column)).set(textEdit.cursor.row, textEdit.textEdit[textEdit.cursor.row].take(textEdit.cursor.column)), //textEdit
149+
{textEdit.cursor.row + 1, 0}, //cursor
150+
{ //data start
151+
{false,false,false,false}, //menusToDraw
152+
textEdit.data.isShift, //isShift
153+
textEdit.data.isCaps, //isCaps
154+
textEdit.data.isScroll, //isScroll
155+
textEdit.data.isCtrl, //isCtrl
156+
textEdit.data.clearHistory, //clearHistory
157+
textEdit.data.switchEditor, //switchEditor
158+
-1, //index
159+
textEdit.data.menu, //menu
160+
textEdit.data.filename, //filename
161+
textEdit.data.textHeight, //textHeight
162+
textEdit.data.textWidth //textWidth
163+
}, //data end
164+
endOfText ? (textSizeRightSize ? textEdit.topLineNumber + 1 : 0) : textEdit.topLineNumber, //topLineNumber
165+
0, //index
166+
textEdit.highlightStart, //highlightStart
167+
textEdit.highlightEnd //highlightEnd
168168
};
169169

170170
texts.push_back(newText);
@@ -179,18 +179,10 @@ better::Text better::newLine(better::Text textEdit, bool autoIndent) { //create
179179
return texts.back();
180180
}
181181

182-
better::charMapArr better::makeCharMapArr(::Uint8 charArray[16]) {
183-
better::charMapArr tempArr {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
184-
for(int i{}; i < 16; ++i) {
185-
tempArr.arr[i] = charArray[i];
186-
}
187-
return tempArr;
188-
}
189-
190-
better::Cursor better::findCursorPos(int topLine, int topColumn, SDL_Event event, int columnOffset) { //change this to switch between different editors in splitscreen
191-
int relativeColumn {static_cast<int>(event.button.x / 8)};
192-
int relativeRow {static_cast<int>(event.button.y / 16) - 1};
193-
return better::Cursor {relativeRow + topLine, relativeColumn + topColumn - static_cast<int>(columnOffset / 8)};
182+
better::Cursor better::findCursorPos(int topLine, int topColumn, SDL_Event event, int columnOffset, int characterHeight, int characterWidth) { //change this to switch between different editors in splitscreen
183+
int relativeColumn {static_cast<int>(event.button.x / characterWidth)};
184+
int relativeRow {static_cast<int>(event.button.y / characterHeight) - 1};
185+
return better::Cursor {relativeRow + topLine, relativeColumn + topColumn - static_cast<int>(columnOffset / characterWidth)};
194186
}
195187

196188
Uint8 better::getRed(Uint32 color) {

src/Core/datatypes.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct Cursor { //store the line number and column number of the cursor
1616
int column;
1717
};
1818

19-
better::Cursor findCursorPos(int topLine, int topColumn, SDL_Event event, int columnOffset);
19+
better::Cursor findCursorPos(int topLine, int topColumn, SDL_Event event, int columnOffset, int characterHeight, int characterWidth);
2020

2121
struct editorData {
2222
bool menusToDraw[4] = {false, false, false, false};
@@ -43,12 +43,6 @@ struct Text {
4343
better::Cursor highlightEnd {0,0};
4444
};
4545

46-
struct charMapArr {
47-
::Uint8 arr[16];
48-
};
49-
50-
better::charMapArr makeCharMapArr(::Uint8 charArray[16]);
51-
5246
better::Text updateText(better::Text textEdit, char newChar);
5347
better::Text backspace(better::Text textEdit);
5448
better::Text newLine(better::Text textEdit, bool autoIndent);

src/Core/fileUtils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ std::filesystem::path better::fileDialog(std::optional<std::filesystem::path> fo
138138
}
139139

140140
SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, 0x22, 0x22, 0x22, 0xFF));
141-
better::renderText(surface, text.textEdit, text.topLineNumber, text.topColumnNumber, 35, 100, text.highlightStart, text.highlightEnd, 0x222222FF, 0x5588AAFF, 0x222222FF, 0x5588AAFF, 0x5588AAFF, 0);
142-
better::drawMenuBar(surface, menu, 0xDDDDDDFF, 0x666666FF, 800, 0);
141+
better::renderText(surface, text.textEdit, text.topLineNumber, text.topColumnNumber, 35, 100, text.highlightStart, text.highlightEnd, 0x222222FF, 0x5588AAFF, 0x222222FF, 0x5588AAFF, 0x5588AAFF, 0, 16, 8);
142+
better::drawMenuBar(surface, menu, 0xDDDDDDFF, 0x666666FF, 800, 0, 16, 8);
143143
SDL_UpdateWindowSurface(window);
144144
SDL_FillRect(surface, &screen, SDL_MapRGBA(surface->format, 0x22, 0x22, 0x22, 0xFF));
145145

@@ -154,12 +154,12 @@ std::filesystem::path better::fileDialog(std::optional<std::filesystem::path> fo
154154
text.topLineNumber = newText.topLineNumber;
155155
text.topColumnNumber = newText.topColumnNumber;
156156
text.data.isScroll = true;
157-
better::renderText(surface, text.textEdit, text.topLineNumber, text.topColumnNumber, 35, 100, text.highlightStart, text.highlightEnd, 0x222222FF, 0x5588AAFF, 0x222222FF, 0x5588AAFF, 0x5588AAFF, 0);
157+
better::renderText(surface, text.textEdit, text.topLineNumber, text.topColumnNumber, 35, 100, text.highlightStart, text.highlightEnd, 0x222222FF, 0x5588AAFF, 0x222222FF, 0x5588AAFF, 0x5588AAFF, 0, 16, 8);
158158
SDL_UpdateWindowSurface(window);
159159
SDL_FillRect(surface, &screen, SDL_MapRGBA(surface->format, 0x22, 0x22, 0x22, 0xFF));
160160
}
161161
else if(event.type == SDL_MOUSEBUTTONDOWN) {
162-
text.cursor = better::findCursorPos(text.topLineNumber, text.topColumnNumber, event, 0);
162+
text.cursor = better::findCursorPos(text.topLineNumber, text.topColumnNumber, event, 0, 16, 8);
163163
if((text.cursor.row > text.textEdit.size() - 1) && text.cursor.row > -1) {
164164
continue;
165165
}
@@ -195,7 +195,7 @@ std::filesystem::path better::fileDialog(std::optional<std::filesystem::path> fo
195195
text.topColumnNumber = 0;
196196
text.topLineNumber = 0;
197197

198-
better::renderText(surface, text.textEdit, text.topLineNumber, text.topColumnNumber, 35, 100, text.highlightStart, text.highlightEnd, 0x222222FF, 0x5588AAFF, 0x222222FF, 0x5588AAFF, 0x5588AAFF, 0);
198+
better::renderText(surface, text.textEdit, text.topLineNumber, text.topColumnNumber, 35, 100, text.highlightStart, text.highlightEnd, 0x222222FF, 0x5588AAFF, 0x222222FF, 0x5588AAFF, 0x5588AAFF, 0, 16, 8);
199199
SDL_UpdateWindowSurface(window);
200200
SDL_FillRect(surface, &screen, SDL_MapRGBA(surface->format, 0x22, 0x22, 0x22, 0xFF));
201201
continue;
@@ -231,7 +231,7 @@ std::filesystem::path better::fileDialog(std::optional<std::filesystem::path> fo
231231
text.topColumnNumber = 0;
232232
text.topLineNumber = 0;
233233

234-
better::renderText(surface, text.textEdit, text.topLineNumber, text.topColumnNumber, 35, 100, text.highlightStart, text.highlightEnd, 0x222222FF, 0x5588AAFF, 0x222222FF, 0x5588AAFF, 0x5588AAFF, 0);
234+
better::renderText(surface, text.textEdit, text.topLineNumber, text.topColumnNumber, 35, 100, text.highlightStart, text.highlightEnd, 0x222222FF, 0x5588AAFF, 0x222222FF, 0x5588AAFF, 0x5588AAFF, 0, 16, 8);
235235
SDL_UpdateWindowSurface(window);
236236
SDL_FillRect(surface, &screen, SDL_MapRGBA(surface->format, 0x22, 0x22, 0x22, 0xFF));
237237
}

0 commit comments

Comments
 (0)