2 define(`HTMLNAME',`terminal_interface-curses_s.html')dnl
3 include(M4MACRO)------------------------------------------------------------------------------
5 -- GNAT ncurses Binding --
7 -- Terminal_Interface.Curses --
13 -- The ncurses Ada95 binding is copyrighted 1996 by --
14 -- Juergen Pfeifer, Email: Juergen.Pfeifer@T-Online.de --
16 -- Permission is hereby granted to reproduce and distribute this --
17 -- binding by any means and for any fee, whether alone or as part --
18 -- of a larger distribution, in source or in binary form, PROVIDED --
19 -- this notice is included with any such distribution, and is not --
20 -- removed from any of its header files. Mention of ncurses and the --
21 -- author of this binding in any applications linked with it is --
22 -- highly appreciated. --
24 -- This binding comes AS IS with no warranty, implied or expressed. --
25 ------------------------------------------------------------------------------
28 ------------------------------------------------------------------------------
31 with Interfaces.C; -- We need this for some assertions.
33 package Terminal_Interface.Curses is
35 include(`Linker_Options')
36 type Window is private;
37 Null_Window : constant Window;
39 type Line_Position is new Natural; -- line coordinate
40 type Column_Position is new Natural; -- column coordinate
42 subtype Line_Count is Line_Position range 1 .. Line_Position'Last;
43 -- Type to count lines. We do not allow null windows, so must be positive
44 subtype Column_Count is Column_Position range 1 .. Column_Position'Last;
45 -- Type to count columns. We do not allow null windows, so must be positive
47 type Key_Code is new Natural;
48 -- That is anything including real characters, special keys and logical
51 subtype Real_Key_Code is Key_Code range 0 .. M4_KEY_MAX;
52 -- This are the codes that potentially represent a real keystroke.
53 -- Not all codes may be possible on a specific terminal. To check the
54 -- availability of a special key, the Has_Key function is provided.
56 subtype Special_Key_Code is Real_Key_Code
57 range M4_SPECIAL_FIRST .. Real_Key_Code'Last;
58 -- Type for a function- or special key number
60 subtype Normal_Key_Code is Real_Key_Code range
61 Character'Pos (Character'First) .. Character'Pos (Character'Last);
62 -- This are the codes for regular (incl. non-graphical) characters.
64 -- Constants for function- and special keys
66 Key_None : constant Special_Key_Code := M4_SPECIAL_FIRST;
67 include(`Key_Definitions')
68 Key_Max : constant Special_Key_Code
69 := Special_Key_Code'Last;
71 subtype User_Key_Code is Key_Code
72 range (Key_Max + 129) .. Key_Code'Last;
73 -- This is reserved for user defined key codes. The range between Key_Max
74 -- and the first user code is reserved for subsystems like menu and forms.
76 -- For those who like to use the original key names we produce them were
77 -- they differ from the original. Please note that they may differ in
81 ------------------------------------------------------------------------------
83 type Color_Number is range 0 .. Integer (Interfaces.C.short'Last);
84 for Color_Number'Size use Interfaces.C.short'Size;
85 -- (n)curses uses a short for the color index
86 -- The model is, that a Color_Number is an index into an array of
87 -- (potentially) definable colors. Some of those indices are
88 -- predefined (see below), although they may not really exist.
91 type RGB_Value is range 0 .. Integer (Interfaces.C.Short'Last);
92 for RGB_Value'Size use Interfaces.C.short'Size;
93 -- Some system may allow to redefine a color by setting RGB values.
95 type Color_Pair is range 0 .. 255;
96 for Color_Pair'Size use 8;
97 subtype Redefinable_Color_Pair is Color_Pair range 1 .. 255;
98 -- (n)curses reserves 1 Byte for the color-pair number. Color Pair 0
99 -- is fixed (Black & White). A color pair is simply a combination of
100 -- two colors described by Color_Numbers, one for the foreground and
101 -- the other for the background
103 include(`Character_Attribute_Set_Rep')
104 -- (n)curses uses half of an integer for attributes.
106 Normal_Video : constant Character_Attribute_Set := (others => False);
108 type Attributed_Character is
110 Attr : Character_Attribute_Set := Normal_Video;
111 Color : Color_Pair := 0;
112 Ch : Character := ' ';
114 pragma Convention (C, Attributed_Character);
115 -- This is the counterpart for the chtype in C.
118 Default_Character : constant Attributed_Character
119 := (Ch => Character'First,
120 Color => Color_Pair'First,
121 Attr => Normal_Video);
123 type Attributed_String is array (Positive range <>) of Attributed_Character;
124 pragma Pack (Attributed_String);
125 -- In this binding we allow strings of attributed characters.
130 Curses_Exception : exception;
132 -- Those exceptions are raised by the ETI (Extended Terminal Interface)
133 -- subpackets for Menu and Forms handling.
135 Eti_System_Error : exception;
136 Eti_Bad_Argument : exception;
137 Eti_Posted : exception;
138 Eti_Connected : exception;
139 Eti_Bad_State : exception;
140 Eti_No_Room : exception;
141 Eti_Not_Posted : exception;
142 Eti_Unknown_Command : exception;
143 Eti_No_Match : exception;
144 Eti_Not_Selectable : exception;
145 Eti_Not_Connected : exception;
146 Eti_Request_Denied : exception;
147 Eti_Invalid_Field : exception;
148 Eti_Current : exception;
150 --------------------------------------------------------------------------
151 -- External C variables
152 -- Conceptually even in C this are kind of constants, but they are
153 -- initialized and sometimes changed by the library routines at runtime
154 -- depending on the type of terminal. I believe the best way to model
155 -- this is to use functions.
156 --------------------------------------------------------------------------
158 function Lines return Line_Count;
159 pragma Inline (Lines);
161 function Columns return Column_Count;
162 pragma Inline (Columns);
164 function Tab_Size return Natural;
165 pragma Inline (Tab_Size);
167 function Number_Of_Colors return Natural;
168 pragma Inline (Number_Of_Colors);
170 function Number_Of_Color_Pairs return Natural;
171 pragma Inline (Number_Of_Color_Pairs);
173 ACS_Map : array (Character'Val (0) .. Character'Val (127)) of
174 Attributed_Character;
175 pragma Import (C, ACS_Map, "acs_map");
178 -- Constants for several symbols from the Alternate Character Set
179 -- You must use this constants as indices into the ACS_Map array
180 -- to get the corresponding attributed character at runtime.
184 -- MANPAGE(`curs_initscr.3x')
185 -- | Not implemented: newterm, set_term, delscreen
187 -- ANCHOR(`stdscr',`Standard_Window')
188 function Standard_Window return Window;
190 pragma Inline (Standard_Window);
192 -- ANCHOR(`initscr()',`Init_Screen')
193 procedure Init_Screen;
195 -- ANCHOR(`initscr()',`Init_Windows')
196 procedure Init_Windows renames Init_Screen;
199 -- ANCHOR(`endwin()',`End_Windows')
200 procedure End_Windows;
202 procedure End_Screen renames End_Windows;
204 -- ANCHOR(`isendwin()',`Is_End_Window')
205 function Is_End_Window return Boolean;
208 -- MANPAGE(`curs_move.3x')
210 -- ANCHOR(`wmove()',`Move_Cursor')
211 procedure Move_Cursor (Win : in Window := Standard_Window;
212 Line : in Line_Position;
213 Column : in Column_Position);
216 -- MANPAGE(`curs_addch.3x')
218 -- ANCHOR(`waddch()',`Add')
219 procedure Add (Win : in Window := Standard_Window;
220 Ch : in Attributed_Character);
223 procedure Add (Win : in Window := Standard_Window;
225 -- Add a single character at the current logical cursor position to
226 -- the window. Use the current windows attributes.
228 -- ANCHOR(`mvwaddch()',`Add')
230 (Win : in Window := Standard_Window;
231 Line : in Line_Position;
232 Column : in Column_Position;
233 Ch : in Attributed_Character);
237 (Win : in Window := Standard_Window;
238 Line : in Line_Position;
239 Column : in Column_Position;
241 -- Move to the position and add a single character into the window
243 -- ANCHOR(`wechochar()',`Add_With_Immediate_Echo')
244 procedure Add_With_Immediate_Echo
245 (Win : in Window := Standard_Window;
246 Ch : in Attributed_Character);
249 procedure Add_With_Immediate_Echo
250 (Win : in Window := Standard_Window;
252 -- Add a character and do an immediate resfresh of the screen.
254 -- MANPAGE(`curs_window.3x')
256 -- ANCHOR(`newwin()',`Create')
258 (Number_Of_Lines : Line_Count;
259 Number_Of_Columns : Column_Count;
260 First_Line_Position : Line_Position;
261 First_Column_Position : Column_Position) return Window;
265 (Number_Of_Lines : Line_Count;
266 Number_Of_Columns : Column_Count;
267 First_Line_Position : Line_Position;
268 First_Column_Position : Column_Position) return Window
271 -- ANCHOR(`delwin()',`Delete')
272 procedure Delete (Win : in out Window);
274 -- Reset Win to Null_Window
276 -- ANCHOR(`subwin()',`Sub_Window')
278 (Win : Window := Standard_Window;
279 Number_Of_Lines : Line_Count;
280 Number_Of_Columns : Column_Count;
281 First_Line_Position : Line_Position;
282 First_Column_Position : Column_Position) return Window;
285 -- ANCHOR(`derwin()',`Derived_Window')
286 function Derived_Window
287 (Win : Window := Standard_Window;
288 Number_Of_Lines : Line_Count;
289 Number_Of_Columns : Column_Count;
290 First_Line_Position : Line_Position;
291 First_Column_Position : Column_Position) return Window;
294 -- ANCHOR(`dupwin()',`Duplicate')
295 function Duplicate (Win : Window) return Window;
298 -- ANCHOR(`mvwin()',`Move_Window')
299 procedure Move_Window (Win : in Window;
300 Line : in Line_Position;
301 Column : in Column_Position);
304 -- ANCHOR(`mvderwin()',`Move_Derived_Window')
305 procedure Move_Derived_Window (Win : in Window;
306 Line : in Line_Position;
307 Column : in Column_Position);
310 -- ANCHOR(`wsyncup()',`Synchronize_Upwards')
311 procedure Synchronize_Upwards (Win : in Window);
313 pragma Import (C, Synchronize_Upwards, "wsyncup");
315 -- ANCHOR(`wsyncdown()',`Synchronize_Downwards')
316 procedure Synchronize_Downwards (Win : in Window);
318 pragma Import (C, Synchronize_Downwards, "wsyncdown");
320 -- ANCHOR(`syncok()',`Set_Synch_Mode')
321 procedure Set_Synch_Mode (Win : in Window := Standard_Window;
322 Mode : in Boolean := False);
325 -- MANPAGE(`curs_addstr.3x')
327 -- ANCHOR(`waddnstr()',`Add')
328 procedure Add (Win : in Window := Standard_Window;
330 Len : in Integer := -1);
332 -- ALIAS(`waddstr()')
334 -- ANCHOR(`mvwaddnstr()',`Add')
335 procedure Add (Win : in Window := Standard_Window;
336 Line : in Line_Position;
337 Column : in Column_Position;
339 Len : in Integer := -1);
341 -- ALIAS(`mvwaddstr()')
343 -- MANPAGE(`curs_addchstr.3x')
345 -- ANCHOR(`waddchnstr()',`Add')
346 procedure Add (Win : in Window := Standard_Window;
347 Str : in Attributed_String;
348 Len : in Integer := -1);
350 -- ALIAS(`waddchstr()')
352 -- ANCHOR(`mvwaddchnstr()',`Add')
353 procedure Add (Win : in Window := Standard_Window;
354 Line : in Line_Position;
355 Column : in Column_Position;
356 Str : in Attributed_String;
357 Len : in Integer := -1);
359 -- ALIAS(`mvwaddchstr()')
361 -- MANPAGE(`curs_border.3x')
363 -- ANCHOR(`wborder()',`Border')
365 (Win : in Window := Standard_Window;
366 Left_Side_Symbol : in Attributed_Character := Default_Character;
367 Right_Side_Symbol : in Attributed_Character := Default_Character;
368 Top_Side_Symbol : in Attributed_Character := Default_Character;
369 Bottom_Side_Symbol : in Attributed_Character := Default_Character;
370 Upper_Left_Corner_Symbol : in Attributed_Character := Default_Character;
371 Upper_Right_Corner_Symbol : in Attributed_Character := Default_Character;
372 Lower_Left_Corner_Symbol : in Attributed_Character := Default_Character;
373 Lower_Right_Corner_Symbol : in Attributed_Character := Default_Character
377 -- ANCHOR(`box()',`Box')
379 (Win : in Window := Standard_Window;
380 Vertical_Symbol : in Attributed_Character := Default_Character;
381 Horizontal_Symbol : in Attributed_Character := Default_Character);
384 -- ANCHOR(`whline()',`Horizontal_Line')
385 procedure Horizontal_Line
386 (Win : in Window := Standard_Window;
387 Line_Size : in Natural;
388 Line_Symbol : in Attributed_Character := Default_Character);
391 -- ANCHOR(`wvline()',`Vertical_Line')
392 procedure Vertical_Line
393 (Win : in Window := Standard_Window;
394 Line_Size : in Natural;
395 Line_Symbol : in Attributed_Character := Default_Character);
398 -- MANPAGE(`curs_getch.3x')
400 -- ANCHOR(`wgetch()',`Get_Keystroke')
401 function Get_Keystroke (Win : Window := Standard_Window)
402 return Real_Key_Code;
404 -- Get a character from the keyboard and echo it - if enabled - to the
406 -- If for any reason (i.e. a timeout) we couldn't get a character the
407 -- returned keycode is Key_None.
409 -- ANCHOR(`ungetch()',`Undo_Keystroke')
410 procedure Undo_Keystroke (Key : in Real_Key_Code);
413 -- ANCHOR(`has_key()',`Has_Key')
414 function Has_Key (Key : Special_Key_Code) return Boolean;
417 -- | Some helper functions
419 function Is_Function_Key (Key : Special_Key_Code) return Boolean;
420 -- Return True if the Key is a function key (i.e. one of F0 .. F63)
422 subtype Function_Key_Number is Integer range 0 .. 63;
423 -- (n)curses allows for 64 function keys.
425 function Function_Key (Key : Real_Key_Code) return Function_Key_Number;
426 -- Return the number of the function key. If the code is not a
427 -- function key, a CONSTRAINT_ERROR will be raised.
429 function Function_Key_Code (Key : Function_Key_Number) return Real_Key_Code;
430 -- Return the key code for a given functionkey number.
432 -- MANPAGE(`curs_attr.3x')
434 -- ANCHOR(`wattron()',`Switch_Character_Attribute')
435 procedure Switch_Character_Attribute
436 (Win : in Window := Standard_Window;
437 Attr : in Character_Attribute_Set := Normal_Video;
438 On : in Boolean := True); -- if False we switch Off.
440 -- ALIAS(`wattroff()')
442 -- ANCHOR(`wattrset()',`Set_Character_Attributes')
443 procedure Set_Character_Attributes
444 (Win : in Window := Standard_Window;
445 Attr : in Character_Attribute_Set := Normal_Video;
446 Color : in Color_Pair := Color_Pair'First);
449 -- ANCHOR(`wattr_get()',`Get_Character_Attribute')
450 function Get_Character_Attribute
451 (Win : in Window := Standard_Window) return Character_Attribute_Set;
454 -- ANCHOR(`wattr_get()',`Get_Character_Attribute')
455 function Get_Character_Attribute
456 (Win : in Window := Standard_Window) return Color_Pair;
459 -- ANCHOR(`wchgat()',`Change_Attributes')
460 procedure Change_Attributes
461 (Win : in Window := Standard_Window;
462 Count : in Integer := -1;
463 Attr : in Character_Attribute_Set := Normal_Video;
464 Color : in Color_Pair := Color_Pair'First);
467 -- ANCHOR(`mvwchgat()',`Change_Attributes')
468 procedure Change_Attributes
469 (Win : in Window := Standard_Window;
470 Line : in Line_Position := Line_Position'First;
471 Column : in Column_Position := Column_Position'First;
472 Count : in Integer := -1;
473 Attr : in Character_Attribute_Set := Normal_Video;
474 Color : in Color_Pair := Color_Pair'First);
477 -- MANPAGE(`curs_beep.3x')
479 -- ANCHOR(`beep()',`Beep')
483 -- ANCHOR(`flash()',`Flash_Screen')
484 procedure Flash_Screen;
487 -- MANPAGE(`curs_inopts.3x')
489 -- | Not implemented : typeahead
491 -- ANCHOR(`cbreak()',`Set_Cbreak_Mode')
492 procedure Set_Cbreak_Mode (SwitchOn : in Boolean := True);
494 -- ALIAS(`nocbreak()')
496 -- ANCHOR(`raw()',`Set_Raw_Mode')
497 procedure Set_Raw_Mode (SwitchOn : in Boolean := True);
501 -- ANCHOR(`echo()',`Set_Echo_Mode')
502 procedure Set_Echo_Mode (SwitchOn : in Boolean := True);
506 -- ANCHOR(`meta()',`Set_Meta_Mode')
507 procedure Set_Meta_Mode (Win : in Window := Standard_Window;
508 SwitchOn : in Boolean := True);
511 -- ANCHOR(`keypad()',`Set_KeyPad_Mode')
512 procedure Set_KeyPad_Mode (Win : in Window := Standard_Window;
513 SwitchOn : in Boolean := True);
516 type Half_Delay_Amount is range 1 .. 255;
518 -- ANCHOR(`halfdelay()',`Half_Delay')
519 procedure Half_Delay (Amount : in Half_Delay_Amount);
522 -- ANCHOR(`intrflush()',`Set_Flush_On_Interrupt_Mode')
523 procedure Set_Flush_On_Interrupt_Mode
524 (Win : in Window := Standard_Window;
525 Mode : in Boolean := True);
528 -- ANCHOR(`qiflush()',`Set_Queue_Interrupt_Mode')
529 procedure Set_Queue_Interrupt_Mode
530 (Win : in Window := Standard_Window;
531 Flush : in Boolean := True);
533 -- ALIAS(`noqiflush()')
535 -- ANCHOR(`nodelay()',`Set_NoDelay_Mode')
536 procedure Set_NoDelay_Mode
537 (Win : in Window := Standard_Window;
538 Mode : in Boolean := False);
541 type Timeout_Mode is (Blocking, Non_Blocking, Delayed);
543 -- ANCHOR(`wtimeout()',`Set_Timeout_Mode')
544 procedure Set_Timeout_Mode (Win : in Window := Standard_Window;
545 Mode : in Timeout_Mode;
546 Amount : in Natural); -- in Miliseconds
548 -- Instead of overloading the semantic of the sign of amount, we
549 -- introduce the Timeout_Mode parameter. This should improve
550 -- readability. For Blocking and Non_Blocking, the Amount is not
553 -- ANCHOR(`notimeout()',`Set_Escape_Time_Mode')
554 procedure Set_Escape_Timer_Mode
555 (Win : in Window := Standard_Window;
556 Timer_Off : in Boolean := False);
559 -- MANPAGE(`curs_outopts.3x')
561 -- ANCHOR(`nl()',`Set_NL_Mode')
562 procedure Set_NL_Mode (SwitchOn : in Boolean := True);
566 -- ANCHOR(`clearok()',`Clear_On_Next_Update')
567 procedure Clear_On_Next_Update
568 (Win : in Window := Standard_Window;
569 Do_Clear : in Boolean := True);
572 -- ANCHOR(`idlok()',`Use_Insert_Delete_Line')
573 procedure Use_Insert_Delete_Line
574 (Win : in Window := Standard_Window;
575 Do_Idl : in Boolean := True);
578 -- ANCHOR(`idcok()',`Use_Insert_Delete_Character')
579 procedure Use_Insert_Delete_Character
580 (Win : in Window := Standard_Window;
581 Do_Idc : in Boolean := True);
584 -- ANCHOR(`leaveok()',`Leave_Cursor_After_Update')
585 procedure Leave_Cursor_After_Update
586 (Win : in Window := Standard_Window;
587 Do_Leave : in Boolean := True);
590 -- ANCHOR(`immedok()',`Immediate_Update_Mode')
591 procedure Immediate_Update_Mode
592 (Win : in Window := Standard_Window;
593 Mode : in Boolean := False);
596 -- ANCHOR(`scrollok()',`Allow_Scrolling')
597 procedure Allow_Scrolling
598 (Win : in Window := Standard_Window;
599 Mode : in Boolean := False);
602 function Scrolling_Allowed (Win : Window := Standard_Window) return Boolean;
603 -- There is no such function in the C interface.
605 -- ANCHOR(`wsetscrreg()',`Set_Scroll_Region')
606 procedure Set_Scroll_Region
607 (Win : in Window := Standard_Window;
608 Top_Line : in Line_Position;
609 Bottom_Line : in Line_Position);
612 -- MANPAGE(`curs_refresh.3x')
614 -- ANCHOR(`doupdate()',`Update_Screen')
615 procedure Update_Screen;
618 -- ANCHOR(`wrefresh()',`Refresh')
619 procedure Refresh (Win : in Window := Standard_Window);
622 -- ANCHOR(`wnoutrefresh()',`Refresh_Without_Update')
623 procedure Refresh_Without_Update
624 (Win : in Window := Standard_Window);
627 -- ANCHOR(`redrawwin()',`Redraw')
628 procedure Redraw (Win : in Window := Standard_Window);
631 -- ANCHOR(`wredrawln()',`Redraw')
632 procedure Redraw (Win : in Window := Standard_Window;
633 Begin_Line : in Line_Position;
634 Line_Count : in Positive);
637 -- MANPAGE(`curs_clear.3x')
639 -- ANCHOR(`werase()',`Erase')
640 procedure Erase (Win : in Window := Standard_Window);
643 -- ANCHOR(`wclear()',`Clear')
645 (Win : in Window := Standard_Window);
648 -- ANCHOR(`wclrtobot()',`Clear_To_End_Of_Screen')
649 procedure Clear_To_End_Of_Screen
650 (Win : in Window := Standard_Window);
653 -- ANCHOR(`wclrtoeol()',`Clear_To_End_Of_Line')
654 procedure Clear_To_End_Of_Line
655 (Win : in Window := Standard_Window);
658 -- MANPAGE(`curs_bkgd.3x')
660 -- ANCHOR(`wbkgdset()',`Set_Background')
661 procedure Set_Background
662 (Win : in Window := Standard_Window;
663 Ch : in Attributed_Character);
666 -- ANCHOR(`wbkgd()',`Change_Background')
667 procedure Change_Background
668 (Win : in Window := Standard_Window;
669 Ch : in Attributed_Character);
672 -- ANCHOR(`wbkgdget()',`Get_Background')
673 function Get_Background (Win : Window := Standard_Window)
674 return Attributed_Character;
677 -- MANPAGE(`curs_touch.3x')
679 -- ANCHOR(`touchwin()',`Touch')
680 procedure Touch (Win : in Window := Standard_Window);
683 -- ANCHOR(`untouchwin()',`Untouch')
684 procedure Untouch (Win : in Window := Standard_Window);
687 -- ANCHOR(`touchline()',`Touch')
688 procedure Touch (Win : in Window := Standard_Window;
689 Start : in Line_Position;
690 Count : in Positive);
693 -- ANCHOR(`wtouchln()',`Change_Line_Status')
694 procedure Change_Lines_Status (Win : in Window := Standard_Window;
695 Start : in Line_Position;
700 -- ANCHOR(`is_linetouched()',`Is_Touched')
701 function Is_Touched (Win : Window := Standard_Window;
702 Line : Line_Position) return Boolean;
705 -- ANCHOR(`is_wintouched()',`Is_Touched')
706 function Is_Touched (Win : Window := Standard_Window) return Boolean;
709 -- MANPAGE(`curs_overlay.3x')
711 -- ANCHOR(`copywin()',`Copy')
713 (Source_Window : in Window;
714 Destination_Window : in Window;
715 Source_Top_Row : in Line_Position;
716 Source_Left_Column : in Column_Position;
717 Destination_Top_Row : in Line_Position;
718 Destination_Left_Column : in Column_Position;
719 Destination_Bottom_Row : in Line_Position;
720 Destination_Right_Column : in Column_Position;
721 Non_Destructive_Mode : in Boolean := True);
724 -- ANCHOR(`overwrite()',`Overwrite')
725 procedure Overwrite (Source_Window : in Window;
726 Destination_Window : in Window);
729 -- ANCHOR(`overlay()',`Overlay')
730 procedure Overlay (Source_Window : in Window;
731 Destination_Window : in Window);
734 -- MANPAGE(`curs_deleteln.3x')
736 -- ANCHOR(`winsdelln()',`Insert_Delete_Lines')
737 procedure Insert_Delete_Lines
738 (Win : in Window := Standard_Window;
739 Lines : in Integer := 1); -- default is to insert one line above
742 -- ANCHOR(`wdeleteln()',`Delete_Line')
743 procedure Delete_Line (Win : in Window := Standard_Window);
746 -- ANCHOR(`winsertln()',`Insert_Line')
747 procedure Insert_Line (Win : in Window := Standard_Window);
750 -- MANPAGE(`curs_getyx.3x')
752 -- ANCHOR(`getmaxyx()',`Get_Size')
754 (Win : in Window := Standard_Window;
755 Number_Of_Lines : out Line_Count;
756 Number_Of_Columns : out Column_Count);
759 -- ANCHOR(`getbegyx()',`Get_Window_Position')
760 procedure Get_Window_Position
761 (Win : in Window := Standard_Window;
762 Top_Left_Line : out Line_Position;
763 Top_Left_Column : out Column_Position);
766 -- ANCHOR(`getyx()',`Get_Cursor_Position')
767 procedure Get_Cursor_Position
768 (Win : in Window := Standard_Window;
769 Line : out Line_Position;
770 Column : out Column_Position);
773 -- ANCHOR(`getparyx()',`Get_Origin_Relative_To_Parent')
774 procedure Get_Origin_Relative_To_Parent
776 Top_Left_Line : out Line_Position;
777 Top_Left_Column : out Column_Position;
778 Is_Not_A_Subwindow : out Boolean);
780 -- Instead of placing -1 in the coordinates as return, we use a boolean
781 -- to return the info that the window has no parent.
783 -- MANPAGE(`curs_pad.3x')
785 -- ANCHOR(`newpad()',`New_Pad')
786 function New_Pad (Lines : Line_Count;
787 Columns : Column_Count) return Window;
790 -- ANCHOR(`subpad()',`Sub_Pad')
793 Number_Of_Lines : Line_Count;
794 Number_Of_Columns : Column_Count;
795 First_Line_Position : Line_Position;
796 First_Column_Position : Column_Position) return Window;
799 -- ANCHOR(`prefresh()',`Refresh')
802 Source_Top_Row : in Line_Position;
803 Source_Left_Column : in Column_Position;
804 Destination_Top_Row : in Line_Position;
805 Destination_Left_Column : in Column_Position;
806 Destination_Bottom_Row : in Line_Position;
807 Destination_Right_Column : in Column_Position);
810 -- ANCHOR(`pnoutrefresh()',`Refresh_Without_Update')
811 procedure Refresh_Without_Update
813 Source_Top_Row : in Line_Position;
814 Source_Left_Column : in Column_Position;
815 Destination_Top_Row : in Line_Position;
816 Destination_Left_Column : in Column_Position;
817 Destination_Bottom_Row : in Line_Position;
818 Destination_Right_Column : in Column_Position);
821 -- ANCHOR(`pechochar()',`Add_Character_To_Pad_And_Echo_It')
822 procedure Add_Character_To_Pad_And_Echo_It
824 Ch : in Attributed_Character);
827 procedure Add_Character_To_Pad_And_Echo_It
831 -- MANPAGE(`curs_scroll.3x')
833 -- ANCHOR(`wscrl()',`Scroll')
834 procedure Scroll (Win : in Window := Standard_Window;
835 Amount : in Integer := 1);
838 -- MANPAGE(`curs_delch.3x')
840 -- ANCHOR(`wdelch()',`Delete_Character')
841 procedure Delete_Character (Win : in Window := Standard_Window);
844 -- ANCHOR(`mvwdelch()',`Delete_Character')
845 procedure Delete_Character
846 (Win : in Window := Standard_Window;
847 Line : in Line_Position;
848 Column : in Column_Position);
851 -- MANPAGE(`curs_inch.3x')
853 -- ANCHOR(`winch()',`Peek')
854 function Peek (Win : Window := Standard_Window)
855 return Attributed_Character;
858 -- ANCHOR(`mvwinch()',`Peek')
860 (Win : Window := Standard_Window;
861 Line : Line_Position;
862 Column : Column_Position) return Attributed_Character;
865 -- MANPAGE(`curs_winch.3x')
867 -- ANCHOR(`winsch()',`Insert')
868 procedure Insert (Win : in Window := Standard_Window;
869 Ch : in Attributed_Character);
872 -- ANCHOR(`mvwinsch()',`Insert')
873 procedure Insert (Win : in Window := Standard_Window;
874 Line : in Line_Position;
875 Column : in Column_Position;
876 Ch : in Attributed_Character);
879 -- MANPAGE(`curs_winch.3x')
881 -- ANCHOR(`winsnstr()',`Insert')
882 procedure Insert (Win : in Window := Standard_Window;
884 Len : in Integer := -1);
886 -- ALIAS(`winsstr()')
888 -- ANCHOR(`mvwinsnstr()',`Insert')
889 procedure Insert (Win : in Window := Standard_Window;
890 Line : in Line_Position;
891 Column : in Column_Position;
893 Len : in Integer := -1);
895 -- ALIAS(`mvwinsstr()')
897 -- MANPAGE(`curs_instr.3x')
899 -- ANCHOR(`winnstr()',`Peek')
900 procedure Peek (Win : in Window := Standard_Window;
902 Len : in Integer := -1);
906 -- ANCHOR(`mvwinnstr()',`Peek')
907 procedure Peek (Win : in Window := Standard_Window;
908 Line : in Line_Position;
909 Column : in Column_Position;
911 Len : in Integer := -1);
913 -- ALIAS(`mvwinstr()')
915 -- MANPAGE(`curs_inchstr.3x')
917 -- ANCHOR(`winchnstr()',`Peek')
918 procedure Peek (Win : in Window := Standard_Window;
919 Str : out Attributed_String;
920 Len : in Integer := -1);
922 -- ALIAS(`winchstr()')
924 -- ANCHOR(`mvwinchnstr()',`Peek')
925 procedure Peek (Win : in Window := Standard_Window;
926 Line : in Line_Position;
927 Column : in Column_Position;
928 Str : out Attributed_String;
929 Len : in Integer := -1);
931 -- ALIAS(`mvwinchstr()')
933 -- MANPAGE(`curs_getstr.3x')
935 -- ANCHOR(`wgetnstr()',`Get')
936 procedure Get (Win : in Window := Standard_Window;
938 Len : in Integer := -1);
940 -- ALIAS(`wgetstr()')
942 procedure Get (Win : in Window := Standard_Window;
943 Line : in Line_Position;
944 Column : in Column_Position;
946 Len : in Integer := -1);
947 -- AKA: not specified in ncurses, should be: mvwgetnstr()
948 -- and mvwgetstr() (which exists)
950 -- MANPAGE(`curs_slk.3x')
952 type Soft_Label_Key_Format is (Three_Two_Three,
954 PC_Style, -- ncurses specific
955 PC_Style_With_Index); -- "
956 type Label_Number is new Positive range 1 .. 12;
957 type Label_Justification is (Left, Centered, Right);
959 -- ANCHOR(`slk_init()',`Init_Soft_Label_Keys')
960 procedure Init_Soft_Label_Keys
961 (Format : in Soft_Label_Key_Format := Three_Two_Three);
964 -- ANCHOR(`slk_set()',`Set_Soft_Label_Key')
965 procedure Set_Soft_Label_Key (Label : in Label_Number;
967 Fmt : in Label_Justification := Left);
970 -- ANCHOR(`slk_refresh()',`Refresh_Soft_Label_Key')
971 procedure Refresh_Soft_Label_Keys;
974 -- ANCHOR(`slk_noutrefresh()',`Refresh_Soft_Label_Keys_Without_Update')
975 procedure Refresh_Soft_Label_Keys_Without_Update;
978 -- ANCHOR(`slk_label()',`Get_Soft_Label_Key')
979 procedure Get_Soft_Label_Key (Label : in Label_Number;
983 -- ANCHOR(`slk_clear()',`Clear_Soft_Label_Keys')
984 procedure Clear_Soft_Label_Keys;
987 -- ANCHOR(`slk_restore()',`Restore_Soft_Label_Keys')
988 procedure Restore_Soft_Label_Keys;
991 -- ANCHOR(`slk_touch()',`Touch_Soft_Label_Keys')
992 procedure Touch_Soft_Label_Keys;
995 -- ANCHOR(`slk_attron()',`Switch_Soft_Label_Key_Attributes')
996 procedure Switch_Soft_Label_Key_Attributes
997 (Attr : in Character_Attribute_Set;
998 On : in Boolean := True);
1000 -- ALIAS(`slk_attroff()')
1002 -- ANCHOR(`slk_attrset()',`Set_Soft_Label_Key_Attributes')
1003 procedure Set_Soft_Label_Key_Attributes
1004 (Attr : in Character_Attribute_Set := Normal_Video;
1005 Color : in Color_Pair := Color_Pair'First);
1008 -- ANCHOR(`slk_attr()',`Get_Soft_Label_Key_Attributes')
1009 function Get_Soft_Label_Key_Attributes return Character_Attribute_Set;
1012 -- ANCHOR(`slk_attr()',`Get_Soft_Label_Key_Attributes')
1013 function Get_Soft_Label_Key_Attributes return Color_Pair;
1016 -- MANPAGE(`curs_util.3x')
1018 -- | Not implemented : filter, use_env, putwin, getwin
1020 -- ANCHOR(`keyname()',`Key_Name')
1021 procedure Key_Name (Key : in Real_Key_Code;
1024 -- The external name for a real keystroke.
1026 -- ANCHOR(`unctrl()',`Un_Control')
1027 procedure Un_Control (Ch : in Attributed_Character;
1031 -- ANCHOR(`delay_output()',`Delay_Output')
1032 procedure Delay_Output (Msecs : in Natural);
1035 -- ANCHOR(`flushinp()',`Flush_Input')
1036 procedure Flush_Input;
1039 -- MANPAGE(`curs_termattrs.3x')
1041 -- ANCHOR(`baudrate()',`Baudrate')
1042 function Baudrate return Natural;
1045 -- ANCHOR(`erasechar()',`Erase_Character')
1046 function Erase_Character return Character;
1049 -- ANCHOR(`killchar()',`Kill_Character')
1050 function Kill_Character return Character;
1053 -- ANCHOR(`has_ic()',`Has_Insert_Character')
1054 function Has_Insert_Character return Boolean;
1057 -- ANCHOR(`has_il()',`Has_Insert_Line')
1058 function Has_Insert_Line return Boolean;
1061 -- ANCHOR(`termattrs()',`Supported_Attributes')
1062 function Supported_Attributes return Character_Attribute_Set;
1065 -- ANCHOR(`longname()',`Long_Name')
1066 procedure Long_Name (Name : out String);
1069 -- ANCHOR(`termname()',`Terminal_Name')
1070 procedure Terminal_Name (Name : out String);
1073 -- MANPAGE(`curs_color.3x')
1075 -- ANCHOR(`start_clolor()',`Start_Color')
1076 procedure Start_Color;
1078 pragma Import (C, Start_Color, "start_color");
1080 -- ANCHOR(`init_pair()',`Init_Pair')
1081 procedure Init_Pair (Pair : in Redefinable_Color_Pair;
1082 Fore : in Color_Number;
1083 Back : in Color_Number);
1086 -- ANCHOR(`pair_content()',`Pair_Content')
1087 procedure Pair_Content (Pair : in Color_Pair;
1088 Fore : out Color_Number;
1089 Back : out Color_Number);
1092 -- ANCHOR(`has_colors()',`Has_Colors')
1093 function Has_Colors return Boolean;
1096 -- ANCHOR(`init_color()',`Init_Color')
1097 procedure Init_Color (Color : in Color_Number;
1099 Green : in RGB_Value;
1100 Blue : in RGB_Value);
1103 -- ANCHOR(`can_change_color()',`Can_Change_Color')
1104 function Can_Change_Color return Boolean;
1107 -- ANCHOR(`color_content()',`Color_Content')
1108 procedure Color_Content (Color : in Color_Number;
1109 Red : out RGB_Value;
1110 Green : out RGB_Value;
1111 Blue : out RGB_Value);
1114 -- MANPAGE(`curs_kernel.3x')
1116 -- | Not implemented: getsyx, setsyx
1118 type Curses_Mode is (Curses, Shell);
1120 -- ANCHOR(`def_prog_mode()',`Save_Curses_Mode')
1121 procedure Save_Curses_Mode (Mode : in Curses_Mode);
1123 -- ALIAS(`def_shell_mode()')
1125 -- ANCHOR(`reset_prog_mode()',`Reset_Curses_Mode')
1126 procedure Reset_Curses_Mode (Mode : in Curses_Mode);
1128 -- ALIAS(`reset_shell_mode()')
1130 -- ANCHOR(`savetty()',`Save_Terminal_State')
1131 procedure Save_Terminal_State;
1134 -- ANCHOR(`resetty();',`Reset_Terminal_State')
1135 procedure Reset_Terminal_State;
1138 type Stdscr_Init_Proc is access
1139 function (Win : Window;
1140 Columns : Column_Count) return Integer;
1141 pragma Convention (C, Stdscr_Init_Proc);
1142 -- N.B.: the return value is actually ignored, but it seems to be
1143 -- a good practice to return 0 if you think all went fine
1144 -- and -1 otherwise.
1146 -- ANCHOR(`ripoffline()',`Rip_Off_Lines')
1147 procedure Rip_Off_Lines (Lines : in Integer;
1148 Proc : in Stdscr_Init_Proc);
1150 -- N.B.: to be more precise, this uses a ncurses specific enhancement of
1151 -- ripoffline(), in which the Lines argument absolute value is the
1152 -- number of lines to be ripped of. The official ripoffline() only
1153 -- uses the sign of Lines to rip of a single line from bottom or top.
1155 type Cursor_Visibility is (Invisible, Normal, Very_Visible);
1157 -- ANCHOR(`curs_set()',`Set_Cursor_Visibility')
1158 procedure Set_Cursor_Visibility (Visibility : in out Cursor_Visibility);
1161 -- ANCHOR(`napms()',`Nap_Milli_Seconds')
1162 procedure Nap_Milli_Seconds (Ms : in Natural);
1165 -- |=====================================================================
1166 -- | Some usefull helpers.
1167 -- |=====================================================================
1168 type Transform_Direction is (From_Screen, To_Screen);
1169 procedure Transform_Coordinates
1170 (W : in Window := Standard_Window;
1171 Line : in out Line_Position;
1172 Column : in out Column_Position;
1173 Dir : in Transform_Direction := From_Screen);
1174 -- This procedure transforms screen coordinates into coordinates relative
1175 -- to the window and vice versa, depending on the Dir parmeter.
1176 -- Screen coordinates are the position informations on the physical device.
1177 -- An Curses_Exception will be raised if Line and Column are not in the
1178 -- Window or if you pass the Null_Window as argument.
1181 type Window is new System.Address;
1182 Null_Window : constant Window := Window (System.Null_Address);
1184 Generation_Bit_Order : constant System.Bit_Order := System.M4_BIT_ORDER;
1185 -- This constant may be different on your system.
1187 end Terminal_Interface.Curses;