Skip to content

Commit

Permalink
Move some methods to Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
magiblot committed Oct 15, 2022
1 parent fab4833 commit 721be80
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
19 changes: 19 additions & 0 deletions include/turbo/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class Editor : protected TScintillaParent
template <class Func>
inline void lockReflow(Func &&func);
inline sptr_t callScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam);

inline void uppercase();
inline void lowercase();
inline void capitalize();
};

template <class Func>
Expand All @@ -119,6 +123,21 @@ inline sptr_t Editor::callScintilla(unsigned int iMessage, uptr_t wParam, sptr_t
return turbo::call(scintilla, iMessage, wParam, lParam);
}

inline void Editor::uppercase()
{
turbo::changeCaseOfSelection(scintilla, caseConvUpper);
}

inline void Editor::lowercase()
{
turbo::changeCaseOfSelection(scintilla, caseConvLower);
}

inline void Editor::capitalize()
{
turbo::changeCaseOfSelection(scintilla, caseConvCapitalize);
}

class EditorView : public TSurfaceView
{
// 'EditorView' is used to display an 'Editor's contents and feed input
Expand Down
15 changes: 0 additions & 15 deletions include/turbo/editstates.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,6 @@ void updateBraces(const ColorScheme *scheme, TScintilla &scintilla);
void stripTrailingSpaces(TScintilla &scintilla);
void ensureNewlineAtEnd(TScintilla &scintilla);

inline void uppercase(TScintilla &scintilla)
{
changeCaseOfSelection(scintilla, caseConvUpper);
}

inline void lowercase(TScintilla &scintilla)
{
changeCaseOfSelection(scintilla, caseConvLower);
}

inline void capitalize(TScintilla &scintilla)
{
changeCaseOfSelection(scintilla, caseConvCapitalize);
}

} // namespace turbo

#endif
6 changes: 3 additions & 3 deletions source/turbo/editwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ void EditorWindow::handleEvent(TEvent &ev) {
handled = message(this, evCommand, cmClose, nullptr); // May delete 'this'!
break;
case cmSelUppercase:
turbo::uppercase(editor.scintilla);
editor.uppercase();
editor.partialRedraw();
break;
case cmSelLowercase:
turbo::lowercase(editor.scintilla);
editor.lowercase();
editor.partialRedraw();
break;
case cmSelCapitalize:
turbo::capitalize(editor.scintilla);
editor.capitalize();
editor.partialRedraw();
break;
default:
Expand Down

0 comments on commit 721be80

Please sign in to comment.