mirror of
https://github.com/fltk/fltk.git
synced 2026-05-22 15:22:34 +08:00
Fix STR # 2484. Middle mouse button paste now works within an Fl_Text_Editor
and from/to other applications. Also fixed interaction between selection and insertion cursor. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8027 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+13
-4
@@ -3592,10 +3592,14 @@ int Fl_Text_Display::handle(int event) {
|
||||
return 1;
|
||||
}
|
||||
dragType = Fl::event_clicks();
|
||||
if (dragType == DRAG_CHAR)
|
||||
if (dragType == DRAG_CHAR) {
|
||||
buffer()->unselect();
|
||||
else if (dragType == DRAG_WORD)
|
||||
Fl::copy("", 0, 0);
|
||||
}
|
||||
else if (dragType == DRAG_WORD) {
|
||||
buffer()->select(word_start(pos), word_end(pos));
|
||||
dragPos = word_start(pos);
|
||||
}
|
||||
|
||||
if (buffer()->primary_selection()->selected())
|
||||
insert_position(buffer()->primary_selection()->end());
|
||||
@@ -3667,6 +3671,8 @@ int Fl_Text_Display::handle(int event) {
|
||||
return 1;
|
||||
} else if (Fl::event_clicks() == DRAG_LINE) {
|
||||
buffer()->select(buffer()->line_start(dragPos), buffer()->next_char(buffer()->line_end(dragPos)));
|
||||
dragPos = line_start(dragPos);
|
||||
dragType = DRAG_CHAR;
|
||||
} else {
|
||||
dragging = 0;
|
||||
if (scroll_direction) {
|
||||
@@ -3675,10 +3681,10 @@ int Fl_Text_Display::handle(int event) {
|
||||
}
|
||||
|
||||
// convert from WORD or LINE selection to CHAR
|
||||
if (insert_position() >= dragPos)
|
||||
/*if (insert_position() >= dragPos)
|
||||
dragPos = buffer()->primary_selection()->start();
|
||||
else
|
||||
dragPos = buffer()->primary_selection()->end();
|
||||
dragPos = buffer()->primary_selection()->end();*/
|
||||
dragType = DRAG_CHAR;
|
||||
}
|
||||
|
||||
@@ -3725,6 +3731,9 @@ int Fl_Text_Display::handle(int event) {
|
||||
// Select all ?
|
||||
if ((Fl::event_state()&(FL_CTRL|FL_COMMAND)) && Fl::event_key()=='a') {
|
||||
buffer()->select(0,buffer()->length());
|
||||
const char *copy = buffer()->selection_text();
|
||||
if (*copy) Fl::copy(copy, strlen(copy), 0);
|
||||
free((void*)copy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -283,6 +283,7 @@ int Fl_Text_Editor::kf_move(int c, Fl_Text_Editor* e) {
|
||||
if (!selected)
|
||||
e->dragPos = e->insert_position();
|
||||
e->buffer()->unselect();
|
||||
Fl::copy("", 0, 0);
|
||||
switch (c) {
|
||||
case FL_Home:
|
||||
e->insert_position(e->buffer()->line_start(e->insert_position()));
|
||||
@@ -330,6 +331,7 @@ int Fl_Text_Editor::kf_ctrl_move(int c, Fl_Text_Editor* e) {
|
||||
e->dragPos = e->insert_position();
|
||||
if (c != FL_Up && c != FL_Down) {
|
||||
e->buffer()->unselect();
|
||||
Fl::copy("", 0, 0);
|
||||
e->show_insert_position();
|
||||
}
|
||||
switch (c) {
|
||||
@@ -369,6 +371,7 @@ int Fl_Text_Editor::kf_meta_move(int c, Fl_Text_Editor* e) {
|
||||
e->dragPos = e->insert_position();
|
||||
if (c != FL_Up && c != FL_Down) {
|
||||
e->buffer()->unselect();
|
||||
Fl::copy("", 0, 0);
|
||||
e->show_insert_position();
|
||||
}
|
||||
switch (c) {
|
||||
@@ -495,11 +498,15 @@ int Fl_Text_Editor::kf_paste(int, Fl_Text_Editor* e) {
|
||||
/** Selects all text in the current buffer.*/
|
||||
int Fl_Text_Editor::kf_select_all(int, Fl_Text_Editor* e) {
|
||||
e->buffer()->select(0, e->buffer()->length());
|
||||
const char *copy = e->buffer()->selection_text();
|
||||
if (*copy) Fl::copy(copy, strlen(copy), 0);
|
||||
free((void*)copy);
|
||||
return 1;
|
||||
}
|
||||
/** Undo last edit in the current buffer. Also deselect previous selection. */
|
||||
int Fl_Text_Editor::kf_undo(int , Fl_Text_Editor* e) {
|
||||
e->buffer()->unselect();
|
||||
Fl::copy("", 0, 0);
|
||||
int crsr;
|
||||
int ret = e->buffer()->undo(&crsr);
|
||||
e->insert_position(crsr);
|
||||
@@ -598,6 +605,11 @@ int Fl_Text_Editor::handle(int event) {
|
||||
// don't let the text_display see this event
|
||||
if (Fl_Group::handle(event)) return 1;
|
||||
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);
|
||||
Fl::focus(this);
|
||||
set_changed();
|
||||
|
||||
Reference in New Issue
Block a user