Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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