@@ -10,7 +10,7 @@ better::Text better::updateText(better::Text textEdit, char newChar) {
1010 bool endOfLine {textEdit.cursor .column == textEdit.textEdit [textEdit.cursor .row ].size ()};
1111 bool endOfScreen {textEdit.cursor .column + 1 >= textEdit.topColumnNumber + textWidth};
1212 immer::flex_vector<char > line {endOfLine ? textEdit.textEdit [textEdit.cursor .row ].push_back (newChar) : textEdit.textEdit [textEdit.cursor .row ].insert (textEdit.cursor .column , newChar)}; // add the character to the line (change to insert unless the cursor is at the end of the line)
13- better::Text tempText {textEdit.textEdit .set (textEdit.cursor .row ,line),{textEdit.cursor .row , textEdit.cursor .column + 1 }, {{false ,false ,false ,false },textEdit.data .isShift ,textEdit.data .isCaps ,textEdit.data .isScroll ,textEdit.data .isCtrl ,textEdit.data .clearHistory ,-1 ,textEdit.data .menu ,textEdit.data .filename ,textEdit.data .textHeight ,textEdit.data .textWidth }, textEdit.topLineNumber , endOfScreen ? textEdit.topColumnNumber + 1 : textEdit.topColumnNumber , textEdit.highlightStart , textEdit.highlightEnd };
13+ better::Text tempText {textEdit.textEdit .set (textEdit.cursor .row ,line),{textEdit.cursor .row , textEdit.cursor .column + 1 }, {{false ,false ,false ,false },textEdit.data .isShift ,textEdit.data .isCaps ,textEdit.data .isScroll ,textEdit.data .isCtrl ,textEdit.data .clearHistory ,textEdit. data . switchEditor , -1 ,textEdit.data .menu ,textEdit.data .filename ,textEdit.data .textHeight ,textEdit.data .textWidth }, textEdit.topLineNumber , endOfScreen ? textEdit.topColumnNumber + 1 : textEdit.topColumnNumber , textEdit.highlightStart , textEdit.highlightEnd };
1414 return tempText;
1515}
1616
@@ -38,12 +38,12 @@ better::Text better::backspace(better::Text text) { //couple of bugs with backsp
3838 topColumnNo = colNo - textWidth;
3939 }
4040 newLine = text.textEdit [text.cursor .row - 1 ] + text.textEdit [text.cursor .row ];
41- return {text.textEdit .erase (text.cursor .row ).set (text.cursor .row - 1 , newLine), {text.cursor .row - 1 , colNo}, {{false ,false ,false ,false },text.data .isShift ,text.data .isCaps ,text.data .isScroll ,text.data .isCtrl ,text.data .clearHistory ,-1 ,text.data .menu ,text.data .filename ,text.data .textHeight ,text.data .textWidth }, text.cursor .row >= text.textEdit .size () - 1 ? text.topLineNumber - 1 : text.topLineNumber , topColumnNo, text.highlightStart , text.highlightEnd };
41+ return {text.textEdit .erase (text.cursor .row ).set (text.cursor .row - 1 , newLine), {text.cursor .row - 1 , colNo}, {{false ,false ,false ,false },text.data .isShift ,text.data .isCaps ,text.data .isScroll ,text.data .isCtrl ,text.data .clearHistory ,text. data . switchEditor , -1 ,text.data .menu ,text.data .filename ,text.data .textHeight ,text.data .textWidth }, text.cursor .row >= text.textEdit .size () - 1 ? text.topLineNumber - 1 : text.topLineNumber , topColumnNo, text.highlightStart , text.highlightEnd };
4242 }
43- return {text.textEdit .erase (text.cursor .row ), {text.cursor .row - 1 , static_cast <int >(text.textEdit [text.cursor .row - 1 ].size ())}, {{false ,false ,false ,false },text.data .isShift ,text.data .isCaps ,text.data .isScroll ,text.data .isCtrl ,text.data .clearHistory ,-1 ,text.data .menu ,text.data .filename ,text.data .textHeight ,text.data .textWidth }, text.cursor .row >= text.textEdit .size () - 1 ? text.topLineNumber - 1 : text.topLineNumber , text.topColumnNumber , text.highlightStart , text.highlightEnd };
43+ return {text.textEdit .erase (text.cursor .row ), {text.cursor .row - 1 , static_cast <int >(text.textEdit [text.cursor .row - 1 ].size ())}, {{false ,false ,false ,false },text.data .isShift ,text.data .isCaps ,text.data .isScroll ,text.data .isCtrl ,text.data .clearHistory ,text. data . switchEditor , -1 ,text.data .menu ,text.data .filename ,text.data .textHeight ,text.data .textWidth }, text.cursor .row >= text.textEdit .size () - 1 ? text.topLineNumber - 1 : text.topLineNumber , text.topColumnNumber , text.highlightStart , text.highlightEnd };
4444 }
4545
46- return {text.textEdit .set (text.cursor .row ,newLine), {text.cursor .row , text.cursor .column - 1 }, {{false ,false ,false ,false },text.data .isShift ,text.data .isCaps ,text.data .isScroll ,text.data .isCtrl ,text.data .clearHistory ,-1 ,text.data .menu ,text.data .filename ,text.data .textHeight ,text.data .textWidth }, text.topLineNumber , text.topColumnNumber , text.highlightStart , text.highlightEnd };
46+ return {text.textEdit .set (text.cursor .row ,newLine), {text.cursor .row , text.cursor .column - 1 }, {{false ,false ,false ,false },text.data .isShift ,text.data .isCaps ,text.data .isScroll ,text.data .isCtrl ,text.data .clearHistory ,text. data . switchEditor , -1 ,text.data .menu ,text.data .filename ,text.data .textHeight ,text.data .textWidth }, text.topLineNumber , text.topColumnNumber , text.highlightStart , text.highlightEnd };
4747}
4848
4949better::Text better::newLine (better::Text textEdit) { // 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
@@ -55,7 +55,7 @@ better::Text better::newLine(better::Text textEdit) { //create cases for the fol
5555 bool endOfText {textEdit.cursor .row == textEdit.textEdit .size () - 1 ? true : false };
5656 bool textSizeRightSize {textEdit.textEdit .size () > (textHeight - 1 ) ? true : false }; // if end of text make sure to not just append a new row
5757
58- better::Text newText {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 )) : 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.cursor .row + 1 , 0 }, {{false ,false ,false ,false },textEdit.data .isShift ,textEdit.data .isCaps ,textEdit.data .isScroll ,textEdit.data .isCtrl ,textEdit.data .clearHistory ,-1 ,textEdit.data .menu ,textEdit.data .filename ,textEdit.data .textHeight ,textEdit.data .textWidth }, endOfText ? (textSizeRightSize ? textEdit.topLineNumber + 1 : 0 ) : textEdit.topLineNumber , 0 , textEdit.highlightStart , textEdit.highlightEnd }; // insert newline unless at bottom
58+ better::Text newText {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 )) : 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.cursor .row + 1 , 0 }, {{false ,false ,false ,false },textEdit.data .isShift ,textEdit.data .isCaps ,textEdit.data .isScroll ,textEdit.data .isCtrl ,textEdit.data .clearHistory ,textEdit. data . switchEditor , -1 ,textEdit.data .menu ,textEdit.data .filename ,textEdit.data .textHeight ,textEdit.data .textWidth }, endOfText ? (textSizeRightSize ? textEdit.topLineNumber + 1 : 0 ) : textEdit.topLineNumber , 0 , textEdit.highlightStart , textEdit.highlightEnd }; // insert newline unless at bottom
5959 int prevIndent {better::getPreviousIndentLevel (textEdit, textEdit.cursor .row )};
6060 texts.push_back (newText);
6161 for (int i{}; i < prevIndent; ++i) {
@@ -73,10 +73,10 @@ better::charMapArr better::makeCharMapArr(::Uint8 charArray[16]) {
7373 return tempArr;
7474}
7575
76- better::Cursor better::findCursorPos (int topLine, int topColumn, SDL_Event event) { // make sure to fix for screen bigger than size of lines
76+ better::Cursor better::findCursorPos (int topLine, int topColumn, SDL_Event event, int columnOffset ) { // change this to switch between different editors in splitscreen
7777 int relativeColumn {static_cast <int >(event.button .x / 8 )};
7878 int relativeRow {static_cast <int >(event.button .y / 16 ) - 1 };
79- return better::Cursor {relativeRow + topLine, relativeColumn + topColumn};
79+ return better::Cursor {relativeRow + topLine, relativeColumn + topColumn - static_cast < int >(columnOffset / 8 ) };
8080}
8181
8282Uint8 better::getRed (Uint32 color) {
0 commit comments