summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2024-10-13 04:20:39 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2024-10-13 04:20:39 +1300
commit947bfd3ac2cafa736e0cf2612e1c0c748c7be37f (patch)
treed2cb0d06fc694d07dba620d74b78be1480a8946e
parentb4090a7acddf951088b75fcce0d6edb721bbbf45 (diff)
Now with space to register an unlimited number of Clipboard_Notify_Handlers
-rw-r--r--src/fltk-static.adb22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/fltk-static.adb b/src/fltk-static.adb
index df531d3..3ec1a7f 100644
--- a/src/fltk-static.adb
+++ b/src/fltk-static.adb
@@ -2,6 +2,7 @@
with
+ Ada.Containers.Vectors,
Interfaces.C.Strings,
System.Address_To_Access_Conversions,
FLTK.Static_Callback_Conversions;
@@ -503,7 +504,11 @@ package body FLTK.Static is
-- This is handled on the Ada side because otherwise there would be
-- no way to specify which callback to remove in FLTK once one was
-- added. The hook is passed during package init.
- Current_Clipboard_Notify : Clipboard_Notify_Handler;
+ package Clipboard_Notify_Vectors is new Ada.Containers.Vectors
+ (Index_Type => Positive,
+ Element_Type => Clipboard_Notify_Handler);
+
+ Current_Clip_Notes : Clipboard_Notify_Vectors.Vector;
procedure Clipboard_Notify_Hook
(S : in Interfaces.C.int;
@@ -514,23 +519,28 @@ package body FLTK.Static is
(S : in Interfaces.C.int;
U : in Storage.Integer_Address) is
begin
- if Current_Clipboard_Notify /= null then
- Current_Clipboard_Notify.all (Buffer_Kind'Val (S));
- end if;
+ for Call of Current_Clip_Notes loop
+ Call.all (Buffer_Kind'Val (S));
+ end loop;
end Clipboard_Notify_Hook;
procedure Add_Clipboard_Notify
(Func : in Clipboard_Notify_Handler) is
begin
- Current_Clipboard_Notify := Func;
+ Current_Clip_Notes.Append (Func);
end Add_Clipboard_Notify;
procedure Remove_Clipboard_Notify
(Func : in Clipboard_Notify_Handler) is
begin
- Current_Clipboard_Notify := null;
+ for Index in Current_Clip_Notes.First_Index .. Current_Clip_Notes.Last_Index loop
+ if Current_Clip_Notes (Index) = Func then
+ Current_Clip_Notes.Delete (Index);
+ return;
+ end if;
+ end loop;
end Remove_Clipboard_Notify;