-------------------------------------------------------------------------------
- generic
- type Element is (<>);
- function W_Get_Element (Win : in Window;
- Offset : in Natural) return Element;
-
- function W_Get_Element (Win : in Window;
- Offset : in Natural) return Element is
- type E_Array is array (Natural range <>) of aliased Element;
- package C_E_Array is new
- Interfaces.C.Pointers (Natural, Element, E_Array, Element'Val (0));
- use C_E_Array;
-
- function To_Pointer is new
- Ada.Unchecked_Conversion (Window, Pointer);
-
- P : Pointer := To_Pointer (Win);
- begin
- if Win = Null_Window then
- raise Curses_Exception;
- else
- P := P + ptrdiff_t (Offset);
- return P.all;
- end if;
- end W_Get_Element;
-
- function W_Get_Int is new W_Get_Element (C_Int);
- function W_Get_Short is new W_Get_Element (C_Short);
- function W_Get_Byte is new W_Get_Element (Interfaces.C.unsigned_char);
-
- function Get_Flag (Win : Window;
- Offset : Natural) return Boolean;
-
- function Get_Flag (Win : Window;
- Offset : Natural) return Boolean
- is
- Res : C_Int;
- begin
- case Sizeof_bool is
- when 1 => Res := C_Int (W_Get_Byte (Win, Offset));
- when 2 => Res := C_Int (W_Get_Short (Win, Offset));
- when 4 => Res := C_Int (W_Get_Int (Win, Offset));
- when others => raise Curses_Exception;
- end case;
-
- case Res is
- when 0 => return False;
- when others => return True;
- end case;
- end Get_Flag;
-