From 3b643fb37910c216d921e742ae30471606093ed9 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Tue, 4 Oct 2016 21:34:08 +1100 Subject: Basic replace functionality added --- src/fltk_binding/c_fl_text_buffer.cpp | 5 +++++ src/fltk_binding/c_fl_text_buffer.h | 1 + src/fltk_binding/fltk-text_buffers.adb | 20 ++++++++++++++++++++ src/fltk_binding/fltk-text_buffers.ads | 6 ++++++ 4 files changed, 32 insertions(+) (limited to 'src/fltk_binding') diff --git a/src/fltk_binding/c_fl_text_buffer.cpp b/src/fltk_binding/c_fl_text_buffer.cpp index b0df365..8b0cde1 100644 --- a/src/fltk_binding/c_fl_text_buffer.cpp +++ b/src/fltk_binding/c_fl_text_buffer.cpp @@ -35,6 +35,11 @@ void fl_text_buffer_call_predelete_callbacks(TEXTBUFFER tb) { } +void fl_text_buffer_insert(TEXTBUFFER tb, int p, const char * item) { + reinterpret_cast(tb)->insert(p, item); +} + + int fl_text_buffer_length(TEXTBUFFER tb) { return reinterpret_cast(tb)->length(); } diff --git a/src/fltk_binding/c_fl_text_buffer.h b/src/fltk_binding/c_fl_text_buffer.h index cd64112..5a1ab08 100644 --- a/src/fltk_binding/c_fl_text_buffer.h +++ b/src/fltk_binding/c_fl_text_buffer.h @@ -15,6 +15,7 @@ extern "C" void fl_text_buffer_add_modify_callback(TEXTBUFFER tb, void * cb, voi extern "C" void fl_text_buffer_add_predelete_callback(TEXTBUFFER tb, void * cb, void * ud); extern "C" void fl_text_buffer_call_modify_callbacks(TEXTBUFFER tb); extern "C" void fl_text_buffer_call_predelete_callbacks(TEXTBUFFER tb); +extern "C" void fl_text_buffer_insert(TEXTBUFFER tb, int p, const char * item); 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); diff --git a/src/fltk_binding/fltk-text_buffers.adb b/src/fltk_binding/fltk-text_buffers.adb index 6df96cb..b3b8344 100644 --- a/src/fltk_binding/fltk-text_buffers.adb +++ b/src/fltk_binding/fltk-text_buffers.adb @@ -46,6 +46,12 @@ package body FLTK.Text_Buffers is pragma Import (C, fl_text_buffer_call_predelete_callbacks, "fl_text_buffer_call_predelete_callbacks"); + procedure fl_text_buffer_insert + (TB : in System.Address; + P : in Interfaces.C.int; + I : in Interfaces.C.char_array); + pragma Import (C, fl_text_buffer_insert, "fl_text_buffer_insert"); + function fl_text_buffer_length (TB : in System.Address) return Interfaces.C.int; @@ -237,6 +243,20 @@ package body FLTK.Text_Buffers is + procedure Insert_Text + (This : in out Text_Buffer; + Pos : in Natural; + Item : in String) is + begin + fl_text_buffer_insert + (This.Void_Ptr, + Interfaces.C.int (Pos), + Interfaces.C.To_C (Item)); + end Insert_Text; + + + + function Length (This : in Text_Buffer) return Natural is diff --git a/src/fltk_binding/fltk-text_buffers.ads b/src/fltk_binding/fltk-text_buffers.ads index 0bb881e..a560076 100644 --- a/src/fltk_binding/fltk-text_buffers.ads +++ b/src/fltk_binding/fltk-text_buffers.ads @@ -56,6 +56,12 @@ package FLTK.Text_Buffers is (This : in out Text_Buffer); + procedure Insert_Text + (This : in out Text_Buffer; + Pos : in Natural; + Item : in String); + + function Length (This : in Text_Buffer) return Natural; -- cgit