📄 terminal_interface-curses.ads.m4
字号:
-- -*- ada -*-define(`HTMLNAME',`terminal_interface-curses__ads.htm')dnlinclude(M4MACRO)-------------------------------------------------------------------------------- ---- GNAT ncurses Binding ---- ---- Terminal_Interface.Curses ---- ---- S P E C ---- ---------------------------------------------------------------------------------- Copyright (c) 1998,2004 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 ---- "Software"), to deal in the Software without restriction, including ---- without limitation the rights to use, copy, modify, merge, publish, ---- distribute, distribute with modifications, sublicense, and/or sell ---- copies of the Software, and to permit persons to whom the Software is ---- furnished to do so, subject to the following conditions: ---- ---- The above copyright notice and this permission notice shall be included ---- in all copies or substantial portions of the Software. ---- ---- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ---- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ---- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ---- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, ---- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR ---- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR ---- THE USE OR OTHER DEALINGS IN THE SOFTWARE. ---- ---- Except as contained in this notice, the name(s) of the above copyright ---- holders shall not be used in advertising or otherwise to promote the ---- sale, use or other dealings in this Software without prior written ---- authorization. ---------------------------------------------------------------------------------- Author: Juergen Pfeifer, 1996-- Version Control:-- $Revision: 1.35 $-- $Date: 2004/08/21 21:37:00 $-- Binding Version 01.00------------------------------------------------------------------------------include(`Base_Defs')with System.Storage_Elements;with Interfaces.C; -- We need this for some assertions.package Terminal_Interface.Curses is pragma Preelaborate (Terminal_Interface.Curses);include(`Linker_Options')include(`Version_Info') type Window is private; Null_Window : constant Window; type Line_Position is new Natural; -- line coordinate type Column_Position is new Natural; -- column coordinate subtype Line_Count is Line_Position range 1 .. Line_Position'Last; -- Type to count lines. We do not allow null windows, so must be positive subtype Column_Count is Column_Position range 1 .. Column_Position'Last; -- Type to count columns. We do not allow null windows, so must be positive type Key_Code is new Integer; -- That is anything including real characters, special keys and logical -- request codes. -- FIXME: The "-1" should be Curses_Err subtype Real_Key_Code is Key_Code range -1 .. M4_KEY_MAX; -- This are the codes that potentially represent a real keystroke. -- Not all codes may be possible on a specific terminal. To check the -- availability of a special key, the Has_Key function is provided. subtype Special_Key_Code is Real_Key_Code range M4_SPECIAL_FIRST .. Real_Key_Code'Last; -- Type for a function- or special key number subtype Normal_Key_Code is Real_Key_Code range Character'Pos (Character'First) .. Character'Pos (Character'Last); -- This are the codes for regular (incl. non-graphical) characters. -- Constants for function- and special keys -- Key_None : constant Special_Key_Code := M4_SPECIAL_FIRST;include(`Key_Definitions') Key_Max : constant Special_Key_Code := Special_Key_Code'Last; subtype User_Key_Code is Key_Code range (Key_Max + 129) .. Key_Code'Last; -- This is reserved for user defined key codes. The range between Key_Max -- and the first user code is reserved for subsystems like menu and forms. -- For those who like to use the original key names we produce them were -- they differ from the original. Please note that they may differ in -- lower/upper case.include(`Old_Keys')dnl------------------------------------------------------------------------------ type Color_Number is range -1 .. Integer (Interfaces.C.short'Last); for Color_Number'Size use Interfaces.C.short'Size; -- (n)curses uses a short for the color index -- The model is, that a Color_Number is an index into an array of -- (potentially) definable colors. Some of those indices are -- predefined (see below), although they may not really exist.include(`Color_Defs') type RGB_Value is range 0 .. Integer (Interfaces.C.short'Last); for RGB_Value'Size use Interfaces.C.short'Size; -- Some system may allow to redefine a color by setting RGB values. type Color_Pair is range 0 .. 255; for Color_Pair'Size use 8; subtype Redefinable_Color_Pair is Color_Pair range 1 .. 255; -- (n)curses reserves 1 Byte for the color-pair number. Color Pair 0 -- is fixed (Black & White). A color pair is simply a combination of -- two colors described by Color_Numbers, one for the foreground and -- the other for the backgroundinclude(`Character_Attribute_Set_Rep') -- (n)curses uses all but the lowest 16 Bits for Attributes. Normal_Video : constant Character_Attribute_Set := (others => False); type Attributed_Character is record Attr : Character_Attribute_Set; Color : Color_Pair; Ch : Character; end record; pragma Convention (C, Attributed_Character); -- This is the counterpart for the chtype in C.include(`AC_Rep') Default_Character : constant Attributed_Character := (Ch => Character'First, Color => Color_Pair'First, Attr => (others => False)); -- preelaboratable Normal_Video type Attributed_String is array (Positive range <>) of Attributed_Character; pragma Pack (Attributed_String); -- In this binding we allow strings of attributed characters. ------------------ -- Exceptions -- ------------------ Curses_Exception : exception; Wrong_Curses_Version : exception; -- Those exceptions are raised by the ETI (Extended Terminal Interface) -- subpackets for Menu and Forms handling. -- Eti_System_Error : exception; Eti_Bad_Argument : exception; Eti_Posted : exception; Eti_Connected : exception; Eti_Bad_State : exception; Eti_No_Room : exception; Eti_Not_Posted : exception; Eti_Unknown_Command : exception; Eti_No_Match : exception; Eti_Not_Selectable : exception; Eti_Not_Connected : exception; Eti_Request_Denied : exception; Eti_Invalid_Field : exception; Eti_Current : exception; -------------------------------------------------------------------------- -- External C variables -- Conceptually even in C this are kind of constants, but they are -- initialized and sometimes changed by the library routines at runtime -- depending on the type of terminal. I believe the best way to model -- this is to use functions. -------------------------------------------------------------------------- function Lines return Line_Count; pragma Inline (Lines); function Columns return Column_Count; pragma Inline (Columns); function Tab_Size return Natural; pragma Inline (Tab_Size); function Number_Of_Colors return Natural; pragma Inline (Number_Of_Colors); function Number_Of_Color_Pairs return Natural; pragma Inline (Number_Of_Color_Pairs); ACS_Map : array (Character'Val (0) .. Character'Val (127)) of Attributed_Character; pragma Import (C, ACS_Map, "acs_map"); -- -- -- Constants for several characters from the Alternate Character Set -- You must use this constants as indices into the ACS_Map array -- to get the corresponding attributed character at runtime. --include(`ACS_Map')dnl -- MANPAGE(`curs_initscr.3x') -- | Not implemented: newterm, set_term, delscreen, curscr -- ANCHOR(`stdscr',`Standard_Window') function Standard_Window return Window; -- AKA pragma Inline (Standard_Window); -- ANCHOR(`initscr()',`Init_Screen') procedure Init_Screen; -- ANCHOR(`initscr()',`Init_Windows') procedure Init_Windows renames Init_Screen; -- AKA pragma Inline (Init_Screen); pragma Inline (Init_Windows); -- ANCHOR(`endwin()',`End_Windows') procedure End_Windows; -- AKA procedure End_Screen renames End_Windows; pragma Inline (End_Windows); pragma Inline (End_Screen); -- ANCHOR(`isendwin()',`Is_End_Window') function Is_End_Window return Boolean; -- AKA pragma Inline (Is_End_Window); -- MANPAGE(`curs_move.3x') -- ANCHOR(`wmove()',`Move_Cursor') procedure Move_Cursor (Win : in Window := Standard_Window; Line : in Line_Position; Column : in Column_Position); -- AKA -- ALIAS(`move()') pragma Inline (Move_Cursor); -- MANPAGE(`curs_addch.3x') -- ANCHOR(`waddch()',`Add') procedure Add (Win : in Window := Standard_Window; Ch : in Attributed_Character); -- AKA -- ALIAS(`addch()') procedure Add (Win : in Window := Standard_Window; Ch : in Character); -- Add a single character at the current logical cursor position to -- the window. Use the current windows attributes. -- ANCHOR(`mvwaddch()',`Add') procedure Add (Win : in Window := Standard_Window; Line : in Line_Position; Column : in Column_Position; Ch : in Attributed_Character); -- AKA -- ALIAS(`mvaddch()') procedure Add (Win : in Window := Standard_Window; Line : in Line_Position; Column : in Column_Position; Ch : in Character); -- Move to the position and add a single character into the window -- There are more Add routines, so the Inline pragma follows later -- ANCHOR(`wechochar()',`Add_With_Immediate_Echo') procedure Add_With_Immediate_Echo (Win : in Window := Standard_Window; Ch : in Attributed_Character); -- AKA -- ALIAS(`echochar()') procedure Add_With_Immediate_Echo (Win : in Window := Standard_Window; Ch : in Character); -- Add a character and do an immediate refresh of the screen. pragma Inline (Add_With_Immediate_Echo); -- MANPAGE(`curs_window.3x') -- Not Implemented: wcursyncup -- ANCHOR(`newwin()',`Create') function Create (Number_Of_Lines : Line_Count; Number_Of_Columns : Column_Count; First_Line_Position : Line_Position; First_Column_Position : Column_Position) return Window; -- Not Implemented: Default Number_Of_Lines, Number_Of_Columns -- the C version lets them be 0, see the man page. -- AKA pragma Inline (Create); function New_Window (Number_Of_Lines : Line_Count; Number_Of_Columns : Column_Count; First_Line_Position : Line_Position; First_Column_Position : Column_Position) return Window renames Create; pragma Inline (New_Window); -- ANCHOR(`delwin()',`Delete') procedure Delete (Win : in out Window); -- AKA -- Reset Win to Null_Window pragma Inline (Delete); -- ANCHOR(`subwin()',`Sub_Window') function Sub_Window (Win : Window := Standard_Window; Number_Of_Lines : Line_Count; Number_Of_Columns : Column_Count; First_Line_Position : Line_Position; First_Column_Position : Column_Position) return Window; -- AKA pragma Inline (Sub_Window); -- ANCHOR(`derwin()',`Derived_Window') function Derived_Window (Win : Window := Standard_Window; Number_Of_Lines : Line_Count; Number_Of_Columns : Column_Count; First_Line_Position : Line_Position; First_Column_Position : Column_Position) return Window; -- AKA pragma Inline (Derived_Window); -- ANCHOR(`dupwin()',`Duplicate') function Duplicate (Win : Window) return Window; -- AKA pragma Inline (Duplicate); -- ANCHOR(`mvwin()',`Move_Window') procedure Move_Window (Win : in Window; Line : in Line_Position; Column : in Column_Position); -- AKA pragma Inline (Move_Window); -- ANCHOR(`mvderwin()',`Move_Derived_Window') procedure Move_Derived_Window (Win : in Window; Line : in Line_Position; Column : in Column_Position); -- AKA pragma Inline (Move_Derived_Window); -- ANCHOR(`wsyncup()',`Synchronize_Upwards') procedure Synchronize_Upwards (Win : in Window); -- AKA pragma Import (C, Synchronize_Upwards, "wsyncup"); -- ANCHOR(`wsyncdown()',`Synchronize_Downwards') procedure Synchronize_Downwards (Win : in Window); -- AKA pragma Import (C, Synchronize_Downwards, "wsyncdown"); -- ANCHOR(`syncok()',`Set_Synch_Mode') procedure Set_Synch_Mode (Win : in Window := Standard_Window; Mode : in Boolean := False); -- AKA pragma Inline (Set_Synch_Mode); -- MANPAGE(`curs_addstr.3x') -- ANCHOR(`waddnstr()',`Add') procedure Add (Win : in Window := Standard_Window; Str : in String; Len : in Integer := -1); -- AKA -- ALIAS(`waddstr()') -- ALIAS(`addnstr()') -- ALIAS(`addstr()') -- ANCHOR(`mvwaddnstr()',`Add') procedure Add (Win : in Window := Standard_Window; Line : in Line_Position; Column : in Column_Position; Str : in String; Len : in Integer := -1); -- AKA -- ALIAS(`mvwaddstr()') -- ALIAS(`mvaddnstr()') -- ALIAS(`mvaddstr()') -- MANPAGE(`curs_addchstr.3x')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -