X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=doc%2Fhtml%2Fada%2Fterminal_interface-curses__adb.htm;fp=doc%2Fhtml%2Fada%2Fterminal_interface-curses__adb.htm;h=1c0137534571b25d72dc31196bd4f1fc2af763d7;hp=ad0c521f6ed14da178ec5f001129ecc80435dd0d;hb=f6718d80c998008de6cfe8e6296bee3958ff86d7;hpb=205f120bce7a338464e79ef846e4f07eff365d6c diff --git a/doc/html/ada/terminal_interface-curses__adb.htm b/doc/html/ada/terminal_interface-curses__adb.htm index ad0c521f..1c013753 100644 --- a/doc/html/ada/terminal_interface-curses__adb.htm +++ b/doc/html/ada/terminal_interface-curses__adb.htm @@ -12,7 +12,7 @@ -- B O D Y -- -- -- ------------------------------------------------------------------------------ --- Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. -- +-- Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- @@ -40,8 +40,8 @@ ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Version Control: --- @Revision: 1.4 @ --- @Date: 2007/05/05 20:09:10 @ +-- @Revision: 1.5 @ +-- @Date: 2008/07/26 18:46:32 @ -- Binding Version 01.00 ------------------------------------------------------------------------------ with System; @@ -59,9 +59,9 @@ package ASF renames Ada.Strings.Fixed; - type chtype_array is array (size_t range <>) + type chtype_array is array (size_t range <>) of aliased Attributed_Character; - pragma Convention (C, chtype_array); + pragma Convention (C, chtype_array); ------------------------------------------------------------------------------ function Key_Name (Key : in Real_Key_Code) return String @@ -406,15 +406,15 @@ ------------------------------------------------------------------------------ procedure Add (Win : in Window := Standard_Window; - Str : in Attributed_String; + Str : in Attributed_String; Len : in Integer := -1) is function Waddchnstr (Win : Window; - Str : chtype_array; + Str : chtype_array; Len : C_Int := -1) return C_Int; pragma Import (C, Waddchnstr, "waddchnstr"); - Txt : chtype_array (0 .. Str'Length); + Txt : chtype_array (0 .. Str'Length); begin for Length in 1 .. size_t (Str'Length) loop Txt (Length - 1) := Str (Natural (Length)); @@ -431,7 +431,7 @@ (Win : in Window := Standard_Window; Line : in Line_Position; Column : in Column_Position; - Str : in Attributed_String; + Str : in Attributed_String; Len : in Integer := -1) is begin @@ -1730,16 +1730,16 @@ ------------------------------------------------------------------------------ procedure Peek (Win : in Window := Standard_Window; - Str : out Attributed_String; + Str : out Attributed_String; Len : in Integer := -1) is function Winchnstr (Win : Window; - Str : chtype_array; -- out + Str : chtype_array; -- out Len : C_Int) return C_Int; pragma Import (C, Winchnstr, "winchnstr"); N : Integer := Len; - Txt : constant chtype_array (0 .. Str'Length) + Txt : constant chtype_array (0 .. Str'Length) := (0 => Default_Character); Cnt : Natural := 0; begin @@ -1769,7 +1769,7 @@ (Win : in Window := Standard_Window; Line : in Line_Position; Column : in Column_Position; - Str : out Attributed_String; + Str : out Attributed_String; Len : in Integer := -1) is begin @@ -2155,7 +2155,8 @@ raise Constraint_Error; end if; if Integer (Fore) >= Number_Of_Colors or else - Integer (Back) >= Number_Of_Colors then raise Constraint_Error; + Integer (Back) >= Number_Of_Colors then + raise Constraint_Error; end if; if Initpair (C_Short (Pair), C_Short (Fore), C_Short (Back)) = Curses_Err then @@ -2163,305 +2164,305 @@ end if; end Init_Pair; - procedure Pair_Content (Pair : in Color_Pair; - Fore : out Color_Number; - Back : out Color_Number) + procedure Pair_Content (Pair : in Color_Pair; + Fore : out Color_Number; + Back : out Color_Number) is - type C_Short_Access is access all C_Short; - function Paircontent (Pair : C_Short; - Fp : C_Short_Access; - Bp : C_Short_Access) return C_Int; + type C_Short_Access is access all C_Short; + function Paircontent (Pair : C_Short; + Fp : C_Short_Access; + Bp : C_Short_Access) return C_Int; pragma Import (C, Paircontent, "pair_content"); - F, B : aliased C_Short; + F, B : aliased C_Short; begin - if Paircontent (C_Short (Pair), F'Access, B'Access) = Curses_Err then + if Paircontent (C_Short (Pair), F'Access, B'Access) = Curses_Err then raise Curses_Exception; else - Fore := Color_Number (F); - Back := Color_Number (B); + Fore := Color_Number (F); + Back := Color_Number (B); end if; end Pair_Content; - function Has_Colors return Boolean + function Has_Colors return Boolean is - function Hascolors return Curses_Bool; + function Hascolors return Curses_Bool; pragma Import (C, Hascolors, "has_colors"); begin - if Hascolors = Curses_Bool_False then + if Hascolors = Curses_Bool_False then return False; else return True; end if; end Has_Colors; - procedure Init_Color (Color : in Color_Number; - Red : in RGB_Value; - Green : in RGB_Value; - Blue : in RGB_Value) + procedure Init_Color (Color : in Color_Number; + Red : in RGB_Value; + Green : in RGB_Value; + Blue : in RGB_Value) is - function Initcolor (Col : C_Short; - Red : C_Short; - Green : C_Short; - Blue : C_Short) return C_Int; + function Initcolor (Col : C_Short; + Red : C_Short; + Green : C_Short; + Blue : C_Short) return C_Int; pragma Import (C, Initcolor, "init_color"); begin - if Initcolor (C_Short (Color), C_Short (Red), C_Short (Green), + if Initcolor (C_Short (Color), C_Short (Red), C_Short (Green), C_Short (Blue)) = Curses_Err then raise Curses_Exception; end if; end Init_Color; - function Can_Change_Color return Boolean + function Can_Change_Color return Boolean is - function Canchangecolor return Curses_Bool; + function Canchangecolor return Curses_Bool; pragma Import (C, Canchangecolor, "can_change_color"); begin - if Canchangecolor = Curses_Bool_False then + if Canchangecolor = Curses_Bool_False then return False; else return True; end if; end Can_Change_Color; - procedure Color_Content (Color : in Color_Number; - Red : out RGB_Value; - Green : out RGB_Value; - Blue : out RGB_Value) + procedure Color_Content (Color : in Color_Number; + Red : out RGB_Value; + Green : out RGB_Value; + Blue : out RGB_Value) is - type C_Short_Access is access all C_Short; + type C_Short_Access is access all C_Short; - function Colorcontent (Color : C_Short; R, G, B : C_Short_Access) + function Colorcontent (Color : C_Short; R, G, B : C_Short_Access) return C_Int; pragma Import (C, Colorcontent, "color_content"); - R, G, B : aliased C_Short; + R, G, B : aliased C_Short; begin - if Colorcontent (C_Short (Color), R'Access, G'Access, B'Access) = + if Colorcontent (C_Short (Color), R'Access, G'Access, B'Access) = Curses_Err then raise Curses_Exception; else - Red := RGB_Value (R); - Green := RGB_Value (G); - Blue := RGB_Value (B); + Red := RGB_Value (R); + Green := RGB_Value (G); + Blue := RGB_Value (B); end if; end Color_Content; ------------------------------------------------------------------------------ - procedure Save_Curses_Mode (Mode : in Curses_Mode) + procedure Save_Curses_Mode (Mode : in Curses_Mode) is - function Def_Prog_Mode return C_Int; + function Def_Prog_Mode return C_Int; pragma Import (C, Def_Prog_Mode, "def_prog_mode"); - function Def_Shell_Mode return C_Int; + function Def_Shell_Mode return C_Int; pragma Import (C, Def_Shell_Mode, "def_shell_mode"); - Err : C_Int; + Err : C_Int; begin case Mode is - when Curses => Err := Def_Prog_Mode; - when Shell => Err := Def_Shell_Mode; + when Curses => Err := Def_Prog_Mode; + when Shell => Err := Def_Shell_Mode; end case; - if Err = Curses_Err then + if Err = Curses_Err then raise Curses_Exception; end if; end Save_Curses_Mode; - procedure Reset_Curses_Mode (Mode : in Curses_Mode) + procedure Reset_Curses_Mode (Mode : in Curses_Mode) is - function Reset_Prog_Mode return C_Int; + function Reset_Prog_Mode return C_Int; pragma Import (C, Reset_Prog_Mode, "reset_prog_mode"); - function Reset_Shell_Mode return C_Int; + function Reset_Shell_Mode return C_Int; pragma Import (C, Reset_Shell_Mode, "reset_shell_mode"); - Err : C_Int; + Err : C_Int; begin case Mode is - when Curses => Err := Reset_Prog_Mode; - when Shell => Err := Reset_Shell_Mode; + when Curses => Err := Reset_Prog_Mode; + when Shell => Err := Reset_Shell_Mode; end case; - if Err = Curses_Err then + if Err = Curses_Err then raise Curses_Exception; end if; end Reset_Curses_Mode; - procedure Save_Terminal_State + procedure Save_Terminal_State is - function Savetty return C_Int; + function Savetty return C_Int; pragma Import (C, Savetty, "savetty"); begin - if Savetty = Curses_Err then + if Savetty = Curses_Err then raise Curses_Exception; end if; end Save_Terminal_State; - procedure Reset_Terminal_State + procedure Reset_Terminal_State is - function Resetty return C_Int; + function Resetty return C_Int; pragma Import (C, Resetty, "resetty"); begin - if Resetty = Curses_Err then + if Resetty = Curses_Err then raise Curses_Exception; end if; end Reset_Terminal_State; - procedure Rip_Off_Lines (Lines : in Integer; - Proc : in Stdscr_Init_Proc) + procedure Rip_Off_Lines (Lines : in Integer; + Proc : in Stdscr_Init_Proc) is - function Ripoffline (Lines : C_Int; - Proc : Stdscr_Init_Proc) return C_Int; + function Ripoffline (Lines : C_Int; + Proc : Stdscr_Init_Proc) return C_Int; pragma Import (C, Ripoffline, "_nc_ripoffline"); begin - if Ripoffline (C_Int (Lines), Proc) = Curses_Err then + if Ripoffline (C_Int (Lines), Proc) = Curses_Err then raise Curses_Exception; end if; end Rip_Off_Lines; - procedure Set_Cursor_Visibility (Visibility : in out Cursor_Visibility) + procedure Set_Cursor_Visibility (Visibility : in out Cursor_Visibility) is - function Curs_Set (Curs : C_Int) return C_Int; + function Curs_Set (Curs : C_Int) return C_Int; pragma Import (C, Curs_Set, "curs_set"); - Res : C_Int; + Res : C_Int; begin - Res := Curs_Set (Cursor_Visibility'Pos (Visibility)); - if Res /= Curses_Err then - Visibility := Cursor_Visibility'Val (Res); + Res := Curs_Set (Cursor_Visibility'Pos (Visibility)); + if Res /= Curses_Err then + Visibility := Cursor_Visibility'Val (Res); end if; end Set_Cursor_Visibility; - procedure Nap_Milli_Seconds (Ms : in Natural) + procedure Nap_Milli_Seconds (Ms : in Natural) is - function Napms (Ms : C_Int) return C_Int; + function Napms (Ms : C_Int) return C_Int; pragma Import (C, Napms, "napms"); begin - if Napms (C_Int (Ms)) = Curses_Err then + if Napms (C_Int (Ms)) = Curses_Err then raise Curses_Exception; end if; end Nap_Milli_Seconds; ------------------------------------------------------------------------------ - function Standard_Window return Window + function Standard_Window return Window is - Result : Window; - pragma Import (C, Result, "stdscr"); + Result : Window; + pragma Import (C, Result, "stdscr"); begin - return Result; + return Result; end Standard_Window; - function Current_Window return Window + function Current_Window return Window is - Result : Window; - pragma Import (C, Result, "curscr"); + Result : Window; + pragma Import (C, Result, "curscr"); begin - return Result; + return Result; end Current_Window; - function Lines return Line_Count + function Lines return Line_Count is - Result : C_Int; - pragma Import (C, Result, "LINES"); + Result : C_Int; + pragma Import (C, Result, "LINES"); begin - return Line_Count (Result); + return Line_Count (Result); end Lines; - function Columns return Column_Count + function Columns return Column_Count is - Result : C_Int; - pragma Import (C, Result, "COLS"); + Result : C_Int; + pragma Import (C, Result, "COLS"); begin - return Column_Count (Result); + return Column_Count (Result); end Columns; - function Tab_Size return Natural + function Tab_Size return Natural is - Result : C_Int; - pragma Import (C, Result, "TABSIZE"); + Result : C_Int; + pragma Import (C, Result, "TABSIZE"); begin - return Natural (Result); + return Natural (Result); end Tab_Size; - function Number_Of_Colors return Natural + function Number_Of_Colors return Natural is - Result : C_Int; - pragma Import (C, Result, "COLORS"); + Result : C_Int; + pragma Import (C, Result, "COLORS"); begin - return Natural (Result); + return Natural (Result); end Number_Of_Colors; - function Number_Of_Color_Pairs return Natural + function Number_Of_Color_Pairs return Natural is - Result : C_Int; - pragma Import (C, Result, "COLOR_PAIRS"); + Result : C_Int; + pragma Import (C, Result, "COLOR_PAIRS"); begin - return Natural (Result); + return Natural (Result); end Number_Of_Color_Pairs; ------------------------------------------------------------------------------ - procedure Transform_Coordinates - (W : in Window := Standard_Window; - Line : in out Line_Position; - Column : in out Column_Position; - Dir : in Transform_Direction := From_Screen) - is - type Int_Access is access all C_Int; - function Transform (W : Window; - Y, X : Int_Access; - Dir : Curses_Bool) return C_Int; + procedure Transform_Coordinates + (W : in Window := Standard_Window; + Line : in out Line_Position; + Column : in out Column_Position; + Dir : in Transform_Direction := From_Screen) + is + type Int_Access is access all C_Int; + function Transform (W : Window; + Y, X : Int_Access; + Dir : Curses_Bool) return C_Int; pragma Import (C, Transform, "wmouse_trafo"); - X : aliased C_Int := C_Int (Column); - Y : aliased C_Int := C_Int (Line); - D : Curses_Bool := Curses_Bool_False; - R : C_Int; + X : aliased C_Int := C_Int (Column); + Y : aliased C_Int := C_Int (Line); + D : Curses_Bool := Curses_Bool_False; + R : C_Int; begin if Dir = To_Screen then - D := 1; + D := 1; end if; - R := Transform (W, Y'Access, X'Access, D); - if R = Curses_False then + R := Transform (W, Y'Access, X'Access, D); + if R = Curses_False then raise Curses_Exception; else - Line := Line_Position (Y); - Column := Column_Position (X); + Line := Line_Position (Y); + Column := Column_Position (X); end if; end Transform_Coordinates; ------------------------------------------------------------------------------ - procedure Use_Default_Colors is - function C_Use_Default_Colors return C_Int; + procedure Use_Default_Colors is + function C_Use_Default_Colors return C_Int; pragma Import (C, C_Use_Default_Colors, "use_default_colors"); - Err : constant C_Int := C_Use_Default_Colors; + Err : constant C_Int := C_Use_Default_Colors; begin - if Err = Curses_Err then + if Err = Curses_Err then raise Curses_Exception; end if; end Use_Default_Colors; - procedure Assume_Default_Colors (Fore : Color_Number := Default_Color; - Back : Color_Number := Default_Color) + procedure Assume_Default_Colors (Fore : Color_Number := Default_Color; + Back : Color_Number := Default_Color) is - function C_Assume_Default_Colors (Fore : C_Int; - Back : C_Int) return C_Int; + function C_Assume_Default_Colors (Fore : C_Int; + Back : C_Int) return C_Int; pragma Import (C, C_Assume_Default_Colors, "assume_default_colors"); - Err : constant C_Int := C_Assume_Default_Colors (C_Int (Fore), + Err : constant C_Int := C_Assume_Default_Colors (C_Int (Fore), C_Int (Back)); begin - if Err = Curses_Err then + if Err = Curses_Err then raise Curses_Exception; end if; end Assume_Default_Colors; ------------------------------------------------------------------------------ - function Curses_Version return String + function Curses_Version return String is - function curses_versionC return chars_ptr; + function curses_versionC return chars_ptr; pragma Import (C, curses_versionC, "curses_version"); - Result : constant chars_ptr := curses_versionC; + Result : constant chars_ptr := curses_versionC; begin - return Fill_String (Result); + return Fill_String (Result); end Curses_Version; ------------------------------------------------------------------------------ - procedure Curses_Free_All is - procedure curses_freeall; + procedure Curses_Free_All is + procedure curses_freeall; pragma Import (C, curses_freeall, "_nc_freeall"); begin -- Use this only for testing: you cannot use curses after calling it, @@ -2471,85 +2472,85 @@ -- _nc_free_and_exit() procedure can do that, but it can be invoked -- safely only from C - and again, that only as the "last" thing done -- before exiting the program. - curses_freeall; + curses_freeall; end Curses_Free_All; ------------------------------------------------------------------------------ - function Use_Extended_Names (Enable : Boolean) return Boolean + function Use_Extended_Names (Enable : Boolean) return Boolean is - function use_extended_namesC (e : Curses_Bool) return C_Int; + function use_extended_namesC (e : Curses_Bool) return C_Int; pragma Import (C, use_extended_namesC, "use_extended_names"); - Res : constant C_Int := - use_extended_namesC (Curses_Bool (Boolean'Pos (Enable))); + Res : constant C_Int := + use_extended_namesC (Curses_Bool (Boolean'Pos (Enable))); begin - if Res = C_Int (Curses_Bool_False) then + if Res = C_Int (Curses_Bool_False) then return False; else return True; end if; end Use_Extended_Names; ------------------------------------------------------------------------------ - procedure Screen_Dump_To_File (Filename : in String) + procedure Screen_Dump_To_File (Filename : in String) is - function scr_dump (f : char_array) return C_Int; + function scr_dump (f : char_array) return C_Int; pragma Import (C, scr_dump, "scr_dump"); - Txt : char_array (0 .. Filename'Length); - Length : size_t; + Txt : char_array (0 .. Filename'Length); + Length : size_t; begin - To_C (Filename, Txt, Length); - if Curses_Err = scr_dump (Txt) then + To_C (Filename, Txt, Length); + if Curses_Err = scr_dump (Txt) then raise Curses_Exception; end if; end Screen_Dump_To_File; - procedure Screen_Restore_From_File (Filename : in String) + procedure Screen_Restore_From_File (Filename : in String) is - function scr_restore (f : char_array) return C_Int; + function scr_restore (f : char_array) return C_Int; pragma Import (C, scr_restore, "scr_restore"); - Txt : char_array (0 .. Filename'Length); - Length : size_t; + Txt : char_array (0 .. Filename'Length); + Length : size_t; begin - To_C (Filename, Txt, Length); - if Curses_Err = scr_restore (Txt) then + To_C (Filename, Txt, Length); + if Curses_Err = scr_restore (Txt) then raise Curses_Exception; end if; end Screen_Restore_From_File; - procedure Screen_Init_From_File (Filename : in String) + procedure Screen_Init_From_File (Filename : in String) is - function scr_init (f : char_array) return C_Int; + function scr_init (f : char_array) return C_Int; pragma Import (C, scr_init, "scr_init"); - Txt : char_array (0 .. Filename'Length); - Length : size_t; + Txt : char_array (0 .. Filename'Length); + Length : size_t; begin - To_C (Filename, Txt, Length); - if Curses_Err = scr_init (Txt) then + To_C (Filename, Txt, Length); + if Curses_Err = scr_init (Txt) then raise Curses_Exception; end if; end Screen_Init_From_File; - procedure Screen_Set_File (Filename : in String) + procedure Screen_Set_File (Filename : in String) is - function scr_set (f : char_array) return C_Int; + function scr_set (f : char_array) return C_Int; pragma Import (C, scr_set, "scr_set"); - Txt : char_array (0 .. Filename'Length); - Length : size_t; + Txt : char_array (0 .. Filename'Length); + Length : size_t; begin - To_C (Filename, Txt, Length); - if Curses_Err = scr_set (Txt) then + To_C (Filename, Txt, Length); + if Curses_Err = scr_set (Txt) then raise Curses_Exception; end if; end Screen_Set_File; ------------------------------------------------------------------------------ - procedure Resize (Win : Window := Standard_Window; - Number_Of_Lines : Line_Count; - Number_Of_Columns : Column_Count) is - function wresize (win : Window; - lines : C_Int; - columns : C_Int) return C_Int; + procedure Resize (Win : Window := Standard_Window; + Number_Of_Lines : Line_Count; + Number_Of_Columns : Column_Count) is + function wresize (win : Window; + lines : C_Int; + columns : C_Int) return C_Int; pragma Import (C, wresize); begin - if wresize (Win, + if wresize (Win, C_Int (Number_Of_Lines), C_Int (Number_Of_Columns)) = Curses_Err then raise Curses_Exception;