Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _COMMON_H
- #define _COMMON_H
- #define TRUE 1
- #define FALSE 0
- #define ALLOC farmalloc
- #define FREEMEM farfree
- #define DEBUG 0
- #include <stdio.h>
- #include <alloc.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <time.h>
- #include <graphics.h>
- #include <dos.h>
- #include <bios.h>
- #include "menu.h"
- #include "ui.h"
- #include "music.h"
- #include "keyboard.h"
- void CheckAlloc(void *);
- /* Check if an allocation completed successfully */
- void DoNothing(void *);
- /* Just an ugly wordaround to remove some warnings */
- void InitGraph(void *);
- /* Function to init graphics driver */
- void ClearGraph(void *);
- /* Function to clear screen */
- struct _Char
- /* Struct of a char */
- {
- struct _Char *next;
- /* pointer to left or right one */
- char ch;
- };
- typedef struct _Char Char;
- struct _Row
- /* Struct of a row */
- {
- struct _Row *next;
- /* pointer to up or down row */
- Char *ch;
- };
- typedef struct _Row Row;
- struct _MouseState
- /* Struct to save a mouse state */
- {
- int x, y;
- /* Saving where the mouse is */
- int key;
- /* Saving if a button is pressed (0: None, 1: Left, 2: Right) */
- int release;
- /* Saving if a button is released (0: None, 1: Left, 2: Right) */
- };
- typedef struct _MouseState MouseState;
- struct _KeyMap
- /* Struct to save the alphabets' keys */
- {
- int chs[26];
- };
- typedef struct _KeyMap KeyMap;
- struct _NumMap
- /* Struct to save the numbers' keys */
- {
- int num[10];
- };
- typedef struct _NumMap NumMap;
- struct _State
- /* Main state structure */
- {
- MouseState mouse;
- /* Saving the current mouse state */
- KeyboardState keyboard;
- /* Saving the current keyboard state */
- char isexit;
- /* Saving the main exit flag */
- FormMenu *menu;
- /* Saving pointer to form menus */
- Menu *contextmenu;
- /* Saving pointer to the context menu */
- int iscontextmenu, cmmousex, cmmousey;
- /* Saving context menu related states */
- KeyBinding *keybinding;
- /* Saving pointer to all key binding definitions */
- Event *redraw;
- /* Event of redrawing */
- char isclearmenu;
- /* Flag to save clear menu state */
- char iskeyboard;
- /* Flag to save if the menu is operating by mouse or by keyboard */
- int ischildwindow, childx1, childy1, childx2, childy2;
- /* Saving child window related properties */
- char dotted, highlight;
- /* The main text box related properties */
- char isdrag;
- /* Flag of dragging child window */
- char ischosen;
- /* Flag of drag-to-choose mode */
- int startrow, startchar, endrow, endchar;
- /* Chosen area flags (the head and the rear locations ) */
- char isedit, chinese, fullwidth, chipunc;
- /* Chinese-input related states */
- int editx1, edity1, editx2, edity2;
- /* Currently available edit area flags */
- long delaytime;
- /* True delay time for adjusting delay() */
- Row *filehead, *childhead, *childhead2;
- /* File head pointers to save the main text and child texts */
- Row *cutboard;
- /* Clipboard pointer */
- Char *searchstring;
- /* Search string pointer */
- char isreplace;
- /* Judging if in replacing mode */
- char *filename;
- /* Name of currently open file */
- int cursorx, cursory, iscursor;
- /* Location for the cursor */
- long cursortime;
- /* Time-stamp logged here */
- int pagemovecount, currentrow, currentcolumn, rowcount;
- /* Distance of current row */
- KeyMap map;
- NumMap nummap;
- /* Main key-mappings */
- FILE *hzkfile;
- /* Font file HZK16 */
- char page;
- char mousetype;
- char nothing;
- /* Some other flags */
- void *mousebuf;
- /* Buffer to save mouse-floating area contents */
- char ispinyin, pinyinpage, sheng, yun;
- /* Pinyin input method related temperate variables */
- Music curmusic;
- /* Current playing music */
- int isput,lastmsx,lastmsy;
- };
- typedef struct _State State;
- void FREEMEMRow(Row *row);
- /* Release all the memory that used by a row */
- void FREEMEMChar(Char *ch);
- /* Free link table struct Char */
- void Exit(void *n);
- /* Flag an exit event */
- void CalcDelay(void *n);
- /* Use biostime to adjust delay() */
- void Delay(void *n, long t);
- /* The fixed delay function */
- /* Some key map definitions */
- #define RIGHTSHIFT 0x01
- #define LEFTSHIFT 0x02
- #define CTRL 0x04
- #define ALT 0x08
- #define ESC 0x100
- #define TAB 0xf00
- #define NOMOD 0xff
- #define ENTER 0x1c00
- #define SPACE 0x3900
- #define BACKSPACE 0x0e00
- #define DELETE 0x5300
- #define PAGEUP 0x4900
- #define PAGEDOWN 0x5100
- #define HOME 0x4700
- #define CTRLHOME 0x7700
- #define END 0x4f00
- #define CTRLEND 0x7500
- #define F1 0x3b00
- #define F2 0x3c00
- #define F3 0x3d00
- #define F4 0x3e00
- #define F5 0x3f00
- #define F6 0x4000
- #define F7 0x4100
- #define F8 0x4200
- #define UP 0x4800
- #define DOWN 0x5000
- #define LEFT 0x4b00
- #define RIGHT 0x4d00
- #define EQUAL 0xd00
- #define MINUS 0xc00
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement