@@ -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
136136better::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
196188Uint8 better::getRed (Uint32 color) {
0 commit comments