@@ -283,6 +283,37 @@ void better::edit1(SDL_Window* window, std::string filename, int textHeight, int
283283 }
284284 }
285285 }
286+ else if (event.key .keysym .sym == ' s' ) {
287+ better::saveFile (texts[editorIndex].back ().textEdit , texts[editorIndex].back ().data .filename );
288+ }
289+ else if (event.key .keysym .sym == ' o' ) {
290+ better::saveFile (texts[editorIndex].back ().textEdit , texts[editorIndex].back ().data .filename );
291+ std::string tempFilename {};
292+ tempFilename = better::fileDialog ().string ();
293+ texts[editorIndex].back ().data .clearHistory = true ;
294+ texts[editorIndex].back ().textEdit = better::readFile (tempFilename);
295+ texts[editorIndex].back ().cursor = {0 ,0 };
296+ texts[editorIndex].back ().topLineNumber = 0 ;
297+ texts[editorIndex].back ().topColumnNumber = 0 ;
298+ texts[editorIndex].back ().highlightStart = {0 ,0 };
299+ texts[editorIndex].back ().highlightEnd = {0 ,0 };
300+ texts[editorIndex].back ().data .index = -1 ;
301+ texts[editorIndex].back ().data .isScroll = false ;
302+ texts[editorIndex].back ().data .isCaps = false ;
303+ texts[editorIndex].back ().data .isShift = false ;
304+ texts[editorIndex].back ().data .isCtrl = false ;
305+ texts[editorIndex].back ().data .menu .clear ();
306+ texts[editorIndex].back ().data .filename = tempFilename;
307+ }
308+ else if (event.key .keysym .sym == ' c' ) {
309+ better::copyClipboard (texts[editorIndex].back ());
310+ }
311+ else if (event.key .keysym .sym == ' v' ) {
312+ texts[editorIndex].push_back (better::pasteClipboard (texts[editorIndex].back ()));
313+ }
314+ else if (event.key .keysym .sym == ' x' ) {
315+ texts[editorIndex].push_back (better::cutClipboard (texts[editorIndex].back ()));
316+ }
286317 }
287318
288319 else if (event.type == SDL_KEYDOWN || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEMOTION || event.type == SDL_MOUSEWHEEL || event.type == SDL_MOUSEBUTTONUP) {
@@ -426,38 +457,8 @@ better::Text better::keyDown(better::Text text, SDL_Event event, SDL_Surface* su
426457 text.topColumnNumber = 0 ;
427458 }
428459 if (text.data .isCtrl ) {
429- std::string tempFilename {};
430- switch (key) {
431- case ' s' :
432- better::saveFile (text.textEdit , text.data .filename );
433- return text;
434- case ' o' :
435- better::saveFile (text.textEdit , text.data .filename );
436- tempFilename = better::fileDialog ().string ();
437- text.data .clearHistory = true ;
438- text.textEdit = better::readFile (tempFilename);
439- text.cursor = {0 ,0 };
440- text.topLineNumber = 0 ;
441- text.topColumnNumber = 0 ;
442- text.highlightStart = {0 ,0 };
443- text.highlightEnd = {0 ,0 };
444- text.data .index = -1 ;
445- text.data .isScroll = false ;
446- text.data .isCaps = false ;
447- text.data .isShift = false ;
448- text.data .isCtrl = false ;
449- text.data .menu .clear ();
450- text.data .filename = tempFilename;
451- return text;
452- case ' c' :
453- better::copyClipboard (text);
454- return text;
455- case ' v' :
456- return better::pasteClipboard (text);
457- case ' x' :
458- return better::cutClipboard (text);
459- }
460460 text.highlightEnd = text.highlightStart ;
461+ return text;
461462 }
462463 if (text.cursor .row == -1 ) {
463464 text.cursor .row = 0 ;
0 commit comments