Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.21 KB | None | 0 0
  1. #ifndef _COMMON_H
  2. #define _COMMON_H
  3.  
  4. #define TRUE 1
  5. #define FALSE 0
  6.  
  7. #define ALLOC farmalloc
  8. #define FREEMEM farfree
  9.  
  10. #define DEBUG 0
  11.  
  12. #include <stdio.h>
  13. #include <alloc.h>
  14. #include <stdlib.h>
  15. #include <conio.h>
  16. #include <time.h>
  17. #include <graphics.h>
  18. #include <dos.h>
  19. #include <bios.h>
  20. #include "menu.h"
  21. #include "ui.h"
  22. #include "music.h"
  23. #include "keyboard.h"
  24.  
  25. void CheckAlloc(void *);
  26. /* Check if an allocation completed successfully */
  27.  
  28. void DoNothing(void *);
  29. /* Just an ugly wordaround to remove some warnings */
  30.  
  31. void InitGraph(void *);
  32. /* Function to init graphics driver */
  33.  
  34. void ClearGraph(void *);
  35. /* Function to clear screen */
  36.  
  37. struct _Char
  38. /* Struct of a char */
  39. {
  40.     struct _Char *next;
  41.     /* pointer to left or right one */
  42.     char ch;
  43. };
  44. typedef struct _Char Char;
  45.  
  46. struct _Row
  47. /* Struct of a row */
  48. {
  49.     struct _Row *next;
  50.     /* pointer to up or down row */
  51.     Char *ch;
  52. };
  53. typedef struct _Row Row;
  54.  
  55. struct _MouseState
  56. /* Struct to save a mouse state */
  57. {
  58.     int x, y;
  59.     /* Saving where the mouse is */
  60.    
  61.     int key;
  62.     /* Saving if a button is pressed (0: None, 1: Left, 2: Right) */
  63.    
  64.     int release;
  65.     /* Saving if a button is released (0: None, 1: Left, 2: Right) */
  66. };
  67. typedef struct _MouseState MouseState;
  68.  
  69. struct _KeyMap
  70. /* Struct to save the alphabets' keys */
  71. {
  72.     int chs[26];
  73. };
  74. typedef struct _KeyMap KeyMap;
  75.  
  76. struct _NumMap
  77. /* Struct to save the numbers' keys */
  78. {
  79.     int num[10];
  80. };
  81. typedef struct _NumMap NumMap;
  82.  
  83. struct _State
  84. /* Main state structure */
  85. {
  86.     MouseState mouse;
  87.     /* Saving the current mouse state */
  88.    
  89.     KeyboardState keyboard;
  90.     /* Saving the current keyboard state */
  91.    
  92.     char isexit;
  93.     /* Saving the main exit flag */
  94.    
  95.     FormMenu *menu;
  96.     /* Saving pointer to form menus */
  97.    
  98.     Menu *contextmenu;
  99.     /* Saving pointer to the context menu */
  100.    
  101.     int iscontextmenu, cmmousex, cmmousey;
  102.     /* Saving context menu related states */
  103.    
  104.     KeyBinding *keybinding;
  105.     /* Saving pointer to all key binding definitions */
  106.    
  107.     Event *redraw;
  108.     /* Event of redrawing */
  109.    
  110.     char isclearmenu;
  111.     /* Flag to save clear menu state */
  112.    
  113.     char iskeyboard;
  114.     /* Flag to save if the menu is operating by mouse or by keyboard */
  115.    
  116.     int ischildwindow, childx1, childy1, childx2, childy2;
  117.     /* Saving child window related properties */
  118.    
  119.     char dotted, highlight;
  120.     /* The main text box related properties */
  121.    
  122.     char isdrag;
  123.     /* Flag of dragging child window */
  124.    
  125.     char ischosen;
  126.     /* Flag of drag-to-choose mode */
  127.    
  128.     int startrow, startchar, endrow, endchar;
  129.     /* Chosen area flags (the head and the rear locations ) */
  130.    
  131.     char isedit, chinese, fullwidth, chipunc;
  132.     /* Chinese-input related states */
  133.    
  134.     int editx1, edity1, editx2, edity2;
  135.     /* Currently available edit area flags */
  136.    
  137.     long delaytime;
  138.     /* True delay time for adjusting delay() */
  139.    
  140.     Row *filehead, *childhead, *childhead2;
  141.     /* File head pointers to save the main text and child texts */
  142.    
  143.     Row *cutboard;
  144.     /* Clipboard pointer */
  145.    
  146.     Char *searchstring;
  147.     /* Search string pointer */
  148.    
  149.     char isreplace;
  150.     /* Judging if in replacing mode */
  151.    
  152.     char *filename;
  153.     /* Name of currently open file */
  154.    
  155.     int cursorx, cursory, iscursor;
  156.     /* Location for the cursor */
  157.    
  158.     long cursortime;
  159.     /* Time-stamp logged here */
  160.    
  161.     int pagemovecount, currentrow, currentcolumn, rowcount;
  162.     /* Distance of current row */
  163.    
  164.     KeyMap map;
  165.     NumMap nummap;
  166.     /* Main key-mappings */
  167.    
  168.     FILE *hzkfile;
  169.     /* Font file HZK16 */
  170.    
  171.     char page;
  172.     char mousetype;
  173.     char nothing;
  174.     /* Some other flags */
  175.    
  176.     void *mousebuf;
  177.     /* Buffer to save mouse-floating area contents */
  178.    
  179.     char ispinyin, pinyinpage, sheng, yun;
  180.     /* Pinyin input method related temperate variables */
  181.    
  182.     Music curmusic;
  183.     /* Current playing music */
  184.    
  185.     int isput,lastmsx,lastmsy;
  186. };
  187. typedef struct _State State;
  188.  
  189. void FREEMEMRow(Row *row);
  190. /* Release all the memory that used by a row */
  191.  
  192. void FREEMEMChar(Char *ch);
  193. /* Free link table struct Char */
  194.  
  195. void Exit(void *n);
  196. /* Flag an exit event */
  197.  
  198. void CalcDelay(void *n);
  199. /* Use biostime to adjust delay() */
  200.  
  201. void Delay(void *n, long t);
  202. /* The fixed delay function */
  203.  
  204. /* Some key map definitions */
  205. #define RIGHTSHIFT  0x01
  206. #define LEFTSHIFT   0x02
  207. #define CTRL        0x04
  208. #define ALT         0x08
  209.  
  210. #define ESC       0x100
  211. #define TAB       0xf00
  212. #define NOMOD     0xff
  213.  
  214. #define ENTER     0x1c00
  215. #define SPACE     0x3900
  216. #define BACKSPACE 0x0e00
  217. #define DELETE    0x5300
  218.  
  219. #define PAGEUP    0x4900
  220. #define PAGEDOWN  0x5100
  221. #define HOME      0x4700
  222. #define CTRLHOME  0x7700
  223. #define END       0x4f00
  224. #define CTRLEND   0x7500
  225.  
  226. #define F1    0x3b00
  227. #define F2    0x3c00
  228. #define F3    0x3d00
  229. #define F4    0x3e00
  230. #define F5    0x3f00
  231. #define F6    0x4000
  232. #define F7    0x4100
  233. #define F8    0x4200
  234.  
  235. #define UP    0x4800
  236. #define DOWN  0x5000
  237. #define LEFT  0x4b00
  238. #define RIGHT 0x4d00
  239.  
  240. #define EQUAL 0xd00
  241. #define MINUS 0xc00
  242.  
  243. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement