openglada_glfw_0.9.0_fc25165c/src/glfw-windows-clipboard.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--  part of OpenGLAda, (c) 2017 Felix Krause
--  released under the terms of the MIT license, see the file "COPYING"

with Interfaces.C.Strings;

with Glfw.API;

package body Glfw.Windows.Clipboard is

   function Get (Object : not null access Window'Class) return String is
      use type Interfaces.C.Strings.chars_ptr;

      Raw : constant Interfaces.C.Strings.chars_ptr
        := API.Get_Clipboard_String (Object.Handle);
   begin
      if Raw = Interfaces.C.Strings.Null_Ptr then
         raise Operation_Exception with "Could not get clipboard string";
      end if;
      return Interfaces.C.Strings.Value (Raw);
   end Get;

   procedure Set (Object : not null access Window'Class; Value : String) is
   begin
      API.Set_Clipboard_String (Object.Handle, Interfaces.C.To_C (Value));
   end Set;

end Glfw.Windows.Clipboard;