summaryrefslogtreecommitdiff
path: root/src/Fl_Text_Editor.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2022-11-22 16:18:56 +0100
committerGitHub <noreply@github.com>2022-11-22 16:18:56 +0100
commit495b2395c14607c030a0270ed7341bf04be7fa56 (patch)
tree84607d73d8f2f7f4717ef044bc70b7aec223e253 /src/Fl_Text_Editor.cxx
parentbe928430a6cc642b82bc1dfe6a94823ae0dd5016 (diff)
Fix selection extension in Fl_Text_*, issue 196 (#550)
Selecting a text range programmatically would not sync some variables with the actual selection. This also fixes a crash bug in macOS when dragging text that was selected by buffer()->select() only.
Diffstat (limited to 'src/Fl_Text_Editor.cxx')
-rw-r--r--src/Fl_Text_Editor.cxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx
index a786ac498..139350048 100644
--- a/src/Fl_Text_Editor.cxx
+++ b/src/Fl_Text_Editor.cxx
@@ -284,6 +284,7 @@ int Fl_Text_Editor::kf_enter(int, Fl_Text_Editor* e) {
return 1;
}
+extern int fl_text_drag_prepare(int pos, int key, Fl_Text_Display* d);
extern void fl_text_drag_me(int pos, Fl_Text_Display* d);
/** Moves the text cursor in the direction indicated by key \p 'c' in editor \p 'e'.
Supported values for 'c' are currently:
@@ -339,6 +340,7 @@ int Fl_Text_Editor::kf_move(int c, Fl_Text_Editor* e) {
\see kf_move()
*/
int Fl_Text_Editor::kf_shift_move(int c, Fl_Text_Editor* e) {
+ fl_text_drag_prepare(-1, c, e);
kf_move(c, e);
fl_text_drag_me(e->insert_position(), e);
char *copy = e->buffer()->selection_text();
@@ -441,6 +443,7 @@ int Fl_Text_Editor::kf_meta_move(int c, Fl_Text_Editor* e) {
\see kf_meta_move().
*/
int Fl_Text_Editor::kf_m_s_move(int c, Fl_Text_Editor* e) {
+ fl_text_drag_prepare(-1, c, e);
kf_meta_move(c, e);
fl_text_drag_me(e->insert_position(), e);
return 1;
@@ -450,6 +453,7 @@ int Fl_Text_Editor::kf_m_s_move(int c, Fl_Text_Editor* e) {
\see kf_ctrl_move().
*/
int Fl_Text_Editor::kf_c_s_move(int c, Fl_Text_Editor* e) {
+ fl_text_drag_prepare(-1, c, e);
kf_ctrl_move(c, e);
fl_text_drag_me(e->insert_position(), e);
return 1;
@@ -709,7 +713,7 @@ int Fl_Text_Editor::handle(int event) {
dragType = DRAG_NONE;
if(buffer()->selected()) {
buffer()->unselect();
- }
+ }
int pos = xy_to_position(Fl::event_x(), Fl::event_y(), CURSOR_POS);
insert_position(pos);
Fl::paste(*this, 0);