console.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. Console Lib for CASIO fx-9860G
  3. by Mike Smith.
  4. */
  5. #ifndef CONSOLE_H
  6. #define CONSOLE_H
  7. #ifdef __cplusplus
  8. extern "C"{
  9. #endif
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include "fxlib.h"
  13. enum CONSOLE_SCREEN_SPEC{
  14. LINE_MAX = 32,
  15. LINE_DISP_MAX = 7,
  16. COL_DISP_MAX = 21,//21
  17. EDIT_LINE_MAX = 2048
  18. };
  19. enum CONSOLE_RETURN_VAL{
  20. CONSOLE_NEW_LINE_SET = 1,
  21. CONSOLE_SUCCEEDED = 0,
  22. CONSOLE_MEM_ERR = -1,
  23. CONSOLE_ARG_ERR = -2,
  24. CONSOLE_NO_EVENT = -3
  25. };
  26. enum CONSOLE_CURSOR_DIRECTION{
  27. CURSOR_UP,
  28. CURSOR_DOWN,
  29. CURSOR_LEFT,
  30. CURSOR_RIGHT
  31. };
  32. enum CONSOLE_LINE_TYPE{
  33. LINE_TYPE_INPUT,
  34. LINE_TYPE_OUTPUT
  35. };
  36. enum CONSOLE_CASE{
  37. LOWER_CASE,
  38. UPPER_CASE
  39. };
  40. struct line{
  41. unsigned char *str;
  42. unsigned char *tex_str;
  43. int readonly;
  44. int type;
  45. int start_col;
  46. int disp_len;
  47. unsigned char tex_flag;
  48. int tex_height, tex_width;
  49. };
  50. struct FMenu{
  51. char* name;
  52. char** str;
  53. unsigned char count;
  54. };
  55. struct location{
  56. int x;
  57. int y;
  58. };
  59. #define MAX_FMENU_ITEMS 7
  60. #define FMENU_TITLE_LENGHT 4
  61. #define is_wchar(c) ((c == 0x7F) || (c == 0xF7) || (c == 0xF9) || (c == 0xE5) || (c == 0xE6) || (c == 0xE7))
  62. #define printf(s) Console_Output((const unsigned char *)s);
  63. int Console_DelStr(unsigned char *str, int end_pos, int n);
  64. int Console_InsStr(unsigned char *dest, const unsigned char *src, int disp_pos);
  65. int Console_GetActualPos(const unsigned char *str, int disp_pos);
  66. int Console_GetDispLen(const unsigned char *str);
  67. int Console_MoveCursor(int direction);
  68. int Console_Input(const unsigned char *str);
  69. int Console_Output(const unsigned char *str);
  70. int Console_Clear_EditLine();
  71. int Console_NewLine(int pre_line_type, int pre_line_readonly);
  72. int Console_Backspace(void);
  73. int Console_GetKey(void);
  74. int Console_Init(void);
  75. int Console_Disp(void);
  76. int Console_FMenu(int key);
  77. void Console_FMenu_Init(void);
  78. int Console_Draw_FMenu(int key, struct FMenu* menu);
  79. char *Console_Make_Entry(const unsigned char* str);
  80. unsigned char *Console_GetLine(void);
  81. unsigned char* Console_GetEditLine();
  82. void Console_Draw_TeX_Popup(unsigned char* str, int width, int height);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif