summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2016-11-13 18:44:21 +1100
committerJed Barber <jjbarber@y7mail.com>2016-11-13 18:44:21 +1100
commit9a7351c664d7f05232cb3f934658c79fffc752fd (patch)
tree789985306b16a84fc2c8a7c420a4d7f679ec3391 /src
parent1ff0512b833a2d310783e4373483a603b91d2707 (diff)
Added jump to feature
Diffstat (limited to 'src')
-rw-r--r--src/adapad.adb25
-rw-r--r--src/fltk_binding/c_fl_text_buffer.cpp10
-rw-r--r--src/fltk_binding/c_fl_text_buffer.h2
-rw-r--r--src/fltk_binding/c_fl_text_display.cpp10
-rw-r--r--src/fltk_binding/c_fl_text_display.h2
-rw-r--r--src/fltk_binding/fltk-dialogs.adb3
-rw-r--r--src/fltk_binding/fltk-dialogs.ads3
-rw-r--r--src/fltk_binding/fltk-text_buffers.adb40
-rw-r--r--src/fltk_binding/fltk-text_buffers.ads14
-rw-r--r--src/fltk_binding/fltk-widgets-groups-text_displays.adb42
-rw-r--r--src/fltk_binding/fltk-widgets-groups-text_displays.ads15
11 files changed, 160 insertions, 6 deletions
diff --git a/src/adapad.adb b/src/adapad.adb
index 71b0a0b..8574d34 100644
--- a/src/adapad.adb
+++ b/src/adapad.adb
@@ -11,9 +11,6 @@ with Windows.Replace;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
-with Ada.Text_IO;
-
-
package body Adapad is
@@ -200,6 +197,25 @@ package body Adapad is
+ procedure Jump_CB
+ (Item : in out FLTK.Widgets.Widget'Class)
+ is
+ User_Input : String := FLTK.Dialogs.Text_Input ("Line number: ");
+ Line_Number : Integer;
+ begin
+ Line_Number := Integer'Value (User_Input);
+ if Line_Number > 0 then
+ Editor.Set_Insert_Position (Buffer.Skip_Lines (0, Line_Number - 1));
+ Editor.Show_Insert_Position;
+ end if;
+ exception
+ when Constraint_Error =>
+ null; -- user has entered nonsense input, do nothing
+ end Jump_CB;
+
+
+
+
procedure Count_CB
(Item : in out FLTK.Widgets.Widget'Class)
is
@@ -457,7 +473,8 @@ begin
Bar.Add (Text => "&Search", Flags => Flag_Submenu);
Bar.Add ("Search/&Find...", Find_CB'Access, Mod_Ctrl + 'f');
Bar.Add ("Search/&Replace...", Replace_CB'Access, Mod_Ctrl + 'h', Flag_Divider);
- Bar.Add ("Search/&Word Count", Count_CB'Access);
+ Bar.Add ("Search/Jump To...", Jump_CB'Access, Mod_Ctrl + 'j');
+ Bar.Add ("Search/Word Count", Count_CB'Access);
Bar.Add (Text => "&Options", Flags => Flag_Submenu);
Bar.Add ("Options/&Word Wrap", Wrap_CB'Access, No_Key, Flag_Toggle);
diff --git a/src/fltk_binding/c_fl_text_buffer.cpp b/src/fltk_binding/c_fl_text_buffer.cpp
index 8b0cde1..a28286f 100644
--- a/src/fltk_binding/c_fl_text_buffer.cpp
+++ b/src/fltk_binding/c_fl_text_buffer.cpp
@@ -69,3 +69,13 @@ void fl_text_buffer_select(TEXTBUFFER tb, int s, int e) {
reinterpret_cast<Fl_Text_Buffer*>(tb)->select(s, e);
}
+
+int fl_text_buffer_skip_lines(TEXTBUFFER tb, int s, int l) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->skip_lines(s, l);
+}
+
+
+int fl_text_buffer_rewind_lines(TEXTBUFFER tb, int s, int l) {
+ reinterpret_cast<Fl_Text_Buffer*>(tb)->rewind_lines(s, l);
+}
+
diff --git a/src/fltk_binding/c_fl_text_buffer.h b/src/fltk_binding/c_fl_text_buffer.h
index 5a1ab08..ed95a6d 100644
--- a/src/fltk_binding/c_fl_text_buffer.h
+++ b/src/fltk_binding/c_fl_text_buffer.h
@@ -22,6 +22,8 @@ extern "C" void fl_text_buffer_remove_selection(TEXTBUFFER tb);
extern "C" int fl_text_buffer_savefile(TEXTBUFFER tb, char * n);
extern "C" int fl_text_buffer_search_forward(TEXTBUFFER tb, int start, const char * item, int * found, int mcase);
extern "C" void fl_text_buffer_select(TEXTBUFFER tb, int s, int e);
+extern "C" int fl_text_buffer_skip_lines(TEXTBUFFER tb, int s, int l);
+extern "C" int fl_text_buffer_rewind_lines(TEXTBUFFER tb, int s, int l);
#endif
diff --git a/src/fltk_binding/c_fl_text_display.cpp b/src/fltk_binding/c_fl_text_display.cpp
index d1785e2..85ad733 100644
--- a/src/fltk_binding/c_fl_text_display.cpp
+++ b/src/fltk_binding/c_fl_text_display.cpp
@@ -88,3 +88,13 @@ 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_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);
+}
+
diff --git a/src/fltk_binding/c_fl_text_display.h b/src/fltk_binding/c_fl_text_display.h
index 2f8e089..3202397 100644
--- a/src/fltk_binding/c_fl_text_display.h
+++ b/src/fltk_binding/c_fl_text_display.h
@@ -26,6 +26,8 @@ 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_skip_lines(TEXTDISPLAY td, int s, int l, int p);
+extern "C" int fl_text_display_rewind_lines(TEXTDISPLAY td, int s, int l);
#endif
diff --git a/src/fltk_binding/fltk-dialogs.adb b/src/fltk_binding/fltk-dialogs.adb
index fed4070..0c9adcf 100644
--- a/src/fltk_binding/fltk-dialogs.adb
+++ b/src/fltk_binding/fltk-dialogs.adb
@@ -82,7 +82,8 @@ package body FLTK.Dialogs is
function Text_Input
- (Message, Default : in String)
+ (Message : in String;
+ Default : in String := "")
return String
is
Result : Interfaces.C.Strings.chars_ptr := dialog_fl_input
diff --git a/src/fltk_binding/fltk-dialogs.ads b/src/fltk_binding/fltk-dialogs.ads
index cf8f80e..cb5b966 100644
--- a/src/fltk_binding/fltk-dialogs.ads
+++ b/src/fltk_binding/fltk-dialogs.ads
@@ -20,7 +20,8 @@ package FLTK.Dialogs is
function Text_Input
- (Message, Default : in String)
+ (Message : in String;
+ Default : in String := "")
return String;
diff --git a/src/fltk_binding/fltk-text_buffers.adb b/src/fltk_binding/fltk-text_buffers.adb
index 7529c1c..ab752ff 100644
--- a/src/fltk_binding/fltk-text_buffers.adb
+++ b/src/fltk_binding/fltk-text_buffers.adb
@@ -84,6 +84,18 @@ package body FLTK.Text_Buffers is
S, E : in Interfaces.C.int);
pragma Import (C, fl_text_buffer_select, "fl_text_buffer_select");
+ 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");
+
+ 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");
+
@@ -336,5 +348,33 @@ package body FLTK.Text_Buffers is
end Set_Selection;
+
+
+ function Skip_Lines
+ (This : in out Text_Buffer;
+ Start, Lines : in Natural)
+ return Natural is
+ begin
+ return Natural (fl_text_buffer_skip_lines
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Lines)));
+ end Skip_Lines;
+
+
+
+
+ function Rewind_Lines
+ (This : in out Text_Buffer;
+ Start, Lines : in Natural)
+ return Natural is
+ begin
+ return Natural (fl_text_buffer_rewind_lines
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Lines)));
+ end Rewind_Lines;
+
+
end FLTK.Text_Buffers;
diff --git a/src/fltk_binding/fltk-text_buffers.ads b/src/fltk_binding/fltk-text_buffers.ads
index a021dbf..5b260d6 100644
--- a/src/fltk_binding/fltk-text_buffers.ads
+++ b/src/fltk_binding/fltk-text_buffers.ads
@@ -91,6 +91,20 @@ package FLTK.Text_Buffers is
Start, Finish : in Natural);
+ -- only takes into account newline characters, not word wrap
+ function Skip_Lines
+ (This : in out Text_Buffer;
+ Start, Lines : in Natural)
+ return Natural;
+
+
+ -- only takes into account newline characters, not word wrap
+ function Rewind_Lines
+ (This : in out Text_Buffer;
+ Start, Lines : in Natural)
+ return Natural;
+
+
private
diff --git a/src/fltk_binding/fltk-widgets-groups-text_displays.adb b/src/fltk_binding/fltk-widgets-groups-text_displays.adb
index 71aeee0..c6a1589 100644
--- a/src/fltk_binding/fltk-widgets-groups-text_displays.adb
+++ b/src/fltk_binding/fltk-widgets-groups-text_displays.adb
@@ -85,6 +85,18 @@ 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_skip_lines
+ (TD : in System.Address;
+ S, L, P : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_display_skip_lines, "fl_text_display_skip_lines");
+
+ function fl_text_display_rewind_lines
+ (TD : in System.Address;
+ S, L : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_text_display_rewind_lines, "fl_text_display_rewind_lines");
+
@@ -264,5 +276,35 @@ package body FLTK.Widgets.Groups.Text_Displays is
end Set_Wrap_Mode;
+
+
+ function Skip_Lines
+ (This : in out 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
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Lines),
+ Boolean'Pos (Start_Pos_Is_Line_Start)));
+ end Skip_Lines;
+
+
+
+
+ function Rewind_Lines
+ (This : in out Text_Display;
+ Start, Lines : in Natural)
+ return Natural is
+ begin
+ return Natural (fl_text_display_rewind_lines
+ (This.Void_Ptr,
+ Interfaces.C.int (Start),
+ Interfaces.C.int (Lines)));
+ end Rewind_Lines;
+
+
end FLTK.Widgets.Groups.Text_Displays;
diff --git a/src/fltk_binding/fltk-widgets-groups-text_displays.ads b/src/fltk_binding/fltk-widgets-groups-text_displays.ads
index a55b28f..6362160 100644
--- a/src/fltk_binding/fltk-widgets-groups-text_displays.ads
+++ b/src/fltk_binding/fltk-widgets-groups-text_displays.ads
@@ -87,6 +87,21 @@ package FLTK.Widgets.Groups.Text_Displays is
Margin : in Natural := 0);
+ -- 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)
+ return Natural;
+
+
+ -- takes into account word wrap as well as newline characters
+ function Rewind_Lines
+ (This : in out Text_Display;
+ Start, Lines : in Natural)
+ return Natural;
+
+
private