Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. ///===========================
  3.  
  4. #define CON_COLOR_BLUE          1
  5. #define CON_COLOR_GREEN         2
  6. #define CON_COLOR_RED           4
  7. #define CON_COLOR_BRIGHT        8
  8. /* öâåò ôîíà */
  9. #define CON_BGR_BLUE            0x10
  10. #define CON_BGR_GREEN           0x20
  11. #define CON_BGR_RED                     0x40
  12. #define CON_BGR_BRIGHT          0x80
  13.  
  14. ///===========================
  15. char console_init_command = FALSE;
  16. static inline void (* _stdcall con_init)(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t);
  17. static inline void (* _cdecl _printf)(const char* format,...);
  18. static inline void (* _stdcall _print)(const char* text);
  19. static inline void (* _stdcall _exit)(char bCloseWindow);
  20. static inline void (* __stdcall _gets)(char* str, int n);
  21. static inline int (* __stdcall _getch)(void);
  22. static inline int (* __stdcall con_get_font_height)(void);
  23. static inline int (* __stdcall con_set_cursor_height)(int new_height);
  24. unsigned (*__stdcall con_get_flags)(void);
  25. unsigned (*__stdcall con_set_flags)(unsigned new_flags);
  26. static inline void (*__stdcall con_cls)(void);
  27.  
  28. ///===========================
  29.  
  30. static inline void print(const char *text)
  31. {
  32.         _print(text);
  33. }
  34.  
  35. char _buf_gets[255];
  36. static inline char *gets(void)
  37. {
  38.         CONSOLE_INIT("console");
  39.         _gets(&_buf_gets,255);
  40.         return &_buf_gets;
  41. }
  42. static inline char getch(void)
  43. {
  44.         CONSOLE_INIT("console");
  45.         _getch();
  46. }
  47.  
  48. static inline void CONSOLE_INIT(char title[])
  49. {
  50.  
  51. if(console_init_command)return;
  52.  
  53. struct_import *imp;
  54.  
  55. imp = cofflib_load("/sys/lib/console.obj");
  56. if (imp == NULL)
  57.         exit();
  58.  
  59. con_init = ( _stdcall  void (*)(unsigned, unsigned, unsigned, unsigned, const char*))
  60.                 cofflib_procload (imp, "con_init");
  61. if (con_init == NULL)
  62.         exit();
  63.  
  64. _printf = ( _cdecl void (*)(const char*,...))
  65.                 cofflib_procload (imp, "con_printf");
  66. if (_printf == NULL)
  67.         exit();
  68.        
  69. _print = ( _cdecl void (*)(const char*))
  70.                 cofflib_procload (imp, "con_write_asciiz");
  71. if (_printf == NULL)
  72.         exit();
  73.  
  74. _exit = ( _stdcall void (*)(char))
  75.                 cofflib_procload (imp, "con_exit");
  76. if (_exit == NULL)
  77.         exit();
  78.  
  79. _gets = ( _stdcall void (*)(char*, int))
  80.                 cofflib_procload (imp, "con_gets");
  81. if (_gets == NULL)
  82.         exit();
  83.  
  84. _getch = ( _stdcall int (*)(void))
  85.                 cofflib_procload (imp, "con_getch2");
  86. if (_getch == NULL)
  87.         exit();
  88.  
  89. con_get_font_height = ( _stdcall int (*)(void))
  90.                 cofflib_procload (imp, "con_get_font_height");
  91. if (con_get_font_height == NULL)
  92.         exit();
  93.  
  94. con_set_cursor_height = ( _stdcall int (*)(int))
  95.                 cofflib_procload (imp, "con_set_cursor_height");
  96. if (con_set_cursor_height == NULL)
  97.         exit();
  98.  
  99. con_get_flags = ( _stdcall unsigned (*)(void))
  100.                 cofflib_procload (imp, "con_get_flags");
  101. if (con_get_flags == NULL)
  102.         exit();
  103.  
  104. con_set_flags = ( _stdcall unsigned (*)(unsigned))
  105.                 cofflib_procload (imp, "con_set_flags");
  106. if (con_set_flags == NULL)
  107.         exit();
  108.  
  109. con_cls = ( _stdcall void (*)(void))
  110.                 cofflib_procload (imp, "con_cls");
  111. if (con_cls == NULL)
  112.         exit();
  113.  
  114. con_init(-1, -1, -1, -1, title);
  115.  
  116. console_init_command = TRUE;
  117. }
  118.