@@ -82,6 +82,8 @@ int selectMenu(bool menus[]);
8282
8383void quitApp (SDL_Cursor* cursor, SDL_Surface* surface, SDL_Window* window);
8484
85+ bool operator !=(better::Text lhs, better::Text rhs);
86+
8587}
8688
8789int main (int argc, char * argv[]) {
@@ -102,6 +104,10 @@ int main(int argc, char* argv[]) {
102104 return 0 ;
103105}
104106
107+ bool better::operator !=(better::Text lhs, better::Text rhs) {
108+ return lhs.textEdit != rhs.textEdit ;
109+ }
110+
105111better::Text better::pasteClipboard (better::Text text) {
106112 std::string clipboardText {};
107113 std::vector<better::Text> tempTexts {text};
@@ -227,12 +233,27 @@ void better::edit1(SDL_Window* window, std::string filename, const int textHeigh
227233 return ;
228234 }
229235
230- if (event.type == SDL_KEYDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEMOTION || event.type == SDL_MOUSEWHEEL || event.type == SDL_MOUSEBUTTONUP) {
236+ if (event.type == SDL_KEYDOWN && texts.back ().data .isCtrl && event.key .keysym .sym == ' z' ) {
237+ if (texts.size () > 1 ) {
238+ texts.pop_back ();
239+ texts.shrink_to_fit ();
240+ }
241+ }
242+
243+ else if (event.type == SDL_KEYDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEMOTION || event.type == SDL_MOUSEWHEEL || event.type == SDL_MOUSEBUTTONUP) {
231244 better::Text tempText {(handlers[event.type ])(texts.back (), event, surface, guiCursor)};
232245 if (tempText.data .clearHistory ) {
233246 texts.clear ();
247+ texts.push_back (tempText);
248+ texts.back ().data .clearHistory = false ;
249+ }
250+ if (tempText != texts.back ()) {
251+ texts.push_back (tempText);
252+ }
253+ else {
254+ texts.pop_back ();
255+ texts.push_back (tempText);
234256 }
235- texts.push_back (tempText);
236257 }
237258 else {
238259 continue ;
@@ -374,7 +395,8 @@ better::Text better::keyDown(better::Text text, SDL_Event event, SDL_Surface* su
374395 if ((text.highlightStart .row != text.highlightEnd .row ) || (text.highlightEnd .column > text.highlightStart .column )) {
375396 return better::handleKey (better::deleteHighlighted (text),key);
376397 }
377-
398+ text.highlightEnd = text.cursor ;
399+ text.highlightStart = text.cursor ;
378400 return better::handleKey (text, key);
379401
380402 }
0 commit comments