summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_text_editor.cpp80
-rw-r--r--src/c_fl_text_editor.h28
-rw-r--r--src/fltk-widgets-groups-text_displays-text_editors.adb196
-rw-r--r--src/fltk-widgets-groups-text_displays-text_editors.ads72
4 files changed, 347 insertions, 29 deletions
diff --git a/src/c_fl_text_editor.cpp b/src/c_fl_text_editor.cpp
index 1056133..282da77 100644
--- a/src/c_fl_text_editor.cpp
+++ b/src/c_fl_text_editor.cpp
@@ -23,42 +23,34 @@ class My_Text_Editor : public Fl_Text_Editor {
h_hook_p handle_hook;
};
-
void My_Text_Editor::draw() {
(*draw_hook)(this->user_data());
}
-
void My_Text_Editor::real_draw() {
Fl_Text_Editor::draw();
}
-
int My_Text_Editor::handle(int e) {
return (*handle_hook)(this->user_data(), e);
}
-
int My_Text_Editor::real_handle(int e) {
return Fl_Text_Editor::handle(e);
}
-
void text_editor_set_draw_hook(TEXTEDITOR te, void * d) {
reinterpret_cast<My_Text_Editor*>(te)->draw_hook = reinterpret_cast<d_hook_p>(d);
}
-
void fl_text_editor_draw(TEXTEDITOR te) {
reinterpret_cast<My_Text_Editor*>(te)->real_draw();
}
-
void text_editor_set_handle_hook(TEXTEDITOR te, void * h) {
reinterpret_cast<My_Text_Editor*>(te)->handle_hook = reinterpret_cast<h_hook_p>(h);
}
-
int fl_text_editor_handle(TEXTEDITOR te, int e) {
return reinterpret_cast<My_Text_Editor*>(te)->real_handle(e);
}
@@ -71,7 +63,6 @@ TEXTEDITOR new_fl_text_editor(int x, int y, int w, int h, char* label) {
return te;
}
-
void free_fl_text_editor(TEXTEDITOR te) {
delete reinterpret_cast<My_Text_Editor*>(te);
}
@@ -83,28 +74,91 @@ void fl_text_editor_undo(TEXTEDITOR te) {
Fl_Text_Editor::kf_undo(0, reinterpret_cast<Fl_Text_Editor*>(te));
}
-
void fl_text_editor_cut(TEXTEDITOR te) {
Fl_Text_Editor::kf_cut(0, reinterpret_cast<Fl_Text_Editor*>(te));
}
-
void fl_text_editor_copy(TEXTEDITOR te) {
Fl_Text_Editor::kf_copy(0, reinterpret_cast<Fl_Text_Editor*>(te));
}
-
void fl_text_editor_paste(TEXTEDITOR te) {
Fl_Text_Editor::kf_paste(0, reinterpret_cast<Fl_Text_Editor*>(te));
}
-
void fl_text_editor_delete(TEXTEDITOR te) {
Fl_Text_Editor::kf_delete(0, reinterpret_cast<Fl_Text_Editor*>(te));
}
+
+
+void fl_text_editor_backspace(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_backspace(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_home(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_home(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_end(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_end(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_insert(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_insert(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_page_down(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_page_down(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_page_up(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_page_up(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_down(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_down(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_left(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_left(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_right(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_right(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+void fl_text_editor_up(TEXTEDITOR te) {
+ Fl_Text_Editor::kf_up(0, reinterpret_cast<Fl_Text_Editor*>(te));
+}
+
+
+
+
void fl_text_editor_remove_key_binding(TEXTEDITOR te, unsigned int k, unsigned long m) {
reinterpret_cast<Fl_Text_Editor*>(te)->remove_key_binding(k, m);
}
+
+
+
+int fl_text_editor_get_insert_mode(TEXTEDITOR te) {
+ return reinterpret_cast<Fl_Text_Editor*>(te)->insert_mode();
+}
+
+void fl_text_editor_set_insert_mode(TEXTEDITOR te, int i) {
+ reinterpret_cast<Fl_Text_Editor*>(te)->insert_mode(i);
+}
+
+
+
+
+//int fl_text_editor_get_tab_nav(TEXTEDITOR te) {
+// return reinterpret_cast<Fl_Text_Editor*>(te)->tab_nav();
+//}
+
+//void fl_text_editor_set_tab_nav(TEXTEDITOR te, int t) {
+// reinterpret_cast<Fl_Text_Editor*>(te)->tab_nav(t);
+//}
+
diff --git a/src/c_fl_text_editor.h b/src/c_fl_text_editor.h
index f6abc6e..dce890e 100644
--- a/src/c_fl_text_editor.h
+++ b/src/c_fl_text_editor.h
@@ -7,23 +7,51 @@
typedef void* TEXTEDITOR;
+
+
extern "C" void text_editor_set_draw_hook(TEXTEDITOR te, void * d);
extern "C" void fl_text_editor_draw(TEXTEDITOR te);
extern "C" void text_editor_set_handle_hook(TEXTEDITOR te, void * h);
extern "C" int fl_text_editor_handle(TEXTEDITOR te, int e);
+
+
extern "C" TEXTEDITOR new_fl_text_editor(int x, int y, int w, int h, char* label);
extern "C" void free_fl_text_editor(TEXTEDITOR te);
+
+
extern "C" void fl_text_editor_undo(TEXTEDITOR te);
extern "C" void fl_text_editor_cut(TEXTEDITOR te);
extern "C" void fl_text_editor_copy(TEXTEDITOR te);
extern "C" void fl_text_editor_paste(TEXTEDITOR te);
extern "C" void fl_text_editor_delete(TEXTEDITOR te);
+
+
+extern "C" void fl_text_editor_backspace(TEXTEDITOR te);
+extern "C" void fl_text_editor_home(TEXTEDITOR te);
+extern "C" void fl_text_editor_end(TEXTEDITOR te);
+extern "C" void fl_text_editor_insert(TEXTEDITOR te);
+extern "C" void fl_text_editor_page_down(TEXTEDITOR te);
+extern "C" void fl_text_editor_page_up(TEXTEDITOR te);
+extern "C" void fl_text_editor_down(TEXTEDITOR te);
+extern "C" void fl_text_editor_left(TEXTEDITOR te);
+extern "C" void fl_text_editor_right(TEXTEDITOR te);
+extern "C" void fl_text_editor_up(TEXTEDITOR te);
+
+
extern "C" void fl_text_editor_remove_key_binding(TEXTEDITOR te, unsigned int k, unsigned long m);
+extern "C" int fl_text_editor_get_insert_mode(TEXTEDITOR te);
+extern "C" void fl_text_editor_set_insert_mode(TEXTEDITOR te, int i);
+
+
+//extern "C" int fl_text_editor_get_tab_nav(TEXTEDITOR te);
+//extern "C" void fl_text_editor_set_tab_nav(TEXTEDITOR te, int t);
+
+
#endif
diff --git a/src/fltk-widgets-groups-text_displays-text_editors.adb b/src/fltk-widgets-groups-text_displays-text_editors.adb
index a541833..dc47d72 100644
--- a/src/fltk-widgets-groups-text_displays-text_editors.adb
+++ b/src/fltk-widgets-groups-text_displays-text_editors.adb
@@ -17,6 +17,8 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
pragma Import (C, text_editor_set_handle_hook, "text_editor_set_handle_hook");
+
+
function new_fl_text_editor
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
@@ -28,6 +30,8 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
pragma Import (C, free_fl_text_editor, "free_fl_text_editor");
+
+
procedure fl_text_editor_undo
(TE : in System.Address);
pragma Import (C, fl_text_editor_undo, "fl_text_editor_undo");
@@ -48,12 +52,86 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
(TE : in System.Address);
pragma Import (C, fl_text_editor_delete, "fl_text_editor_delete");
+
+
+ procedure fl_text_editor_backspace
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_backspace, "fl_text_editor_backspace");
+
+ procedure fl_text_editor_home
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_home, "fl_text_editor_home");
+
+ procedure fl_text_editor_end
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_end, "fl_text_editor_end");
+
+ procedure fl_text_editor_insert
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_insert, "fl_text_editor_insert");
+
+ procedure fl_text_editor_page_down
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_page_down, "fl_text_editor_page_down");
+
+ procedure fl_text_editor_page_up
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_page_up, "fl_text_editor_page_up");
+
+ procedure fl_text_editor_down
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_down, "fl_text_editor_down");
+
+ procedure fl_text_editor_left
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_left, "fl_text_editor_left");
+
+ procedure fl_text_editor_right
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_right, "fl_text_editor_right");
+
+ procedure fl_text_editor_up
+ (TE : in System.Address);
+ pragma Import (C, fl_text_editor_up, "fl_text_editor_up");
+
+
+
+
procedure fl_text_editor_remove_key_binding
(TE : in System.Address;
K : in Interfaces.C.unsigned;
M : in Interfaces.C.unsigned_long);
pragma Import (C, fl_text_editor_remove_key_binding, "fl_text_editor_remove_key_binding");
+
+
+
+ function fl_text_editor_get_insert_mode
+ (TE : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_editor_get_insert_mode, "fl_text_editor_get_insert_mode");
+
+ procedure fl_text_editor_set_insert_mode
+ (TE : in System.Address;
+ I : in Interfaces.C.int);
+ pragma Import (C, fl_text_editor_set_insert_mode, "fl_text_editor_set_insert_mode");
+
+
+
+
+ -- function fl_text_editor_get_tab_nav
+ -- (TE : in System.Address)
+ -- return Interfaces.C.int;
+ -- pragma Import (C, fl_text_editor_get_tab_nav, "fl_text_editor_get_tab_nav");
+
+ -- procedure fl_text_editor_set_tab_nav
+ -- (TE : in System.Address;
+ -- T : in Interfaces.C.int);
+ -- pragma Import (C, fl_text_editor_set_tab_nav, "fl_text_editor_set_tab_nav");
+
+
+
+
procedure fl_text_editor_draw
(W : in System.Address);
pragma Import (C, fl_text_editor_draw, "fl_text_editor_draw");
@@ -114,8 +192,6 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
end Undo;
-
-
procedure Cut
(This : in out Text_Editor) is
begin
@@ -123,8 +199,6 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
end Cut;
-
-
procedure Copy
(This : in out Text_Editor) is
begin
@@ -132,8 +206,6 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
end Copy;
-
-
procedure Paste
(This : in out Text_Editor) is
begin
@@ -141,8 +213,6 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
end Paste;
-
-
procedure Delete
(This : in out Text_Editor) is
begin
@@ -152,6 +222,78 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
+ procedure Backspace_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_backspace (This.Void_Ptr);
+ end Backspace_Key;
+
+
+ procedure Home_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_home (This.Void_Ptr);
+ end Home_Key;
+
+
+ procedure End_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_end (This.Void_Ptr);
+ end End_Key;
+
+
+ procedure Insert_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_insert (This.Void_Ptr);
+ end Insert_Key;
+
+
+ procedure Page_Down_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_page_down (This.Void_Ptr);
+ end Page_Down_Key;
+
+
+ procedure Page_Up_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_page_up (This.Void_Ptr);
+ end Page_Up_Key;
+
+
+ procedure Down_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_down (This.Void_Ptr);
+ end Down_Key;
+
+
+ procedure Left_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_left (This.Void_Ptr);
+ end Left_Key;
+
+
+ procedure Right_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_right (This.Void_Ptr);
+ end Right_Key;
+
+
+ procedure Up_Key
+ (This : in out Text_Editor) is
+ begin
+ fl_text_editor_up (This.Void_Ptr);
+ end Up_Key;
+
+
+
+
procedure Remove_Key_Binding
(This : in out Text_Editor;
Key : in Shortcut_Key)
@@ -167,6 +309,42 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
+ function Get_Insert_Mode
+ (This : in Text_Editor)
+ return Insert_Mode is
+ begin
+ return Insert_Mode'Val (fl_text_editor_get_insert_mode (This.Void_Ptr));
+ end Get_Insert_Mode;
+
+
+ procedure Set_Insert_Mode
+ (This : in out Text_Editor;
+ To : in Insert_Mode) is
+ begin
+ fl_text_editor_set_insert_mode (This.Void_Ptr, Insert_Mode'Pos (To));
+ end Set_Insert_Mode;
+
+
+
+
+ -- function Get_Tab_Nav_Mode
+ -- (This : in Text_Editor)
+ -- return Tab_Navigation is
+ -- begin
+ -- return Tab_Navigation'Val (fl_text_editor_get_tab_nav (This.Void_Ptr));
+ -- end Get_Tab_Nav_Mode;
+
+
+ -- procedure Set_Tab_Nav_Mode
+ -- (This : in out Text_Editor;
+ -- To : in Tab_Navigation) is
+ -- begin
+ -- fl_text_editor_set_tab_nav (This.Void_Ptr, Tab_Navigation'Pos (To));
+ -- end Set_Tab_Nav_Mode;
+
+
+
+
procedure Draw
(This : in out Text_Editor) is
begin
@@ -174,8 +352,6 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
end Draw;
-
-
function Handle
(This : in out Text_Editor;
Event : in Event_Kind)
diff --git a/src/fltk-widgets-groups-text_displays-text_editors.ads b/src/fltk-widgets-groups-text_displays-text_editors.ads
index 8d88642..8eafe25 100644
--- a/src/fltk-widgets-groups-text_displays-text_editors.ads
+++ b/src/fltk-widgets-groups-text_displays-text_editors.ads
@@ -5,6 +5,11 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is
type Text_Editor is new Text_Display with private;
+ type Insert_Mode is (Before, After);
+ -- type Tab_Navigation is (Insert_Char, Widget_Focus);
+
+
+
function Create
(X, Y, W, H : in Integer;
@@ -12,35 +17,91 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is
return Text_Editor;
+
+
procedure Undo
(This : in out Text_Editor);
-
procedure Cut
(This : in out Text_Editor);
-
procedure Copy
(This : in out Text_Editor);
-
procedure Paste
(This : in out Text_Editor);
-
procedure Delete
(This : in out Text_Editor);
+
+
+ procedure Backspace_Key
+ (This : in out Text_Editor);
+
+ procedure Home_Key
+ (This : in out Text_Editor);
+
+ procedure End_Key
+ (This : in out Text_Editor);
+
+ procedure Insert_Key
+ (This : in out Text_Editor);
+
+ procedure Page_Down_Key
+ (This : in out Text_Editor);
+
+ procedure Page_Up_Key
+ (This : in out Text_Editor);
+
+ procedure Down_Key
+ (This : in out Text_Editor);
+
+ procedure Left_Key
+ (This : in out Text_Editor);
+
+ procedure Right_Key
+ (This : in out Text_Editor);
+
+ procedure Up_Key
+ (This : in out Text_Editor);
+
+
+
+
procedure Remove_Key_Binding
(This : in out Text_Editor;
Key : in Shortcut_Key);
+
+
+ function Get_Insert_Mode
+ (This : in Text_Editor)
+ return Insert_Mode;
+
+ procedure Set_Insert_Mode
+ (This : in out Text_Editor;
+ To : in Insert_Mode);
+
+
+
+
+ -- function Get_Tab_Nav_Mode
+ -- (This : in Text_Editor)
+ -- return Tab_Navigation;
+
+ -- procedure Set_Tab_Nav_Mode
+ -- (This : in out Text_Editor;
+ -- To : in Tab_Navigation);
+
+
+
+
procedure Draw
(This : in out Text_Editor);
-
function Handle
(This : in out Text_Editor;
Event : in Event_Kind)
@@ -52,7 +113,6 @@ private
type Text_Editor is new Text_Display with null record;
-
overriding procedure Finalize
(This : in out Text_Editor);