diff options
-rw-r--r-- | src/adapad.adb | 10 | ||||
-rw-r--r-- | src/fltk_binding/c_fl_text_buffer.cpp | 9 | ||||
-rw-r--r-- | src/fltk_binding/c_fl_text_buffer.h | 1 | ||||
-rw-r--r-- | src/fltk_binding/fltk-text_buffers.adb | 19 | ||||
-rw-r--r-- | src/fltk_binding/fltk-text_buffers.ads | 6 |
5 files changed, 39 insertions, 6 deletions
diff --git a/src/adapad.adb b/src/adapad.adb index 8574d34..a045cfe 100644 --- a/src/adapad.adb +++ b/src/adapad.adb @@ -220,14 +220,16 @@ package body Adapad is (Item : in out FLTK.Widgets.Widget'Class) is Restore_Position : Natural := Editor.Get_Insert_Position; - Current_Position, New_Position, Result : Natural := 0; + Current_Position, Result : Natural := 0; begin Editor.Set_Insert_Position (0); + if Character'Pos (Buffer.Character_At (0)) > Character'Pos (' ') then + Result := 1; + end if; loop Editor.Next_Word; - New_Position := Editor.Get_Insert_Position; - exit when New_Position = Buffer.Length; - Current_Position := New_Position; + Current_Position := Editor.Get_Insert_Position; + exit when Current_Position = Buffer.Length; Result := Result + 1; end loop; Editor.Set_Insert_Position (Restore_Position); diff --git a/src/fltk_binding/c_fl_text_buffer.cpp b/src/fltk_binding/c_fl_text_buffer.cpp index a28286f..20699e8 100644 --- a/src/fltk_binding/c_fl_text_buffer.cpp +++ b/src/fltk_binding/c_fl_text_buffer.cpp @@ -71,11 +71,16 @@ void fl_text_buffer_select(TEXTBUFFER tb, int s, int e) { int fl_text_buffer_skip_lines(TEXTBUFFER tb, int s, int l) { - reinterpret_cast<Fl_Text_Buffer*>(tb)->skip_lines(s, l); + return 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); + return reinterpret_cast<Fl_Text_Buffer*>(tb)->rewind_lines(s, l); +} + + +unsigned int fl_text_buffer_char_at(TEXTBUFFER tb, int p) { + return reinterpret_cast<Fl_Text_Buffer*>(tb)->char_at(p); } diff --git a/src/fltk_binding/c_fl_text_buffer.h b/src/fltk_binding/c_fl_text_buffer.h index ed95a6d..0ee2e5a 100644 --- a/src/fltk_binding/c_fl_text_buffer.h +++ b/src/fltk_binding/c_fl_text_buffer.h @@ -24,6 +24,7 @@ extern "C" int fl_text_buffer_search_forward(TEXTBUFFER tb, int start, const cha 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); +extern "C" unsigned int fl_text_buffer_char_at(TEXTBUFFER tb, int p); #endif diff --git a/src/fltk_binding/fltk-text_buffers.adb b/src/fltk_binding/fltk-text_buffers.adb index ab752ff..5db105d 100644 --- a/src/fltk_binding/fltk-text_buffers.adb +++ b/src/fltk_binding/fltk-text_buffers.adb @@ -96,6 +96,12 @@ package body FLTK.Text_Buffers is return Interfaces.C.int; pragma Import (C, fl_text_buffer_rewind_lines, "fl_text_buffer_rewind_lines"); + 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"); + @@ -376,5 +382,18 @@ package body FLTK.Text_Buffers is end Rewind_Lines; + + + function Character_At + (This : in Text_Buffer; + Pos : in Natural) + return Character is + begin + return Character'Val (fl_text_buffer_char_at + (This.Void_Ptr, + Interfaces.C.int (Pos))); + end Character_At; + + end FLTK.Text_Buffers; diff --git a/src/fltk_binding/fltk-text_buffers.ads b/src/fltk_binding/fltk-text_buffers.ads index 5b260d6..171fd84 100644 --- a/src/fltk_binding/fltk-text_buffers.ads +++ b/src/fltk_binding/fltk-text_buffers.ads @@ -105,6 +105,12 @@ package FLTK.Text_Buffers is return Natural; + function Character_At + (This : in Text_Buffer; + Pos : in Natural) + return Character; + + private |