summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2018-05-01 00:16:31 +1000
committerJed Barber <jjbarber@y7mail.com>2018-05-01 00:16:31 +1000
commit6bb8375e7f8f5a888b0fa800ba09c1e5a950399d (patch)
tree7b437af6fdbee56fed4697dc1d3a5d4fe9808fae
parent71c1c5bb789f315239a64cb22002088ddcb353b1 (diff)
Completed and polished FLTK.Text_Buffers
-rw-r--r--doc/fl_text_buffer.html881
-rw-r--r--progress.txt2
-rw-r--r--src/c_fl_text_buffer.cpp172
-rw-r--r--src/c_fl_text_buffer.h88
-rw-r--r--src/fltk-text_buffers.adb893
-rw-r--r--src/fltk-text_buffers.ads345
6 files changed, 2250 insertions, 131 deletions
diff --git a/doc/fl_text_buffer.html b/doc/fl_text_buffer.html
new file mode 100644
index 0000000..8fe431f
--- /dev/null
+++ b/doc/fl_text_buffer.html
@@ -0,0 +1,881 @@
+
+<!DOCTYPE html>
+
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Fl_Text_Buffer Binding Map</title>
+ <link href="map.css" rel="stylesheet">
+ </head>
+
+ <body>
+
+
+<h2>Fl_Text_Buffer Binding Map</h2>
+
+
+<table class="package">
+ <tr><th colspan="2">Package name</th></tr>
+
+ <tr>
+ <td>Fl_Text_Buffer</td>
+ <td>FLTK.Text_Buffers</td>
+ </tr>
+
+</table>
+
+
+
+<table class="type">
+ <tr><th colspan="2">Types</th></tr>
+
+ <tr>
+ <td>Fl_Text_Buffer</td>
+ <td>Text_Buffer</td>
+ </tr>
+
+ <tr>
+ <td>&nbsp;</td>
+ <td>Text_Buffer_Reference</td>
+ </tr>
+
+ <tr>
+ <td>&nbsp;</td>
+ <td>Position</td>
+ </tr>
+
+ <tr>
+ <td>&nbsp;</td>
+ <td>Modification</td>
+ </tr>
+
+ <tr>
+ <td>Fl_Text_Modify_Cb</td>
+ <td>Modify_Callback</td>
+ </tr>
+
+ <tr>
+ <td>Fl_Text_Predelete_Cb</td>
+ <td>Predelete_Callback</td>
+ </tr>
+
+ <tr>
+ <td>Fl_Text_Selection</td>
+ <td>&nbsp;</td>
+ </tr>
+
+</table>
+
+
+
+<table class="function">
+ <tr><th colspan="2">Functions and Procedures</th></tr>
+
+ <tr>
+<td><pre>
+Fl_Text_Buffer(int requestedSize=0, int preferredGapSize=1024);
+</pre></td>
+<td><pre>
+function Create
+ (Requested_Size : in Natural := 0;
+ Preferred_Gap_Size : in Natural := 1024)
+ return Text_Buffer;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void add_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void *cbArg);
+</pre></td>
+<td><pre>
+procedure Add_Modify_Callback
+ (This : in out Text_Buffer;
+ Func : in Modify_Callback);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void add_predelete_callback(Fl_Text_Predelete_Cb bufPredelCB, void *cbArg);
+</pre></td>
+<td><pre>
+procedure Add_Predelete_Callback
+ (This : in out Text_Buffer;
+ Func : in Predelete_Callback);
+</pre></td>
+ </tr>
+
+ <tr>
+<td>&nbsp;</td>
+<td><pre>
+procedure Enable_Callbacks
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td>&nbsp;</td>
+<td><pre>
+procedure Disable_Callbacks
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+const char * address(int pos) const;
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+char * address(int pos);
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+void append(const char *t);
+</pre></td>
+<td><pre>
+procedure Append_Text
+ (This : in out Text_Buffer;
+ Text : in String);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int appendFile(const char *file, int buflen=128*1024);
+</pre></td>
+<td><pre>
+procedure Append_File
+ (This : in out Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+char byte_at(int pos) const;
+</pre></td>
+<td><pre>
+function Byte_At
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void call_modify_callbacks();
+</pre></td>
+<td><pre>
+procedure Call_Modify_Callbacks
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void call_predelete_callbacks();
+</pre></td>
+<td><pre>
+procedure Call_Predelete_Callbacks
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void canUndo(char flag=1);
+</pre></td>
+<td><pre>
+procedure Can_Undo
+ (This : in out Text_Buffer;
+ Flag : in Boolean);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+unsigned int char_at(int pos) const;
+</pre></td>
+<td><pre>
+function Character_At
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void copy(Fl_Text_Buffer *fromBuf, int fromStart, int fromEnd, int toPos);
+</pre></td>
+<td><pre>
+procedure Copy
+ (This : in out Text_Buffer;
+ From : in Text_Buffer;
+ Start, Finish : in Position;
+ Insert_Pos : in Position);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int count_displayed_characters(int lineStartPos, int targetPos) const;
+</pre></td>
+<td><pre>
+function Count_Displayed_Characters
+ (This : in Text_Buffer;
+ Start, Finish : in Position)
+ return Integer;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int count_lines(int startPos, int endPos) const;
+</pre></td>
+<td><pre>
+function Count_Lines
+ (This : in Text_Buffer;
+ Start, Finish : in Position)
+ return Integer;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int findchar_backward(int startPos, unsigned int searchChar, int *foundPos) const;
+</pre></td>
+<td><pre>
+function Findchar_Backward
+ (This : in Text_Buffer;
+ Start_At : in Position;
+ Item : in Character;
+ Found_At : out Position)
+ return Boolean;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int findchar_forward(int startPos, unsigned searchChar, int *foundPos) const;
+</pre></td>
+<td><pre>
+function Findchar_Forward
+ (This : in Text_Buffer;
+ Start_At : in Position;
+ Item : in Character;
+ Found_At : out Position)
+ return Boolean;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void highlight(int start, int end);
+</pre></td>
+<td><pre>
+procedure Set_Highlight
+ (This : in out Text_Buffer;
+ Start, Finish : in Position);
+</pre></td>
+ </tr>
+
+ <tr>
+<td>&nbsp;</td>
+<td><pre>
+procedure Get_Highlight
+ (This : in Text_Buffer;
+ Start, Finish : out Position);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int highlight();
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+int highlight_position(int *start, int *end);
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+const Fl_Text_Selection * highlight_selection() const;
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+char * highlight_text();
+</pre></td>
+<td><pre>
+function Get_Highlighted_Text
+ (This : in Text_Buffer)
+ return String;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void insert(int pos, const char *text);
+</pre></td>
+<td><pre>
+procedure Insert_Text
+ (This : in out Text_Buffer;
+ Place : in Position;
+ Text : in String);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int insertfile(const char *file, int pos, int buflen=128*1024);
+</pre></td>
+<td><pre>
+procedure Insert_File
+ (This : in out Text_Buffer;
+ Name : in String;
+ Place : in Position;
+ Buffer : in Natural := 128 * 1024);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int length() const;
+</pre></td>
+<td><pre>
+function Length
+ (This : in Text_Buffer)
+ return Natural;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int line_end(int pos) const;
+</pre></td>
+<td><pre>
+function Line_End
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int line_start(int pos) const;
+</pre></td>
+<td><pre>
+function Line_Start
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+char * line_text(int pos) const;
+</pre></td>
+<td><pre>
+function Line_Text
+ (This : in Text_Buffer;
+ Place : in Position)
+ return String;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int loadfile(const char *file, int buflen=128*1024);
+</pre></td>
+<td><pre>
+procedure Load_File
+ (This : in out Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int next_char(int ix) const;
+</pre></td>
+<td><pre>
+function Next_Char
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int next_char_clipped(int ix) const;
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+int outputfile(const char *file, int start, int end, int buflen=128*1024);
+</pre></td>
+<td><pre>
+procedure Output_File
+ (This : in Text_Buffer;
+ Name : in String;
+ Start, Finish : in Position;
+ Buffer : in Natural := 128 * 1024);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int prev_char(int ix) const;
+</pre></td>
+<td><pre>
+function Prev_Char
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int prev_char_clipped(int ix) const;
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+const Fl_Text_Selection * primary_selection() const;
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+Fl_Text_Selection * primary_selection();
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+void remove(int start, int end);
+</pre></td>
+<td><pre>
+procedure Remove_Text
+ (This : in out Text_Buffer;
+ Start, Finish : in Position);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void *cbArg);
+</pre></td>
+<td><pre>
+procedure Remove_Modify_Callback
+ (This : in out Text_Buffer;
+ Func : in Modify_Callback);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void remove_predelete_callback(Fl_Text_Predelete_Cb predelCB, void *cbArg);
+</pre></td>
+<td><pre>
+procedure Remove_Predelete_Callback
+ (This : in out Text_Buffer;
+ Func : in Predelete_Callback);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void remove_secondary_selection();
+</pre></td>
+<td><pre>
+procedure Remove_Secondary_Selection
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void remove_selection();
+</pre></td>
+<td><pre>
+procedure Remove_Selection
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void replace(int start, int end, const char *text);
+</pre></td>
+<td><pre>
+procedure Replace_Text
+ (This : in out Text_Buffer;
+ Start, Finish : in Position;
+ Text : in String);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void replace_secondary_selection(const char *text);
+</pre></td>
+<td><pre>
+procedure Replace_Secondary_Selection
+ (This : in out Text_Buffer;
+ Text : in String);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void replace_selection(const char *text);
+</pre></td>
+<td><pre>
+procedure Replace_Selection
+ (This : in out Text_Buffer;
+ Text : in String);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int rewind_lines(int startPos, int nLines);
+</pre></td>
+<td><pre>
+function Rewind_Lines
+ (This : in out Text_Buffer;
+ Start : in Position;
+ Lines : in Natural)
+ return Position;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int savefile(const char *file, int buflen=128*1024);
+</pre></td>
+<td><pre>
+procedure Save_File
+ (This : in Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int search_backward(int startPos, const char *searchString, int *foundPos, int matchCase=0) const;
+</pre></td>
+<td><pre>
+function Search_Backward
+ (This : in Text_Buffer;
+ Start_At : in Position;
+ Item : in String;
+ Found_At : out Position;
+ Match_Case : in Boolean := False)
+ return Boolean;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int search_forward(int startPos, const char *searchString, int *foundPos, int matchCase=0) const;
+</pre></td>
+<td><pre>
+function Search_Forward
+ (This : in Text_Buffer;
+ Start_At : in Position;
+ Item : in String;
+ Found_At : out Position;
+ Match_Case : in Boolean := False)
+ return Boolean;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void secondary_select(int start, int end);
+</pre></td>
+<td><pre>
+procedure Set_Secondary_Selection
+ (This : in out Text_Buffer;
+ Start, Finish : in Position);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int secondary_selected();
+</pre></td>
+<td><pre>
+function Has_Secondary_Selection
+ (This : in Text_Buffer)
+ return Boolean;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+const Fl_Text_Selection * secondary_selection() const;
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+int secondary_selection_position(int *start, int *end);
+</pre></td>
+<td><pre>
+function Get_Secondary_Selection
+ (This : in Text_Buffer;
+ Start, Finish : out Position)
+ return Boolean;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+char * secondary_selection_text();
+</pre></td>
+<td><pre>
+function Secondary_Selection_Text
+ (This : in Text_Buffer)
+ return String;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void secondary_unselect();
+</pre></td>
+<td><pre>
+procedure Secondary_Unselect
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void select(int start, int end);
+</pre></td>
+<td><pre>
+procedure Set_Selection
+ (This : in out Text_Buffer;
+ Start, Finish : in Position);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int selected() const;
+</pre></td>
+<td><pre>
+function Has_Selection
+ (This : in Text_Buffer)
+ return Boolean;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int selection_position(int *start, int *end);
+</pre></td>
+<td><pre>
+function Get_Selection
+ (This : in Text_Buffer;
+ Start, Finish : out Position)
+ return Boolean;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+char * selection_text();
+</pre></td>
+<td><pre>
+function Selection_Text
+ (This : in Text_Buffer)
+ return String;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int skip_displayed_characters(int lineStartPos, int nChars);
+</pre></td>
+<td><pre>
+function Skip_Displayed_Characters
+ (This : in Text_Buffer;
+ Start : in Position;
+ Chars : in Natural)
+ return Position;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int skip_lines(int startPos, int nLines);
+</pre></td>
+<td><pre>
+function Skip_Lines
+ (This : in out Text_Buffer;
+ Start : in Position;
+ Lines : in Natural)
+ return Position;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int tab_distance() const;
+</pre></td>
+<td><pre>
+function Get_Tab_Width
+ (This : in Text_Buffer)
+ return Natural;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void tab_distance(int tabDist);
+</pre></td>
+<td><pre>
+procedure Set_Tab_Width
+ (This : in out Text_Buffer;
+ To : in Natural);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+char * text() const;
+</pre></td>
+<td><pre>
+function Get_Entire_Text
+ (This : in Text_Buffer)
+ return String;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void text(const char *text);
+</pre></td>
+<td><pre>
+procedure Set_Entire_Text
+ (This : in out Text_Buffer;
+ Text : in String);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+char * text_range(int start, int end) const;
+</pre></td>
+<td><pre>
+function Text_At
+ (This : in Text_Buffer;
+ Start, Finish : in Position)
+ return String;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int undo(int *cp=0);
+</pre></td>
+<td>&nbsp;</td>
+ </tr>
+
+ <tr>
+<td><pre>
+void unhighlight();
+</pre></td>
+<td><pre>
+procedure Unhighlight
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+void unselect();
+</pre></td>
+<td><pre>
+procedure Unselect
+ (This : in out Text_Buffer);
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int utf8_align(int) const;
+</pre></td>
+<td><pre>
+function UTF8_Align
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int word_end(int pos) const;
+</pre></td>
+<td><pre>
+function Word_End
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+</pre></td>
+ </tr>
+
+ <tr>
+<td><pre>
+int word_start(int pos) const;
+</pre></td>
+<td><pre>
+function Word_Start
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+</pre></td>
+ </tr>
+
+</table>
+
+
+ </body>
+</html>
+
diff --git a/progress.txt b/progress.txt
index 558d332..a9a1f4e 100644
--- a/progress.txt
+++ b/progress.txt
@@ -27,6 +27,7 @@ FLTK.Images.RGB.JPEG
FLTK.Images.RGB.PNG
FLTK.Images.RGB.PNM
FLTK.Images.Shared
+FLTK.Text_Buffers
FLTK.Tooltips
FLTK.Widgets.Boxes
FLTK.Widgets.Buttons
@@ -104,7 +105,6 @@ FLTK.Devices.Graphics
FLTK.Devices.Surfaces
FLTK.Environment
FLTK.Menu_Items
-FLTK.Text_Buffers
FLTK.Widgets
FLTK.Widgets.Groups
FLTK.Widgets.Menus
diff --git a/src/c_fl_text_buffer.cpp b/src/c_fl_text_buffer.cpp
index 46d7700..2df65f6 100644
--- a/src/c_fl_text_buffer.cpp
+++ b/src/c_fl_text_buffer.cpp
@@ -37,12 +37,24 @@ void fl_text_buffer_call_predelete_callbacks(TEXTBUFFER tb) {
-int fl_text_buffer_loadfile(TEXTBUFFER tb, char * n) {
- return reinterpret_cast<Fl_Text_Buffer*>(tb)->loadfile(n);
+int fl_text_buffer_loadfile(TEXTBUFFER tb, char * n, int b) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->loadfile(n,b);
}
-int fl_text_buffer_savefile(TEXTBUFFER tb, char * n) {
- return reinterpret_cast<Fl_Text_Buffer*>(tb)->savefile(n);
+int fl_text_buffer_appendfile(TEXTBUFFER tb, char * n, int b) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->appendfile(n,b);
+}
+
+int fl_text_buffer_insertfile(TEXTBUFFER tb, char * n, int p, int b) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->insertfile(n,p,b);
+}
+
+int fl_text_buffer_outputfile(TEXTBUFFER tb, char * n, int f, int t, int b) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->outputfile(n,f,t,b);
+}
+
+int fl_text_buffer_savefile(TEXTBUFFER tb, char * n, int b) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->savefile(n,b);
}
@@ -52,10 +64,30 @@ void fl_text_buffer_insert(TEXTBUFFER tb, int p, const char * item) {
reinterpret_cast<Fl_Text_Buffer*>(tb)->insert(p, item);
}
+void fl_text_buffer_append(TEXTBUFFER tb, const char * item) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->append(item);
+}
+
+void fl_text_buffer_replace(TEXTBUFFER tb, int s, int f, const char * text) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->replace(s, f, text);
+}
+
void fl_text_buffer_remove(TEXTBUFFER tb, int s, int f) {
reinterpret_cast<Fl_Text_Buffer*>(tb)->remove(s, f);
}
+char * fl_text_buffer_get_text(TEXTBUFFER tb) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->text();
+}
+
+void fl_text_buffer_set_text(TEXTBUFFER tb, char * t) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->text(t);
+}
+
+char fl_text_buffer_byte_at(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->byte_at(p);
+}
+
unsigned int fl_text_buffer_char_at(TEXTBUFFER tb, int p) {
return reinterpret_cast<Fl_Text_Buffer*>(tb)->char_at(p);
}
@@ -64,10 +96,37 @@ char * fl_text_buffer_text_range(TEXTBUFFER tb, int s, int f) {
return reinterpret_cast<Fl_Text_Buffer*>(tb)->text_range(s, f);
}
+int fl_text_buffer_next_char(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->next_char(p);
+}
+
+int fl_text_buffer_prev_char(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->prev_char(p);
+}
+
+
+
+
+int fl_text_buffer_count_displayed_characters(TEXTBUFFER tb, int s, int f) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->count_displayed_characters(s,f);
+}
+
+int fl_text_buffer_count_lines(TEXTBUFFER tb, int s, int f) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->count_lines(s,f);
+}
+
int fl_text_buffer_length(TEXTBUFFER tb) {
return reinterpret_cast<Fl_Text_Buffer*>(tb)->length();
}
+int fl_text_buffer_get_tab_distance(TEXTBUFFER tb) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->tab_distance();
+}
+
+void fl_text_buffer_set_tab_distance(TEXTBUFFER tb, int t) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->tab_distance(t);
+}
+
@@ -75,21 +134,83 @@ 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_secondary_selection_position(TEXTBUFFER tb, int * s, int * e) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->secondary_selection_position(s,e);
+}
+
void fl_text_buffer_select(TEXTBUFFER tb, int s, int e) {
reinterpret_cast<Fl_Text_Buffer*>(tb)->select(s, e);
}
+void fl_text_buffer_secondary_select(TEXTBUFFER tb, int s, int e) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->secondary_select(s,e);
+}
+
int fl_text_buffer_selected(TEXTBUFFER tb) {
return reinterpret_cast<Fl_Text_Buffer*>(tb)->selected();
}
+int fl_text_buffer_secondary_selected(TEXTBUFFER tb) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->secondary_selected();
+}
+
+char * fl_text_buffer_selection_text(TEXTBUFFER tb) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->selection_text();
+}
+
+char * fl_text_buffer_secondary_selection_text(TEXTBUFFER tb) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->secondary_selection_text();
+}
+
+void fl_text_buffer_replace_selection(TEXTBUFFER tb, char * t) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->replace_selection(t);
+}
+
+void fl_text_buffer_replace_secondary_selection(TEXTBUFFER tb, char * t) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->replace_secondary_selection(t);
+}
+
void fl_text_buffer_remove_selection(TEXTBUFFER tb) {
reinterpret_cast<Fl_Text_Buffer*>(tb)->remove_selection();
}
+void fl_text_buffer_remove_secondary_selection(TEXTBUFFER tb) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->remove_secondary_selection();
+}
+
+void fl_text_buffer_unselect(TEXTBUFFER tb) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->unselect();
+}
+
+void fl_text_buffer_secondary_unselect(TEXTBUFFER tb) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->secondary_unselect();
+}
+
+
+
+
+void fl_text_buffer_highlight(TEXTBUFFER tb, int f, int t) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->highlight(f,t);
+}
+
+char * fl_text_buffer_highlight_text(TEXTBUFFER tb) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->highlight_text();
+}
+
+void fl_text_buffer_unhighlight(TEXTBUFFER tb) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->unhighlight();
+}
+
+int fl_text_buffer_findchar_forward(TEXTBUFFER tb, int start, unsigned int item, int * found) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->findchar_forward(start, item, found);
+}
+
+int fl_text_buffer_findchar_backward(TEXTBUFFER tb, int start, unsigned int item, int * found) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->findchar_backward(start, item, found);
+}
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);
@@ -99,6 +220,29 @@ int fl_text_buffer_search_backward(TEXTBUFFER tb, int start, const char * item,
return reinterpret_cast<Fl_Text_Buffer*>(tb)->search_backward(start, item, found, mcase);
}
+
+
+
+int fl_text_buffer_word_start(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->word_start(p);
+}
+
+int fl_text_buffer_word_end(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->word_end(p);
+}
+
+int fl_text_buffer_line_start(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->line_start(p);
+}
+
+int fl_text_buffer_line_end(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->line_end(p);
+}
+
+char * fl_text_buffer_line_text(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->line_text(p);
+}
+
int fl_text_buffer_skip_lines(TEXTBUFFER tb, int s, int l) {
return reinterpret_cast<Fl_Text_Buffer*>(tb)->skip_lines(s, l);
}
@@ -107,3 +251,23 @@ int fl_text_buffer_rewind_lines(TEXTBUFFER tb, int s, int l) {
return reinterpret_cast<Fl_Text_Buffer*>(tb)->rewind_lines(s, l);
}
+int fl_text_buffer_skip_displayed_characters(TEXTBUFFER tb, int s, int n) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->skip_displayed_characters(s,n);
+}
+
+
+
+
+void fl_text_buffer_canundo(TEXTBUFFER tb, char f) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->canUndo(f);
+}
+
+void fl_text_buffer_copy(TEXTBUFFER tb, TEXTBUFFER tb2, int s, int f, int i) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->copy(reinterpret_cast<Fl_Text_Buffer*>(tb2),s,f,i);
+}
+
+int fl_text_buffer_utf8_align(TEXTBUFFER tb, int p) {
+ return reinterpret_cast<Fl_Text_Buffer*>(tb)->utf8_align(p);
+}
+
+
diff --git a/src/c_fl_text_buffer.h b/src/c_fl_text_buffer.h
index 757a132..0feb4e8 100644
--- a/src/c_fl_text_buffer.h
+++ b/src/c_fl_text_buffer.h
@@ -11,39 +11,85 @@ typedef void* TEXTBUFFER;
-extern "C" TEXTBUFFER new_fl_text_buffer(int rs, int pgs);
-extern "C" void free_fl_text_buffer(TEXTBUFFER tb);
+extern "C" inline TEXTBUFFER new_fl_text_buffer(int rs, int pgs);
+extern "C" inline void free_fl_text_buffer(TEXTBUFFER tb);
-extern "C" void fl_text_buffer_add_modify_callback(TEXTBUFFER tb, void * cb, void * ud);
-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" inline void fl_text_buffer_add_modify_callback(TEXTBUFFER tb, void * cb, void * ud);
+extern "C" inline void fl_text_buffer_add_predelete_callback(TEXTBUFFER tb, void * cb, void * ud);
+extern "C" inline void fl_text_buffer_call_modify_callbacks(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_call_predelete_callbacks(TEXTBUFFER tb);
-extern "C" int fl_text_buffer_loadfile(TEXTBUFFER tb, char * n);
-extern "C" int fl_text_buffer_savefile(TEXTBUFFER tb, char * n);
+extern "C" inline int fl_text_buffer_loadfile(TEXTBUFFER tb, char * n, int b);
+extern "C" inline int fl_text_buffer_appendfile(TEXTBUFFER tb, char * n, int b);
+extern "C" inline int fl_text_buffer_insertfile(TEXTBUFFER tb, char * n, int p, int b);
+extern "C" inline int fl_text_buffer_outputfile(TEXTBUFFER tb, char * n, int f, int t, int b);
+extern "C" inline int fl_text_buffer_savefile(TEXTBUFFER tb, char * n, int b);
-extern "C" void fl_text_buffer_insert(TEXTBUFFER tb, int p, const char * item);
-extern "C" void fl_text_buffer_remove(TEXTBUFFER tb, int s, int f);
-extern "C" unsigned int fl_text_buffer_char_at(TEXTBUFFER tb, int p);
-extern "C" char * fl_text_buffer_text_range(TEXTBUFFER tb, int s, int f);
-extern "C" int fl_text_buffer_length(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_insert(TEXTBUFFER tb, int p, const char * item);
+extern "C" inline void fl_text_buffer_append(TEXTBUFFER tb, const char * item);
+extern "C" inline void fl_text_buffer_replace(TEXTBUFFER tb, int s, int f, const char * text);
+extern "C" inline void fl_text_buffer_remove(TEXTBUFFER tb, int s, int f);
+extern "C" inline char * fl_text_buffer_get_text(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_set_text(TEXTBUFFER tb, char * t);
+extern "C" inline char fl_text_buffer_byte_at(TEXTBUFFER tb, int p);
+extern "C" inline unsigned int fl_text_buffer_char_at(TEXTBUFFER tb, int p);
+extern "C" inline char * fl_text_buffer_text_range(TEXTBUFFER tb, int s, int f);
+extern "C" inline int fl_text_buffer_next_char(TEXTBUFFER tb, int p);
+extern "C" inline int fl_text_buffer_prev_char(TEXTBUFFER tb, int p);
-extern "C" int fl_text_buffer_selection_position(TEXTBUFFER tb, int * s, int * e);
-extern "C" void fl_text_buffer_select(TEXTBUFFER tb, int s, int e);
-extern "C" int fl_text_buffer_selected(TEXTBUFFER tb);
-extern "C" void fl_text_buffer_remove_selection(TEXTBUFFER tb);
+extern "C" inline int fl_text_buffer_count_displayed_characters(TEXTBUFFER tb, int s, int f);
+extern "C" inline int fl_text_buffer_count_lines(TEXTBUFFER tb, int s, int f);
+extern "C" inline int fl_text_buffer_length(TEXTBUFFER tb);
+extern "C" inline int fl_text_buffer_get_tab_distance(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_set_tab_distance(TEXTBUFFER tb, int t);
-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" 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" inline int fl_text_buffer_selection_position(TEXTBUFFER tb, int * s, int * e);
+extern "C" inline int fl_text_buffer_secondary_selection_position(TEXTBUFFER tb, int * s, int * e);
+extern "C" inline void fl_text_buffer_select(TEXTBUFFER tb, int s, int e);
+extern "C" inline void fl_text_buffer_secondary_select(TEXTBUFFER tb, int s, int e);
+extern "C" inline int fl_text_buffer_selected(TEXTBUFFER tb);
+extern "C" inline int fl_text_buffer_secondary_selected(TEXTBUFFER tb);
+extern "C" inline char * fl_text_buffer_selection_text(TEXTBUFFER tb);
+extern "C" inline char * fl_text_buffer_secondary_selection_text(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_replace_selection(TEXTBUFFER tb, char * t);
+extern "C" inline void fl_text_buffer_replace_secondary_selection(TEXTBUFFER tb, char * t);
+extern "C" inline void fl_text_buffer_remove_selection(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_remove_secondary_selection(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_unselect(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_secondary_unselect(TEXTBUFFER tb);
+
+
+extern "C" inline void fl_text_buffer_highlight(TEXTBUFFER tb, int f, int t);
+extern "C" inline char * fl_text_buffer_highlight_text(TEXTBUFFER tb);
+extern "C" inline void fl_text_buffer_unhighlight(TEXTBUFFER tb);
+
+
+extern "C" inline int fl_text_buffer_findchar_forward(TEXTBUFFER tb, int start, unsigned int item, int * found);
+extern "C" inline int fl_text_buffer_findchar_backward(TEXTBUFFER tb, int start, unsigned int item, int * found);
+extern "C" inline int fl_text_buffer_search_forward(TEXTBUFFER tb, int start, const char * item, int * found, int mcase);
+extern "C" inline int fl_text_buffer_search_backward(TEXTBUFFER tb, int start, const char * item, int * found, int mcase);
+
+
+extern "C" inline int fl_text_buffer_word_start(TEXTBUFFER tb, int p);
+extern "C" inline int fl_text_buffer_word_end(TEXTBUFFER tb, int p);
+extern "C" inline int fl_text_buffer_line_start(TEXTBUFFER tb, int p);
+extern "C" inline int fl_text_buffer_line_end(TEXTBUFFER tb, int p);
+extern "C" inline char * fl_text_buffer_line_text(TEXTBUFFER tb, int p);
+extern "C" inline int fl_text_buffer_skip_lines(TEXTBUFFER tb, int s, int l);
+extern "C" inline int fl_text_buffer_rewind_lines(TEXTBUFFER tb, int s, int l);
+extern "C" inline int fl_text_buffer_skip_displayed_characters(TEXTBUFFER tb, int s, int n);
+
+
+extern "C" inline void fl_text_buffer_canundo(TEXTBUFFER tb, char f);
+extern "C" inline void fl_text_buffer_copy(TEXTBUFFER tb, TEXTBUFFER tb2, int s, int f, int i);
+extern "C" inline int fl_text_buffer_utf8_align(TEXTBUFFER tb, int p);
#endif
diff --git a/src/fltk-text_buffers.adb b/src/fltk-text_buffers.adb
index 394ff02..92e4922 100644
--- a/src/fltk-text_buffers.adb
+++ b/src/fltk-text_buffers.adb
@@ -26,10 +26,12 @@ package body FLTK.Text_Buffers is
(RS, PGS : in Interfaces.C.int)
return System.Address;
pragma Import (C, new_fl_text_buffer, "new_fl_text_buffer");
+ pragma Inline (new_fl_text_buffer);
procedure free_fl_text_buffer
(TB : in System.Address);
pragma Import (C, free_fl_text_buffer, "free_fl_text_buffer");
+ pragma Inline (free_fl_text_buffer);
@@ -38,36 +40,69 @@ package body FLTK.Text_Buffers is
(TB, CB, UD : in System.Address);
pragma Import (C, fl_text_buffer_add_modify_callback,
"fl_text_buffer_add_modify_callback");
+ pragma Inline (fl_text_buffer_add_modify_callback);
procedure fl_text_buffer_add_predelete_callback
(TB, CB, UD : in System.Address);
pragma Import (C, fl_text_buffer_add_predelete_callback,
"fl_text_buffer_add_predelete_callback");
+ pragma Inline (fl_text_buffer_add_predelete_callback);
procedure fl_text_buffer_call_modify_callbacks
(TB : in System.Address);
pragma Import (C, fl_text_buffer_call_modify_callbacks,
"fl_text_buffer_call_modify_callbacks");
+ pragma Inline (fl_text_buffer_call_modify_callbacks);
procedure fl_text_buffer_call_predelete_callbacks
(TB : in System.Address);
pragma Import (C, fl_text_buffer_call_predelete_callbacks,
"fl_text_buffer_call_predelete_callbacks");
+ pragma Inline (fl_text_buffer_call_predelete_callbacks);
function fl_text_buffer_loadfile
(TB : in System.Address;
- N : in Interfaces.C.char_array)
+ N : in Interfaces.C.char_array;
+ B : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_loadfile, "fl_text_buffer_loadfile");
+ pragma Inline (fl_text_buffer_loadfile);
+
+ function fl_text_buffer_appendfile
+ (TB : in System.Address;
+ N : in Interfaces.C.char_array;
+ B : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_appendfile, "fl_text_buffer_appendfile");
+ pragma Inline (fl_text_buffer_appendfile);
+
+ function fl_text_buffer_insertfile
+ (TB : in System.Address;
+ N : in Interfaces.C.char_array;
+ P, B : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_insertfile, "fl_text_buffer_insertfile");
+ pragma Inline (fl_text_buffer_insertfile);
+
+ function fl_text_buffer_outputfile
+ (TB : in System.Address;
+ N : in Interfaces.C.char_array;
+ F, T : in Interfaces.C.int;
+ B : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_outputfile, "fl_text_buffer_outputfile");
+ pragma Inline (fl_text_buffer_outputfile);
function fl_text_buffer_savefile
(TB : in System.Address;
- N : in Interfaces.C.char_array)
+ N : in Interfaces.C.char_array;
+ B : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_savefile, "fl_text_buffer_savefile");
+ pragma Inline (fl_text_buffer_savefile);
@@ -77,28 +112,109 @@ package body FLTK.Text_Buffers is
P : in Interfaces.C.int;
I : in Interfaces.C.char_array);
pragma Import (C, fl_text_buffer_insert, "fl_text_buffer_insert");
+ pragma Inline (fl_text_buffer_insert);
+
+ procedure fl_text_buffer_append
+ (TB : in System.Address;
+ I : in Interfaces.C.char_array);
+ pragma Import (C, fl_text_buffer_append, "fl_text_buffer_append");
+ pragma Inline (fl_text_buffer_append);
+
+ procedure fl_text_buffer_replace
+ (TB : in System.Address;
+ S, F : in Interfaces.C.int;
+ T : in Interfaces.C.char_array);
+ pragma Import (C, fl_text_buffer_replace, "fl_text_buffer_replace");
+ pragma Inline (fl_text_buffer_replace);
procedure fl_text_buffer_remove
(TB : in System.Address;
S, F : in Interfaces.C.int);
pragma Import (C, fl_text_buffer_remove, "fl_text_buffer_remove");
+ pragma Inline (fl_text_buffer_remove);
+
+ function fl_text_buffer_get_text
+ (TB : in System.Address)
+ return Interfaces.C.Strings.chars_ptr;
+ pragma Import (C, fl_text_buffer_get_text, "fl_text_buffer_get_text");
+ pragma Inline (fl_text_buffer_get_text);
+
+ procedure fl_text_buffer_set_text
+ (TB : in System.Address;
+ T : in Interfaces.C.char_array);
+ pragma Import (C, fl_text_buffer_set_text, "fl_text_buffer_set_text");
+ pragma Inline (fl_text_buffer_set_text);
+
+ function fl_text_buffer_byte_at
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.char;
+ pragma Import (C, fl_text_buffer_byte_at, "fl_text_buffer_byte_at");
+ pragma Inline (fl_text_buffer_byte_at);
function fl_text_buffer_char_at
(TB : in System.Address;
P : in Interfaces.C.int)
return Interfaces.C.unsigned;
pragma Import (C, fl_text_buffer_char_at, "fl_text_buffer_char_at");
+ pragma Inline (fl_text_buffer_char_at);
function fl_text_buffer_text_range
(TB : in System.Address;
S, F : in Interfaces.C.int)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, fl_text_buffer_text_range, "fl_text_buffer_text_range");
+ pragma Inline (fl_text_buffer_text_range);
+
+ function fl_text_buffer_next_char
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_next_char, "fl_text_buffer_next_char");
+ pragma Inline (fl_text_buffer_next_char);
+
+ function fl_text_buffer_prev_char
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_prev_char, "fl_text_buffer_prev_char");
+ pragma Inline (fl_text_buffer_prev_char);
+
+
+
+
+ function fl_text_buffer_count_displayed_characters
+ (TB : in System.Address;
+ S, F : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_count_displayed_characters,
+ "fl_text_buffer_count_displayed_characters");
+ pragma Inline (fl_text_buffer_count_displayed_characters);
+
+ function fl_text_buffer_count_lines
+ (TB : in System.Address;
+ S, F : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_count_lines, "fl_text_buffer_count_lines");
+ pragma Inline (fl_text_buffer_count_lines);
function fl_text_buffer_length
(TB : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_length, "fl_text_buffer_length");
+ pragma Inline (fl_text_buffer_length);
+
+ function fl_text_buffer_get_tab_distance
+ (TB : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_get_tab_distance, "fl_text_buffer_get_tab_distance");
+ pragma Inline (fl_text_buffer_get_tab_distance);
+
+ procedure fl_text_buffer_set_tab_distance
+ (TB : in System.Address;
+ T : in Interfaces.C.int);
+ pragma Import (C, fl_text_buffer_set_tab_distance, "fl_text_buffer_set_tab_distance");
+ pragma Inline (fl_text_buffer_set_tab_distance);
@@ -108,23 +224,127 @@ package body FLTK.Text_Buffers is
S, E : out Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_selection_position, "fl_text_buffer_selection_position");
+ pragma Inline (fl_text_buffer_selection_position);
+
+ function fl_text_buffer_secondary_selection_position
+ (TB : in System.Address;
+ S, E : out Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_secondary_selection_position,
+ "fl_text_buffer_secondary_selection_position");
+ pragma Inline (fl_text_buffer_secondary_selection_position);
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");
+ pragma Inline (fl_text_buffer_select);
+
+ procedure fl_text_buffer_secondary_select
+ (TB : in System.Address;
+ S, E : in Interfaces.C.int);
+ pragma Import (C, fl_text_buffer_secondary_select, "fl_text_buffer_secondary_select");
+ pragma Inline (fl_text_buffer_secondary_select);
function fl_text_buffer_selected
(TB : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_selected, "fl_text_buffer_selected");
+ pragma Inline (fl_text_buffer_selected);
+
+ function fl_text_buffer_secondary_selected
+ (TB : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_secondary_selected, "fl_text_buffer_secondary_selected");
+ pragma Inline (fl_text_buffer_secondary_selected);
+
+ function fl_text_buffer_selection_text
+ (TB : in System.Address)
+ return Interfaces.C.Strings.chars_ptr;
+ pragma Import (C, fl_text_buffer_selection_text, "fl_text_buffer_selection_text");
+ pragma Inline (fl_text_buffer_selection_text);
+
+ function fl_text_buffer_secondary_selection_text
+ (TB : in System.Address)
+ return Interfaces.C.Strings.chars_ptr;
+ pragma Import (C, fl_text_buffer_secondary_selection_text,
+ "fl_text_buffer_secondary_selection_text");
+ pragma Inline (fl_text_buffer_secondary_selection_text);
+
+ procedure fl_text_buffer_replace_selection
+ (TB : in System.Address;
+ T : in Interfaces.C.char_array);
+ pragma Import (C, fl_text_buffer_replace_selection, "fl_text_buffer_replace_selection");
+ pragma Inline (fl_text_buffer_replace_selection);
+
+ procedure fl_text_buffer_replace_secondary_selection
+ (TB : in System.Address;
+ T : in Interfaces.C.char_array);
+ pragma Import (C, fl_text_buffer_replace_secondary_selection,
+ "fl_text_buffer_replace_secondary_selection");
+ pragma Inline (fl_text_buffer_replace_secondary_selection);
procedure fl_text_buffer_remove_selection
(TB : in System.Address);
pragma Import (C, fl_text_buffer_remove_selection, "fl_text_buffer_remove_selection");
+ pragma Inline (fl_text_buffer_remove_selection);
+
+ procedure fl_text_buffer_remove_secondary_selection
+ (TB : in System.Address);
+ pragma Import (C, fl_text_buffer_remove_secondary_selection,
+ "fl_text_buffer_remove_secondary_selection");
+ pragma Inline (fl_text_buffer_remove_secondary_selection);
+ procedure fl_text_buffer_unselect
+ (TB : in System.Address);
+ pragma Import (C, fl_text_buffer_unselect, "fl_text_buffer_unselect");
+ pragma Inline (fl_text_buffer_unselect);
+
+ procedure fl_text_buffer_secondary_unselect
+ (TB : in System.Address);
+ pragma Import (C, fl_text_buffer_secondary_unselect, "fl_text_buffer_secondary_unselect");
+ pragma Inline (fl_text_buffer_secondary_unselect);
+
+
+
+
+ procedure fl_text_buffer_highlight
+ (TB : in System.Address;
+ F, T : in Interfaces.C.int);
+ pragma Import (C, fl_text_buffer_highlight, "fl_text_buffer_highlight");
+ pragma Inline (fl_text_buffer_highlight);
+ function fl_text_buffer_highlight_text
+ (TB : in System.Address)
+ return Interfaces.C.Strings.chars_ptr;
+ pragma Import (C, fl_text_buffer_highlight_text, "fl_text_buffer_highlight_text");
+ pragma Inline (fl_text_buffer_highlight_text);
+
+ procedure fl_text_buffer_unhighlight
+ (TB : in System.Address);
+ pragma Import (C, fl_text_buffer_unhighlight, "fl_text_buffer_unhighlight");
+ pragma Inline (fl_text_buffer_unhighlight);
+
+
+
+
+ function fl_text_buffer_findchar_forward
+ (TB : in System.Address;
+ SP : in Interfaces.C.int;
+ IT : in Interfaces.C.unsigned;
+ FP : out Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_findchar_forward, "fl_text_buffer_findchar_forward");
+ pragma Inline (fl_text_buffer_findchar_forward);
+ function fl_text_buffer_findchar_backward
+ (TB : in System.Address;
+ SP : in Interfaces.C.int;
+ IT : in Interfaces.C.unsigned;
+ FP : out Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_findchar_backward, "fl_text_buffer_findchar_backward");
+ pragma Inline (fl_text_buffer_findchar_backward);
function fl_text_buffer_search_forward
(TB : in System.Address;
@@ -134,6 +354,7 @@ package body FLTK.Text_Buffers is
CA : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_search_forward, "fl_text_buffer_search_forward");
+ pragma Inline (fl_text_buffer_search_forward);
function fl_text_buffer_search_backward
(TB : in System.Address;
@@ -143,18 +364,89 @@ package body FLTK.Text_Buffers is
CA : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_search_backward, "fl_text_buffer_search_backward");
+ pragma Inline (fl_text_buffer_search_backward);
+
+
+
+
+ function fl_text_buffer_word_start
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_word_start, "fl_text_buffer_word_start");
+ pragma Inline (fl_text_buffer_word_start);
+
+ function fl_text_buffer_word_end
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_word_end, "fl_text_buffer_word_end");
+ pragma Inline (fl_text_buffer_word_end);
+
+ function fl_text_buffer_line_start
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_line_start, "fl_text_buffer_line_start");
+ pragma Inline (fl_text_buffer_line_start);
+
+ function fl_text_buffer_line_end
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_line_end, "fl_text_buffer_line_end");
+ pragma Inline (fl_text_buffer_line_end);
+
+ function fl_text_buffer_line_text
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.Strings.chars_ptr;
+ pragma Import (C, fl_text_buffer_line_text, "fl_text_buffer_line_text");
+ pragma Inline (fl_text_buffer_line_text);
function fl_text_buffer_skip_lines
(TB : in System.Address;
S, L : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_skip_lines, "fl_text_buffer_skip_lines");
+ pragma Inline (fl_text_buffer_skip_lines);
function fl_text_buffer_rewind_lines
(TB : in System.Address;
S, L : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_buffer_rewind_lines, "fl_text_buffer_rewind_lines");
+ pragma Inline (fl_text_buffer_rewind_lines);
+
+ function fl_text_buffer_skip_displayed_characters
+ (TB : in System.Address;
+ S, N : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_skip_displayed_characters,
+ "fl_text_buffer_skip_displayed_characters");
+ pragma Inline (fl_text_buffer_skip_displayed_characters);
+
+
+
+
+ procedure fl_text_buffer_canundo
+ (TB : in System.Address;
+ F : in Interfaces.C.char);
+ pragma Import (C, fl_text_buffer_canundo, "fl_text_buffer_canundo");
+ pragma Inline (fl_text_buffer_canundo);
+
+ procedure fl_text_buffer_copy
+ (TB, TB2 : in System.Address;
+ S, F, I : in Interfaces.C.int);
+ pragma Import (C, fl_text_buffer_copy, "fl_text_buffer_copy");
+ pragma Inline (fl_text_buffer_copy);
+
+ function fl_text_buffer_utf8_align
+ (TB : in System.Address;
+ P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_buffer_utf8_align, "fl_text_buffer_utf8_align");
+ pragma Inline (fl_text_buffer_utf8_align);
@@ -247,6 +539,15 @@ package body FLTK.Text_Buffers is
This.Modify_CBs := Modify_Vectors.Empty_Vector;
This.Predelete_CBs := Predelete_Vectors.Empty_Vector;
This.CB_Active := True;
+
+ fl_text_buffer_add_modify_callback
+ (This.Void_Ptr,
+ Modify_Callback_Hook'Address,
+ This'Address);
+ fl_text_buffer_add_predelete_callback
+ (This.Void_Ptr,
+ Predelete_Callback_Hook'Address,
+ This'Address);
end return;
end Create;
@@ -259,12 +560,6 @@ package body FLTK.Text_Buffers is
(This : in out Text_Buffer;
Func : in Modify_Callback) is
begin
- if This.Modify_CBs.Length = 0 then
- fl_text_buffer_add_modify_callback
- (This.Void_Ptr,
- Modify_Callback_Hook'Address,
- This'Address);
- end if;
This.Modify_CBs.Append (Func);
end Add_Modify_Callback;
@@ -273,16 +568,36 @@ package body FLTK.Text_Buffers is
(This : in out Text_Buffer;
Func : in Predelete_Callback) is
begin
- if This.Predelete_CBs.Length = 0 then
- fl_text_buffer_add_predelete_callback
- (This.Void_Ptr,
- Predelete_Callback_Hook'Address,
- This'Address);
- end if;
This.Predelete_CBs.Append (Func);
end Add_Predelete_Callback;
+ procedure Remove_Modify_Callback
+ (This : in out Text_Buffer;
+ Func : in Modify_Callback) is
+ begin
+ for I in reverse This.Modify_CBs.First_Index .. This.Modify_CBs.Last_Index loop
+ if This.Modify_CBs.Element (I) = Func then
+ This.Modify_CBs.Delete (I);
+ return;
+ end if;
+ end loop;
+ end Remove_Modify_Callback;
+
+
+ procedure Remove_Predelete_Callback
+ (This : in out Text_Buffer;
+ Func : in Predelete_Callback) is
+ begin
+ for I in reverse This.Predelete_CBs.First_Index .. This.Predelete_CBs.Last_Index loop
+ if This.Predelete_CBs.Element (I) = Func then
+ This.Predelete_CBs.Delete (I);
+ return;
+ end if;
+ end loop;
+ end Remove_Predelete_Callback;
+
+
procedure Call_Modify_Callbacks
(This : in out Text_Buffer) is
begin
@@ -314,12 +629,14 @@ package body FLTK.Text_Buffers is
procedure Load_File
- (This : in Text_Buffer;
- Name : in String)
+ (This : in out Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024)
is
Err_No : Interfaces.C.int := fl_text_buffer_loadfile
(This.Void_Ptr,
- Interfaces.C.To_C (Name));
+ Interfaces.C.To_C (Name),
+ Interfaces.C.int (Buffer));
begin
if Err_No /= 0 then
raise Storage_Error;
@@ -327,13 +644,68 @@ package body FLTK.Text_Buffers is
end Load_File;
+ procedure Append_File
+ (This : in out Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024)
+ is
+ Err_No : Interfaces.C.int := fl_text_buffer_appendfile
+ (This.Void_Ptr,
+ Interfaces.C.To_C (Name),
+ Interfaces.C.int (Buffer));
+ begin
+ if Err_No /= 0 then
+ raise Storage_Error;
+ end if;
+ end Append_File;
+
+
+ procedure Insert_File
+ (This : in out Text_Buffer;
+ Name : in String;
+ Place : in Position;
+ Buffer : in Natural := 128 * 1024)
+ is
+ Err_No : Interfaces.C.int := fl_text_buffer_insertfile
+ (This.Void_Ptr,
+ Interfaces.C.To_C (Name),
+ Interfaces.C.int (Place),
+ Interfaces.C.int (Buffer));
+ begin
+ if Err_No /= 0 then
+ raise Storage_Error;
+ end if;
+ end Insert_File;
+
+
+ procedure Output_File
+ (This : in Text_Buffer;
+ Name : in String;
+ Start, Finish : in Position;
+ Buffer : in Natural := 128 * 1024)
+ is
+ Err_No : Interfaces.C.int := fl_text_buffer_outputfile
+ (This.Void_Ptr,
+ Interfaces.C.To_C (Name),
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish),
+ Interfaces.C.int (Buffer));
+ begin
+ if Err_No /= 0 then
+ raise Storage_Error;
+ end if;
+ end Output_File;
+
+
procedure Save_File
- (This : in Text_Buffer;
- Name : in String)
+ (This : in Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024)
is
Err_No : Interfaces.C.int := fl_text_buffer_savefile
(This.Void_Ptr,
- Interfaces.C.To_C (Name));
+ Interfaces.C.To_C (Name),
+ Interfaces.C.int (Buffer));
begin
if Err_No /= 0 then
raise Storage_Error;
@@ -344,20 +716,43 @@ package body FLTK.Text_Buffers is
procedure Insert_Text
- (This : in out Text_Buffer;
- Pos : in Natural;
- Item : in String) is
+ (This : in out Text_Buffer;
+ Place : in Position;
+ Text : in String) is
begin
fl_text_buffer_insert
(This.Void_Ptr,
- Interfaces.C.int (Pos),
- Interfaces.C.To_C (Item));
+ Interfaces.C.int (Place),
+ Interfaces.C.To_C (Text));
end Insert_Text;
+ procedure Append_Text
+ (This : in out Text_Buffer;
+ Text : in String) is
+ begin
+ fl_text_buffer_append
+ (This.Void_Ptr,
+ Interfaces.C.To_C (Text));
+ end Append_Text;
+
+
+ procedure Replace_Text
+ (This : in out Text_Buffer;
+ Start, Finish : in Position;
+ Text : in String) is
+ begin
+ fl_text_buffer_replace
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish),
+ Interfaces.C.To_C (Text));
+ end Replace_Text;
+
+
procedure Remove_Text
(This : in out Text_Buffer;
- Start, Finish : in Natural) is
+ Start, Finish : in Position) is
begin
fl_text_buffer_remove
(This.Void_Ptr,
@@ -366,20 +761,51 @@ package body FLTK.Text_Buffers is
end Remove_Text;
+ function Get_Entire_Text
+ (This : in Text_Buffer)
+ return String
+ is
+ Raw : Interfaces.C.Strings.chars_ptr :=
+ fl_text_buffer_get_text (This.Void_Ptr);
+ Ada_String : String := Interfaces.C.Strings.Value (Raw);
+ begin
+ Interfaces.C.Strings.Free (Raw);
+ return Ada_String;
+ end Get_Entire_Text;
+
+
+ procedure Set_Entire_Text
+ (This : in out Text_Buffer;
+ Text : in String) is
+ begin
+ fl_text_buffer_set_text (This.Void_Ptr, Interfaces.C.To_C (Text));
+ end Set_Entire_Text;
+
+
+ function Byte_At
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character is
+ begin
+ return Character'Val (Interfaces.C.char'Pos
+ (fl_text_buffer_byte_at (This.Void_Ptr, Interfaces.C.int (Place))));
+ end Byte_At;
+
+
function Character_At
(This : in Text_Buffer;
- Pos : in Natural)
+ Place : in Position)
return Character is
begin
return Character'Val (fl_text_buffer_char_at
(This.Void_Ptr,
- Interfaces.C.int (Pos)));
+ Interfaces.C.int (Place)));
end Character_At;
function Text_At
(This : in Text_Buffer;
- Start, Finish : in Natural)
+ Start, Finish : in Position)
return String
is
C_Str : Interfaces.C.Strings.chars_ptr := fl_text_buffer_text_range
@@ -393,6 +819,54 @@ package body FLTK.Text_Buffers is
end Text_At;
+ function Next_Char
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character is
+ begin
+ return Character'Val (fl_text_buffer_next_char
+ (This.Void_Ptr,
+ Interfaces.C.int (Place)));
+ end Next_Char;
+
+
+ function Prev_Char
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character is
+ begin
+ return Character'Val (fl_text_buffer_prev_char
+ (This.Void_Ptr,
+ Interfaces.C.int (Place)));
+ end Prev_Char;
+
+
+
+
+ function Count_Displayed_Characters
+ (This : in Text_Buffer;
+ Start, Finish : in Position)
+ return Integer is
+ begin
+ return Integer (fl_text_buffer_count_displayed_characters
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish)));
+ end Count_Displayed_Characters;
+
+
+ function Count_Lines
+ (This : in Text_Buffer;
+ Start, Finish : in Position)
+ return Integer is
+ begin
+ return Integer (fl_text_buffer_count_lines
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish)));
+ end Count_Lines;
+
+
function Length
(This : in Text_Buffer)
return Natural is
@@ -401,30 +875,51 @@ package body FLTK.Text_Buffers is
end Length;
+ function Get_Tab_Width
+ (This : in Text_Buffer)
+ return Natural is
+ begin
+ return Natural (fl_text_buffer_get_tab_distance (This.Void_Ptr));
+ end Get_Tab_Width;
+
+
+ procedure Set_Tab_Width
+ (This : in out Text_Buffer;
+ To : in Natural) is
+ begin
+ fl_text_buffer_set_tab_distance (This.Void_Ptr, Interfaces.C.int (To));
+ end Set_Tab_Width;
+
+
function Get_Selection
(This : in Text_Buffer;
- Start, Finish : out Natural)
- return Boolean
- is
- Result, Start_Raw, Finish_Raw : Interfaces.C.int;
+ Start, Finish : out Position)
+ return Boolean is
begin
- Result := fl_text_buffer_selection_position
+ return 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;
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish)) /= 0;
end Get_Selection;
+ function Get_Secondary_Selection
+ (This : in Text_Buffer;
+ Start, Finish : out Position)
+ return Boolean is
+ begin
+ return fl_text_buffer_secondary_selection_position
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish)) /= 0;
+ end Get_Secondary_Selection;
+
+
procedure Set_Selection
(This : in out Text_Buffer;
- Start, Finish : in Natural) is
+ Start, Finish : in Position) is
begin
fl_text_buffer_select
(This.Void_Ptr,
@@ -433,6 +928,17 @@ package body FLTK.Text_Buffers is
end Set_Selection;
+ procedure Set_Secondary_Selection
+ (This : in out Text_Buffer;
+ Start, Finish : in Position) is
+ begin
+ fl_text_buffer_secondary_select
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish));
+ end Set_Secondary_Selection;
+
+
function Has_Selection
(This : in Text_Buffer)
return Boolean is
@@ -441,65 +947,252 @@ package body FLTK.Text_Buffers is
end Has_Selection;
- procedure Remove_Selected_Text
+ function Has_Secondary_Selection
+ (This : in Text_Buffer)
+ return Boolean is
+ begin
+ return fl_text_buffer_secondary_selected (This.Void_Ptr) /= 0;
+ end Has_Secondary_Selection;
+
+
+ function Selection_Text
+ (This : in Text_Buffer)
+ return String
+ is
+ Raw : Interfaces.C.Strings.chars_ptr :=
+ fl_text_buffer_selection_text (This.Void_Ptr);
+ Ada_String : String := Interfaces.C.Strings.Value (Raw);
+ begin
+ Interfaces.C.Strings.Free (Raw);
+ return Ada_String;
+ end Selection_Text;
+
+
+ function Secondary_Selection_Text
+ (This : in Text_Buffer)
+ return String
+ is
+ Raw : Interfaces.C.Strings.chars_ptr :=
+ fl_text_buffer_secondary_selection_text (This.Void_Ptr);
+ Ada_String : String := Interfaces.C.Strings.Value (Raw);
+ begin
+ Interfaces.C.Strings.Free (Raw);
+ return Ada_String;
+ end Secondary_Selection_Text;
+
+
+ procedure Replace_Selection
+ (This : in out Text_Buffer;
+ Text : in String) is
+ begin
+ fl_text_buffer_replace_selection (This.Void_Ptr, Interfaces.C.To_C (Text));
+ end Replace_Selection;
+
+
+ procedure Replace_Secondary_Selection
+ (This : in out Text_Buffer;
+ Text : in String) is
+ begin
+ fl_text_buffer_replace_secondary_selection (This.Void_Ptr, Interfaces.C.To_C (Text));
+ end Replace_Secondary_Selection;
+
+
+ procedure Remove_Selection
(This : in out Text_Buffer) is
begin
fl_text_buffer_remove_selection (This.Void_Ptr);
- end Remove_Selected_Text;
+ end Remove_Selection;
+
+
+ procedure Remove_Secondary_Selection
+ (This : in out Text_Buffer) is
+ begin
+ fl_text_buffer_remove_secondary_selection (This.Void_Ptr);
+ end Remove_Secondary_Selection;
+ procedure Unselect
+ (This : in out Text_Buffer) is
+ begin
+ fl_text_buffer_unselect (This.Void_Ptr);
+ end Unselect;
+
+
+ procedure Secondary_Unselect
+ (This : in out Text_Buffer) is
+ begin
+ fl_text_buffer_secondary_unselect (This.Void_Ptr);
+ end Secondary_Unselect;
+
+
+
+
+ procedure Get_Highlight
+ (This : in Text_Buffer;
+ Start, Finish : out Position) is
+ begin
+ Start := This.High_From;
+ Finish := This.High_To;
+ end Get_Highlight;
+
+
+ procedure Set_Highlight
+ (This : in out Text_Buffer;
+ Start, Finish : in Position) is
+ begin
+ This.High_From := Start;
+ This.High_To := Finish;
+ fl_text_buffer_highlight
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish));
+ end Set_Highlight;
+
+
+ function Get_Highlighted_Text
+ (This : in Text_Buffer)
+ return String
+ is
+ Raw : Interfaces.C.Strings.chars_ptr :=
+ fl_text_buffer_highlight_text (This.Void_Ptr);
+ Ada_String : String := Interfaces.C.Strings.Value (Raw);
+ begin
+ Interfaces.C.Strings.Free (Raw);
+ return Ada_String;
+ end Get_Highlighted_Text;
+
+
+ procedure Unhighlight
+ (This : in out Text_Buffer) is
+ begin
+ fl_text_buffer_unhighlight (This.Void_Ptr);
+ end Unhighlight;
+
+
+
+
+ function Findchar_Forward
+ (This : in Text_Buffer;
+ Start_At : in Position;
+ Item : in Character;
+ Found_At : out Position)
+ return Boolean is
+ begin
+ return fl_text_buffer_findchar_forward
+ (This.Void_Ptr,
+ Interfaces.C.int (Start_At),
+ Character'Pos (Item),
+ Interfaces.C.int (Found_At)) /= 0;
+ end Findchar_Forward;
+
+
+ function Findchar_Backward
+ (This : in Text_Buffer;
+ Start_At : in Position;
+ Item : in Character;
+ Found_At : out Position)
+ return Boolean is
+ begin
+ return fl_text_buffer_findchar_backward
+ (This.Void_Ptr,
+ Interfaces.C.int (Start_At),
+ Character'Pos (Item),
+ Interfaces.C.int (Found_At)) /= 0;
+ end Findchar_Backward;
function Search_Forward
(This : in Text_Buffer;
- Start_At : in Natural;
+ Start_At : in Position;
Item : in String;
- Found_At : out Natural;
- Match_Case : in Boolean)
- return Boolean
- is
- Found_Raw, Result : Interfaces.C.int;
+ Found_At : out Position;
+ Match_Case : in Boolean := False)
+ return Boolean is
begin
- Result := fl_text_buffer_search_forward
+ return fl_text_buffer_search_forward
(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;
+ Interfaces.C.int (Found_At),
+ Boolean'Pos (Match_Case)) /= 0;
end Search_Forward;
function Search_Backward
(This : in Text_Buffer;
- Start_At : in Natural;
+ Start_At : in Position;
Item : in String;
- Found_At : out Natural;
- Match_Case : in Boolean)
- return Boolean
- is
- Found_Raw, Result : Interfaces.C.int;
+ Found_At : out Position;
+ Match_Case : in Boolean := False)
+ return Boolean is
begin
- Result := fl_text_buffer_search_backward
+ return 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;
+ Interfaces.C.int (Found_At),
+ Boolean'Pos (Match_Case)) /= 0;
end Search_Backward;
+
+
+ function Word_Start
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position is
+ begin
+ return Position (fl_text_buffer_word_start (This.Void_Ptr, Interfaces.C.int (Place)));
+ end Word_Start;
+
+
+ function Word_End
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position is
+ begin
+ return Position (fl_text_buffer_word_end (This.Void_Ptr, Interfaces.C.int (Place)));
+ end Word_End;
+
+
+ function Line_Start
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position is
+ begin
+ return Position (fl_text_buffer_line_start (This.Void_Ptr, Interfaces.C.int (Place)));
+ end Line_Start;
+
+
+ function Line_End
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position is
+ begin
+ return Position (fl_text_buffer_line_end (This.Void_Ptr, Interfaces.C.int (Place)));
+ end Line_End;
+
+
+ function Line_Text
+ (This : in Text_Buffer;
+ Place : in Position)
+ return String
+ is
+ Raw : Interfaces.C.Strings.chars_ptr := fl_text_buffer_line_text
+ (This.Void_Ptr,
+ Interfaces.C.int (Place));
+ Ada_String : String := Interfaces.C.Strings.Value (Raw);
+ begin
+ Interfaces.C.Strings.Free (Raw);
+ return Ada_String;
+ end Line_Text;
+
+
function Skip_Lines
- (This : in out Text_Buffer;
- Start, Lines : in Natural)
- return Natural is
+ (This : in out Text_Buffer;
+ Start : in Position;
+ Lines : in Natural)
+ return Position is
begin
return Natural (fl_text_buffer_skip_lines
(This.Void_Ptr,
@@ -509,9 +1202,10 @@ package body FLTK.Text_Buffers is
function Rewind_Lines
- (This : in out Text_Buffer;
- Start, Lines : in Natural)
- return Natural is
+ (This : in out Text_Buffer;
+ Start : in Position;
+ Lines : in Natural)
+ return Position is
begin
return Natural (fl_text_buffer_rewind_lines
(This.Void_Ptr,
@@ -520,5 +1214,52 @@ package body FLTK.Text_Buffers is
end Rewind_Lines;
+ function Skip_Displayed_Characters
+ (This : in Text_Buffer;
+ Start : in Position;
+ Chars : in Natural)
+ return Position is
+ begin
+ return Natural (fl_text_buffer_skip_displayed_characters
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Chars)));
+ end Skip_Displayed_Characters;
+
+
+
+
+ procedure Can_Undo
+ (This : in out Text_Buffer;
+ Flag : in Boolean) is
+ begin
+ fl_text_buffer_canundo (This.Void_Ptr, Interfaces.C.char'Val (Boolean'Pos (Flag)));
+ end Can_Undo;
+
+
+ procedure Copy
+ (This : in out Text_Buffer;
+ From : in Text_Buffer;
+ Start, Finish : in Position;
+ Insert_Pos : in Position) is
+ begin
+ fl_text_buffer_copy
+ (This.Void_Ptr,
+ From.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish),
+ Interfaces.C.int (Insert_Pos));
+ end Copy;
+
+
+ function UTF8_Align
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position is
+ begin
+ return Position (fl_text_buffer_utf8_align (This.Void_Ptr, Interfaces.C.int (Place)));
+ end UTF8_Align;
+
+
end FLTK.Text_Buffers;
diff --git a/src/fltk-text_buffers.ads b/src/fltk-text_buffers.ads
index a2b5a6a..956c03e 100644
--- a/src/fltk-text_buffers.ads
+++ b/src/fltk-text_buffers.ads
@@ -15,7 +15,7 @@ package FLTK.Text_Buffers is
type Text_Buffer_Reference (Data : access Text_Buffer'Class) is limited null record
with Implicit_Dereference => Data;
- type Position is new Natural;
+ subtype Position is Natural;
type Modification is (Insert, Restyle, Delete, None);
@@ -52,6 +52,14 @@ package FLTK.Text_Buffers is
(This : in out Text_Buffer;
Func : in Predelete_Callback);
+ procedure Remove_Modify_Callback
+ (This : in out Text_Buffer;
+ Func : in Modify_Callback);
+
+ procedure Remove_Predelete_Callback
+ (This : in out Text_Buffer;
+ Func : in Predelete_Callback);
+
procedure Call_Modify_Callbacks
(This : in out Text_Buffer);
@@ -68,88 +76,284 @@ package FLTK.Text_Buffers is
procedure Load_File
- (This : in Text_Buffer;
- Name : in String);
+ (This : in out Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024);
+
+ procedure Append_File
+ (This : in out Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024);
+
+ procedure Insert_File
+ (This : in out Text_Buffer;
+ Name : in String;
+ Place : in Position;
+ Buffer : in Natural := 128 * 1024);
+
+ procedure Output_File
+ (This : in Text_Buffer;
+ Name : in String;
+ Start, Finish : in Position;
+ Buffer : in Natural := 128 * 1024);
procedure Save_File
- (This : in Text_Buffer;
- Name : in String);
+ (This : in Text_Buffer;
+ Name : in String;
+ Buffer : in Natural := 128 * 1024);
procedure Insert_Text
+ (This : in out Text_Buffer;
+ Place : in Position;
+ Text : in String);
+
+ procedure Append_Text
(This : in out Text_Buffer;
- Pos : in Natural;
- Item : in String);
+ Text : in String);
+
+ procedure Replace_Text
+ (This : in out Text_Buffer;
+ Start, Finish : in Position;
+ Text : in String);
procedure Remove_Text
(This : in out Text_Buffer;
- Start, Finish : in Natural);
+ Start, Finish : in Position);
+
+ function Get_Entire_Text
+ (This : in Text_Buffer)
+ return String;
+
+ procedure Set_Entire_Text
+ (This : in out Text_Buffer;
+ Text : in String);
+
+ function Byte_At
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character;
function Character_At
- (This : in Text_Buffer;
- Pos : in Natural)
+ (This : in Text_Buffer;
+ Place : in Position)
return Character;
function Text_At
(This : in Text_Buffer;
- Start, Finish : in Natural)
+ Start, Finish : in Position)
return String;
+ function Next_Char
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character;
+
+ function Prev_Char
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Character;
+
+
+
+
+ function Count_Displayed_Characters
+ (This : in Text_Buffer;
+ Start, Finish : in Position)
+ return Integer;
+
+ function Count_Lines
+ (This : in Text_Buffer;
+ Start, Finish : in Position)
+ return Integer;
+
function Length
(This : in Text_Buffer)
return Natural;
+ function Get_Tab_Width
+ (This : in Text_Buffer)
+ return Natural;
+
+ procedure Set_Tab_Width
+ (This : in out Text_Buffer;
+ To : in Natural);
+
function Get_Selection
(This : in Text_Buffer;
- Start, Finish : out Natural)
+ Start, Finish : out Position)
+ return Boolean;
+
+ function Get_Secondary_Selection
+ (This : in Text_Buffer;
+ Start, Finish : out Position)
return Boolean;
procedure Set_Selection
(This : in out Text_Buffer;
- Start, Finish : in Natural);
+ Start, Finish : in Position);
+
+ procedure Set_Secondary_Selection
+ (This : in out Text_Buffer;
+ Start, Finish : in Position);
function Has_Selection
(This : in Text_Buffer)
return Boolean;
- procedure Remove_Selected_Text
+ function Has_Secondary_Selection
+ (This : in Text_Buffer)
+ return Boolean;
+
+ function Selection_Text
+ (This : in Text_Buffer)
+ return String;
+
+ function Secondary_Selection_Text
+ (This : in Text_Buffer)
+ return String;
+
+ procedure Replace_Selection
+ (This : in out Text_Buffer;
+ Text : in String);
+
+ procedure Replace_Secondary_Selection
+ (This : in out Text_Buffer;
+ Text : in String);
+
+ procedure Remove_Selection
+ (This : in out Text_Buffer);
+
+ procedure Remove_Secondary_Selection
+ (This : in out Text_Buffer);
+
+ procedure Unselect
+ (This : in out Text_Buffer);
+
+ procedure Secondary_Unselect
(This : in out Text_Buffer);
+ procedure Get_Highlight
+ (This : in Text_Buffer;
+ Start, Finish : out Position);
+
+ procedure Set_Highlight
+ (This : in out Text_Buffer;
+ Start, Finish : in Position);
+
+ function Get_Highlighted_Text
+ (This : in Text_Buffer)
+ return String;
+
+ procedure Unhighlight
+ (This : in out Text_Buffer);
+
+
+
+
+ function Findchar_Forward
+ (This : in Text_Buffer;
+ Start_At : in Position;
+ Item : in Character;
+ Found_At : out Position)
+ return Boolean;
+
+ function Findchar_Backward
+ (This : in Text_Buffer;
+ Start_At : in Position;
+ Item : in Character;
+ Found_At : out Position)
+ return Boolean;
+
function Search_Forward
(This : in Text_Buffer;
- Start_At : in Natural;
+ Start_At : in Position;
Item : in String;
- Found_At : out Natural;
- Match_Case : in Boolean)
+ Found_At : out Position;
+ Match_Case : in Boolean := False)
return Boolean;
function Search_Backward
(This : in Text_Buffer;
- Start_At : in Natural;
+ Start_At : in Position;
Item : in String;
- Found_At : out Natural;
- Match_Case : in Boolean)
+ Found_At : out Position;
+ Match_Case : in Boolean := False)
return Boolean;
+
+
+
+ function Word_Start
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+
+ function Word_End
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+
+ function Line_Start
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+
+ function Line_End
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
+
+ function Line_Text
+ (This : in Text_Buffer;
+ Place : in Position)
+ return String;
+
-- only takes into account newline characters, not word wrap
function Skip_Lines
- (This : in out Text_Buffer;
- Start, Lines : in Natural)
- return Natural;
+ (This : in out Text_Buffer;
+ Start : in Position;
+ Lines : in Natural)
+ return Position;
-- only takes into account newline characters, not word wrap
function Rewind_Lines
- (This : in out Text_Buffer;
- Start, Lines : in Natural)
- return Natural;
+ (This : in out Text_Buffer;
+ Start : in Position;
+ Lines : in Natural)
+ return Position;
+
+ function Skip_Displayed_Characters
+ (This : in Text_Buffer;
+ Start : in Position;
+ Chars : in Natural)
+ return Position;
+
+
+
+
+ procedure Can_Undo
+ (This : in out Text_Buffer;
+ Flag : in Boolean);
+
+ procedure Copy
+ (This : in out Text_Buffer;
+ From : in Text_Buffer;
+ Start, Finish : in Position;
+ Insert_Pos : in Position);
+
+ function UTF8_Align
+ (This : in Text_Buffer;
+ Place : in Position)
+ return Position;
private
@@ -167,9 +371,10 @@ private
type Text_Buffer is new Wrapper with
record
- CB_Active : Boolean;
- Modify_CBs : Modify_Vectors.Vector;
- Predelete_CBs : Predelete_Vectors.Vector;
+ CB_Active : Boolean;
+ Modify_CBs : Modify_Vectors.Vector;
+ Predelete_CBs : Predelete_Vectors.Vector;
+ High_From, High_To : Natural := 0;
end record;
overriding procedure Finalize
@@ -195,5 +400,87 @@ private
package Text_Buffer_Convert is new System.Address_To_Access_Conversions (Text_Buffer);
+
+
+ pragma Inline (Add_Modify_Callback);
+ pragma Inline (Add_Predelete_Callback);
+ pragma Inline (Remove_Modify_Callback);
+ pragma Inline (Remove_Predelete_Callback);
+ pragma Inline (Call_Modify_Callbacks);
+ pragma Inline (Call_Predelete_Callbacks);
+ pragma Inline (Enable_Callbacks);
+ pragma Inline (Disable_Callbacks);
+
+
+ pragma Inline (Load_File);
+ pragma Inline (Append_File);
+ pragma Inline (Insert_File);
+ pragma Inline (Output_File);
+ pragma Inline (Save_File);
+
+
+ pragma Inline (Insert_Text);
+ pragma Inline (Append_Text);
+ pragma Inline (Replace_Text);
+ pragma Inline (Remove_Text);
+ pragma Inline (Get_Entire_Text);
+ pragma Inline (Set_Entire_Text);
+ pragma Inline (Byte_At);
+ pragma Inline (Character_At);
+ pragma Inline (Text_At);
+ pragma Inline (Next_Char);
+ pragma Inline (Prev_Char);
+
+
+ pragma Inline (Count_Displayed_Characters);
+ pragma Inline (Count_Lines);
+ pragma Inline (Length);
+ pragma Inline (Get_Tab_Width);
+ pragma Inline (Set_Tab_Width);
+
+
+ pragma Inline (Get_Selection);
+ pragma Inline (Get_Secondary_Selection);
+ pragma Inline (Set_Selection);
+ pragma Inline (Set_Secondary_Selection);
+ pragma Inline (Has_Selection);
+ pragma Inline (Has_Secondary_Selection);
+ pragma Inline (Selection_Text);
+ pragma Inline (Secondary_Selection_Text);
+ pragma Inline (Replace_Selection);
+ pragma Inline (Replace_Secondary_Selection);
+ pragma Inline (Remove_Selection);
+ pragma Inline (Remove_Secondary_Selection);
+ pragma Inline (Unselect);
+ pragma Inline (Secondary_Unselect);
+
+
+ pragma Inline (Get_Highlight);
+ pragma Inline (Set_Highlight);
+ pragma Inline (Get_Highlighted_Text);
+ pragma Inline (Unhighlight);
+
+
+ pragma Inline (Findchar_Forward);
+ pragma Inline (Findchar_Backward);
+ pragma Inline (Search_Forward);
+ pragma Inline (Search_Backward);
+
+
+ pragma Inline (Word_Start);
+ pragma Inline (Word_End);
+ pragma Inline (Line_Start);
+ pragma Inline (Line_End);
+ pragma Inline (Line_Text);
+ pragma Inline (Skip_Lines);
+ pragma Inline (Rewind_Lines);
+ pragma Inline (Skip_Displayed_Characters);
+
+
+ pragma Inline (Can_Undo);
+ pragma Inline (Copy);
+ pragma Inline (UTF8_Align);
+
+
end FLTK.Text_Buffers;