2001-08-02 01:24:49 +04:00
|
|
|
//
|
2001-08-07 03:51:39 +04:00
|
|
|
// "$Id: Fl_Text_Editor.H,v 1.1.2.2 2001/08/06 23:51:39 easysw Exp $"
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
// Header file for Fl_Text_Editor class.
|
|
|
|
//
|
|
|
|
// Copyright Mark Edel. Permission to distribute under the LGPL for
|
|
|
|
// the FLTK library granted by Mark Edel.
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
|
|
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FL_TEXT_EDITOR_H
|
|
|
|
#define FL_TEXT_EDITOR_H
|
|
|
|
|
2001-08-04 16:21:34 +04:00
|
|
|
#include "Fl_Text_Display.H"
|
2001-08-02 01:24:49 +04:00
|
|
|
|
|
|
|
// key will match in any state
|
|
|
|
#define FL_TEXT_EDITOR_ANY_STATE (-1L)
|
|
|
|
|
2001-08-07 03:51:39 +04:00
|
|
|
class Fl_Text_Editor : public Fl_Text_Display {
|
2001-08-02 01:24:49 +04:00
|
|
|
public:
|
|
|
|
typedef int (*Key_Func)(int key, Fl_Text_Editor* editor);
|
|
|
|
|
2001-08-04 16:21:34 +04:00
|
|
|
struct FL_EXPORT Key_Binding {
|
2001-08-02 01:24:49 +04:00
|
|
|
int key;
|
|
|
|
int state;
|
|
|
|
Key_Func function;
|
|
|
|
Key_Binding* next;
|
|
|
|
};
|
|
|
|
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT Fl_Text_Editor(int X, int Y, int W, int H, const char* l = 0);
|
2001-08-02 01:24:49 +04:00
|
|
|
~Fl_Text_Editor() { remove_all_key_bindings(); }
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT virtual int handle(int e);
|
2001-08-02 01:24:49 +04:00
|
|
|
void insert_mode(int b) { insert_mode_ = b; }
|
|
|
|
int insert_mode() { return insert_mode_; }
|
|
|
|
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT void add_key_binding(int key, int state, Key_Func f, Key_Binding** list);
|
2001-08-02 01:24:49 +04:00
|
|
|
void add_key_binding(int key, int state, Key_Func f)
|
|
|
|
{ add_key_binding(key, state, f, &key_bindings); }
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT void remove_key_binding(int key, int state, Key_Binding** list);
|
2001-08-02 01:24:49 +04:00
|
|
|
void remove_key_binding(int key, int state)
|
|
|
|
{ remove_key_binding(key, state, &key_bindings); }
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT void remove_all_key_bindings(Key_Binding** list);
|
2001-08-02 01:24:49 +04:00
|
|
|
void remove_all_key_bindings() { remove_all_key_bindings(&key_bindings); }
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT void add_default_key_bindings(Key_Binding** list);
|
|
|
|
FL_EXPORT Key_Func bound_key_function(int key, int state, Key_Binding* list);
|
2001-08-02 01:24:49 +04:00
|
|
|
Key_Func bound_key_function(int key, int state)
|
|
|
|
{ return bound_key_function(key, state, key_bindings); }
|
|
|
|
void default_key_function(Key_Func f) { default_key_function_ = f; }
|
|
|
|
|
|
|
|
// functions for the built in default bindings
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT static int kf_default(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_ignore(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_backspace(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_enter(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_move(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_shift_move(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_ctrl_move(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_c_s_move(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_home(int, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_end(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_left(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_up(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_right(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_down(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_page_up(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_page_down(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_insert(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_delete(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_copy(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_cut(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_paste(int c, Fl_Text_Editor* e);
|
|
|
|
FL_EXPORT static int kf_select_all(int c, Fl_Text_Editor* e);
|
2001-08-02 01:24:49 +04:00
|
|
|
|
|
|
|
protected:
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT int handle_key();
|
2001-08-02 01:24:49 +04:00
|
|
|
|
|
|
|
int insert_mode_;
|
|
|
|
Key_Binding* key_bindings;
|
2001-08-07 03:51:39 +04:00
|
|
|
FL_EXPORT static Key_Binding* global_key_bindings;
|
2001-08-02 01:24:49 +04:00
|
|
|
Key_Func default_key_function_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
2001-08-07 03:51:39 +04:00
|
|
|
// End of "$Id: Fl_Text_Editor.H,v 1.1.2.2 2001/08/06 23:51:39 easysw Exp $".
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
|