2 define(`HTMLNAME',`terminal_interface-curses__ads.htm')dnl
3 include(M4MACRO)------------------------------------------------------------------------------
5 -- GNAT ncurses Binding --
7 -- Terminal_Interface.Curses --
11 ------------------------------------------------------------------------------
12 -- Copyright (c) 1998 Free Software Foundation, Inc. --
14 -- Permission is hereby granted, free of charge, to any person obtaining a --
15 -- copy of this software and associated documentation files (the --
16 -- "Software"), to deal in the Software without restriction, including --
17 -- without limitation the rights to use, copy, modify, merge, publish, --
18 -- distribute, distribute with modifications, sublicense, and/or sell --
19 -- copies of the Software, and to permit persons to whom the Software is --
20 -- furnished to do so, subject to the following conditions: --
22 -- The above copyright notice and this permission notice shall be included --
23 -- in all copies or substantial portions of the Software. --
25 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
26 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
27 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
28 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
29 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
30 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
31 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
33 -- Except as contained in this notice, the name(s) of the above copyright --
34 -- holders shall not be used in advertising or otherwise to promote the --
35 -- sale, use or other dealings in this Software without prior written --
37 ------------------------------------------------------------------------------
38 -- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
41 -- Binding Version 01.00
42 ------------------------------------------------------------------------------
44 with System.Storage_Elements;
45 with Interfaces.C; -- We need this for some assertions.
47 package Terminal_Interface.Curses is
48 pragma Preelaborate (Terminal_Interface.Curses);
49 include(`Linker_Options')
50 include(`Version_Info')
51 type Window is private;
52 Null_Window : constant Window;
54 type Line_Position is new Natural; -- line coordinate
55 type Column_Position is new Natural; -- column coordinate
57 subtype Line_Count is Line_Position range 1 .. Line_Position'Last;
58 -- Type to count lines. We do not allow null windows, so must be positive
59 subtype Column_Count is Column_Position range 1 .. Column_Position'Last;
60 -- Type to count columns. We do not allow null windows, so must be positive
62 type Key_Code is new Natural;
63 -- That is anything including real characters, special keys and logical
66 subtype Real_Key_Code is Key_Code range 0 .. M4_KEY_MAX;
67 -- This are the codes that potentially represent a real keystroke.
68 -- Not all codes may be possible on a specific terminal. To check the
69 -- availability of a special key, the Has_Key function is provided.
71 subtype Special_Key_Code is Real_Key_Code
72 range M4_SPECIAL_FIRST .. Real_Key_Code'Last;
73 -- Type for a function- or special key number
75 subtype Normal_Key_Code is Real_Key_Code range
76 Character'Pos (Character'First) .. Character'Pos (Character'Last);
77 -- This are the codes for regular (incl. non-graphical) characters.
79 -- Constants for function- and special keys
81 Key_None : constant Special_Key_Code := M4_SPECIAL_FIRST;
82 include(`Key_Definitions')
83 Key_Max : constant Special_Key_Code
84 := Special_Key_Code'Last;
86 subtype User_Key_Code is Key_Code
87 range (Key_Max + 129) .. Key_Code'Last;
88 -- This is reserved for user defined key codes. The range between Key_Max
89 -- and the first user code is reserved for subsystems like menu and forms.
91 -- For those who like to use the original key names we produce them were
92 -- they differ from the original. Please note that they may differ in
94 include(`Old_Keys')dnl
96 ------------------------------------------------------------------------------
98 type Color_Number is range 0 .. Integer (Interfaces.C.short'Last);
99 for Color_Number'Size use Interfaces.C.short'Size;
100 -- (n)curses uses a short for the color index
101 -- The model is, that a Color_Number is an index into an array of
102 -- (potentially) definable colors. Some of those indices are
103 -- predefined (see below), although they may not really exist.
105 include(`Color_Defs')
106 type RGB_Value is range 0 .. Integer (Interfaces.C.short'Last);
107 for RGB_Value'Size use Interfaces.C.short'Size;
108 -- Some system may allow to redefine a color by setting RGB values.
110 type Color_Pair is range 0 .. 255;
111 for Color_Pair'Size use 8;
112 subtype Redefinable_Color_Pair is Color_Pair range 1 .. 255;
113 -- (n)curses reserves 1 Byte for the color-pair number. Color Pair 0
114 -- is fixed (Black & White). A color pair is simply a combination of
115 -- two colors described by Color_Numbers, one for the foreground and
116 -- the other for the background
118 include(`Character_Attribute_Set_Rep')
119 -- (n)curses uses all but the lowes 16 Bits for Attributes.
121 Normal_Video : constant Character_Attribute_Set := (others => False);
123 type Attributed_Character is
125 Attr : Character_Attribute_Set;
129 pragma Convention (C, Attributed_Character);
130 -- This is the counterpart for the chtype in C.
133 Default_Character : constant Attributed_Character
134 := (Ch => Character'First,
135 Color => Color_Pair'First,
136 Attr => (others => False)); -- preelaboratable Normal_Video
138 type Attributed_String is array (Positive range <>) of Attributed_Character;
139 pragma Pack (Attributed_String);
140 -- In this binding we allow strings of attributed characters.
145 Curses_Exception : exception;
146 Wrong_Curses_Version : exception;
148 -- Those exceptions are raised by the ETI (Extended Terminal Interface)
149 -- subpackets for Menu and Forms handling.
151 Eti_System_Error : exception;
152 Eti_Bad_Argument : exception;
153 Eti_Posted : exception;
154 Eti_Connected : exception;
155 Eti_Bad_State : exception;
156 Eti_No_Room : exception;
157 Eti_Not_Posted : exception;
158 Eti_Unknown_Command : exception;
159 Eti_No_Match : exception;
160 Eti_Not_Selectable : exception;
161 Eti_Not_Connected : exception;
162 Eti_Request_Denied : exception;
163 Eti_Invalid_Field : exception;
164 Eti_Current : exception;
166 --------------------------------------------------------------------------
167 -- External C variables
168 -- Conceptually even in C this are kind of constants, but they are
169 -- initialized and sometimes changed by the library routines at runtime
170 -- depending on the type of terminal. I believe the best way to model
171 -- this is to use functions.
172 --------------------------------------------------------------------------
174 function Lines return Line_Count;
175 pragma Inline (Lines);
177 function Columns return Column_Count;
178 pragma Inline (Columns);
180 function Tab_Size return Natural;
181 pragma Inline (Tab_Size);
183 function Number_Of_Colors return Natural;
184 pragma Inline (Number_Of_Colors);
186 function Number_Of_Color_Pairs return Natural;
187 pragma Inline (Number_Of_Color_Pairs);
189 ACS_Map : array (Character'Val (0) .. Character'Val (127)) of
190 Attributed_Character;
191 pragma Import (C, ACS_Map, "acs_map");
194 -- Constants for several symbols from the Alternate Character Set
195 -- You must use this constants as indices into the ACS_Map array
196 -- to get the corresponding attributed character at runtime.
198 include(`ACS_Map')dnl
200 -- MANPAGE(`curs_initscr.3x')
201 -- | Not implemented: newterm, set_term, delscreen
203 -- ANCHOR(`stdscr',`Standard_Window')
204 function Standard_Window return Window;
206 pragma Inline (Standard_Window);
208 -- ANCHOR(`initscr()',`Init_Screen')
209 procedure Init_Screen;
211 -- ANCHOR(`initscr()',`Init_Windows')
212 procedure Init_Windows renames Init_Screen;
214 pragma Inline (Init_Screen);
215 pragma Inline (Init_Windows);
217 -- ANCHOR(`endwin()',`End_Windows')
218 procedure End_Windows;
220 procedure End_Screen renames End_Windows;
221 pragma Inline (End_Windows);
222 pragma Inline (End_Screen);
224 -- ANCHOR(`isendwin()',`Is_End_Window')
225 function Is_End_Window return Boolean;
227 pragma Inline (Is_End_Window);
229 -- MANPAGE(`curs_move.3x')
231 -- ANCHOR(`wmove()',`Move_Cursor')
232 procedure Move_Cursor (Win : in Window := Standard_Window;
233 Line : in Line_Position;
234 Column : in Column_Position);
236 pragma Inline (Move_Cursor);
238 -- MANPAGE(`curs_addch.3x')
240 -- ANCHOR(`waddch()',`Add')
241 procedure Add (Win : in Window := Standard_Window;
242 Ch : in Attributed_Character);
245 procedure Add (Win : in Window := Standard_Window;
247 -- Add a single character at the current logical cursor position to
248 -- the window. Use the current windows attributes.
250 -- ANCHOR(`mvwaddch()',`Add')
252 (Win : in Window := Standard_Window;
253 Line : in Line_Position;
254 Column : in Column_Position;
255 Ch : in Attributed_Character);
259 (Win : in Window := Standard_Window;
260 Line : in Line_Position;
261 Column : in Column_Position;
263 -- Move to the position and add a single character into the window
264 -- There are more Add routines, so the Inline pragma follows later
266 -- ANCHOR(`wechochar()',`Add_With_Immediate_Echo')
267 procedure Add_With_Immediate_Echo
268 (Win : in Window := Standard_Window;
269 Ch : in Attributed_Character);
272 procedure Add_With_Immediate_Echo
273 (Win : in Window := Standard_Window;
275 -- Add a character and do an immediate resfresh of the screen.
276 pragma Inline (Add_With_Immediate_Echo);
278 -- MANPAGE(`curs_window.3x')
280 -- ANCHOR(`newwin()',`Create')
282 (Number_Of_Lines : Line_Count;
283 Number_Of_Columns : Column_Count;
284 First_Line_Position : Line_Position;
285 First_Column_Position : Column_Position) return Window;
287 pragma Inline (Create);
290 (Number_Of_Lines : Line_Count;
291 Number_Of_Columns : Column_Count;
292 First_Line_Position : Line_Position;
293 First_Column_Position : Column_Position) return Window
295 pragma Inline (New_Window);
297 -- ANCHOR(`delwin()',`Delete')
298 procedure Delete (Win : in out Window);
300 -- Reset Win to Null_Window
301 pragma Inline (Delete);
303 -- ANCHOR(`subwin()',`Sub_Window')
305 (Win : Window := Standard_Window;
306 Number_Of_Lines : Line_Count;
307 Number_Of_Columns : Column_Count;
308 First_Line_Position : Line_Position;
309 First_Column_Position : Column_Position) return Window;
311 pragma Inline (Sub_Window);
313 -- ANCHOR(`derwin()',`Derived_Window')
314 function Derived_Window
315 (Win : Window := Standard_Window;
316 Number_Of_Lines : Line_Count;
317 Number_Of_Columns : Column_Count;
318 First_Line_Position : Line_Position;
319 First_Column_Position : Column_Position) return Window;
321 pragma Inline (Derived_Window);
323 -- ANCHOR(`dupwin()',`Duplicate')
324 function Duplicate (Win : Window) return Window;
326 pragma Inline (Duplicate);
328 -- ANCHOR(`mvwin()',`Move_Window')
329 procedure Move_Window (Win : in Window;
330 Line : in Line_Position;
331 Column : in Column_Position);
333 pragma Inline (Move_Window);
335 -- ANCHOR(`mvderwin()',`Move_Derived_Window')
336 procedure Move_Derived_Window (Win : in Window;
337 Line : in Line_Position;
338 Column : in Column_Position);
340 pragma Inline (Move_Derived_Window);
342 -- ANCHOR(`wsyncup()',`Synchronize_Upwards')
343 procedure Synchronize_Upwards (Win : in Window);
345 pragma Import (C, Synchronize_Upwards, "wsyncup");
347 -- ANCHOR(`wsyncdown()',`Synchronize_Downwards')
348 procedure Synchronize_Downwards (Win : in Window);
350 pragma Import (C, Synchronize_Downwards, "wsyncdown");
352 -- ANCHOR(`syncok()',`Set_Synch_Mode')
353 procedure Set_Synch_Mode (Win : in Window := Standard_Window;
354 Mode : in Boolean := False);
356 pragma Inline (Set_Synch_Mode);
358 -- MANPAGE(`curs_addstr.3x')
360 -- ANCHOR(`waddnstr()',`Add')
361 procedure Add (Win : in Window := Standard_Window;
363 Len : in Integer := -1);
365 -- ALIAS(`waddstr()')
367 -- ANCHOR(`mvwaddnstr()',`Add')
368 procedure Add (Win : in Window := Standard_Window;
369 Line : in Line_Position;
370 Column : in Column_Position;
372 Len : in Integer := -1);
374 -- ALIAS(`mvwaddstr()')
376 -- MANPAGE(`curs_addchstr.3x')
378 -- ANCHOR(`waddchnstr()',`Add')
379 procedure Add (Win : in Window := Standard_Window;
380 Str : in Attributed_String;
381 Len : in Integer := -1);
383 -- ALIAS(`waddchstr()')
385 -- ANCHOR(`mvwaddchnstr()',`Add')
386 procedure Add (Win : in Window := Standard_Window;
387 Line : in Line_Position;
388 Column : in Column_Position;
389 Str : in Attributed_String;
390 Len : in Integer := -1);
392 -- ALIAS(`mvwaddchstr()')
395 -- MANPAGE(`curs_border.3x')
397 -- ANCHOR(`wborder()',`Border')
399 (Win : in Window := Standard_Window;
400 Left_Side_Symbol : in Attributed_Character := Default_Character;
401 Right_Side_Symbol : in Attributed_Character := Default_Character;
402 Top_Side_Symbol : in Attributed_Character := Default_Character;
403 Bottom_Side_Symbol : in Attributed_Character := Default_Character;
404 Upper_Left_Corner_Symbol : in Attributed_Character := Default_Character;
405 Upper_Right_Corner_Symbol : in Attributed_Character := Default_Character;
406 Lower_Left_Corner_Symbol : in Attributed_Character := Default_Character;
407 Lower_Right_Corner_Symbol : in Attributed_Character := Default_Character
410 pragma Inline (Border);
412 -- ANCHOR(`box()',`Box')
414 (Win : in Window := Standard_Window;
415 Vertical_Symbol : in Attributed_Character := Default_Character;
416 Horizontal_Symbol : in Attributed_Character := Default_Character);
420 -- ANCHOR(`whline()',`Horizontal_Line')
421 procedure Horizontal_Line
422 (Win : in Window := Standard_Window;
423 Line_Size : in Natural;
424 Line_Symbol : in Attributed_Character := Default_Character);
426 pragma Inline (Horizontal_Line);
428 -- ANCHOR(`wvline()',`Vertical_Line')
429 procedure Vertical_Line
430 (Win : in Window := Standard_Window;
431 Line_Size : in Natural;
432 Line_Symbol : in Attributed_Character := Default_Character);
434 pragma Inline (Vertical_Line);
436 -- MANPAGE(`curs_getch.3x')
438 -- ANCHOR(`wgetch()',`Get_Keystroke')
439 function Get_Keystroke (Win : Window := Standard_Window)
440 return Real_Key_Code;
442 -- Get a character from the keyboard and echo it - if enabled - to the
444 -- If for any reason (i.e. a timeout) we couldn't get a character the
445 -- returned keycode is Key_None.
446 pragma Inline (Get_Keystroke);
448 -- ANCHOR(`ungetch()',`Undo_Keystroke')
449 procedure Undo_Keystroke (Key : in Real_Key_Code);
451 pragma Inline (Undo_Keystroke);
453 -- ANCHOR(`has_key()',`Has_Key')
454 function Has_Key (Key : Special_Key_Code) return Boolean;
456 pragma Inline (Has_Key);
459 -- | Some helper functions
461 function Is_Function_Key (Key : Special_Key_Code) return Boolean;
462 -- Return True if the Key is a function key (i.e. one of F0 .. F63)
463 pragma Inline (Is_Function_Key);
465 subtype Function_Key_Number is Integer range 0 .. 63;
466 -- (n)curses allows for 64 function keys.
468 function Function_Key (Key : Real_Key_Code) return Function_Key_Number;
469 -- Return the number of the function key. If the code is not a
470 -- function key, a CONSTRAINT_ERROR will be raised.
471 pragma Inline (Function_Key);
473 function Function_Key_Code (Key : Function_Key_Number) return Real_Key_Code;
474 -- Return the key code for a given functionkey number.
475 pragma Inline (Function_Key_Code);
477 -- MANPAGE(`curs_attr.3x')
479 -- ANCHOR(`wattron()',`Switch_Character_Attribute')
480 procedure Switch_Character_Attribute
481 (Win : in Window := Standard_Window;
482 Attr : in Character_Attribute_Set := Normal_Video;
483 On : in Boolean := True); -- if False we switch Off.
485 -- ALIAS(`wattroff()')
487 -- ANCHOR(`wattrset()',`Set_Character_Attributes')
488 procedure Set_Character_Attributes
489 (Win : in Window := Standard_Window;
490 Attr : in Character_Attribute_Set := Normal_Video;
491 Color : in Color_Pair := Color_Pair'First);
493 pragma Inline (Set_Character_Attributes);
495 -- ANCHOR(`wattr_get()',`Get_Character_Attributes')
496 function Get_Character_Attribute
497 (Win : in Window := Standard_Window) return Character_Attribute_Set;
500 -- ANCHOR(`wattr_get()',`Get_Character_Attribute')
501 function Get_Character_Attribute
502 (Win : in Window := Standard_Window) return Color_Pair;
504 pragma Inline (Get_Character_Attribute);
506 -- ANCHOR(`wcolor_set()',`Set_Color')
507 procedure Set_Color (Win : in Window := Standard_Window;
508 Pair : in Color_Pair);
510 pragma Inline (Set_Color);
512 -- ANCHOR(`wchgat()',`Change_Attributes')
513 procedure Change_Attributes
514 (Win : in Window := Standard_Window;
515 Count : in Integer := -1;
516 Attr : in Character_Attribute_Set := Normal_Video;
517 Color : in Color_Pair := Color_Pair'First);
520 -- ANCHOR(`mvwchgat()',`Change_Attributes')
521 procedure Change_Attributes
522 (Win : in Window := Standard_Window;
523 Line : in Line_Position := Line_Position'First;
524 Column : in Column_Position := Column_Position'First;
525 Count : in Integer := -1;
526 Attr : in Character_Attribute_Set := Normal_Video;
527 Color : in Color_Pair := Color_Pair'First);
529 pragma Inline (Change_Attributes);
531 -- MANPAGE(`curs_beep.3x')
533 -- ANCHOR(`beep()',`Beep')
536 pragma Inline (Beep);
538 -- ANCHOR(`flash()',`Flash_Screen')
539 procedure Flash_Screen;
541 pragma Inline (Flash_Screen);
543 -- MANPAGE(`curs_inopts.3x')
545 -- | Not implemented : typeahead
547 -- ANCHOR(`cbreak()',`Set_Cbreak_Mode')
548 procedure Set_Cbreak_Mode (SwitchOn : in Boolean := True);
550 -- ALIAS(`nocbreak()')
551 pragma Inline (Set_Cbreak_Mode);
553 -- ANCHOR(`raw()',`Set_Raw_Mode')
554 procedure Set_Raw_Mode (SwitchOn : in Boolean := True);
557 pragma Inline (Set_Raw_Mode);
559 -- ANCHOR(`echo()',`Set_Echo_Mode')
560 procedure Set_Echo_Mode (SwitchOn : in Boolean := True);
563 pragma Inline (Set_Echo_Mode);
565 -- ANCHOR(`meta()',`Set_Meta_Mode')
566 procedure Set_Meta_Mode (Win : in Window := Standard_Window;
567 SwitchOn : in Boolean := True);
569 pragma Inline (Set_Meta_Mode);
571 -- ANCHOR(`keypad()',`Set_KeyPad_Mode')
572 procedure Set_KeyPad_Mode (Win : in Window := Standard_Window;
573 SwitchOn : in Boolean := True);
575 pragma Inline (Set_KeyPad_Mode);
577 type Half_Delay_Amount is range 1 .. 255;
579 -- ANCHOR(`halfdelay()',`Half_Delay')
580 procedure Half_Delay (Amount : in Half_Delay_Amount);
582 pragma Inline (Half_Delay);
584 -- ANCHOR(`intrflush()',`Set_Flush_On_Interrupt_Mode')
585 procedure Set_Flush_On_Interrupt_Mode
586 (Win : in Window := Standard_Window;
587 Mode : in Boolean := True);
589 pragma Inline (Set_Flush_On_Interrupt_Mode);
591 -- ANCHOR(`qiflush()',`Set_Queue_Interrupt_Mode')
592 procedure Set_Queue_Interrupt_Mode
593 (Win : in Window := Standard_Window;
594 Flush : in Boolean := True);
596 -- ALIAS(`noqiflush()')
597 pragma Inline (Set_Queue_Interrupt_Mode);
599 -- ANCHOR(`nodelay()',`Set_NoDelay_Mode')
600 procedure Set_NoDelay_Mode
601 (Win : in Window := Standard_Window;
602 Mode : in Boolean := False);
604 pragma Inline (Set_NoDelay_Mode);
606 type Timeout_Mode is (Blocking, Non_Blocking, Delayed);
608 -- ANCHOR(`wtimeout()',`Set_Timeout_Mode')
609 procedure Set_Timeout_Mode (Win : in Window := Standard_Window;
610 Mode : in Timeout_Mode;
611 Amount : in Natural); -- in Miliseconds
613 -- Instead of overloading the semantic of the sign of amount, we
614 -- introduce the Timeout_Mode parameter. This should improve
615 -- readability. For Blocking and Non_Blocking, the Amount is not
617 -- We don't inline this procedure.
619 -- ANCHOR(`notimeout()',`Set_Escape_Time_Mode')
620 procedure Set_Escape_Timer_Mode
621 (Win : in Window := Standard_Window;
622 Timer_Off : in Boolean := False);
624 pragma Inline (Set_Escape_Timer_Mode);
626 -- MANPAGE(`curs_outopts.3x')
628 -- ANCHOR(`nl()',`Set_NL_Mode')
629 procedure Set_NL_Mode (SwitchOn : in Boolean := True);
632 pragma Inline (Set_NL_Mode);
634 -- ANCHOR(`clearok()',`Clear_On_Next_Update')
635 procedure Clear_On_Next_Update
636 (Win : in Window := Standard_Window;
637 Do_Clear : in Boolean := True);
639 pragma Inline (Clear_On_Next_Update);
641 -- ANCHOR(`idlok()',`Use_Insert_Delete_Line')
642 procedure Use_Insert_Delete_Line
643 (Win : in Window := Standard_Window;
644 Do_Idl : in Boolean := True);
646 pragma Inline (Use_Insert_Delete_Line);
648 -- ANCHOR(`idcok()',`Use_Insert_Delete_Character')
649 procedure Use_Insert_Delete_Character
650 (Win : in Window := Standard_Window;
651 Do_Idc : in Boolean := True);
653 pragma Inline (Use_Insert_Delete_Character);
655 -- ANCHOR(`leaveok()',`Leave_Cursor_After_Update')
656 procedure Leave_Cursor_After_Update
657 (Win : in Window := Standard_Window;
658 Do_Leave : in Boolean := True);
660 pragma Inline (Leave_Cursor_After_Update);
662 -- ANCHOR(`immedok()',`Immediate_Update_Mode')
663 procedure Immediate_Update_Mode
664 (Win : in Window := Standard_Window;
665 Mode : in Boolean := False);
667 pragma Inline (Immediate_Update_Mode);
669 -- ANCHOR(`scrollok()',`Allow_Scrolling')
670 procedure Allow_Scrolling
671 (Win : in Window := Standard_Window;
672 Mode : in Boolean := False);
674 pragma Inline (Allow_Scrolling);
676 function Scrolling_Allowed (Win : Window := Standard_Window) return Boolean;
677 -- There is no such function in the C interface.
678 pragma Inline (Scrolling_Allowed);
680 -- ANCHOR(`wsetscrreg()',`Set_Scroll_Region')
681 procedure Set_Scroll_Region
682 (Win : in Window := Standard_Window;
683 Top_Line : in Line_Position;
684 Bottom_Line : in Line_Position);
686 pragma Inline (Set_Scroll_Region);
688 -- MANPAGE(`curs_refresh.3x')
690 -- ANCHOR(`doupdate()',`Update_Screen')
691 procedure Update_Screen;
693 pragma Inline (Update_Screen);
695 -- ANCHOR(`wrefresh()',`Refresh')
696 procedure Refresh (Win : in Window := Standard_Window);
698 -- There is an overloaded Refresh for Pads.
699 -- The Inline pragma appears there
701 -- ANCHOR(`wnoutrefresh()',`Refresh_Without_Update')
702 procedure Refresh_Without_Update
703 (Win : in Window := Standard_Window);
705 -- There is an overloaded Refresh_Without_Update for Pads.
706 -- The Inline pragma appears there
708 -- ANCHOR(`redrawwin()',`Redraw')
709 procedure Redraw (Win : in Window := Standard_Window);
712 -- ANCHOR(`wredrawln()',`Redraw')
713 procedure Redraw (Win : in Window := Standard_Window;
714 Begin_Line : in Line_Position;
715 Line_Count : in Positive);
717 pragma Inline (Redraw);
719 -- MANPAGE(`curs_clear.3x')
721 -- ANCHOR(`werase()',`Erase')
722 procedure Erase (Win : in Window := Standard_Window);
724 pragma Inline (Erase);
726 -- ANCHOR(`wclear()',`Clear')
728 (Win : in Window := Standard_Window);
730 pragma Inline (Clear);
732 -- ANCHOR(`wclrtobot()',`Clear_To_End_Of_Screen')
733 procedure Clear_To_End_Of_Screen
734 (Win : in Window := Standard_Window);
736 pragma Inline (Clear_To_End_Of_Screen);
738 -- ANCHOR(`wclrtoeol()',`Clear_To_End_Of_Line')
739 procedure Clear_To_End_Of_Line
740 (Win : in Window := Standard_Window);
742 pragma Inline (Clear_To_End_Of_Line);
744 -- MANPAGE(`curs_bkgd.3x')
746 -- ANCHOR(`wbkgdset()',`Set_Background')
747 procedure Set_Background
748 (Win : in Window := Standard_Window;
749 Ch : in Attributed_Character);
751 pragma Inline (Set_Background);
753 -- ANCHOR(`wbkgd()',`Change_Background')
754 procedure Change_Background
755 (Win : in Window := Standard_Window;
756 Ch : in Attributed_Character);
758 pragma Inline (Change_Background);
760 -- ANCHOR(`wbkgdget()',`Get_Background')
761 function Get_Background (Win : Window := Standard_Window)
762 return Attributed_Character;
764 pragma Inline (Get_Background);
766 -- MANPAGE(`curs_touch.3x')
768 -- ANCHOR(`untouchwin()',`Untouch')
769 procedure Untouch (Win : in Window := Standard_Window);
771 pragma Inline (Untouch);
773 -- ANCHOR(`touchwin()',`Touch')
774 procedure Touch (Win : in Window := Standard_Window);
777 -- ANCHOR(`touchline()',`Touch')
778 procedure Touch (Win : in Window := Standard_Window;
779 Start : in Line_Position;
780 Count : in Positive);
782 pragma Inline (Touch);
784 -- ANCHOR(`wtouchln()',`Change_Line_Status')
785 procedure Change_Lines_Status (Win : in Window := Standard_Window;
786 Start : in Line_Position;
790 pragma Inline (Change_Lines_Status);
792 -- ANCHOR(`is_linetouched()',`Is_Touched')
793 function Is_Touched (Win : Window := Standard_Window;
794 Line : Line_Position) return Boolean;
797 -- ANCHOR(`is_wintouched()',`Is_Touched')
798 function Is_Touched (Win : Window := Standard_Window) return Boolean;
800 pragma Inline (Is_Touched);
802 -- MANPAGE(`curs_overlay.3x')
804 -- ANCHOR(`copywin()',`Copy')
806 (Source_Window : in Window;
807 Destination_Window : in Window;
808 Source_Top_Row : in Line_Position;
809 Source_Left_Column : in Column_Position;
810 Destination_Top_Row : in Line_Position;
811 Destination_Left_Column : in Column_Position;
812 Destination_Bottom_Row : in Line_Position;
813 Destination_Right_Column : in Column_Position;
814 Non_Destructive_Mode : in Boolean := True);
816 pragma Inline (Copy);
818 -- ANCHOR(`overwrite()',`Overwrite')
819 procedure Overwrite (Source_Window : in Window;
820 Destination_Window : in Window);
822 pragma Inline (Overwrite);
824 -- ANCHOR(`overlay()',`Overlay')
825 procedure Overlay (Source_Window : in Window;
826 Destination_Window : in Window);
828 pragma Inline (Overlay);
830 -- MANPAGE(`curs_deleteln.3x')
832 -- ANCHOR(`winsdelln()',`Insert_Delete_Lines')
833 procedure Insert_Delete_Lines
834 (Win : in Window := Standard_Window;
835 Lines : in Integer := 1); -- default is to insert one line above
837 pragma Inline (Insert_Delete_Lines);
839 -- ANCHOR(`wdeleteln()',`Delete_Line')
840 procedure Delete_Line (Win : in Window := Standard_Window);
842 pragma Inline (Delete_Line);
844 -- ANCHOR(`winsertln()',`Insert_Line')
845 procedure Insert_Line (Win : in Window := Standard_Window);
847 pragma Inline (Insert_Line);
849 -- MANPAGE(`curs_getyx.3x')
851 -- ANCHOR(`getmaxyx()',`Get_Size')
853 (Win : in Window := Standard_Window;
854 Number_Of_Lines : out Line_Count;
855 Number_Of_Columns : out Column_Count);
857 pragma Inline (Get_Size);
859 -- ANCHOR(`getbegyx()',`Get_Window_Position')
860 procedure Get_Window_Position
861 (Win : in Window := Standard_Window;
862 Top_Left_Line : out Line_Position;
863 Top_Left_Column : out Column_Position);
865 pragma Inline (Get_Window_Position);
867 -- ANCHOR(`getyx()',`Get_Cursor_Position')
868 procedure Get_Cursor_Position
869 (Win : in Window := Standard_Window;
870 Line : out Line_Position;
871 Column : out Column_Position);
873 pragma Inline (Get_Cursor_Position);
875 -- ANCHOR(`getparyx()',`Get_Origin_Relative_To_Parent')
876 procedure Get_Origin_Relative_To_Parent
878 Top_Left_Line : out Line_Position;
879 Top_Left_Column : out Column_Position;
880 Is_Not_A_Subwindow : out Boolean);
882 -- Instead of placing -1 in the coordinates as return, we use a boolean
883 -- to return the info that the window has no parent.
884 pragma Inline (Get_Origin_Relative_To_Parent);
886 -- MANPAGE(`curs_pad.3x')
888 -- ANCHOR(`newpad()',`New_Pad')
889 function New_Pad (Lines : Line_Count;
890 Columns : Column_Count) return Window;
892 pragma Inline (New_Pad);
894 -- ANCHOR(`subpad()',`Sub_Pad')
897 Number_Of_Lines : Line_Count;
898 Number_Of_Columns : Column_Count;
899 First_Line_Position : Line_Position;
900 First_Column_Position : Column_Position) return Window;
902 pragma Inline (Sub_Pad);
904 -- ANCHOR(`prefresh()',`Refresh')
907 Source_Top_Row : in Line_Position;
908 Source_Left_Column : in Column_Position;
909 Destination_Top_Row : in Line_Position;
910 Destination_Left_Column : in Column_Position;
911 Destination_Bottom_Row : in Line_Position;
912 Destination_Right_Column : in Column_Position);
914 pragma Inline (Refresh);
916 -- ANCHOR(`pnoutrefresh()',`Refresh_Without_Update')
917 procedure Refresh_Without_Update
919 Source_Top_Row : in Line_Position;
920 Source_Left_Column : in Column_Position;
921 Destination_Top_Row : in Line_Position;
922 Destination_Left_Column : in Column_Position;
923 Destination_Bottom_Row : in Line_Position;
924 Destination_Right_Column : in Column_Position);
926 pragma Inline (Refresh_Without_Update);
928 -- ANCHOR(`pechochar()',`Add_Character_To_Pad_And_Echo_It')
929 procedure Add_Character_To_Pad_And_Echo_It
931 Ch : in Attributed_Character);
934 procedure Add_Character_To_Pad_And_Echo_It
937 pragma Inline (Add_Character_To_Pad_And_Echo_It);
939 -- MANPAGE(`curs_scroll.3x')
941 -- ANCHOR(`wscrl()',`Scroll')
942 procedure Scroll (Win : in Window := Standard_Window;
943 Amount : in Integer := 1);
945 pragma Inline (Scroll);
947 -- MANPAGE(`curs_delch.3x')
949 -- ANCHOR(`wdelch()',`Delete_Character')
950 procedure Delete_Character (Win : in Window := Standard_Window);
953 -- ANCHOR(`mvwdelch()',`Delete_Character')
954 procedure Delete_Character
955 (Win : in Window := Standard_Window;
956 Line : in Line_Position;
957 Column : in Column_Position);
959 pragma Inline (Delete_Character);
961 -- MANPAGE(`curs_inch.3x')
963 -- ANCHOR(`winch()',`Peek')
964 function Peek (Win : Window := Standard_Window)
965 return Attributed_Character;
968 -- ANCHOR(`mvwinch()',`Peek')
970 (Win : Window := Standard_Window;
971 Line : Line_Position;
972 Column : Column_Position) return Attributed_Character;
974 -- More Peek's follow, pragma Inline appears later.
976 -- MANPAGE(`curs_winch.3x')
978 -- ANCHOR(`winsch()',`Insert')
979 procedure Insert (Win : in Window := Standard_Window;
980 Ch : in Attributed_Character);
983 -- ANCHOR(`mvwinsch()',`Insert')
984 procedure Insert (Win : in Window := Standard_Window;
985 Line : in Line_Position;
986 Column : in Column_Position;
987 Ch : in Attributed_Character);
990 -- MANPAGE(`curs_winch.3x')
992 -- ANCHOR(`winsnstr()',`Insert')
993 procedure Insert (Win : in Window := Standard_Window;
995 Len : in Integer := -1);
997 -- ALIAS(`winsstr()')
999 -- ANCHOR(`mvwinsnstr()',`Insert')
1000 procedure Insert (Win : in Window := Standard_Window;
1001 Line : in Line_Position;
1002 Column : in Column_Position;
1004 Len : in Integer := -1);
1006 -- ALIAS(`mvwinsstr()')
1007 pragma Inline (Insert);
1009 -- MANPAGE(`curs_instr.3x')
1011 -- ANCHOR(`winnstr()',`Peek')
1012 procedure Peek (Win : in Window := Standard_Window;
1014 Len : in Integer := -1);
1016 -- ALIAS(`winstr()')
1018 -- ANCHOR(`mvwinnstr()',`Peek')
1019 procedure Peek (Win : in Window := Standard_Window;
1020 Line : in Line_Position;
1021 Column : in Column_Position;
1023 Len : in Integer := -1);
1025 -- ALIAS(`mvwinstr()')
1027 -- MANPAGE(`curs_inchstr.3x')
1029 -- ANCHOR(`winchnstr()',`Peek')
1030 procedure Peek (Win : in Window := Standard_Window;
1031 Str : out Attributed_String;
1032 Len : in Integer := -1);
1034 -- ALIAS(`winchstr()')
1036 -- ANCHOR(`mvwinchnstr()',`Peek')
1037 procedure Peek (Win : in Window := Standard_Window;
1038 Line : in Line_Position;
1039 Column : in Column_Position;
1040 Str : out Attributed_String;
1041 Len : in Integer := -1);
1043 -- ALIAS(`mvwinchstr()')
1044 -- We don't inline the Peek procedures
1046 -- MANPAGE(`curs_getstr.3x')
1048 -- ANCHOR(`wgetnstr()',`Get')
1049 procedure Get (Win : in Window := Standard_Window;
1051 Len : in Integer := -1);
1053 -- ALIAS(`wgetstr()')
1055 procedure Get (Win : in Window := Standard_Window;
1056 Line : in Line_Position;
1057 Column : in Column_Position;
1059 Len : in Integer := -1);
1061 -- not specified in ncurses, should be: mvwgetnstr()
1062 -- and mvwgetstr() (which exists)
1063 -- Get is not inlined
1065 -- MANPAGE(`curs_slk.3x')
1067 type Soft_Label_Key_Format is (Three_Two_Three,
1069 PC_Style, -- ncurses specific
1070 PC_Style_With_Index); -- "
1071 type Label_Number is new Positive range 1 .. 12;
1072 type Label_Justification is (Left, Centered, Right);
1074 -- ANCHOR(`slk_init()',`Init_Soft_Label_Keys')
1075 procedure Init_Soft_Label_Keys
1076 (Format : in Soft_Label_Key_Format := Three_Two_Three);
1078 pragma Inline (Init_Soft_Label_Keys);
1080 -- ANCHOR(`slk_set()',`Set_Soft_Label_Key')
1081 procedure Set_Soft_Label_Key (Label : in Label_Number;
1083 Fmt : in Label_Justification := Left);
1085 -- We don't inline this procedure
1087 -- ANCHOR(`slk_refresh()',`Refresh_Soft_Label_Key')
1088 procedure Refresh_Soft_Label_Keys;
1090 pragma Inline (Refresh_Soft_Label_Keys);
1092 -- ANCHOR(`slk_noutrefresh()',`Refresh_Soft_Label_Keys_Without_Update')
1093 procedure Refresh_Soft_Label_Keys_Without_Update;
1095 pragma Inline (Refresh_Soft_Label_Keys_Without_Update);
1097 -- ANCHOR(`slk_label()',`Get_Soft_Label_Key')
1098 procedure Get_Soft_Label_Key (Label : in Label_Number;
1102 -- ANCHOR(`slk_label()',`Get_Soft_Label_Key')
1103 function Get_Soft_Label_Key (Label : in Label_Number) return String;
1106 pragma Inline (Get_Soft_Label_Key);
1108 -- ANCHOR(`slk_clear()',`Clear_Soft_Label_Keys')
1109 procedure Clear_Soft_Label_Keys;
1111 pragma Inline (Clear_Soft_Label_Keys);
1113 -- ANCHOR(`slk_restore()',`Restore_Soft_Label_Keys')
1114 procedure Restore_Soft_Label_Keys;
1116 pragma Inline (Restore_Soft_Label_Keys);
1118 -- ANCHOR(`slk_touch()',`Touch_Soft_Label_Keys')
1119 procedure Touch_Soft_Label_Keys;
1121 pragma Inline (Touch_Soft_Label_Keys);
1123 -- ANCHOR(`slk_attron()',`Switch_Soft_Label_Key_Attributes')
1124 procedure Switch_Soft_Label_Key_Attributes
1125 (Attr : in Character_Attribute_Set;
1126 On : in Boolean := True);
1128 -- ALIAS(`slk_attroff()')
1129 pragma Inline (Switch_Soft_Label_Key_Attributes);
1131 -- ANCHOR(`slk_attrset()',`Set_Soft_Label_Key_Attributes')
1132 procedure Set_Soft_Label_Key_Attributes
1133 (Attr : in Character_Attribute_Set := Normal_Video;
1134 Color : in Color_Pair := Color_Pair'First);
1136 pragma Inline (Set_Soft_Label_Key_Attributes);
1138 -- ANCHOR(`slk_attr()',`Get_Soft_Label_Key_Attributes')
1139 function Get_Soft_Label_Key_Attributes return Character_Attribute_Set;
1142 -- ANCHOR(`slk_attr()',`Get_Soft_Label_Key_Attributes')
1143 function Get_Soft_Label_Key_Attributes return Color_Pair;
1145 pragma Inline (Get_Soft_Label_Key_Attributes);
1147 -- ANCHOR(`slk_color()',`Set_Soft_Label_Key_Color')
1148 procedure Set_Soft_Label_Key_Color (Pair : in Color_Pair);
1150 pragma Inline (Set_Soft_Label_Key_Color);
1152 -- MANPAGE(`keyok.3x')
1154 -- ANCHOR(`keyok()',`Enable_Key')
1155 procedure Enable_Key (Key : in Special_Key_Code;
1156 Enable : in Boolean := True);
1158 pragma Inline (Enable_Key);
1160 -- MANPAGE(`define_key.3x')
1162 -- ANCHOR(`define_key()',`Define_Key')
1163 procedure Define_Key (Definition : in String;
1164 Key : in Special_Key_Code);
1166 pragma Inline (Define_Key);
1168 -- MANPAGE(`curs_util.3x')
1170 -- | Not implemented : filter, use_env, putwin, getwin
1172 -- ANCHOR(`keyname()',`Key_Name')
1173 procedure Key_Name (Key : in Real_Key_Code;
1176 -- The external name for a real keystroke.
1178 -- ANCHOR(`keyname()',`Key_Name')
1179 function Key_Name (Key : in Real_Key_Code) return String;
1182 -- We don't inline this routine
1184 -- ANCHOR(`unctrl()',`Un_Control')
1185 procedure Un_Control (Ch : in Attributed_Character;
1189 -- ANCHOR(`unctrl()',`Un_Control')
1190 function Un_Control (Ch : in Attributed_Character) return String;
1193 pragma Inline (Un_Control);
1195 -- ANCHOR(`delay_output()',`Delay_Output')
1196 procedure Delay_Output (Msecs : in Natural);
1198 pragma Inline (Delay_Output);
1200 -- ANCHOR(`flushinp()',`Flush_Input')
1201 procedure Flush_Input;
1203 pragma Inline (Flush_Input);
1205 -- MANPAGE(`curs_termattrs.3x')
1207 -- ANCHOR(`baudrate()',`Baudrate')
1208 function Baudrate return Natural;
1210 pragma Inline (Baudrate);
1212 -- ANCHOR(`erasechar()',`Erase_Character')
1213 function Erase_Character return Character;
1215 pragma Inline (Erase_Character);
1217 -- ANCHOR(`killchar()',`Kill_Character')
1218 function Kill_Character return Character;
1220 pragma Inline (Kill_Character);
1222 -- ANCHOR(`has_ic()',`Has_Insert_Character')
1223 function Has_Insert_Character return Boolean;
1225 pragma Inline (Has_Insert_Character);
1227 -- ANCHOR(`has_il()',`Has_Insert_Line')
1228 function Has_Insert_Line return Boolean;
1230 pragma Inline (Has_Insert_Line);
1232 -- ANCHOR(`termattrs()',`Supported_Attributes')
1233 function Supported_Attributes return Character_Attribute_Set;
1235 pragma Inline (Supported_Attributes);
1237 -- ANCHOR(`longname()',`Long_Name')
1238 procedure Long_Name (Name : out String);
1241 -- ANCHOR(`longname()',`Long_Name')
1242 function Long_Name return String;
1245 pragma Inline (Long_Name);
1247 -- ANCHOR(`termname()',`Terminal_Name')
1248 procedure Terminal_Name (Name : out String);
1251 -- ANCHOR(`termname()',`Terminal_Name')
1252 function Terminal_Name return String;
1255 pragma Inline (Terminal_Name);
1257 -- MANPAGE(`curs_color.3x')
1259 -- ANCHOR(`start_clolor()',`Start_Color')
1260 procedure Start_Color;
1262 pragma Import (C, Start_Color, "start_color");
1264 -- ANCHOR(`init_pair()',`Init_Pair')
1265 procedure Init_Pair (Pair : in Redefinable_Color_Pair;
1266 Fore : in Color_Number;
1267 Back : in Color_Number);
1269 pragma Inline (Init_Pair);
1271 -- ANCHOR(`pair_content()',`Pair_Content')
1272 procedure Pair_Content (Pair : in Color_Pair;
1273 Fore : out Color_Number;
1274 Back : out Color_Number);
1276 pragma Inline (Pair_Content);
1278 -- ANCHOR(`has_colors()',`Has_Colors')
1279 function Has_Colors return Boolean;
1281 pragma Inline (Has_Colors);
1283 -- ANCHOR(`init_color()',`Init_Color')
1284 procedure Init_Color (Color : in Color_Number;
1286 Green : in RGB_Value;
1287 Blue : in RGB_Value);
1289 pragma Inline (Init_Color);
1291 -- ANCHOR(`can_change_color()',`Can_Change_Color')
1292 function Can_Change_Color return Boolean;
1294 pragma Inline (Can_Change_Color);
1296 -- ANCHOR(`color_content()',`Color_Content')
1297 procedure Color_Content (Color : in Color_Number;
1298 Red : out RGB_Value;
1299 Green : out RGB_Value;
1300 Blue : out RGB_Value);
1302 pragma Inline (Color_Content);
1304 -- MANPAGE(`curs_kernel.3x')
1306 -- | Not implemented: getsyx, setsyx
1308 type Curses_Mode is (Curses, Shell);
1310 -- ANCHOR(`def_prog_mode()',`Save_Curses_Mode')
1311 procedure Save_Curses_Mode (Mode : in Curses_Mode);
1313 -- ALIAS(`def_shell_mode()')
1314 pragma Inline (Save_Curses_Mode);
1316 -- ANCHOR(`reset_prog_mode()',`Reset_Curses_Mode')
1317 procedure Reset_Curses_Mode (Mode : in Curses_Mode);
1319 -- ALIAS(`reset_shell_mode()')
1320 pragma Inline (Reset_Curses_Mode);
1322 -- ANCHOR(`savetty()',`Save_Terminal_State')
1323 procedure Save_Terminal_State;
1325 pragma Inline (Save_Terminal_State);
1327 -- ANCHOR(`resetty();',`Reset_Terminal_State')
1328 procedure Reset_Terminal_State;
1330 pragma Inline (Reset_Terminal_State);
1332 type Stdscr_Init_Proc is access
1333 function (Win : Window;
1334 Columns : Column_Count) return Integer;
1335 pragma Convention (C, Stdscr_Init_Proc);
1336 -- N.B.: the return value is actually ignored, but it seems to be
1337 -- a good practice to return 0 if you think all went fine
1338 -- and -1 otherwise.
1340 -- ANCHOR(`ripoffline()',`Rip_Off_Lines')
1341 procedure Rip_Off_Lines (Lines : in Integer;
1342 Proc : in Stdscr_Init_Proc);
1344 -- N.B.: to be more precise, this uses a ncurses specific enhancement of
1345 -- ripoffline(), in which the Lines argument absolute value is the
1346 -- number of lines to be ripped of. The official ripoffline() only
1347 -- uses the sign of Lines to rip of a single line from bottom or top.
1348 pragma Inline (Rip_Off_Lines);
1350 type Cursor_Visibility is (Invisible, Normal, Very_Visible);
1352 -- ANCHOR(`curs_set()',`Set_Cursor_Visibility')
1353 procedure Set_Cursor_Visibility (Visibility : in out Cursor_Visibility);
1355 pragma Inline (Set_Cursor_Visibility);
1357 -- ANCHOR(`napms()',`Nap_Milli_Seconds')
1358 procedure Nap_Milli_Seconds (Ms : in Natural);
1360 pragma Inline (Nap_Milli_Seconds);
1362 -- |=====================================================================
1363 -- | Some usefull helpers.
1364 -- |=====================================================================
1365 type Transform_Direction is (From_Screen, To_Screen);
1366 procedure Transform_Coordinates
1367 (W : in Window := Standard_Window;
1368 Line : in out Line_Position;
1369 Column : in out Column_Position;
1370 Dir : in Transform_Direction := From_Screen);
1371 -- This procedure transforms screen coordinates into coordinates relative
1372 -- to the window and vice versa, depending on the Dir parmeter.
1373 -- Screen coordinates are the position informations on the physical device.
1374 -- An Curses_Exception will be raised if Line and Column are not in the
1375 -- Window or if you pass the Null_Window as argument.
1376 -- We don't inline this procedure
1379 type Window is new System.Storage_Elements.Integer_Address;
1380 Null_Window : constant Window := 0;
1382 -- The next constants are generated and may be different on your
1385 include(`Window_Offsets')dnl
1386 Curses_Bool_False : constant Curses_Bool := 0;
1388 end Terminal_Interface.Curses;