diff options
-rw-r--r-- | src/c_fl_text_display.cpp | 170 | ||||
-rw-r--r-- | src/c_fl_text_display.h | 65 | ||||
-rw-r--r-- | src/fltk-widgets-groups-text_displays.adb | 534 | ||||
-rw-r--r-- | src/fltk-widgets-groups-text_displays.ads | 178 |
4 files changed, 843 insertions, 104 deletions
diff --git a/src/c_fl_text_display.cpp b/src/c_fl_text_display.cpp index 34d3c0f..9cc087e 100644 --- a/src/c_fl_text_display.cpp +++ b/src/c_fl_text_display.cpp @@ -25,42 +25,34 @@ class My_Text_Display : public Fl_Text_Display { h_hook_p handle_hook; }; - void My_Text_Display::draw() { (*draw_hook)(this->user_data()); } - void My_Text_Display::real_draw() { Fl_Text_Display::draw(); } - int My_Text_Display::handle(int e) { return (*handle_hook)(this->user_data(), e); } - int My_Text_Display::real_handle(int e) { return Fl_Text_Display::handle(e); } - void text_display_set_draw_hook(TEXTDISPLAY td, void * d) { reinterpret_cast<My_Text_Display*>(td)->draw_hook = reinterpret_cast<d_hook_p>(d); } - void fl_text_display_draw(TEXTDISPLAY td) { reinterpret_cast<My_Text_Display*>(td)->real_draw(); } - void text_display_set_handle_hook(TEXTDISPLAY td, void * h) { reinterpret_cast<My_Text_Display*>(td)->handle_hook = reinterpret_cast<h_hook_p>(h); } - int fl_text_display_handle(TEXTDISPLAY td, int e) { return reinterpret_cast<My_Text_Display*>(td)->real_handle(e); } @@ -73,7 +65,6 @@ TEXTDISPLAY new_fl_text_display(int x, int y, int w, int h, char* label) { return td; } - void free_fl_text_display(TEXTDISPLAY td) { delete reinterpret_cast<My_Text_Display*>(td); } @@ -87,113 +78,234 @@ TEXTBUFFER fl_text_display_get_buffer(TEXTDISPLAY td) { return reinterpret_cast<Fl_Text_Display*>(td)->buffer(); } - void fl_text_display_set_buffer(TEXTDISPLAY td, TEXTBUFFER tb) { reinterpret_cast<Fl_Text_Display*>(td)->buffer(reinterpret_cast<Fl_Text_Buffer*>(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_in_selection(TEXTDISPLAY td, int x, int y) { + return reinterpret_cast<Fl_Text_Display*>(td)->in_selection(x, y); +} -int fl_text_display_get_cursor_color(TEXTDISPLAY td) { - return reinterpret_cast<Fl_Text_Display*>(td)->cursor_color(); +int fl_text_display_position_to_xy(TEXTDISPLAY td, int p, int * x, int * y) { + return reinterpret_cast<Fl_Text_Display*>(td)->position_to_xy(p, x, y); } -void fl_text_display_set_cursor_color(TEXTDISPLAY td, int c) { - reinterpret_cast<Fl_Text_Display*>(td)->cursor_color(c); + + +unsigned 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, unsigned 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); } +void fl_text_display_hide_cursor(TEXTDISPLAY td) { + reinterpret_cast<Fl_Text_Display*>(td)->hide_cursor(); +} -int fl_text_display_get_text_color(TEXTDISPLAY td) { - return reinterpret_cast<Fl_Text_Display*>(td)->textcolor(); +void fl_text_display_show_cursor(TEXTDISPLAY td) { + reinterpret_cast<Fl_Text_Display*>(td)->show_cursor(); } -void fl_text_display_set_text_color(TEXTDISPLAY td, int c) { - reinterpret_cast<Fl_Text_Display*>(td)->textcolor(static_cast<Fl_Color>(c)); + + +unsigned int fl_text_display_get_text_color(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->textcolor(); } +void fl_text_display_set_text_color(TEXTDISPLAY td, unsigned int c) { + reinterpret_cast<Fl_Text_Display*>(td)->textcolor(static_cast<Fl_Color>(c)); +} int fl_text_display_get_text_font(TEXTDISPLAY td) { return reinterpret_cast<Fl_Text_Display*>(td)->textfont(); } - void fl_text_display_set_text_font(TEXTDISPLAY td, int f) { reinterpret_cast<Fl_Text_Display*>(td)->textfont(static_cast<Fl_Font>(f)); } - int fl_text_display_get_text_size(TEXTDISPLAY td) { return reinterpret_cast<Fl_Text_Display*>(td)->textsize(); } - void fl_text_display_set_text_size(TEXTDISPLAY td, int s) { reinterpret_cast<Fl_Text_Display*>(td)->textsize(static_cast<Fl_Fontsize>(s)); } + + +void fl_text_display_insert(TEXTDISPLAY td, char * i) { + reinterpret_cast<Fl_Text_Display*>(td)->insert(i); +} + 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(); } + + +int fl_text_display_word_start(TEXTDISPLAY td, int p) { + return reinterpret_cast<Fl_Text_Display*>(td)->word_start(p); +} + +int fl_text_display_word_end(TEXTDISPLAY td, int p) { + return reinterpret_cast<Fl_Text_Display*>(td)->word_end(p); +} + void fl_text_display_next_word(TEXTDISPLAY td) { reinterpret_cast<Fl_Text_Display*>(td)->next_word(); } - void fl_text_display_previous_word(TEXTDISPLAY td) { reinterpret_cast<Fl_Text_Display*>(td)->previous_word(); } - void fl_text_display_wrap_mode(TEXTDISPLAY td, int w, int m) { reinterpret_cast<Fl_Text_Display*>(td)->wrap_mode(w, m); } + + +int fl_text_display_line_start(TEXTDISPLAY td, int s) { + return reinterpret_cast<Fl_Text_Display*>(td)->line_start(s); +} + +int fl_text_display_line_end(TEXTDISPLAY td, int s, int p) { + return reinterpret_cast<Fl_Text_Display*>(td)->line_end(s, p); +} + 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); } - int fl_text_display_rewind_lines(TEXTDISPLAY td, int s, int l) { return reinterpret_cast<Fl_Text_Display*>(td)->rewind_lines(s, l); } -void fl_text_display_linenumber_width(TEXTDISPLAY td, int w) { + + +unsigned int fl_text_display_get_linenumber_align(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->linenumber_align(); +} + +void fl_text_display_set_linenumber_align(TEXTDISPLAY td, unsigned int a) { + reinterpret_cast<Fl_Text_Display*>(td)->linenumber_align(a); +} + +unsigned int fl_text_display_get_linenumber_bgcolor(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->linenumber_bgcolor(); +} + +void fl_text_display_set_linenumber_bgcolor(TEXTDISPLAY td, unsigned int c) { + reinterpret_cast<Fl_Text_Display*>(td)->linenumber_bgcolor(c); +} + +unsigned int fl_text_display_get_linenumber_fgcolor(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->linenumber_fgcolor(); +} + +void fl_text_display_set_linenumber_fgcolor(TEXTDISPLAY td, unsigned int c) { + reinterpret_cast<Fl_Text_Display*>(td)->linenumber_fgcolor(c); +} + +int fl_text_display_get_linenumber_font(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->linenumber_font(); +} + +void fl_text_display_set_linenumber_font(TEXTDISPLAY td, int f) { + reinterpret_cast<Fl_Text_Display*>(td)->linenumber_font(f); +} + +int fl_text_display_get_linenumber_size(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->linenumber_size(); +} + +void fl_text_display_set_linenumber_size(TEXTDISPLAY td, int s) { + reinterpret_cast<Fl_Text_Display*>(td)->linenumber_size(s); +} + +int fl_text_display_get_linenumber_width(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->linenumber_width(); +} + +void fl_text_display_set_linenumber_width(TEXTDISPLAY td, int w) { reinterpret_cast<Fl_Text_Display*>(td)->linenumber_width(w); } + + + +int fl_text_display_move_down(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->move_down(); +} + +int fl_text_display_move_left(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->move_left(); +} + +int fl_text_display_move_right(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->move_right(); +} + +int fl_text_display_move_up(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->move_up(); +} + + + + +void fl_text_display_scroll(TEXTDISPLAY td, int l) { + reinterpret_cast<Fl_Text_Display*>(td)->scroll(l, 1); +} + +unsigned int fl_text_display_get_scrollbar_align(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->scrollbar_align(); +} + +void fl_text_display_set_scrollbar_align(TEXTDISPLAY td, unsigned int a) { + reinterpret_cast<Fl_Text_Display*>(td)->scrollbar_align(a); +} + +int fl_text_display_get_scrollbar_width(TEXTDISPLAY td) { + return reinterpret_cast<Fl_Text_Display*>(td)->scrollbar_width(); +} + +void fl_text_display_set_scrollbar_width(TEXTDISPLAY td, int w) { + reinterpret_cast<Fl_Text_Display*>(td)->scrollbar_width(w); +} + diff --git a/src/c_fl_text_display.h b/src/c_fl_text_display.h index 2d47cc4..3b7e7e3 100644 --- a/src/c_fl_text_display.h +++ b/src/c_fl_text_display.h @@ -6,42 +6,97 @@ #include "c_fl_text_buffer.h" + + typedef void* TEXTDISPLAY; + + extern "C" void text_display_set_draw_hook(TEXTDISPLAY td, void * d); extern "C" void fl_text_display_draw(TEXTDISPLAY td); extern "C" void text_display_set_handle_hook(TEXTDISPLAY td, void * h); extern "C" int fl_text_display_handle(TEXTDISPLAY td, int e); + + extern "C" TEXTDISPLAY new_fl_text_display(int x, int y, int w, int h, char* label); 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" int fl_text_display_in_selection(TEXTDISPLAY td, int x, int y); +extern "C" int fl_text_display_position_to_xy(TEXTDISPLAY td, int p, int * x, int * y); + + +extern "C" unsigned int fl_text_display_get_cursor_color(TEXTDISPLAY td); +extern "C" void fl_text_display_set_cursor_color(TEXTDISPLAY td, unsigned 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" void fl_text_display_hide_cursor(TEXTDISPLAY td); +extern "C" void fl_text_display_show_cursor(TEXTDISPLAY td); + + +extern "C" unsigned int fl_text_display_get_text_color(TEXTDISPLAY td); +extern "C" void fl_text_display_set_text_color(TEXTDISPLAY td, unsigned int c); 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" void fl_text_display_insert(TEXTDISPLAY td, char * i); 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); + + +extern "C" int fl_text_display_word_start(TEXTDISPLAY td, int p); +extern "C" int fl_text_display_word_end(TEXTDISPLAY td, int p); 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_line_start(TEXTDISPLAY td, int s); +extern "C" int fl_text_display_line_end(TEXTDISPLAY td, int s, int p); 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); + + +extern "C" unsigned int fl_text_display_get_linenumber_align(TEXTDISPLAY td); +extern "C" void fl_text_display_set_linenumber_align(TEXTDISPLAY td, unsigned int a); +extern "C" unsigned int fl_text_display_get_linenumber_bgcolor(TEXTDISPLAY td); +extern "C" void fl_text_display_set_linenumber_bgcolor(TEXTDISPLAY td, unsigned int c); +extern "C" unsigned int fl_text_display_get_linenumber_fgcolor(TEXTDISPLAY td); +extern "C" void fl_text_display_set_linenumber_fgcolor(TEXTDISPLAY td, unsigned int c); +extern "C" int fl_text_display_get_linenumber_font(TEXTDISPLAY td); +extern "C" void fl_text_display_set_linenumber_font(TEXTDISPLAY td, int f); +extern "C" int fl_text_display_get_linenumber_size(TEXTDISPLAY td); +extern "C" void fl_text_display_set_linenumber_size(TEXTDISPLAY td, int s); +extern "C" int fl_text_display_get_linenumber_width(TEXTDISPLAY td); +extern "C" void fl_text_display_set_linenumber_width(TEXTDISPLAY td, int w); + + +extern "C" int fl_text_display_move_down(TEXTDISPLAY td); +extern "C" int fl_text_display_move_left(TEXTDISPLAY td); +extern "C" int fl_text_display_move_right(TEXTDISPLAY td); +extern "C" int fl_text_display_move_up(TEXTDISPLAY td); + + +extern "C" void fl_text_display_scroll(TEXTDISPLAY td, int l); +extern "C" unsigned int fl_text_display_get_scrollbar_align(TEXTDISPLAY td); +extern "C" void fl_text_display_set_scrollbar_align(TEXTDISPLAY td, unsigned int a); +extern "C" int fl_text_display_get_scrollbar_width(TEXTDISPLAY td); +extern "C" void fl_text_display_set_scrollbar_width(TEXTDISPLAY td, int w); #endif diff --git a/src/fltk-widgets-groups-text_displays.adb b/src/fltk-widgets-groups-text_displays.adb index 1bee23f..fbff6ef 100644 --- a/src/fltk-widgets-groups-text_displays.adb +++ b/src/fltk-widgets-groups-text_displays.adb @@ -3,6 +3,7 @@ with Interfaces.C; with System; with FLTK.Text_Buffers; +use type Interfaces.C.int; use type System.Address; @@ -18,6 +19,8 @@ package body FLTK.Widgets.Groups.Text_Displays is pragma Import (C, text_display_set_handle_hook, "text_display_set_handle_hook"); + + function new_fl_text_display (X, Y, W, H : in Interfaces.C.int; Label : in Interfaces.C.char_array) @@ -29,6 +32,8 @@ package body FLTK.Widgets.Groups.Text_Displays is pragma Import (C, free_fl_text_display, "free_fl_text_display"); + + function fl_text_display_get_buffer (TD : in System.Address) return System.Address; @@ -38,6 +43,9 @@ 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) @@ -50,14 +58,30 @@ package body FLTK.Widgets.Groups.Text_Displays is return Interfaces.C.double; pragma Import (C, fl_text_display_x_to_col, "fl_text_display_x_to_col"); + function fl_text_display_in_selection + (TD : in System.Address; + X, Y : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_text_display_in_selection, "fl_text_display_in_selection"); + + function fl_text_display_position_to_xy + (TD : in System.Address; + P : in Interfaces.C.int; + X, Y : out Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_text_display_position_to_xy, "fl_text_display_position_to_xy"); + + + + function fl_text_display_get_cursor_color (TD : in System.Address) - return Interfaces.C.int; + return Interfaces.C.unsigned; 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); + C : in Interfaces.C.unsigned); pragma Import (C, fl_text_display_set_cursor_color, "fl_text_display_set_cursor_color"); procedure fl_text_display_set_cursor_style @@ -65,14 +89,25 @@ package body FLTK.Widgets.Groups.Text_Displays is S : in Interfaces.C.int); pragma Import (C, fl_text_display_set_cursor_style, "fl_text_display_set_cursor_style"); + procedure fl_text_display_hide_cursor + (TD : in System.Address); + pragma Import (C, fl_text_display_hide_cursor, "fl_text_display_hide_cursor"); + + procedure fl_text_display_show_cursor + (TD : in System.Address); + pragma Import (C, fl_text_display_show_cursor, "fl_text_display_show_cursor"); + + + + function fl_text_display_get_text_color (TD : in System.Address) - return Interfaces.C.int; + return Interfaces.C.unsigned; pragma Import (C, fl_text_display_get_text_color, "fl_text_display_get_text_color"); procedure fl_text_display_set_text_color (TD : in System.Address; - C : in Interfaces.C.int); + C : in Interfaces.C.unsigned); pragma Import (C, fl_text_display_set_text_color, "fl_text_display_set_text_color"); function fl_text_display_get_text_font @@ -95,6 +130,14 @@ 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"); + + + + procedure fl_text_display_insert + (TD : in System.Address; + I : in Interfaces.C.char_array); + pragma Import (C, fl_text_display_insert, "fl_text_display_insert"); + function fl_text_display_get_insert_pos (TD : in System.Address) return Interfaces.C.int; @@ -109,6 +152,21 @@ package body FLTK.Widgets.Groups.Text_Displays is (TD : in System.Address); pragma Import (C, fl_text_display_show_insert_pos, "fl_text_display_show_insert_pos"); + + + + function fl_text_display_word_start + (TD : in System.Address; + P : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_text_display_word_start, "fl_text_display_word_start"); + + function fl_text_display_word_end + (TD : in System.Address; + P : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_text_display_word_end, "fl_text_display_word_end"); + procedure fl_text_display_next_word (TD : in System.Address); pragma Import (C, fl_text_display_next_word, "fl_text_display_next_word"); @@ -122,6 +180,21 @@ 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_line_start + (TD : in System.Address; + S : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_text_display_line_start, "fl_text_display_line_start"); + + function fl_text_display_line_end + (TD : in System.Address; + S, P : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_text_display_line_end, "fl_text_display_line_end"); + function fl_text_display_count_lines (TD : in System.Address; S, F, P : in Interfaces.C.int) @@ -140,10 +213,134 @@ package body FLTK.Widgets.Groups.Text_Displays is return Interfaces.C.int; pragma Import (C, fl_text_display_rewind_lines, "fl_text_display_rewind_lines"); - procedure fl_text_display_linenumber_width + + + + function fl_text_display_get_linenumber_align + (TD : in System.Address) + return Interfaces.C.unsigned; + pragma Import (C, fl_text_display_get_linenumber_align, + "fl_text_display_get_linenumber_align"); + + procedure fl_text_display_set_linenumber_align + (TD : in System.Address; + A : in Interfaces.C.unsigned); + pragma Import (C, fl_text_display_set_linenumber_align, + "fl_text_display_set_linenumber_align"); + + function fl_text_display_get_linenumber_bgcolor + (TD : in System.Address) + return Interfaces.C.unsigned; + pragma Import (C, fl_text_display_get_linenumber_bgcolor, + "fl_text_display_get_linenumber_bgcolor"); + + procedure fl_text_display_set_linenumber_bgcolor + (TD : in System.Address; + C : in Interfaces.C.unsigned); + pragma Import (C, fl_text_display_set_linenumber_bgcolor, + "fl_text_display_set_linenumber_bgcolor"); + + function fl_text_display_get_linenumber_fgcolor + (TD : in System.Address) + return Interfaces.C.unsigned; + pragma Import (C, fl_text_display_get_linenumber_fgcolor, + "fl_text_display_get_linenumber_fgcolor"); + + procedure fl_text_display_set_linenumber_fgcolor + (TD : in System.Address; + C : in Interfaces.C.unsigned); + pragma Import (C, fl_text_display_set_linenumber_fgcolor, + "fl_text_display_set_linenumber_fgcolor"); + + function fl_text_display_get_linenumber_font + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_display_get_linenumber_font, + "fl_text_display_get_linenumber_font"); + + procedure fl_text_display_set_linenumber_font + (TD : in System.Address; + F : in Interfaces.C.int); + pragma Import (C, fl_text_display_set_linenumber_font, + "fl_text_display_set_linenumber_font"); + + function fl_text_display_get_linenumber_size + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_display_get_linenumber_size, + "fl_text_display_get_linenumber_size"); + + procedure fl_text_display_set_linenumber_size + (TD : in System.Address; + S : in Interfaces.C.int); + pragma Import (C, fl_text_display_set_linenumber_size, + "fl_text_display_set_linenumber_size"); + + function fl_text_display_get_linenumber_width + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_display_get_linenumber_width, + "fl_text_display_get_linenumber_width"); + + procedure fl_text_display_set_linenumber_width + (TD : in System.Address; + W : in Interfaces.C.int); + pragma Import (C, fl_text_display_set_linenumber_width, + "fl_text_display_set_linenumber_width"); + + + + + function fl_text_display_move_down + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_display_move_down, "fl_text_display_move_down"); + + function fl_text_display_move_left + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_display_move_left, "fl_text_display_move_left"); + + function fl_text_display_move_right + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_display_move_right, "fl_text_display_move_right"); + + function fl_text_display_move_up + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_display_move_up, "fl_text_display_move_up"); + + + + + procedure fl_text_display_scroll + (TD : in System.Address; + L : in Interfaces.C.int); + pragma Import (C, fl_text_display_scroll, "fl_text_display_scroll"); + + function fl_text_display_get_scrollbar_align + (TD : in System.Address) + return Interfaces.C.unsigned; + pragma Import (C, fl_text_display_get_scrollbar_align, "fl_text_display_get_scrollbar_align"); + + procedure fl_text_display_set_scrollbar_align + (TD : in System.Address; + A : in Interfaces.C.unsigned); + pragma Import (C, fl_text_display_set_scrollbar_align, "fl_text_display_set_scrollbar_align"); + + function fl_text_display_get_scrollbar_width + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_display_get_scrollbar_width, "fl_text_display_get_scrollbar_width"); + + procedure fl_text_display_set_scrollbar_width (TD : in System.Address; W : in Interfaces.C.int); - pragma Import (C, fl_text_display_linenumber_width, "fl_text_display_linenumber_width"); + pragma Import (C, fl_text_display_set_scrollbar_width, "fl_text_display_set_scrollbar_width"); + + + procedure fl_text_display_draw (W : in System.Address); @@ -206,8 +403,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Get_Buffer; - - procedure Set_Buffer (This : in out Text_Display; Buff : in out FLTK.Text_Buffers.Text_Buffer) is @@ -229,8 +424,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Col_To_X; - - function X_To_Col (This : in Text_Display; X_Pos : in Integer) @@ -241,6 +434,33 @@ package body FLTK.Widgets.Groups.Text_Displays is end X_To_Col; + function In_Selection + (This : in Text_Display; + X, Y : in Integer) + return Boolean is + begin + return fl_text_display_in_selection + (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y)) /= 0; + end In_Selection; + + + procedure Position_To_XY + (This : in Text_Display; + Pos : in Integer; + X, Y : out Integer; + Vert_Out : out Boolean) + is + Raw_X, Raw_Y : Interfaces.C.int; + begin + Vert_Out := fl_text_display_position_to_xy + (This.Void_Ptr, + Interfaces.C.int (Pos), + Raw_X, Raw_Y) /= 0; + X := Integer (Raw_X); + Y := Integer (Raw_Y); + end Position_To_XY; + + function Get_Cursor_Color @@ -251,18 +471,14 @@ package body FLTK.Widgets.Groups.Text_Displays is 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)); + fl_text_display_set_cursor_color (This.Void_Ptr, Interfaces.C.unsigned (Col)); end Set_Cursor_Color; - - procedure Set_Cursor_Style (This : in out Text_Display; Style : in Cursor_Style) is @@ -271,6 +487,20 @@ package body FLTK.Widgets.Groups.Text_Displays is end Set_Cursor_Style; + procedure Hide_Cursor + (This : in out Text_Display) is + begin + fl_text_display_hide_cursor (This.Void_Ptr); + end Hide_Cursor; + + + procedure Show_Cursor + (This : in out Text_Display) is + begin + fl_text_display_show_cursor (This.Void_Ptr); + end Show_Cursor; + + function Get_Text_Color @@ -281,18 +511,14 @@ package body FLTK.Widgets.Groups.Text_Displays is end Get_Text_Color; - - procedure Set_Text_Color (This : in out Text_Display; Col : in Color) is begin - fl_text_display_set_text_color (This.Void_Ptr, Interfaces.C.int (Col)); + fl_text_display_set_text_color (This.Void_Ptr, Interfaces.C.unsigned (Col)); end Set_Text_Color; - - function Get_Text_Font (This : in Text_Display) return Font_Kind is @@ -301,8 +527,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Get_Text_Font; - - procedure Set_Text_Font (This : in out Text_Display; Font : in Font_Kind) is @@ -311,8 +535,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Set_Text_Font; - - function Get_Text_Size (This : in Text_Display) return Font_Size is @@ -321,8 +543,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Get_Text_Size; - - procedure Set_Text_Size (This : in out Text_Display; Size : in Font_Size) is @@ -333,6 +553,14 @@ package body FLTK.Widgets.Groups.Text_Displays is + procedure Insert_Text + (This : in out Text_Display; + Item : in String) is + begin + fl_text_display_insert (This.Void_Ptr, Interfaces.C.To_C (Item)); + end Insert_Text; + + function Get_Insert_Position (This : in Text_Display) return Natural is @@ -341,8 +569,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Get_Insert_Position; - - procedure Set_Insert_Position (This : in out Text_Display; Pos : in Natural) is @@ -351,8 +577,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Set_Insert_Position; - - procedure Show_Insert_Position (This : in out Text_Display) is begin @@ -362,6 +586,28 @@ package body FLTK.Widgets.Groups.Text_Displays is + function Word_Start + (This : in out Text_Display; + Pos : in Natural) + return Natural is + begin + return Natural (fl_text_display_word_start + (This.Void_Ptr, + Interfaces.C.int (Pos))); + end Word_Start; + + + function Word_End + (This : in out Text_Display; + Pos : in Natural) + return Natural is + begin + return Natural (fl_text_display_word_end + (This.Void_Ptr, + Interfaces.C.int (Pos))); + end Word_End; + + procedure Next_Word (This : in out Text_Display) is begin @@ -369,8 +615,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Next_Word; - - procedure Previous_Word (This : in out Text_Display) is begin @@ -378,8 +622,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Previous_Word; - - procedure Set_Wrap_Mode (This : in out Text_Display; Mode : in Wrap_Mode; @@ -394,6 +636,30 @@ package body FLTK.Widgets.Groups.Text_Displays is + function Line_Start + (This : in Text_Display; + Pos : in Natural) + return Natural is + begin + return Natural (fl_text_display_line_start + (This.Void_Ptr, + Interfaces.C.int (Pos))); + end Line_Start; + + + function Line_End + (This : in Text_Display; + Pos : in Natural; + Start_Pos_Is_Line_Start : in Boolean := False) + return Natural is + begin + return Natural (fl_text_display_line_end + (This.Void_Ptr, + Interfaces.C.int (Pos), + Boolean'Pos (Start_Pos_Is_Line_Start))); + end Line_End; + + function Count_Lines (This : in Text_Display; Start, Finish : in Natural; @@ -408,12 +674,10 @@ package body FLTK.Widgets.Groups.Text_Displays is end Count_Lines; - - function Skip_Lines - (This : in out Text_Display; - Start, Lines : in Natural; - Start_Pos_Is_Line_Start : in Boolean := False) + (This : in Text_Display; + Start, Lines : in Natural; + Start_Pos_Is_Line_Start : in Boolean := False) return Natural is begin return Natural (fl_text_display_skip_lines @@ -424,11 +688,9 @@ package body FLTK.Widgets.Groups.Text_Displays is end Skip_Lines; - - function Rewind_Lines - (This : in out Text_Display; - Start, Lines : in Natural) + (This : in Text_Display; + Start, Lines : in Natural) return Natural is begin return Natural (fl_text_display_rewind_lines @@ -440,11 +702,109 @@ package body FLTK.Widgets.Groups.Text_Displays is + function Get_Linenumber_Alignment + (This : in Text_Display) + return Alignment is + begin + return Alignment (fl_text_display_get_linenumber_align (This.Void_Ptr)); + end Get_Linenumber_Alignment; + + + procedure Set_Linenumber_Alignment + (This : in out Text_Display; + To : in Alignment) is + begin + fl_text_display_set_linenumber_align + (This.Void_Ptr, + Interfaces.C.unsigned (To)); + end Set_Linenumber_Alignment; + + + function Get_Linenumber_Back_Color + (This : in Text_Display) + return Color is + begin + return Color (fl_text_display_get_linenumber_bgcolor (This.Void_Ptr)); + end Get_Linenumber_Back_Color; + + + procedure Set_Linenumber_Back_Color + (This : in out Text_Display; + To : in Color) is + begin + fl_text_display_set_linenumber_bgcolor + (This.Void_Ptr, + Interfaces.C.unsigned (To)); + end Set_Linenumber_Back_Color; + + + function Get_Linenumber_Fore_Color + (This : in Text_Display) + return Color is + begin + return Color (fl_text_display_get_linenumber_fgcolor (This.Void_Ptr)); + end Get_Linenumber_Fore_Color; + + + procedure Set_Linenumber_Fore_Color + (This : in out Text_Display; + To : in Color) is + begin + fl_text_display_set_linenumber_fgcolor + (This.Void_Ptr, + Interfaces.C.unsigned (To)); + end Set_Linenumber_Fore_Color; + + + function Get_Linenumber_Font + (This : in Text_Display) + return Font_Kind is + begin + return Font_Kind'Val (fl_text_display_get_linenumber_font (This.Void_Ptr)); + end Get_Linenumber_Font; + + + procedure Set_Linenumber_Font + (This : in out Text_Display; + To : in Font_Kind) is + begin + fl_text_display_set_linenumber_font + (This.Void_Ptr, + Font_Kind'Pos (To)); + end Set_Linenumber_Font; + + + function Get_Linenumber_Size + (This : in Text_Display) + return Font_Size is + begin + return Font_Size (fl_text_display_get_linenumber_size (This.Void_Ptr)); + end Get_Linenumber_Size; + + + procedure Set_Linenumber_Size + (This : in out Text_Display; + To : in Font_Size) is + begin + fl_text_display_set_linenumber_size + (This.Void_Ptr, + Interfaces.C.int (To)); + end Set_Linenumber_Size; + + + function Get_Linenumber_Width + (This : in Text_Display) + return Natural is + begin + return Natural (fl_text_display_get_linenumber_width (This.Void_Ptr)); + end Get_Linenumber_Width; + + procedure Set_Linenumber_Width (This : in out Text_Display; Width : in Natural) is begin - fl_text_display_linenumber_width + fl_text_display_set_linenumber_width (This.Void_Ptr, Interfaces.C.int (Width)); end Set_Linenumber_Width; @@ -452,6 +812,90 @@ package body FLTK.Widgets.Groups.Text_Displays is + procedure Move_Down + (This : in out Text_Display) is + begin + if fl_text_display_move_down (This.Void_Ptr) = 0 then + raise Bounds_Error; + end if; + end Move_Down; + + + procedure Move_Left + (This : in out Text_Display) is + begin + if fl_text_display_move_left (This.Void_Ptr) = 0 then + raise Bounds_Error; + end if; + end Move_Left; + + + procedure Move_Right + (This : in out Text_Display) is + begin + if fl_text_display_move_right (This.Void_Ptr) = 0 then + raise Bounds_Error; + end if; + end Move_Right; + + + procedure Move_Up + (This : in out Text_Display) is + begin + if fl_text_display_move_up (This.Void_Ptr) = 0 then + raise Bounds_Error; + end if; + end Move_Up; + + + + + procedure Scroll_To + (This : in out Text_Display; + Line : in Natural) is + begin + fl_text_display_scroll (This.Void_Ptr, Interfaces.C.int (Line)); + end Scroll_To; + + + function Get_Scrollbar_Alignment + (This : in Text_Display) + return Alignment is + begin + return Alignment (fl_text_display_get_scrollbar_align (This.Void_Ptr)); + end Get_Scrollbar_Alignment; + + + procedure Set_Scrollbar_Alignment + (This : in out Text_Display; + Align : in Alignment) is + begin + fl_text_display_set_scrollbar_align + (This.Void_Ptr, + Interfaces.C.unsigned (Align)); + end Set_Scrollbar_Alignment; + + + function Get_Scrollbar_Width + (This : in Text_Display) + return Natural is + begin + return Natural (fl_text_display_get_scrollbar_width (This.Void_Ptr)); + end Get_Scrollbar_Width; + + + procedure Set_Scrollbar_Width + (This : in out Text_Display; + Width : in Natural) is + begin + fl_text_display_set_scrollbar_width + (This.Void_Ptr, + Interfaces.C.int (Width)); + end Set_Scrollbar_Width; + + + + procedure Draw (This : in out Text_Display) is begin @@ -459,8 +903,6 @@ package body FLTK.Widgets.Groups.Text_Displays is end Draw; - - function Handle (This : in out Text_Display; Event : in Event_Kind) diff --git a/src/fltk-widgets-groups-text_displays.ads b/src/fltk-widgets-groups-text_displays.ads index c1c3ea8..09cf31c 100644 --- a/src/fltk-widgets-groups-text_displays.ads +++ b/src/fltk-widgets-groups-text_displays.ads @@ -8,10 +8,13 @@ package FLTK.Widgets.Groups.Text_Displays is type Text_Display is new Group with private; - - type Wrap_Mode is (Wrap_None, Wrap_At_Column, Wrap_At_Pixel, Wrap_At_Bounds); + type Wrap_Mode is (None, Column, Pixel, Bounds); type Cursor_Style is (Normal, Caret, Dim, Block, Heavy, Simple); + Bounds_Error : exception; + + + function Create (X, Y, W, H : in Integer; @@ -19,132 +22,260 @@ package FLTK.Widgets.Groups.Text_Displays is return Text_Display; + + function Get_Buffer (This : in Text_Display) return FLTK.Text_Buffers.Text_Buffer_Cursor; - procedure Set_Buffer (This : in out Text_Display; 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 In_Selection + (This : in Text_Display; + X, Y : in Integer) + return Boolean; + + procedure Position_To_XY + (This : in Text_Display; + Pos : in Integer; + X, Y : out Integer; + Vert_Out : out Boolean); + + + 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); + procedure Hide_Cursor + (This : in out Text_Display); + + procedure Show_Cursor + (This : in out Text_Display); + + + function Get_Text_Color (This : in Text_Display) return Color; - procedure Set_Text_Color (This : in out Text_Display; Col : in Color); - function Get_Text_Font (This : in Text_Display) return Font_Kind; - procedure Set_Text_Font (This : in out Text_Display; Font : in Font_Kind); - function Get_Text_Size (This : in Text_Display) return Font_Size; - procedure Set_Text_Size (This : in out Text_Display; Size : in Font_Size); + + + procedure Insert_Text + (This : in out Text_Display; + Item : in String); + 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); + + + function Word_Start + (This : in out Text_Display; + Pos : in Natural) + return Natural; + + function Word_End + (This : in out Text_Display; + Pos : in Natural) + return Natural; + procedure Next_Word (This : in out Text_Display); - procedure Previous_Word (This : in out Text_Display); - procedure Set_Wrap_Mode (This : in out Text_Display; Mode : in Wrap_Mode; Margin : in Natural := 0); + + + -- takes into account word wrap + function Line_Start + (This : in Text_Display; + Pos : in Natural) + return Natural; + + -- takes into account word wrap + function Line_End + (This : in Text_Display; + Pos : in Natural; + Start_Pos_Is_Line_Start : in Boolean := False) + return Natural; + 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; - Start, Lines : in Natural; - Start_Pos_Is_Line_Start : in Boolean := False) + (This : in Text_Display; + Start, Lines : in Natural; + Start_Pos_Is_Line_Start : in Boolean := False) return Natural; - -- takes into account word wrap as well as newline characters function Rewind_Lines - (This : in out Text_Display; - Start, Lines : in Natural) + (This : in Text_Display; + Start, Lines : in Natural) return Natural; + + + function Get_Linenumber_Alignment + (This : in Text_Display) + return Alignment; + + procedure Set_Linenumber_Alignment + (This : in out Text_Display; + To : in Alignment); + + function Get_Linenumber_Back_Color + (This : in Text_Display) + return Color; + + procedure Set_Linenumber_Back_Color + (This : in out Text_Display; + To : in Color); + + function Get_Linenumber_Fore_Color + (This : in Text_Display) + return Color; + + procedure Set_Linenumber_Fore_Color + (This : in out Text_Display; + To : in Color); + + function Get_Linenumber_Font + (This : in Text_Display) + return Font_Kind; + + procedure Set_Linenumber_Font + (This : in out Text_Display; + To : in Font_Kind); + + function Get_Linenumber_Size + (This : in Text_Display) + return Font_Size; + + procedure Set_Linenumber_Size + (This : in out Text_Display; + To : in Font_Size); + + function Get_Linenumber_Width + (This : in Text_Display) + return Natural; + procedure Set_Linenumber_Width (This : in out Text_Display; Width : in Natural); - procedure Draw + + + procedure Move_Down + (This : in out Text_Display); + + procedure Move_Left + (This : in out Text_Display); + + procedure Move_Right + (This : in out Text_Display); + + procedure Move_Up (This : in out Text_Display); + + + procedure Scroll_To + (This : in out Text_Display; + Line : in Natural); + + function Get_Scrollbar_Alignment + (This : in Text_Display) + return Alignment; + + procedure Set_Scrollbar_Alignment + (This : in out Text_Display; + Align : in Alignment); + + function Get_Scrollbar_Width + (This : in Text_Display) + return Natural; + + procedure Set_Scrollbar_Width + (This : in out Text_Display; + Width : in Natural); + + + + + procedure Draw + (This : in out Text_Display); + function Handle (This : in out Text_Display; Event : in Event_Kind) @@ -159,7 +290,6 @@ private Buffer : access FLTK.Text_Buffers.Text_Buffer; end record; - overriding procedure Finalize (This : in out Text_Display); |