Subversion Repositories Kolibri OS

Rev

Rev 8582 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. console.obj exports the following functions
  2.  
  3. typedef unsigned long dword; /* 32-bit unsigned integer */
  4. typedef unsigned short word; /* 16-bit unsigned integer */
  5.  
  6. void __stdcall con_init(dword wnd_width, dword wnd_height,
  7.         dword scr_width, dword scr_height, const char* title);
  8. Console initialization. Must be called only once.
  9. wnd_width, wnd_height - width and height (in units of characters) of the visible region;
  10. scr_width, scr_height - width and height (in units of characters) of console;
  11. Any of these four parameters can be set to -1 (=0xFFFFFFFF)
  12. to use the library's default values;
  13. title - console window's caption.
  14.  
  15. void __stdcall con_exit(bool bCloseWindow);
  16. You should call this funstion at the end of the program.
  17. If bCloseWindow is zero, the string "[Finished]" will be added to the caption of the window
  18. and the console window will remain on the screen until the user
  19. closes it.
  20.  
  21. void __stdcall con_set_title(const char* title);
  22. Set new window caption.
  23.  
  24. void __stdcall con_write_asciiz(const char* string);
  25. Display ASCIIZ-string to the console at the current position, shifting
  26. the current position.
  27.  
  28. void __stdcall con_write_string(const char* string, dword length);
  29. Similar to con_write_asciiz, but length of the string must be given as a separate parameter
  30.  
  31. int __cdecl con_printf(const char* format, ...)
  32. Standard "printf" function from ANSI C.
  33.  
  34. dword __stdcall con_get_flags(void);
  35. Get output flags.
  36. dword __stdcall con_set_flags(dword new_flags);
  37. Set output flags. This function returns previous values.
  38. Flags (bitmask):
  39. /* text color */
  40. #define CON_COLOR_BLUE          0x01
  41. #define CON_COLOR_GREEN 0x02
  42. #define CON_COLOR_RED           0x04
  43. #define CON_COLOR_BRIGHT        0x08
  44. /* background color */
  45. #define CON_BGR_BLUE            0x10
  46. #define CON_BGR_GREEN           0x20
  47. #define CON_BGR_RED             0x40
  48. #define CON_BGR_BRIGHT          0x80
  49. /* output controls */
  50. #define CON_IGNORE_SPECIALS     0x100
  51. /* if this flag is cleared, function interprets special characters:
  52. 10 ('\n') - next line
  53. 13 ('\r') - carriage return
  54. 8 ('\b') - backspace
  55. 9 ('\t') - tab
  56. 27 ('\033' = '\x1B') - the beginning of Esc-sequences;
  57. otherwise, these characters will be displayed like ordinary characters. */
  58. /* Supported Esc-sequences:
  59.         Esc[<number1>;<number2>;<number3>m - choice of character attributes:
  60.                 You can specify one, two or three codes in any order;
  61.                 0 = normal mode (white on black)
  62.                 1 = bright selection
  63.                 5 = bright background
  64.                 7 = inverse mode (black on white)
  65.                 30 = black characters
  66.                 31 = red characters
  67.                 32 = green characters
  68.                 33 = yellow characters
  69.                 34 = blue characters
  70.                 35 = magenta characters
  71.                 36 = cyan characters
  72.                 37 = white characters
  73.                 40 = black background
  74.                 41 = red background
  75.                 42 = green background
  76.                 43 = yellow background
  77.                 44 = blue background
  78.                 45 = magenta background
  79.                 46 = cyan background
  80.                 47 = white background
  81.         The following sequences appeared in version 5 of library:
  82.         Esc[<number>A - move cursor to <number> lines up
  83.         Esc[<number>B - move cursor to <number> lines down
  84.         Esc[<number>C - move cursor to <number> positions right
  85.         Esc[<number>D - move cursor to <number> positions left
  86.         Esc[<number1>;<number2>H = Esc[<number1>;<number2>f -
  87.                 move cursor to <number1>,<number2>     
  88.         Esc[2J - clear screen, move cursor to upper left corner        
  89.         The following sequences appeared in version 9 of library:      
  90.         Esc[J or Esc[0J - Erase everything below cursor
  91.         Esc[1J - Erase everything above cursor 
  92.         Esc[K - Erase in line
  93.         Esc[<number>L - Insert <number> lines at the cursor position
  94.         Esc[<number>M - Delete <number> lines at the cursor position
  95.         Esc[<number>P - Delete <number chars at the cursor position
  96.         Esc[<number>X - Erase <number chars at the cursor position
  97.         Esc[<number>d - Set cursor to absolute line position
  98.         Esc[<number1>;<number2>f - Cursor position
  99.         Esc[<mode>h - Set mode (see below)
  100.         Esc[<mode>l - Reset mode (see below)
  101.         The following modes are currently supported:
  102.                 ?1 - Application cursor keys
  103.                 ?25 - Show/Hide cursor
  104.                 ?1049 - Alternative screen buffer. The alternative buffer has no scrollback.
  105.         Esc[<number1>;<number2>r - Set scroll region from row <number1> to row <number2>
  106.                 (Use in combination with insert/delete lines)
  107.         Esc]0<string>ST/BEL - Set window caption. The string is terminated with ASCII char 0x07 or 0x9C.
  108.         Esc]2<string>ST/BEL - Implemented identical as Esc]0.
  109. */
  110. /* signal "console closed"; appeared in version 6;
  111.         ignored by con_set_flags */
  112. #define CON_WINDOW_CLOSED 0x200
  113. The default value for flags = 7. (grey text on black background)
  114.  
  115. int __stdcall con_get_font_height(void);
  116. Get the height of the font.
  117.  
  118. int __stdcall con_get_cursor_height(void);
  119. Get the height of the cursor.
  120. int __stdcall con_set_cursor_height(int new_height);
  121. Set the height of the cursor. This function returns previous value.
  122. An attempt to set the value out of the correct interval (from 0 to
  123. font_height-1) is ignored.
  124. Cursor with zero height isn't displayed.
  125. Default value: - 15% from  font height.
  126.  
  127. int __stdcall con_getch(void);
  128. Get one character from the keyboard.
  129.  
  130. For normal characters function returns ASCII-code. For extended
  131. characters (eg, Fx, and arrows), first function call returns 0
  132. and second call returns the extended code (similar to the DOS-function
  133. input). Starting from version 7, after closing the console window,
  134. this function returns 0.
  135.  
  136. word __stdcall con_getch2(void);
  137. Reads a character from the keyboard. Low byte contains the ASCII-code
  138. (0 for extended characters), high byte - advanced code (like in BIOS
  139. input functions). Starting from version 7, after closing the console
  140. window, this function returns 0.
  141.  
  142. int __stdcall con_kbhit(void);
  143. Returns 1 if a key was pressed, 0 otherwise. To read pressed keys use
  144. con_getch and con_getch2. Starting from version 6, after closing
  145. the console window, this function returns 1.
  146.  
  147. char* __stdcall con_gets(char* str, int n);
  148. Reads a string from the keyboard. Reading is interrupted when got
  149. "new line" character, or after reading the (n-1) characters (depending on
  150. what comes first). In the first case the newline is also recorded in the
  151. str. The acquired line is complemented by a null character.
  152. Starting from version 6, the function returns a pointer to the entered
  153. line if reading was successful, and NULL if the console window was closed.
  154.  
  155. typedef int (__stdcall * con_gets2_callback)(int keycode, char** pstr, int* pn, int* ppos);
  156. char* __stdcall con_gets2(con_gets2_callback callback, char* str, int n);
  157. Con_gets completely analogous, except that when the user
  158. press unrecognized key, it calls the specified callback-procedure
  159. (which may, for example, handle up / down for history and tab to enter
  160. autocompletion). You should pass to the procedure: key code and three pointers
  161. - to the string, to the maximum length and to the current position.
  162. function may change the contents of string and may change the string
  163. itself (for example, to reallocate memory for increase the limit),
  164. maximum length, and position of the line - pointers are passed for it.
  165. Return value: 0 = line wasn't changed 1 = line changed, you should
  166. remove old string and display new, 2 = line changed, it is necessary
  167. to display it; 3 = immediately exit the function.
  168. Starting from version 6, the function returns a pointer to the entered
  169. line with the successful reading, and NULL if the console window was closed.
  170.  
  171. void __stdcall con_cls();
  172. Clear screen and set cursor at upper left corner.
  173.  
  174.  
  175. void __stdcall con_get_cursor_pos(int* px, int* py);
  176. Wrote current (x) coordinate of cursor to *px, and (y) to *py.
  177.  
  178. void __stdcall con_set_cursor_pos(int x, int y);
  179. Set the cursor position to the specified coordinates. If any of the
  180. parameters beyond the relevant range (from 0 to 1 scr_width-
  181. for x, from 0 to 1 for scr_height-y, scr_width scr_height and were asked if
  182. call con_init), then the corresponding coordinate of the cursor does not change.
  183.  
  184. int __stdcall con_get_input(char* buf, int buflen);
  185. Read as many input events as are available and fit in the receive buffer.
  186. Input event can be regular ASCII code from keyboard, but also escape codes for special keys.
  187. The support for mouse events via escape codes is not yet implemented.