summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-06-02 00:59:01 +1000
committerJed Barber <jjbarber@y7mail.com>2017-06-02 00:59:01 +1000
commit2bedfea19a5dc0df0f7487098af3fe247f47f00a (patch)
tree940d71b17bdea38fcfa9950d26f48ee23671e229
parentfbdf22f733d8fafd7193bee3080e2eaeab95b86f (diff)
More methods added to Text_Display widget
-rw-r--r--src/c_fl_text_display.cpp30
-rw-r--r--src/c_fl_text_display.h6
-rw-r--r--src/fltk-widgets-groups-text_displays.adb103
-rw-r--r--src/fltk-widgets-groups-text_displays.ads35
4 files changed, 174 insertions, 0 deletions
diff --git a/src/c_fl_text_display.cpp b/src/c_fl_text_display.cpp
index 8ae0f01..34d3c0f 100644
--- a/src/c_fl_text_display.cpp
+++ b/src/c_fl_text_display.cpp
@@ -93,6 +93,31 @@ void fl_text_display_set_buffer(TEXTDISPLAY td, TEXTBUFFER tb) {
}
+double fl_text_display_col_to_x(TEXTDISPLAY td, double c) {
+ return reinterpret_cast<Fl_Text_Display*>(td)->col_to_x(c);
+}
+
+
+double fl_text_display_x_to_col(TEXTDISPLAY td, double x) {
+ return reinterpret_cast<Fl_Text_Display*>(td)->x_to_col(x);
+}
+
+
+int fl_text_display_get_cursor_color(TEXTDISPLAY td) {
+ return reinterpret_cast<Fl_Text_Display*>(td)->cursor_color();
+}
+
+
+void fl_text_display_set_cursor_color(TEXTDISPLAY td, int c) {
+ reinterpret_cast<Fl_Text_Display*>(td)->cursor_color(c);
+}
+
+
+void fl_text_display_set_cursor_style(TEXTDISPLAY td, int s) {
+ reinterpret_cast<Fl_Text_Display*>(td)->cursor_style(s);
+}
+
+
int fl_text_display_get_text_color(TEXTDISPLAY td) {
return reinterpret_cast<Fl_Text_Display*>(td)->textcolor();
}
@@ -153,6 +178,11 @@ void fl_text_display_wrap_mode(TEXTDISPLAY td, int w, int m) {
}
+int fl_text_display_count_lines(TEXTDISPLAY td, int s, int f, int p) {
+ return reinterpret_cast<Fl_Text_Display*>(td)->count_lines(s, f, p);
+}
+
+
int fl_text_display_skip_lines(TEXTDISPLAY td, int s, int l, int p) {
return reinterpret_cast<Fl_Text_Display*>(td)->skip_lines(s, l, p);
}
diff --git a/src/c_fl_text_display.h b/src/c_fl_text_display.h
index 86c5f65..2d47cc4 100644
--- a/src/c_fl_text_display.h
+++ b/src/c_fl_text_display.h
@@ -21,6 +21,11 @@ extern "C" void free_fl_text_display(TEXTDISPLAY td);
extern "C" TEXTBUFFER fl_text_display_get_buffer(TEXTDISPLAY td);
extern "C" void fl_text_display_set_buffer(TEXTDISPLAY td, TEXTBUFFER tb);
+extern "C" double fl_text_display_col_to_x(TEXTDISPLAY td, double c);
+extern "C" double fl_text_display_x_to_col(TEXTDISPLAY td, double x);
+extern "C" int fl_text_display_get_cursor_color(TEXTDISPLAY td);
+extern "C" void fl_text_display_set_cursor_color(TEXTDISPLAY td, int c);
+extern "C" void fl_text_display_set_cursor_style(TEXTDISPLAY td, int s);
extern "C" int fl_text_display_get_text_color(TEXTDISPLAY td);
extern "C" void fl_text_display_set_text_color(TEXTDISPLAY td, int c);
extern "C" int fl_text_display_get_text_font(TEXTDISPLAY td);
@@ -33,6 +38,7 @@ extern "C" void fl_text_display_show_insert_pos(TEXTDISPLAY td);
extern "C" void fl_text_display_next_word(TEXTDISPLAY td);
extern "C" void fl_text_display_previous_word(TEXTDISPLAY td);
extern "C" void fl_text_display_wrap_mode(TEXTDISPLAY td, int w, int m);
+extern "C" int fl_text_display_count_lines(TEXTDISPLAY td, int s, int f, int p);
extern "C" int fl_text_display_skip_lines(TEXTDISPLAY td, int s, int l, int p);
extern "C" int fl_text_display_rewind_lines(TEXTDISPLAY td, int s, int l);
extern "C" void fl_text_display_linenumber_width(TEXTDISPLAY td, int w);
diff --git a/src/fltk-widgets-groups-text_displays.adb b/src/fltk-widgets-groups-text_displays.adb
index 27324c2..1bee23f 100644
--- a/src/fltk-widgets-groups-text_displays.adb
+++ b/src/fltk-widgets-groups-text_displays.adb
@@ -38,6 +38,33 @@ package body FLTK.Widgets.Groups.Text_Displays is
(TD, TB : in System.Address);
pragma Import (C, fl_text_display_set_buffer, "fl_text_display_set_buffer");
+ function fl_text_display_col_to_x
+ (TD : in System.Address;
+ C : in Interfaces.C.double)
+ return Interfaces.C.double;
+ pragma Import (C, fl_text_display_col_to_x, "fl_text_display_col_to_x");
+
+ function fl_text_display_x_to_col
+ (TD : in System.Address;
+ X : in Interfaces.C.double)
+ return Interfaces.C.double;
+ pragma Import (C, fl_text_display_x_to_col, "fl_text_display_x_to_col");
+
+ function fl_text_display_get_cursor_color
+ (TD : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_display_get_cursor_color, "fl_text_display_get_cursor_color");
+
+ procedure fl_text_display_set_cursor_color
+ (TD : in System.Address;
+ C : in Interfaces.C.int);
+ pragma Import (C, fl_text_display_set_cursor_color, "fl_text_display_set_cursor_color");
+
+ procedure fl_text_display_set_cursor_style
+ (TD : in System.Address;
+ S : in Interfaces.C.int);
+ pragma Import (C, fl_text_display_set_cursor_style, "fl_text_display_set_cursor_style");
+
function fl_text_display_get_text_color
(TD : in System.Address)
return Interfaces.C.int;
@@ -95,6 +122,12 @@ package body FLTK.Widgets.Groups.Text_Displays is
W, M : in Interfaces.C.int);
pragma Import (C, fl_text_display_wrap_mode, "fl_text_display_wrap_mode");
+ function fl_text_display_count_lines
+ (TD : in System.Address;
+ S, F, P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_display_count_lines, "fl_text_display_count_lines");
+
function fl_text_display_skip_lines
(TD : in System.Address;
S, L, P : in Interfaces.C.int)
@@ -186,6 +219,60 @@ package body FLTK.Widgets.Groups.Text_Displays is
+ function Col_To_X
+ (This : in Text_Display;
+ Col_Num : in Integer)
+ return Integer is
+ begin
+ return Integer (Interfaces.C.double'Rounding
+ (fl_text_display_col_to_x (This.Void_Ptr, Interfaces.C.double (Col_Num))));
+ end Col_To_X;
+
+
+
+
+ function X_To_Col
+ (This : in Text_Display;
+ X_Pos : in Integer)
+ return Integer is
+ begin
+ return Integer (Interfaces.C.double'Rounding
+ (fl_text_display_x_to_col (This.Void_Ptr, Interfaces.C.double (X_Pos))));
+ end X_To_Col;
+
+
+
+
+ function Get_Cursor_Color
+ (This : in Text_Display)
+ return Color is
+ begin
+ return Color (fl_text_display_get_cursor_color (This.Void_Ptr));
+ end Get_Cursor_Color;
+
+
+
+
+ procedure Set_Cursor_Color
+ (This : in out Text_Display;
+ Col : in Color) is
+ begin
+ fl_text_display_set_cursor_color (This.Void_Ptr, Interfaces.C.int (Col));
+ end Set_Cursor_Color;
+
+
+
+
+ procedure Set_Cursor_Style
+ (This : in out Text_Display;
+ Style : in Cursor_Style) is
+ begin
+ fl_text_display_set_cursor_style (This.Void_Ptr, Cursor_Style'Pos (Style));
+ end Set_Cursor_Style;
+
+
+
+
function Get_Text_Color
(This : in Text_Display)
return Color is
@@ -307,6 +394,22 @@ package body FLTK.Widgets.Groups.Text_Displays is
+ function Count_Lines
+ (This : in Text_Display;
+ Start, Finish : in Natural;
+ Start_Pos_Is_Line_Start : in Boolean := False)
+ return Natural is
+ begin
+ return Natural (fl_text_display_count_lines
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Finish),
+ Boolean'Pos (Start_Pos_Is_Line_Start)));
+ end Count_Lines;
+
+
+
+
function Skip_Lines
(This : in out Text_Display;
Start, Lines : in Natural;
diff --git a/src/fltk-widgets-groups-text_displays.ads b/src/fltk-widgets-groups-text_displays.ads
index 2a6d50d..c1c3ea8 100644
--- a/src/fltk-widgets-groups-text_displays.ads
+++ b/src/fltk-widgets-groups-text_displays.ads
@@ -10,6 +10,7 @@ package FLTK.Widgets.Groups.Text_Displays is
type Wrap_Mode is (Wrap_None, Wrap_At_Column, Wrap_At_Pixel, Wrap_At_Bounds);
+ type Cursor_Style is (Normal, Caret, Dim, Block, Heavy, Simple);
function Create
@@ -28,6 +29,33 @@ package FLTK.Widgets.Groups.Text_Displays is
Buff : in out FLTK.Text_Buffers.Text_Buffer);
+ function Col_To_X
+ (This : in Text_Display;
+ Col_Num : in Integer)
+ return Integer;
+
+
+ function X_To_Col
+ (This : in Text_Display;
+ X_Pos : in Integer)
+ return Integer;
+
+
+ function Get_Cursor_Color
+ (This : in Text_Display)
+ return Color;
+
+
+ procedure Set_Cursor_Color
+ (This : in out Text_Display;
+ Col : in Color);
+
+
+ procedure Set_Cursor_Style
+ (This : in out Text_Display;
+ Style : in Cursor_Style);
+
+
function Get_Text_Color
(This : in Text_Display)
return Color;
@@ -86,6 +114,13 @@ package FLTK.Widgets.Groups.Text_Displays is
Margin : in Natural := 0);
+ function Count_Lines
+ (This : in Text_Display;
+ Start, Finish : in Natural;
+ Start_Pos_Is_Line_Start : in Boolean := False)
+ return Natural;
+
+
-- takes into account word wrap as well as newline characters
function Skip_Lines
(This : in out Text_Display;