Home Index classes Index static functions Index enumerations Index structure types

{Console|_functions}


CLASS {Console|_functions} , UNTESTED, NATIVE, ABSTRACT, INFINITE:


{Console} - a set of static functions to work with console. The embedded AL-IV operation << with the empty left side can be used to output text to the console, >> with a variable at the right side - to input string values. Still << and >> operations can be concatenated, there is a convenient way to provide prompted input: first, output a question, then ask to input something in response, e.g.:
<< "Please enter your age " >> STR age|_string_value


IMPORT : {NATIVE_Console} , {String_functions} , {Mathematics} .


---------------------------------------------------------- 'console colors'


ENUMERATION {colors|_of_console} :

        'BLACK|_COLOR' ,

        'BLUE|_COLOR' ,

        'GREEN|_COLOR' ,

        'TEAL|_COLOR' ,

        'MAROON|_COLOR' ,

        'MAGENTA|_COLOR' ,

        'OLIVE|_COLOR' ,

        'SILVER|_COLOR' ,

        'GRAY|_COLOR' ,

        'LIGHT_BLUE|_COLOR' ,

        'LIME|_COLOR' ,

        'CYAN|_COLOR' ,

        'RED|_COLOR' ,

        'FUCHSIA|_COLOR' ,

        'YELLOW|_COLOR' ,

        'WHITE|_COLOR' .


Color names for console. Usually, console can use 16 or 15 different colors.


FUN Console_color|_text_on_black (
     
{colors} C|olor_for_text ) , NATIVE


Setting text color while ouput to the console.


FUN Console_colors|_foreground_background (
     
{colors} F|oreground ,
     
{colors} B|ackground ) , NATIVE


Setting both text and paper colors for the console.


FUN Get_console_color (
     
INT Which|_color_0fore_1back ) ==> {colors} , NATIVE


Getting current text or paper color set for the console last time.


----------------------------------------- 'console ANSI (ESCAPE-sequences)'

  

FUN Console_ANSI|_colors|_control_support_add (
     
BOOL Add|_FALSE_to_remove ) , NATIVE


Setting the support for the ANSI console commands to control console colors. By default, the supporting is off. With the support turned on, escape sequences are supported which allows to control console colors without separate calls of functions Console_color/Console_colors (but calling functions Fg/Bg in the sequences of strings sending to the console).


FUN Support_console_ANSI_colors ==> BOOL , NATIVE


Returns TRUE, if the console is supporting ANSI sequences.


FUN Fg|Foreground_color_console ( {colors} C|olor_for_text ) ==> STR


Creates a escape-sequence to change the foreground (text) color to output to the console. E.g.: << Fg('RED') "This text is red" Fg('SILVER') " and now - SILVER"


FUN Bg|Background_color_console ( {colors} C|olor_for_text ) ==> STR


Creates a escape-sequence to change the background (paper) color to output to the console. E.g.: << Bg('BLUE') "This text is on the BLUE" Fg('BLACK') " and now on BLACK"


ENUMERATION {special_con|sole_control_commands} :

        'RESET|_NORMAL' ,

        'HI|GH_INTENSITY' ,

        'SAVE|_COLORS' ,

        'PREV|IOUS_COLORS_RESTORE' ,

        'INVERSE|_COLORS' .


Special commands for the console, to use them in the function Con(command)


FUN Con|sole_special_color_control (
     
{special_con} Sp|ecial_command ) ==> STR


Function to create a escape sequence corresponding to a special command from the enumeration {special_con}.


FUN Extended_write ( STR S|tring_to_write ) , CALLBACK



FUN Write_direct (
     
STR S|tring_to_write ) , NATIVE



------------------------------------------------------ 'console char input'

 

FUN Input_ready ==> BOOL , NATIVE


Returns TRUE, if any characters are ready in the input buffer.


FUN Get_char ==> STR , NATIVE


Awaiting at least one character typed and returns it (removing from the input queue).


FUN End_input ==> BOOL , NATIVE



FUN Key_pressed ( INT Key|_code ) ==> BOOL , NATIVE


Returns TRUE, if the specified keyboard key is pressed.


FUN Cursor_X|_position ==> INT , NATIVE


Returns current X coordinate in the console (which is the character position in the current line).


FUN Cursor_Y|_position ==> INT , NATIVE


Returns current Y coordinate in the console (which is the index of the current line from the top, starting from 0).


FUN Set_cursor_pos|ition ( INT X|_coordinate , INT Y|_coordinate )


Moves current output position in the console to the given characters coordinatates.


FUN Console_height ==> INT , NATIVE


Returns current console height in character lines.


FUN Console_width ==> INT , NATIVE


Returns current console width in characters.


FUN Set_console_size ( INT W|idth_console , INT H|eight_console )


Sets the console size.


----------------------------------------------------------- 'input numbers'

  

FUNCTION Input_int|_number ==> INT



FUNCTION Input_real|_number ==> REAL


END