summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2016-10-04 18:52:32 +1100
committerJed Barber <jjbarber@y7mail.com>2016-10-04 18:52:32 +1100
commit3f1a529a3b82c322678163cb70a8884fdf3eb920 (patch)
treef4c37f9c5d156d5d66658df7cae20557c8f6ac02
parentbc54653c3e5277afecaecf2f208e1ee335df3a6e (diff)
Basic find functionality working
-rw-r--r--c_fl_input.cpp5
-rw-r--r--c_fl_input.h3
-rw-r--r--c_fl_text_buffer.cpp5
-rw-r--r--c_fl_text_buffer.h1
-rw-r--r--c_fl_text_display.cpp15
-rw-r--r--c_fl_text_display.h3
-rw-r--r--fltk-text_buffers.adb34
-rw-r--r--fltk-text_buffers.ads9
-rw-r--r--fltk-widgets-buttons.ads2
-rw-r--r--fltk-widgets-groups-text_displays.adb43
-rw-r--r--fltk-widgets-groups-text_displays.ads14
-rw-r--r--fltk-widgets-inputs.adb16
-rw-r--r--fltk-widgets-inputs.ads5
13 files changed, 154 insertions, 1 deletions
diff --git a/c_fl_input.cpp b/c_fl_input.cpp
index 4ee251c..4f19bd1 100644
--- a/c_fl_input.cpp
+++ b/c_fl_input.cpp
@@ -14,3 +14,8 @@ void free_fl_input(INPUT i) {
delete reinterpret_cast<Fl_Input*>(i);
}
+
+const char * fl_input_get_value(INPUT i) {
+ return reinterpret_cast<Fl_Input*>(i)->value();
+}
+
diff --git a/c_fl_input.h b/c_fl_input.h
index b3b1190..cb40d42 100644
--- a/c_fl_input.h
+++ b/c_fl_input.h
@@ -11,5 +11,8 @@ extern "C" INPUT new_fl_input(int x, int y, int w, int h, char* label);
extern "C" void free_fl_input(INPUT i);
+extern "C" const char * fl_input_get_value(INPUT i);
+
+
#endif
diff --git a/c_fl_text_buffer.cpp b/c_fl_text_buffer.cpp
index 089ca33..b0df365 100644
--- a/c_fl_text_buffer.cpp
+++ b/c_fl_text_buffer.cpp
@@ -55,6 +55,11 @@ int fl_text_buffer_savefile(TEXTBUFFER tb, char * n) {
}
+int fl_text_buffer_search_forward(TEXTBUFFER tb, int start, const char * item, int * found, int mcase) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->search_forward(start, item, found, mcase);
+}
+
+
void fl_text_buffer_select(TEXTBUFFER tb, int s, int e) {
reinterpret_cast<Fl_Text_Buffer*>(tb)->select(s, e);
}
diff --git a/c_fl_text_buffer.h b/c_fl_text_buffer.h
index 906ef8c..cd64112 100644
--- a/c_fl_text_buffer.h
+++ b/c_fl_text_buffer.h
@@ -19,6 +19,7 @@ extern "C" int fl_text_buffer_length(TEXTBUFFER tb);
extern "C" int fl_text_buffer_loadfile(TEXTBUFFER tb, char * n);
extern "C" void fl_text_buffer_remove_selection(TEXTBUFFER tb);
extern "C" int fl_text_buffer_savefile(TEXTBUFFER tb, char * n);
+extern "C" int fl_text_buffer_search_forward(TEXTBUFFER tb, int start, const char * item, int * found, int mcase);
extern "C" void fl_text_buffer_select(TEXTBUFFER tb, int s, int e);
diff --git a/c_fl_text_display.cpp b/c_fl_text_display.cpp
index c45e778..94eb002 100644
--- a/c_fl_text_display.cpp
+++ b/c_fl_text_display.cpp
@@ -58,3 +58,18 @@ void fl_text_display_set_text_size(TEXTDISPLAY td, int s) {
reinterpret_cast<Fl_Text_Display*>(td)->textsize(static_cast<Fl_Fontsize>(s));
}
+
+int fl_text_display_get_insert_pos(TEXTDISPLAY td) {
+ return reinterpret_cast<Fl_Text_Display*>(td)->insert_position();
+}
+
+
+void fl_text_display_set_insert_pos(TEXTDISPLAY td, int p) {
+ reinterpret_cast<Fl_Text_Display*>(td)->insert_position(p);
+}
+
+
+void fl_text_display_show_insert_pos(TEXTDISPLAY td) {
+ reinterpret_cast<Fl_Text_Display*>(td)->show_insert_position();
+}
+
diff --git a/c_fl_text_display.h b/c_fl_text_display.h
index dba1706..5a91774 100644
--- a/c_fl_text_display.h
+++ b/c_fl_text_display.h
@@ -20,6 +20,9 @@ extern "C" int fl_text_display_get_text_font(TEXTDISPLAY td);
extern "C" void fl_text_display_set_text_font(TEXTDISPLAY td, int f);
extern "C" int fl_text_display_get_text_size(TEXTDISPLAY td);
extern "C" void fl_text_display_set_text_size(TEXTDISPLAY td, int s);
+extern "C" int fl_text_display_get_insert_pos(TEXTDISPLAY td);
+extern "C" void fl_text_display_set_insert_pos(TEXTDISPLAY td, int p);
+extern "C" void fl_text_display_show_insert_pos(TEXTDISPLAY td);
#endif
diff --git a/fltk-text_buffers.adb b/fltk-text_buffers.adb
index 6a25399..6df96cb 100644
--- a/fltk-text_buffers.adb
+++ b/fltk-text_buffers.adb
@@ -67,6 +67,15 @@ package body FLTK.Text_Buffers is
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_savefile, "fl_text_buffer_savefile");
+ function fl_text_buffer_search_forward
+ (TB : in System.Address;
+ SP : in Interfaces.C.int;
+ IT : in Interfaces.C.char_array;
+ FP : out Interfaces.C.int;
+ CA : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_search_forward, "fl_text_buffer_search_forward");
+
procedure fl_text_buffer_select
(TB : in System.Address;
S, E : in Interfaces.C.int);
@@ -281,6 +290,31 @@ package body FLTK.Text_Buffers is
+ function Search_Forward
+ (This : in Text_Buffer;
+ Start_At : in Natural;
+ Item : in String;
+ Found_At : out Natural;
+ Match_Case : in Boolean)
+ return Boolean is
+
+ Found_Raw : Interfaces.C.int;
+ Result : Interfaces.C.int;
+
+ begin
+ Result := fl_text_buffer_search_forward
+ (This.Void_Ptr,
+ Interfaces.C.int (Start_At),
+ Interfaces.C.To_C (Item),
+ Found_Raw,
+ Boolean'Pos (Match_Case));
+ Found_At := Natural (Found_Raw);
+ return Boolean'Val (Result);
+ end Search_Forward;
+
+
+
+
procedure Set_Selection
(This : in out Text_Buffer;
Start, Finish : in Natural) is
diff --git a/fltk-text_buffers.ads b/fltk-text_buffers.ads
index eea9b73..0bb881e 100644
--- a/fltk-text_buffers.ads
+++ b/fltk-text_buffers.ads
@@ -75,6 +75,15 @@ package FLTK.Text_Buffers is
Name : in String);
+ function Search_Forward
+ (This : in Text_Buffer;
+ Start_At : in Natural;
+ Item : in String;
+ Found_At : out Natural;
+ Match_Case : in Boolean)
+ return Boolean;
+
+
procedure Set_Selection
(This : in out Text_Buffer;
Start, Finish : in Natural);
diff --git a/fltk-widgets-buttons.ads b/fltk-widgets-buttons.ads
index a31ed79..403ad1a 100644
--- a/fltk-widgets-buttons.ads
+++ b/fltk-widgets-buttons.ads
@@ -6,7 +6,7 @@ package FLTK.Widgets.Buttons is
type Button is new Widget with private;
- type State is (On, Off);
+ type State is (Off, On);
function Create
diff --git a/fltk-widgets-groups-text_displays.adb b/fltk-widgets-groups-text_displays.adb
index 0151536..473ceea 100644
--- a/fltk-widgets-groups-text_displays.adb
+++ b/fltk-widgets-groups-text_displays.adb
@@ -57,6 +57,20 @@ package body FLTK.Widgets.Groups.Text_Displays is
S : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_text_size, "fl_text_display_set_text_size");
+ function fl_text_display_get_insert_pos
+ (TD : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_display_get_insert_pos, "fl_text_display_get_insert_pos");
+
+ procedure fl_text_display_set_insert_pos
+ (TD : in System.Address;
+ P : in Interfaces.C.int);
+ pragma Import (C, fl_text_display_set_insert_pos, "fl_text_display_set_insert_pos");
+
+ procedure fl_text_display_show_insert_pos
+ (TD : in System.Address);
+ pragma Import (C, fl_text_display_show_insert_pos, "fl_text_display_show_insert_pos");
+
@@ -175,5 +189,34 @@ package body FLTK.Widgets.Groups.Text_Displays is
end Set_Text_Size;
+
+
+ function Get_Insert_Position
+ (This : in Text_Display)
+ return Natural is
+ begin
+ return Natural (fl_text_display_get_insert_pos (This.Void_Ptr));
+ end Get_Insert_Position;
+
+
+
+
+ procedure Set_Insert_Position
+ (This : in out Text_Display;
+ Pos : in Natural) is
+ begin
+ fl_text_display_set_insert_pos (This.Void_Ptr, Interfaces.C.int (Pos));
+ end Set_Insert_Position;
+
+
+
+
+ procedure Show_Insert_Position
+ (This : in out Text_Display) is
+ begin
+ fl_text_display_show_insert_pos (This.Void_Ptr);
+ end Show_Insert_Position;
+
+
end FLTK.Widgets.Groups.Text_Displays;
diff --git a/fltk-widgets-groups-text_displays.ads b/fltk-widgets-groups-text_displays.ads
index bb99e78..84c6551 100644
--- a/fltk-widgets-groups-text_displays.ads
+++ b/fltk-widgets-groups-text_displays.ads
@@ -56,6 +56,20 @@ package FLTK.Widgets.Groups.Text_Displays is
Size : in Font_Size);
+ function Get_Insert_Position
+ (This : in Text_Display)
+ return Natural;
+
+
+ procedure Set_Insert_Position
+ (This : in out Text_Display;
+ Pos : in Natural);
+
+
+ procedure Show_Insert_Position
+ (This : in out Text_Display);
+
+
private
diff --git a/fltk-widgets-inputs.adb b/fltk-widgets-inputs.adb
index 17ab621..9af8e87 100644
--- a/fltk-widgets-inputs.adb
+++ b/fltk-widgets-inputs.adb
@@ -1,6 +1,7 @@
with Interfaces.C;
+with Interfaces.C.Strings;
with System;
use type System.Address;
@@ -18,6 +19,11 @@ package body FLTK.Widgets.Inputs is
(F : in System.Address);
pragma Import (C, free_fl_input, "free_fl_input");
+ function fl_input_get_value
+ (F : in System.Address)
+ return Interfaces.C.Strings.chars_ptr;
+ pragma Import (C, fl_input_get_value, "fl_input_get_value");
+
@@ -54,5 +60,15 @@ package body FLTK.Widgets.Inputs is
end Create;
+
+
+ function Get_Value
+ (This : in Input)
+ return String is
+ begin
+ return Interfaces.C.Strings.Value (fl_input_get_value (This.Void_Ptr));
+ end Get_Value;
+
+
end FLTK.Widgets.Inputs;
diff --git a/fltk-widgets-inputs.ads b/fltk-widgets-inputs.ads
index c1ebfbb..0f818ac 100644
--- a/fltk-widgets-inputs.ads
+++ b/fltk-widgets-inputs.ads
@@ -12,6 +12,11 @@ package FLTK.Widgets.Inputs is
return Input;
+ function Get_Value
+ (This : in Input)
+ return String;
+
+
private