[31m-- main is main file of main project written with Ada.[m
[31m-- Main is Copyright (C) 2025 Manuel De Girardi ; [m
[31m--[m
[31m--   This program is free software; you can redistribute it and/or modify[m
[31m--   it under the terms of the GNU General Public License as published by[m
[31m--   the Free Software Foundation; either version 2 of the License, or[m
[31m--   (at your option) any later version.[m
[31m--[m
[31m--   This program is distributed in the hope that it will be useful,[m
[31m--   but WITHOUT ANY WARRANTY; without even the implied warranty of[m
[31m--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the[m
[31m--   GNU General Public License for more details.[m
[31m--[m
[31m--   You should have received a copy of the GNU General Public License[m
[31m--   along with this program; if not, write to the Free Software[m
[31m--   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA[m
[31m--[m
[31m-- Date := "2025-06-04 18:32:28"[m
[31m-- Version := "0.0.0r"[m
[01;34mwith[m M[31m.[mANSI[31m.[mConsole[31m;[m
[01;34muse[m M[31m.[mANSI[31m.[mConsole[31m;[m

[01;34mgeneric[m
   Term_Lines_Max [31m:[m Positive [31m:=[m [35m24[m[31m;[m
   Term_Columns_Max [31m:[m Positive [31m:=[m [35m80[m[31m;[m
[01;34mpackage[m M[31m.[mAnsi[31m.[mWindows [01;34mis[m
               
   [31m-- Les procédures ce programme d'exemple supposent un mode d'écran de[m
   [31m-- 25 lignes sur Term_Columns_Max colonnes (c'est le mode d'écran standard, mais[m
   [31m-- mais il est tout de même fixé par la procédure d'initialisation).[m

   [01;34msubtype[m Line_Type   [01;34mis[m Natural [01;34mrange[m [35m1[m[31m..[mTerm_Lines_Max[31m;[m
   [01;34msubtype[m Column_Type [01;34mis[m Natural [01;34mrange[m [35m1[m[31m..[mTerm_Columns_Max[31m;[m
   [01;34msubtype[m Height_Type [01;34mis[m Natural [01;34mrange[m [35m0[m[31m..[mTerm_Lines_Max[31m;[m
   [01;34msubtype[m Width_Type  [01;34mis[m Natural [01;34mrange[m [35m0[m[31m..[mTerm_Columns_Max[31m;[m

   [31m-- On défini un type fenêtre très basique, qui correspond simplement[m
   [31m-- au spécification d'un rectangle. Les fenêtre sont un cadre, avec[m
   [31m-- une pseudo case ferme en haut à droite. La manière de dessiner le cadre[m
   [31m-- d'une fenêtre impose des restriction sur leurs dimensions possibles. La[m
   [31m-- largeur d'une fenêtre est de 5 au minimum, et la hauteur minimum est 2.[m

   [01;34msubtype[m Window_Line_Type   [01;34mis[m Line_Type[31m;[m
   [01;34msubtype[m Window_Column_Type [01;34mis[m Column_Type[31m;[m
   [01;34msubtype[m Window_Height_Type [01;34mis[m Height_Type [01;34mrange[m [35m2[m[31m..[mTerm_Lines_Max[31m;[m
   [01;34msubtype[m Window_Width_Type  [01;34mis[m Width_Type  [01;34mrange[m [35m5[m[31m..[mTerm_Columns_Max[31m;[m

   [31m-- La zone cliente d'une fenêtre, la zone qui est à l'intérieur, à[m
   [31m-- des dimensions bien sûre inférieur à celle de la fenêtre elle-même.[m
   [31m-- La largeur de la zone cliente fait 2 de moins que la largeur de la[m
   [31m-- fenêtre, idem pour la hauteur.[m

   [01;34msubtype[m Client_Line_Type   [01;34mis[m Window_Line_Type   [01;34mrange[m [35m1[m[31m..[mTerm_Lines_Max [31m-[m [35m2[m[31m;[m
   [01;34msubtype[m Client_Column_Type [01;34mis[m Window_Column_Type [01;34mrange[m [35m1[m[31m..[mTerm_Columns_Max [31m-[m [35m2[m[31m;[m
   [01;34msubtype[m Client_Height_Type [01;34mis[m Height_Type [01;34mrange[m [35m0[m[31m..[mTerm_Lines_Max [31m-[m [35m2[m[31m;[m
   [01;34msubtype[m Client_Width_Type  [01;34mis[m Width_Type  [01;34mrange[m [35m0[m[31m..[mTerm_Columns_Max [31m-[m [35m2[m[31m;[m

   [31m-- On défini maintenant un type fenêtre.[m
   [31m-- En plus de ces coordonnées et dimensions, une fenêtre spécifie la[m
   [31m-- couleur du cadre, et la couleur de la case ferme. On pourra[m
   [31m-- également spécifier le type de cadre.[m

   [01;34mtype[m Frame_Type_Enum [01;34mis[m [31m([mSingle_Line_Frame[31m,[m Double_Line_Frame[31m);[m

   [01;34mtype[m Window_Type [01;34mis[m
      [01;34mrecord[m
	 L [31m:[m Window_Line_Type[31m;[m
	 C [31m:[m Window_Column_Type[31m;[m
	 H [31m:[m Window_Height_Type[31m;[m
	 W [31m:[m Window_Width_Type[31m;[m
	 Frame_Type      [31m:[m Frame_Type_Enum[31m;[m
	 Frame_Color     [31m:[m Color_Type[31m;[m
	 Close_Box_Color [31m:[m Color_Type[31m;[m
      [01;34mend[m [01;34mrecord[m[31m;[m [31m-- Window_Type[m

   [31m-- Un type zone cliente n'a pas besoin de coordonné, car elle sont[m
   [31m-- toujours (1,1). Il n'y aura donc que des dimensions.[m

   [01;34mtype[m Client_Type [01;34mis[m
      [01;34mrecord[m
	 H [31m:[m Client_Height_Type[31m;[m
	 W [31m:[m Client_Width_Type[31m;[m
      [01;34mend[m [01;34mrecord[m[31m;[m [31m-- Window_Type[m

   Metric_Error [31m:[m [01;34mexception[m[31m;[m [31m-- Positionnement ou dimensionnement incorrect.[m
   
   [01;34mfunction[m [01;30mReal_Length[m [31m([mLine [31m:[m [01;34min[m [32mWide_String[m[31m)[m [01;34mreturn[m Natural[31m;[m
   [31m-- Just to count escape colored Chars and tabulations.[m
   
   
   [01;34mprocedure[m Initialize[31m;[m         
   
   [01;34mprocedure[m Clear_Screen[31m;[m
   
   [01;34mprocedure[m Leave_And_Restore_Defaults[31m;[m
   
   
   [31m-- Dessine un fond d'espace de travail. Le rectangle défini par[m
   [31m-- les coordonnées et les dimensions, est rempli avec un caractère[m
   [31m-- spécial.   [m
   [01;34mprocedure[m [01;30mDraw_Desktop_Background[m [31m([m
				      L      [31m:[m [01;34min[m Line_Type[31m;[m
				      C      [31m:[m [01;34min[m Column_Type[31m;[m
				      H      [31m:[m [01;34min[m Height_Type[31m;[m
				      W      [31m:[m [01;34min[m Width_Type[31m;[m
				      Color  [31m:[m [01;34min[m Color_Type[31m);[m  
   
   [31m-- Dessine un fenêtre, c'est-à-dire un cadre, un fond rempli d'espace,[m
   [31m-- et un bouton « ferme » en haut à droite du cadre.[m
   [01;34mprocedure[m [01;30mDraw_Window[m [31m([mW [31m:[m [01;34min[m Window_Type[31m);[m
   
   [01;34mprocedure[m [01;30mEnlight_Window[m [31m([mW [31m:[m [01;34min[m Window_Type[31m);[m
   
   [01;34mprocedure[m [01;30mEnlighted_Draw[m [31m([m
		   W      [31m:[m [01;34min[m Window_Type[31m;[m
		   L      [31m:[m [01;34min[m Client_Line_Type[31m;[m
		   C      [31m:[m [01;34min[m Client_Column_Type[31m;[m
		   Color  [31m:[m [01;34min[m Color_Type[31m;[m
		   Text   [31m:[m [01;34min[m [32mWide_String[m[31m);[m
     
   [31m-- Dessine un caractère dans la zone cliente d'une fenêtre, aux coordonnées[m
   [31m-- spécifiées avec la couleur indiquée.[m
   [01;34mprocedure[m [01;30mDraw[m [31m([m
		   W      [31m:[m [01;34min[m Window_Type[31m;[m
		   L      [31m:[m [01;34min[m Client_Line_Type[31m;[m
		   C      [31m:[m [01;34min[m Client_Column_Type[31m;[m
		   Color  [31m:[m [01;34min[m Color_Type[31m;[m
		   Ch     [31m:[m [01;34min[m Wide_Character[31m);[m
   
   [31m-- Dessine du texte dans la zone cliente d'une fenêtre, aux coordonnées[m
   [31m-- spécifiées avec la couleur indiquée.[m
   [01;34mprocedure[m [01;30mDraw[m [31m([m
		   W      [31m:[m [01;34min[m Window_Type[31m;[m
		   L      [31m:[m [01;34min[m Client_Line_Type[31m;[m
		   C      [31m:[m [01;34min[m Client_Column_Type[31m;[m
		   Color  [31m:[m [01;34min[m Color_Type[31m;[m
		   Text   [31m:[m [01;34min[m [32mWide_String[m[31m);[m
   
   [01;34mprocedure[m [01;30mEnlighted_Draw[m [31m([m
			     W      [31m:[m [01;34min[m Window_Type[31m;[m
			     L      [31m:[m [01;34min[m Client_Line_Type[31m;[m
			     C      [31m:[m [01;34min[m Client_Column_Type[31m;[m
			     Color  [31m:[m [01;34min[m Color_Type[31m;[m
			     Ch     [31m:[m [01;34min[m Wide_Character[31m);[m
     
   [31m-- Dessine du texte centré. Comme c'est le centrage qui donne la coordonnée[m
   [31m-- horizontal, on ne spécifie bien sûre que la coordonnée vertical.[m
   [01;34mprocedure[m [01;30mDraw_Centered[m [31m([m
			    W      [31m:[m [01;34min[m Window_Type[31m;[m
			    L      [31m:[m [01;34min[m Client_Line_Type[31m;[m
			    Color  [31m:[m [01;34min[m Color_Type[31m;[m
			    Text   [31m:[m [01;34min[m [32mWide_String[m[31m);[m
   
   [01;34mprocedure[m [01;30mMove_Cursor_To[m [31m([m
			     W [31m:[m [01;34min[m Window_Type[31m;[m
			     L [31m:[m [01;34min[m Client_Line_Type[31m;[m
			     C [31m:[m [01;34min[m Client_Column_Type[31m);[m
   
   [01;34mfunction[m [01;30mIs_Printable[m [31m([mC [31m:[m [01;34min[m Wide_Character[31m)[m
			 [01;34mreturn[m [32mBoolean[m[31m;[m
   
   
   [01;34mfunction[m [01;30mFit_In_Screen[m [31m([m
			   L [31m:[m [01;34min[m Line_Type[31m;[m
			   C [31m:[m [01;34min[m Column_Type[31m;[m
			   H [31m:[m [01;34min[m Height_Type[31m;[m
			   W [31m:[m [01;34min[m Width_Type[31m)[m
			  [01;34mreturn[m [32mBoolean[m[31m;[m
   
   [01;34mfunction[m [01;30mFit_In_Window[m [31m([m
			   Window [31m:[m [01;34min[m Window_Type[31m;[m
			   L [31m:[m [01;34min[m Line_Type[31m;[m
			   C [31m:[m [01;34min[m Column_Type[31m;[m
			   H [31m:[m [01;34min[m Height_Type[31m;[m
			   W [31m:[m [01;34min[m Width_Type[31m)[m
			  [01;34mreturn[m [32mBoolean[m[31m;[m
   
   [01;34mfunction[m [01;30mFit_In_Client[m [31m([m
			   Window [31m:[m [01;34min[m Window_Type[31m;[m
			   L [31m:[m [01;34min[m Line_Type[31m;[m
			   C [31m:[m [01;34min[m Column_Type[31m;[m
			   H [31m:[m [01;34min[m Height_Type[31m;[m
			   W [31m:[m [01;34min[m Width_Type[31m)[m
			  [01;34mreturn[m [32mBoolean[m[31m;[m
   
   [01;34msubtype[m Key_Title_Type [01;34mis[m [32mString[m [31m([m[35m1[m[31m..[m[35m9[m[31m);[m
   
   Key_Title [31m:[m [01;34mconstant[m [01;34marray[m [31m([mKey_Type[31m)[m [01;34mof[m Key_Title_Type [31m:=[m 
     [31m([mKey_F1                [31m=>[m [31m"F1       "[m[31m,[m
      Key_F2                [31m=>[m [31m"F2       "[m[31m,[m
      Key_F3                [31m=>[m [31m"F3       "[m[31m,[m
      Key_F4                [31m=>[m [31m"F4       "[m[31m,[m
      Key_F5                [31m=>[m [31m"F5       "[m[31m,[m
      Key_F6                [31m=>[m [31m"F6       "[m[31m,[m
      Key_F7                [31m=>[m [31m"F7       "[m[31m,[m
      Key_F8                [31m=>[m [31m"F8       "[m[31m,[m
      Key_F9                [31m=>[m [31m"F9       "[m[31m,[m
      Key_F10               [31m=>[m [31m"F10      "[m[31m,[m
      Key_F11               [31m=>[m [31m"F11      "[m[31m,[m
      Key_F12               [31m=>[m [31m"F12      "[m[31m,[m
      Keypad_Home           [31m=>[m [31m"KP-Home  "[m[31m,[m
      Keypad_Up_Arrow       [31m=>[m [31m"KP-Up    "[m[31m,[m
      Keypad_Page_Up        [31m=>[m [31m"KP-PgUp  "[m[31m,[m
      Keypad_Left_Arrow     [31m=>[m [31m"KP-Left  "[m[31m,[m
      Keypad_Right_Arrow    [31m=>[m [31m"KP-Right "[m[31m,[m
      Keypad_End            [31m=>[m [31m"KP-End   "[m[31m,[m
      Keypad_Down_Arrow     [31m=>[m [31m"KP-Down  "[m[31m,[m
      Keypad_Page_Down      [31m=>[m [31m"KP-PgDn  "[m[31m,[m
      Keypad_Insert         [31m=>[m [31m"KP-Insert"[m[31m,[m
      Keypad_Delete         [31m=>[m [31m"KP-Delete"[m[31m,[m
      Key_Home              [31m=>[m [31m"Home     "[m[31m,[m
      Key_Up_Arrow          [31m=>[m [31m"Up       "[m[31m,[m
      Key_Page_Up           [31m=>[m [31m"Page-Up  "[m[31m,[m
      Key_Left_Arrow        [31m=>[m [31m"Left     "[m[31m,[m
      Key_Right_Arrow       [31m=>[m [31m"Right    "[m[31m,[m
      Key_End               [31m=>[m [31m"End      "[m[31m,[m
      Key_Down_Arrow        [31m=>[m [31m"Down     "[m[31m,[m
      Key_Page_Down         [31m=>[m [31m"Page-Down"[m[31m,[m
      Key_Insert            [31m=>[m [31m"Insert   "[m[31m,[m
      Key_Delete            [31m=>[m [31m"Delete   "[m[31m,[m
      Key_Print_Screen      [31m=>[m [31m"PrnScreen"[m[31m,[m
      Key_Pause_Break       [31m=>[m [31m"Pause    "[m[31m,[m
      Key_Escape            [31m=>[m [31m"Escape   "[m[31m,[m
      Key_Backspace         [31m=>[m [31m"Backspace"[m[31m,[m
      Key_Enter             [31m=>[m [31m"Enter    "[m[31m,[m
      Key_Tab               [31m=>[m [31m"Tab      "[m[31m,[m
      Key_Null              [31m=>[m [31m"Null     "[m[31m,[m
      Key_A                 [31m=>[m [31m"<A>      "[m[31m,[m
      Key_B                 [31m=>[m [31m"<B>      "[m[31m,[m
      Key_C                 [31m=>[m [31m"<C>      "[m[31m,[m
      Key_D                 [31m=>[m [31m"<D>      "[m[31m,[m
      Key_E                 [31m=>[m [31m"<E>      "[m[31m,[m
      Key_F                 [31m=>[m [31m"<F>      "[m[31m,[m
      Key_G                 [31m=>[m [31m"<G>      "[m[31m,[m
      Key_H                 [31m=>[m [31m"<H>      "[m[31m,[m
      Key_I                 [31m=>[m [31m"<I>      "[m[31m,[m
      Key_J                 [31m=>[m [31m"<J>      "[m[31m,[m
      Key_K                 [31m=>[m [31m"<K>      "[m[31m,[m
      Key_L                 [31m=>[m [31m"<L>      "[m[31m,[m
      Key_M                 [31m=>[m [31m"<M>      "[m[31m,[m
      Key_N                 [31m=>[m [31m"<N>      "[m[31m,[m
      Key_O                 [31m=>[m [31m"<O>      "[m[31m,[m
      Key_P                 [31m=>[m [31m"<P>      "[m[31m,[m
      Key_Q                 [31m=>[m [31m"<Q>      "[m[31m,[m
      Key_R                 [31m=>[m [31m"<R>      "[m[31m,[m
      Key_S                 [31m=>[m [31m"<S>      "[m[31m,[m
      Key_T                 [31m=>[m [31m"<T>      "[m[31m,[m
      Key_U                 [31m=>[m [31m"<U>      "[m[31m,[m
      Key_V                 [31m=>[m [31m"<V>      "[m[31m,[m
      Key_W                 [31m=>[m [31m"<W>      "[m[31m,[m
      Key_X                 [31m=>[m [31m"<X>      "[m[31m,[m
      Key_Y                 [31m=>[m [31m"<Y>      "[m[31m,[m
      Key_Z                 [31m=>[m [31m"<Z>      "[m[31m,[m
      Key_0                 [31m=>[m [31m"<0>      "[m[31m,[m
      Key_1                 [31m=>[m [31m"<1>      "[m[31m,[m
      Key_2                 [31m=>[m [31m"<2>      "[m[31m,[m
      Key_3                 [31m=>[m [31m"<3>      "[m[31m,[m
      Key_4                 [31m=>[m [31m"<4>      "[m[31m,[m
      Key_5                 [31m=>[m [31m"<5>      "[m[31m,[m
      Key_6                 [31m=>[m [31m"<6>      "[m[31m,[m
      Key_7                 [31m=>[m [31m"<7>      "[m[31m,[m
      Key_8                 [31m=>[m [31m"<8>      "[m[31m,[m
      Key_9                 [31m=>[m [31m"<9>      "[m[31m,[m
      Key_Minus             [31m=>[m [31m"<->      "[m[31m,[m
      Key_Equal             [31m=>[m [31m"<=>      "[m[31m,[m
      Key_Left_Square       [31m=>[m [31m"<[>      "[m[31m,[m
      Key_Right_Square      [31m=>[m [31m"<]>      "[m[31m,[m
      Key_Space             [31m=>[m [31m"< >      "[m[31m,[m
      Key_Semicolon         [31m=>[m [31m"<;>      "[m[31m,[m
      Key_Single_Quote      [31m=>[m [31m"<'>      "[m[31m,[m
      Key_Comma             [31m=>[m [31m"<,>      "[m[31m,[m
      Key_Dot               [31m=>[m [31m"<.>      "[m[31m,[m
      Key_Slash             [31m=>[m [31m"</>      "[m[31m,[m
      Key_Left_Single_Quote [31m=>[m [31m"<`>      "[m[31m,[m
      Keypad_Enter          [31m=>[m [31m"KP-< >   "[m[31m,[m
      Keypad_Slash          [31m=>[m [31m"KP-</>   "[m[31m,[m
      Keypad_Star           [31m=>[m [31m"KP-<*>   "[m[31m,[m
      Keypad_Minus          [31m=>[m [31m"KP-<->   "[m[31m,[m
      Keypad_Plus           [31m=>[m [31m"KP-<+>   "[m[31m,[m
      Keypad_Middle         [31m=>[m [31m"KP-Middle"[m[31m);[m
   
   [01;34msubtype[m Modifier_Key_Title_Type [01;34mis[m [32mString[m [31m([m[35m1[m[31m..[m[35m5[m[31m);[m
   
   Modifier_Key_Title [31m:[m [01;34mconstant[m [01;34marray[m [31m([mModifier_Key_Type[31m)[m [01;34mof[m
     Modifier_Key_Title_Type [31m:=[m [31m([m
				 No_Modifier_Key  [31m=>[m [31m"     "[m[31m,[m
				 Alt_Key          [31m=>[m [31m"  Alt"[m[31m,[m
				 Ctrl_Key         [31m=>[m [31m" Ctrl"[m[31m,[m
				 Shift_Key        [31m=>[m [31m"Shift"[m[31m);[m
   
   Draw_Buffer [31m:[m [32mWide_String[m [31m([mColumn_Type[31m);[m

[01;34mend[m M[31m.[mAnsi[31m.[mWindows [31m;[m 
