diff options
Diffstat (limited to 'src/fltk_binding')
-rw-r--r-- | src/fltk_binding/c_fl_text_buffer.cpp | 10 | ||||
-rw-r--r-- | src/fltk_binding/c_fl_text_buffer.h | 2 | ||||
-rw-r--r-- | src/fltk_binding/fltk-text_buffers.adb | 70 | ||||
-rw-r--r-- | src/fltk_binding/fltk-text_buffers.ads | 15 |
4 files changed, 93 insertions, 4 deletions
diff --git a/src/fltk_binding/c_fl_text_buffer.cpp b/src/fltk_binding/c_fl_text_buffer.cpp index 20699e8..623aea7 100644 --- a/src/fltk_binding/c_fl_text_buffer.cpp +++ b/src/fltk_binding/c_fl_text_buffer.cpp @@ -65,11 +65,21 @@ int fl_text_buffer_search_forward(TEXTBUFFER tb, int start, const char * item, i } +int fl_text_buffer_search_backward(TEXTBUFFER tb, int start, const char * item, int * found, int mcase) { + return reinterpret_cast<Fl_Text_Buffer*>(tb)->search_backward(start, item, found, mcase); +} + + void fl_text_buffer_select(TEXTBUFFER tb, int s, int e) { reinterpret_cast<Fl_Text_Buffer*>(tb)->select(s, e); } +int fl_text_buffer_selection_position(TEXTBUFFER tb, int * s, int * e) { + return reinterpret_cast<Fl_Text_Buffer*>(tb)->selection_position(s, e); +} + + int fl_text_buffer_skip_lines(TEXTBUFFER tb, int s, int l) { return reinterpret_cast<Fl_Text_Buffer*>(tb)->skip_lines(s, l); } diff --git a/src/fltk_binding/c_fl_text_buffer.h b/src/fltk_binding/c_fl_text_buffer.h index 0ee2e5a..4c5edb3 100644 --- a/src/fltk_binding/c_fl_text_buffer.h +++ b/src/fltk_binding/c_fl_text_buffer.h @@ -21,7 +21,9 @@ 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" int fl_text_buffer_search_backward(TEXTBUFFER tb, int start, const char * item, int * found, int mcase); extern "C" void fl_text_buffer_select(TEXTBUFFER tb, int s, int e); +extern "C" int fl_text_buffer_selection_position(TEXTBUFFER tb, int * s, int * e); extern "C" int fl_text_buffer_skip_lines(TEXTBUFFER tb, int s, int l); extern "C" int fl_text_buffer_rewind_lines(TEXTBUFFER tb, int s, int l); extern "C" unsigned int fl_text_buffer_char_at(TEXTBUFFER tb, int p); diff --git a/src/fltk_binding/fltk-text_buffers.adb b/src/fltk_binding/fltk-text_buffers.adb index 5db105d..6ff5b55 100644 --- a/src/fltk_binding/fltk-text_buffers.adb +++ b/src/fltk_binding/fltk-text_buffers.adb @@ -79,11 +79,26 @@ package body FLTK.Text_Buffers is return Interfaces.C.int; pragma Import (C, fl_text_buffer_search_forward, "fl_text_buffer_search_forward"); + function fl_text_buffer_search_backward + (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_backward, "fl_text_buffer_search_backward"); + procedure fl_text_buffer_select (TB : in System.Address; S, E : in Interfaces.C.int); pragma Import (C, fl_text_buffer_select, "fl_text_buffer_select"); + function fl_text_buffer_selection_position + (TB : in System.Address; + S, E : out Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_text_buffer_selection_position, "fl_text_buffer_selection_position"); + function fl_text_buffer_skip_lines (TB : in System.Address; S, L : in Interfaces.C.int) @@ -327,8 +342,7 @@ package body FLTK.Text_Buffers is Match_Case : in Boolean) return Boolean is - Found_Raw : Interfaces.C.int; - Result : Interfaces.C.int; + Found_Raw, Result : Interfaces.C.int; begin Result := fl_text_buffer_search_forward (This.Void_Ptr, @@ -336,13 +350,40 @@ package body FLTK.Text_Buffers is Interfaces.C.To_C (Item), Found_Raw, Boolean'Pos (Match_Case)); - Found_At := Natural (Found_Raw); - return Boolean'Val (Result); + if Result /= 0 then + Found_At := Natural (Found_Raw); + end if; + return Result /= 0; end Search_Forward; + function Search_Backward + (This : in Text_Buffer; + Start_At : in Natural; + Item : in String; + Found_At : out Natural; + Match_Case : in Boolean) + return Boolean + is + Found_Raw, Result : Interfaces.C.int; + begin + Result := fl_text_buffer_search_backward + (This.Void_Ptr, + Interfaces.C.int (Start_At), + Interfaces.C.To_C (Item), + Found_Raw, + Boolean'Pos (Match_Case)); + if Result /= 0 then + Found_At := Natural (Found_Raw); + end if; + return Result /= 0; + end Search_Backward; + + + + procedure Set_Selection (This : in out Text_Buffer; Start, Finish : in Natural) is @@ -356,6 +397,27 @@ package body FLTK.Text_Buffers is + function Get_Selection + (This : in Text_Buffer; + Start, Finish : out Natural) + return Boolean + is + Result, Start_Raw, Finish_Raw : Interfaces.C.int; + begin + Result := fl_text_buffer_selection_position + (This.Void_Ptr, + Start_Raw, + Finish_Raw); + if Result /= 0 then + Start := Natural (Start_Raw); + Finish := Natural (Finish_Raw); + end if; + return Result /= 0; + end Get_Selection; + + + + function Skip_Lines (This : in out Text_Buffer; Start, Lines : in Natural) diff --git a/src/fltk_binding/fltk-text_buffers.ads b/src/fltk_binding/fltk-text_buffers.ads index 171fd84..582de1d 100644 --- a/src/fltk_binding/fltk-text_buffers.ads +++ b/src/fltk_binding/fltk-text_buffers.ads @@ -86,11 +86,26 @@ package FLTK.Text_Buffers is return Boolean; + function Search_Backward + (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); + function Get_Selection + (This : in Text_Buffer; + Start, Finish : out Natural) + return Boolean; + + -- only takes into account newline characters, not word wrap function Skip_Lines (This : in out Text_Buffer; |