summaryrefslogtreecommitdiff
path: root/src/Fl_Text_Editor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Text_Editor.cxx')
-rw-r--r--src/Fl_Text_Editor.cxx61
1 files changed, 25 insertions, 36 deletions
diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx
index 0b14258..decc121 100644
--- a/src/Fl_Text_Editor.cxx
+++ b/src/Fl_Text_Editor.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Text_Editor.cxx,v 1.9.2.18 2004/04/11 04:38:58 easysw Exp $"
+// "$Id: Fl_Text_Editor.cxx,v 1.9.2.21 2004/07/27 16:02:21 easysw Exp $"
//
// Copyright 2001-2004 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@@ -47,8 +47,6 @@ Fl_Text_Editor::Fl_Text_Editor(int X, int Y, int W, int H, const char* l)
Fl_Text_Editor::Key_Binding* Fl_Text_Editor::global_key_bindings = 0;
-static int ctrl_a(int, Fl_Text_Editor* e);
-
// These are the default key bindings every widget should start with
static struct {
int key;
@@ -102,7 +100,7 @@ static struct {
{ FL_Insert, FL_CTRL, Fl_Text_Editor::kf_copy },
{ 'v', FL_CTRL, Fl_Text_Editor::kf_paste },
{ FL_Insert, FL_SHIFT, Fl_Text_Editor::kf_paste },
- { 'a', FL_CTRL, ctrl_a },
+ { 'a', FL_CTRL, Fl_Text_Editor::kf_select_all },
#ifdef __APPLE__
// Define CMD+key accelerators...
@@ -110,7 +108,7 @@ static struct {
{ 'x', FL_COMMAND, Fl_Text_Editor::kf_cut },
{ 'c', FL_COMMAND, Fl_Text_Editor::kf_copy },
{ 'v', FL_COMMAND, Fl_Text_Editor::kf_paste },
- { 'a', FL_COMMAND, ctrl_a },
+ { 'a', FL_COMMAND, Fl_Text_Editor::kf_select_all },
#endif // __APPLE__
{ 0, 0, 0 }
@@ -187,8 +185,8 @@ int Fl_Text_Editor::kf_default(int c, Fl_Text_Editor* e) {
if (e->insert_mode()) e->insert(s);
else e->overstrike(s);
e->show_insert_position();
+ e->set_changed();
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
- else e->set_changed();
return 1;
}
@@ -201,7 +199,8 @@ int Fl_Text_Editor::kf_backspace(int, Fl_Text_Editor* e) {
e->buffer()->select(e->insert_position(), e->insert_position()+1);
kill_selection(e);
e->show_insert_position();
- if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
+ e->set_changed();
+ if (e->when()&FL_WHEN_CHANGED) e->do_callback();
return 1;
}
@@ -209,7 +208,8 @@ int Fl_Text_Editor::kf_enter(int, Fl_Text_Editor* e) {
kill_selection(e);
e->insert("\n");
e->show_insert_position();
- if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
+ e->set_changed();
+ if (e->when()&FL_WHEN_CHANGED) e->do_callback();
return 1;
}
@@ -301,20 +301,6 @@ int Fl_Text_Editor::kf_c_s_move(int c, Fl_Text_Editor* e) {
return 1;
}
-static int ctrl_a(int, Fl_Text_Editor* e) {
- // make 2+ ^A's in a row toggle select-all:
- int i = e->buffer()->line_start(e->insert_position());
- if (i != e->insert_position())
- return Fl_Text_Editor::kf_move(FL_Home, e);
- else {
- if (e->buffer()->selected())
- e->buffer()->unselect();
- else
- Fl_Text_Editor::kf_select_all(0, e);
- }
- return 1;
-}
-
int Fl_Text_Editor::kf_home(int, Fl_Text_Editor* e) {
return kf_move(FL_Home, e);
}
@@ -358,7 +344,8 @@ int Fl_Text_Editor::kf_delete(int, Fl_Text_Editor* e) {
e->buffer()->select(e->insert_position(), e->insert_position()+1);
kill_selection(e);
e->show_insert_position();
- if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
+ e->set_changed();
+ if (e->when()&FL_WHEN_CHANGED) e->do_callback();
return 1;
}
@@ -374,7 +361,8 @@ int Fl_Text_Editor::kf_copy(int, Fl_Text_Editor* e) {
int Fl_Text_Editor::kf_cut(int c, Fl_Text_Editor* e) {
kf_copy(c, e);
kill_selection(e);
- if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
+ e->set_changed();
+ if (e->when()&FL_WHEN_CHANGED) e->do_callback();
return 1;
}
@@ -382,7 +370,8 @@ int Fl_Text_Editor::kf_paste(int, Fl_Text_Editor* e) {
kill_selection(e);
Fl::paste(*e, 1);
e->show_insert_position();
- if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
+ e->set_changed();
+ if (e->when()&FL_WHEN_CHANGED) e->do_callback();
return 1;
}
@@ -397,7 +386,8 @@ int Fl_Text_Editor::kf_undo(int , Fl_Text_Editor* e) {
int ret = e->buffer()->undo(&crsr);
e->insert_position(crsr);
e->show_insert_position();
- if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
+ e->set_changed();
+ if (e->when()&FL_WHEN_CHANGED) e->do_callback();
return ret;
}
@@ -415,8 +405,8 @@ int Fl_Text_Editor::handle_key() {
else overstrike(Fl::event_text());
}
show_insert_position();
+ set_changed();
if (when()&FL_WHEN_CHANGED) do_callback();
- else set_changed();
return 1;
}
@@ -433,8 +423,7 @@ int Fl_Text_Editor::handle_key() {
void Fl_Text_Editor::maybe_do_callback() {
// printf("Fl_Text_Editor::maybe_do_callback()\n");
// printf("changed()=%d, when()=%x\n", changed(), when());
- if (changed() || (when()&FL_WHEN_NOT_CHANGED)) {
- clear_changed(); do_callback();}
+ if (changed() || (when()&FL_WHEN_NOT_CHANGED)) do_callback();
}
int Fl_Text_Editor::handle(int event) {
@@ -444,22 +433,21 @@ int Fl_Text_Editor::handle(int event) {
dragType = -1;
Fl::paste(*this, 0);
Fl::focus(this);
- if (when()&FL_WHEN_CHANGED) do_callback(); else set_changed();
+ set_changed();
+ if (when()&FL_WHEN_CHANGED) do_callback();
return 1;
}
switch (event) {
case FL_FOCUS:
show_cursor(mCursorOn); // redraws the cursor
- if (buffer()->primary_selection()->start() !=
- buffer()->primary_selection()->end()) redraw(); // Redraw selections...
+ if (buffer()->selected()) redraw(); // Redraw selections...
Fl::focus(this);
return 1;
case FL_UNFOCUS:
show_cursor(mCursorOn); // redraws the cursor
- if (buffer()->primary_selection()->start() !=
- buffer()->primary_selection()->end()) redraw(); // Redraw selections...
+ if (buffer()->selected()) redraw(); // Redraw selections...
case FL_HIDE:
if (when() & FL_WHEN_RELEASE) maybe_do_callback();
return 1;
@@ -476,7 +464,8 @@ int Fl_Text_Editor::handle(int event) {
if (insert_mode()) insert(Fl::event_text());
else overstrike(Fl::event_text());
show_insert_position();
- if (when()&FL_WHEN_CHANGED) do_callback(); else set_changed();
+ set_changed();
+ if (when()&FL_WHEN_CHANGED) do_callback();
return 1;
case FL_ENTER:
@@ -490,5 +479,5 @@ int Fl_Text_Editor::handle(int event) {
}
//
-// End of "$Id: Fl_Text_Editor.cxx,v 1.9.2.18 2004/04/11 04:38:58 easysw Exp $".
+// End of "$Id: Fl_Text_Editor.cxx,v 1.9.2.21 2004/07/27 16:02:21 easysw Exp $".
//