Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 17.66 KB | None | 0 0
  1. void CheckAlloc(void *);
  2. /* Check if an allocation completed successfully */
  3.  
  4. void DoNothing(void *);
  5. /* Just an ugly wordaround to remove some warnings */
  6.  
  7. void InitGraph(void *);
  8. /* Function to init graphics driver */
  9.  
  10. void ClearGraph(void *);
  11. /* Function to clear screen */
  12.  
  13. struct _Char
  14. /* Struct of a char */
  15. {
  16.     struct _Char *next;
  17.     /* pointer to left or right one */
  18.     char ch;
  19. };
  20. typedef struct _Char Char;
  21.  
  22. struct _Row
  23. /* Struct of a row */
  24. {
  25.     struct _Row *next;
  26.     /* pointer to up or down row */
  27.     Char *ch;
  28. };
  29. typedef struct _Row Row;
  30.  
  31. struct _MouseState
  32. /* Struct to save a mouse state */
  33. {
  34.     int x, y;
  35.     /* Saving where the mouse is */
  36.    
  37.     int key;
  38.     /* Saving if a button is pressed (0: None, 1: Left, 2: Right) */
  39.    
  40.     int release;
  41.     /* Saving if a button is released (0: None, 1: Left, 2: Right) */
  42. };
  43. typedef struct _MouseState MouseState;
  44.  
  45. struct _KeyMap
  46. /* Struct to save the alphabets' keys */
  47. {
  48.     int chs[26];
  49. };
  50. typedef struct _KeyMap KeyMap;
  51.  
  52. struct _NumMap
  53. /* Struct to save the numbers' keys */
  54. {
  55.     int num[10];
  56. };
  57. typedef struct _NumMap NumMap;
  58.  
  59. struct _State
  60. /* Main state structure */
  61. {
  62.     MouseState mouse;
  63.     /* Saving the current mouse state */
  64.    
  65.     KeyboardState keyboard;
  66.     /* Saving the current keyboard state */
  67.    
  68.     char isexit;
  69.     /* Saving the main exit flag */
  70.    
  71.     FormMenu *menu;
  72.     /* Saving pointer to form menus */
  73.    
  74.     Menu *contextmenu;
  75.     /* Saving pointer to the context menu */
  76.    
  77.     int iscontextmenu, cmmousex, cmmousey;
  78.     /* Saving context menu related states */
  79.    
  80.     KeyBinding *keybinding;
  81.     /* Saving pointer to all key binding definitions */
  82.    
  83.     Event *redraw;
  84.     /* Event of redrawing */
  85.    
  86.     char isclearmenu;
  87.     /* Flag to save clear menu state */
  88.    
  89.     char iskeyboard;
  90.     /* Flag to save if the menu is operating by mouse or by keyboard */
  91.    
  92.     int ischildwindow, childx1, childy1, childx2, childy2;
  93.     /* Saving child window related properties */
  94.    
  95.     char dotted, highlight;
  96.     /* The main text box related properties */
  97.    
  98.     char isdrag;
  99.     /* Flag of dragging child window */
  100.    
  101.     char ischosen;
  102.     /* Flag of drag-to-choose mode */
  103.    
  104.     int startrow, startchar, endrow, endchar;
  105.     /* Chosen area flags (the head and the rear locations ) */
  106.    
  107.     char isedit, chinese, fullwidth, chipunc;
  108.     /* Chinese-input related states */
  109.    
  110.     int editx1, edity1, editx2, edity2;
  111.     /* Currently available edit area flags */
  112.    
  113.     long delaytime;
  114.     /* True delay time for adjusting delay() */
  115.    
  116.     Row *filehead, *childhead, *childhead2;
  117.     /* File head pointers to save the main text and child texts */
  118.    
  119.     Row *cutboard;
  120.     /* Clipboard pointer */
  121.    
  122.     Char *searchstring;
  123.     /* Search string pointer */
  124.    
  125.     char isreplace;
  126.     /* Judging if in replacing mode */
  127.    
  128.     char *filename;
  129.     /* Name of currently open file */
  130.    
  131.     int cursorx, cursory, iscursor;
  132.     /* Location for the cursor */
  133.    
  134.     long cursortime;
  135.     /* Time-stamp logged here */
  136.    
  137.     int pagemovecount, currentrow, currentcolumn, rowcount;
  138.     /* Distance of current row */
  139.    
  140.     KeyMap map;
  141.     NumMap nummap;
  142.     /* Main key-mappings */
  143.    
  144.     FILE *hzkfile;
  145.     /* Font file HZK16 */
  146.    
  147.     char page;
  148.     char mousetype;
  149.     char nothing;
  150.     /* Some other flags */
  151.    
  152.     void *mousebuf;
  153.     /* Buffer to save mouse-floating area contents */
  154.    
  155.     char ispinyin, pinyinpage, sheng, yun;
  156.     /* Pinyin input method related temperate variables */
  157.    
  158.     Music curmusic;
  159.     /* Current playing music */
  160.    
  161.     int isput,lastmsx,lastmsy;
  162. };
  163. typedef struct _State State;
  164.  
  165. void FREEMEMRow(Row *row);
  166. /* Release all the memory that used by a row */
  167.  
  168. void FREEMEMChar(Char *ch);
  169. /* Free link table struct Char */
  170.  
  171. void Exit(void *n);
  172. /* Flag an exit event */
  173.  
  174. void CalcDelay(void *n);
  175. /* Use biostime to adjust delay() */
  176.  
  177. void Delay(void *n, long t);
  178. /* The fixed delay function */
  179.  
  180. void MsgBox(void *n, char *title, char *message);
  181. /* Message Box function */
  182.  
  183. void DrawOpenWindow(void *n);
  184. /* Draw "Open" window */
  185.  
  186. void DrawSaveWindow(void *);
  187. /* Draw "Save" window */
  188.  
  189. void DrawSaveAsWindow(void *);
  190. /* Draw "Save as" window */
  191.  
  192. void DrawFindWindow(void *);
  193. /* Draw "Find" window */
  194.  
  195. void DrawReplaceWindow(void *);
  196. /* Draw "Replace" window */
  197.  
  198. void SwitchTextBox(void *n);
  199. /* Switch text box for replace window */
  200.  
  201. void CloseChildWindow(void *);
  202. /* Close the child window */
  203.  
  204. void CheckChildButton(void *);
  205. /* Check if clicked an button on child window */
  206.  
  207. void MoveChildWindow(void *n);
  208. /* Check and move the child window */
  209.  
  210. void CheckEnterSubmit(void *n);
  211. /* Check Enter key to submit the currently opened window */
  212.  
  213. void SubmitButton(void *n);
  214. /* Submit key functions */
  215.  
  216. void OpenButton(void *n);
  217. /* Check if the Open window button is clicked */
  218.  
  219. void MsgBoxButton(void *n);
  220. /* Check if the Message Box button is clicked */
  221.  
  222. void CancelButton(void *n);
  223. /* Cancel button is clicked */
  224.  
  225. void Compile(void *n);
  226. /* Compile and run the currently open C code */
  227.  
  228. struct _event
  229. {
  230.     void (*func)(void *);
  231.     struct _event *next;
  232. };
  233. typedef struct _event Event;
  234.  
  235. void RegEvent(Event *e, void (*func)(void *));
  236. /* Register a new func as event */
  237.  
  238. void DoEvent(Event *e, void *data);
  239. /* Do a event */
  240.  
  241. void InitEvent(Event *e);
  242. /* Initialize a event */
  243.  
  244. void FreeEvent(Event *e);
  245. /* Free memory of an event chain */
  246.  
  247. struct _KeyboardState
  248. {
  249.     int key;
  250.     int modifier;
  251. };
  252. typedef struct _KeyboardState KeyboardState;
  253.  
  254. struct _keybinding
  255. {
  256.     KeyboardState key;
  257.     Event *event;
  258.     struct _keybinding *next;
  259. };
  260. typedef struct _keybinding KeyBinding;
  261.  
  262. void CheckKeyboard(void *n);
  263. /* Read keyboard states and save it */
  264.  
  265. void LoadKeyBinding(void *n);
  266. /* Load-time initialization for key bindings */
  267.  
  268. void InitKeyBinding(KeyBinding *kb);
  269. /* Initialize a key binding struct */
  270.  
  271. void AddKeyBinding(void *n, KeyboardState key, Event *event);
  272. /* Add a key binding with an event */
  273.  
  274. KeyboardState KBState(int key, int modifier);
  275. /* Simply packaging a key binding into a KeyboardState struct */
  276.  
  277. void CheckKeyBinding(void *n);
  278. /* Check if matches a key binding */
  279.  
  280. void LoadKeyMap(void *n);
  281. /* Load A-Z Keymappings (Recorded manually by Felix Yan) */
  282.  
  283. void CheckChar(void *n, int key, int shift, int chipunc, int fullwidth, char *punc);
  284. /* Check if a character should be inserted to text */
  285.  
  286. void CharInput(void *n);
  287. /* Fetch & switch characters (Recorded manually by Felix Yan) */
  288.  
  289. char Lowercase(char ch);
  290. /* Lowercase of a char */
  291.  
  292. int NotNameChar(char ch);
  293. /* Judge if a char is a name char */
  294.  
  295. int IsNumber(char ch);
  296. /* Judge if a char is a number */
  297.  
  298. void OutTextxy(void *n, int x, int y, char *p, int color);
  299. /* Output a normal string that may include any character including Chinese */
  300.  
  301. void OpenHZK(void *n);
  302. /* Open the HZK file on the program loading progress */
  303.  
  304. void CloseHZK(void *n);
  305. /* Close the HZK file when closing program */
  306.  
  307. struct _KeyboardState
  308. {
  309.     int key;
  310.     int modifier;
  311. };
  312. typedef struct _KeyboardState KeyboardState;
  313.  
  314. struct _keybinding
  315. {
  316.     KeyboardState key;
  317.     Event *event;
  318.     struct _keybinding *next;
  319. };
  320. typedef struct _keybinding KeyBinding;
  321.  
  322. void CheckKeyboard(void *n);
  323. /* Read keyboard states and save it */
  324.  
  325. void LoadKeyBinding(void *n);
  326. /* Load-time initialization for key bindings */
  327.  
  328. void InitKeyBinding(KeyBinding *kb);
  329. /* Initialize a key binding struct */
  330.  
  331. void AddKeyBinding(void *n, KeyboardState key, Event *event);
  332. /* Add a key binding with an event */
  333.  
  334. KeyboardState KBState(int key, int modifier);
  335. /* Simply packaging a key binding into a KeyboardState struct */
  336.  
  337. void CheckKeyBinding(void *n);
  338. /* Check if matches a key binding */
  339.  
  340. void LoadKeyMap(void *n);
  341. /* Load A-Z Keymappings (Recorded manually by Felix Yan) */
  342.  
  343. void CheckChar(void *n, int key, int shift, int chipunc, int fullwidth, char *punc);
  344. /* Check if a character should be inserted to text */
  345.  
  346. void CharInput(void *n);
  347. /* Fetch & switch characters (Recorded manually by Felix Yan) */
  348.  
  349. struct _Logo
  350. /* Struct of a part of the whole logo, saving some points that the
  351.  * program will string them together with line. */
  352. {
  353.     int n;
  354.     /* Number of the points */
  355.     int *x, *y;
  356.     /* X,Y coordinates for every point */
  357. };
  358. typedef struct _Logo Logo;
  359.  
  360. struct _Logos
  361. /* Struct of the whole logo, saving pointers to each part of the logo.*/
  362. {
  363.     int n;
  364.     /* Number of parts */
  365.     Logo **logo;
  366.     /* pointer to each logo */
  367. };
  368. typedef struct _Logos Logos;
  369.  
  370. Logos *GetLogoXY(void);
  371. /* Function to read the logo from file and return a pointer to it. */
  372.  
  373. void DrawLogo(void *);
  374. /* Draw out the Logo */
  375.  
  376. struct _Menu
  377. {
  378.     char *text;
  379.     char enabled, moveover;
  380.     struct _Menu *next;
  381.     Event *func;
  382. };
  383. typedef struct _Menu Menu;
  384.  
  385. struct _FormMenu
  386. {
  387.     Menu *menu;
  388.     char *text;
  389.     char moveover, pressed;
  390.     struct _FormMenu *next;
  391. };
  392. typedef struct _FormMenu FormMenu;
  393.  
  394. void InitFormMenuItem(FormMenu *menu);
  395. /* Initialize a form menu item, give default values */
  396.  
  397. void AddFormMenu(FormMenu *menu, char *title);
  398. /* Add an form menu item to an existing chain */
  399.  
  400. void DrawFormMenu(void *null);
  401. /* Draw all the form menus */
  402.  
  403. void IsMoveOverFormMenu(void *n);
  404. /* Judging if mouse is moving over a form menu */
  405.  
  406. void DrawMoveOverFormMenu(void *n);
  407. /* Draw the highlight effect of moving-over form menu */
  408.  
  409. void IsClickFormMenu(void *n);
  410. /* Judging if clicked an form menu */
  411.  
  412. void DoubleOver(void *n);
  413. /* Only a workaround for form menus */
  414.  
  415. void DrawClickFormMenu(void *n);
  416. /* Draw click effect for form menus */
  417.  
  418. void InitMenuItem(Menu *menu);
  419. /* Menu item initialization */
  420.  
  421. void AddMenu(Menu *menu, char enabled, char *title, Event *func);
  422. /* Add a menu item to an existing menu chain */
  423.  
  424. void DrawMenu(void *n, Menu *menu, int x, int y);
  425. /* Draw a menu */
  426.  
  427. void IsMoveOverMenu(void *n);
  428. /* Judging if moving over a menu item */
  429.  
  430. void DrawMoveOverMenu(void *n);
  431. /* Draw if moving over a menu item */
  432.  
  433. void ClearMenuMoveOver(void *n);
  434. /* Clear all move over states */
  435.  
  436. Menu *GetUpMenu(FormMenu *formmenu, Menu *menu);
  437. /* Get the upper menu item */
  438.  
  439. Menu *GetDownMenu(FormMenu *formmenu, Menu *menu);
  440. /* Get the down menu item */
  441.  
  442. FormMenu *GetLeftFormMenu();
  443. /* Get left form menu item */
  444.  
  445. FormMenu *GetRightFormMenu();
  446. /* Get right form menu item */
  447.  
  448. FormMenu *FindPressedFormMenu(void *n);
  449. /* Find the currently pressed form menu */
  450.  
  451. Menu *FindMoveOverMenu(void *n);
  452. /* Find the currently moving over menu item */
  453.  
  454. void MenuUp(void *n);
  455. /* Menu up! */
  456.  
  457. void MenuDown(void *n);
  458. /* Menu down! */
  459.  
  460. void FormMenuLeft(void *n);
  461. /* Move left form menu */
  462.  
  463. void FormMenuRight(void *n);
  464. /* Move right form menu */
  465.  
  466. void AddMenuToFormMenu(Menu *menu, FormMenu *formmenu);
  467. /* Add a menu to a form menu */
  468.  
  469. void OpenMenu(FormMenu *menu, int n);
  470. /* Open a form menu */
  471.  
  472. void OpenMenu0(void *n);
  473. /* Open the first form menu */
  474.  
  475. void OpenMenu1(void *n);
  476. /* Open the second form menu */
  477.  
  478. void OpenMenu2(void *n);
  479. /* Open the third form menu */
  480.  
  481. void OpenMenu3(void *n);
  482. /* Open the forth form menu */
  483.  
  484. void OpenMenu4(void *n);
  485. /* Open the fifth form menu */
  486.  
  487. void ChildTitleContextMenu(void *n);
  488. /* Context menu operations */
  489.  
  490. int InitMouse();
  491. /* Initialize mouse */
  492.  
  493. void ShowMouse(void *n, int x, int y);
  494. /* Show the windows-like mouse pointer */
  495.  
  496. void HideMouse(void *n);
  497. /* Hide the windows-like mouse pointer */
  498.  
  499. void GetMouseXY(int *x,int *y);
  500. /* Get current mouse position */
  501.  
  502. void SetMouseXY(int x,int y);
  503. /* Move mouse to specific position */
  504.  
  505. int GetPressInfo(int button);
  506. /* Get mouse pressing info */
  507.  
  508. int GetReleaseInfo(int button);
  509. /* Get mouse release info */
  510.  
  511. void SetXRange(int min,int max);
  512. /* Set mouse movable range along X axis */
  513.  
  514. void SetYRange(int min,int max);
  515. /* Set mouse movable range along Y axis */
  516.  
  517. void DrawMouse(int x,int y);
  518. /* Draw moving mouse pointer */
  519.  
  520. void DrawMouseEdit(int x,int y);
  521. /* Draw editing mouse pointer */
  522.  
  523. int PinRA(int x, int y, int x1, int y1, int x2, int y2);
  524. /* Judging if a pointer is in a rectangle */
  525.  
  526. void LoadMouse(void *null);
  527. /* Loading default mouse properties */
  528.  
  529. void RedrawMouse(void *n);
  530. /* Redraw the mouse pointer if needed */
  531.  
  532. void MouseAway(void *n);
  533. /* Disable mouse pointer to avoid some bugs */
  534.  
  535. void PlayMusic(void *n);
  536. /* Music daemon, called in everything time of mainloop */
  537.  
  538. void StartupMusic(void *n);
  539. /* Play startup music */
  540.  
  541. void LogoutMusic(void *n);
  542. /* Play logout music */
  543.  
  544. void RandomMusic(void *n);
  545. /* Play a random music, except for startup music and logout music */
  546.  
  547. enum _Music
  548. /* Enumerator of songs */
  549. {
  550.     None,
  551.     Startup,
  552.     Logout,
  553.     Laputa,
  554.     Musicbox,
  555.     Lovesale,
  556.     Romeo,
  557.     Joy,
  558.     Minuet,
  559.     Turkey,
  560.     LoveIsBlue
  561. };
  562. typedef enum _Music Music;
  563.  
  564. void IMSwitch(void *n);
  565. /* Input method switch (en <=> zh) */
  566.  
  567. void PuncSwitch(void *n);
  568. /* Punctuation switch (en <=> zh) */
  569.  
  570. void WidthSwitch(void *n);
  571. /* Width switch (fullwidth <=> halfwidth) */
  572.  
  573. void CheckIMSwitch(void *n);
  574. /* Check if a switch should be made */
  575.  
  576. void PinyinInput(void *n);
  577. /* Pinyin input function */
  578.  
  579. void PinyinShow(void *n);
  580. /* Show candidate Chinese characters */
  581.  
  582. void SaveSearchString(void *n);
  583. /* Saving current search string */
  584.  
  585. void CmdSearch(void *n);
  586. /* Search button function */
  587.  
  588. void DoSearch(void *n);
  589. /* Do a search to find the search string */
  590.  
  591. void CmdReplace(void *n);
  592. /* Replace button function */
  593.  
  594. struct _RGB
  595. /* Color struct! */
  596. {
  597.     unsigned char b;
  598.     /* BLUE */
  599.    
  600.     unsigned char g;
  601.     /* GREEN */
  602.    
  603.     unsigned char r;
  604.     /* RED */
  605. };
  606. typedef struct _RGB RGB;
  607.  
  608. void DrawTextBox(int x1, int y1, int x2, int y2);
  609. /* Draw an text box similar to Win9x */
  610.  
  611. void DrawButton(void *n, int x1, int y1, int x2, int y2, char *title);
  612. /* Draw a button on a specific place */
  613.  
  614. void DrawWindow(void *n, int x1, int y1, int x2, int y2, char *title);
  615. /* Draw an interface similar to Win9x */
  616.  
  617. void DrawStatusBox(void *n);
  618. /* Draw an status box similar to Win9x */
  619.  
  620. void DrawMainTextBox(void *n);
  621. /* The main text box */
  622.  
  623. void DrawMainWindow(void *n);
  624. /* Draw main window */
  625.  
  626. void IsExit(void *n);
  627. /* Check whether an window should be closed */
  628.  
  629. int RAvsRA(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
  630. /* If a RectAngle covers the other one */
  631.  
  632. void SetColor(unsigned int n);
  633. /* Workaround for quick access to change the function */
  634.  
  635. void FadingColor(void *null);
  636. /* Color fading while loading and unloading */
  637.  
  638. void InitColor(void *null);
  639. /* Initialize all colors to black, so the fading could work later */
  640.  
  641. void ChangeDotted(void *n);
  642. /* Change dotted mode */
  643.  
  644. void ChangeHighlight(void *n);
  645. /* Change highlight mode */
  646.  
  647. void CheckStatus(void *n);
  648. /* Check and display the status in the main status box */
  649.  
  650. void ShowHelp(void *n);
  651. /* Show Help messages */
  652.  
  653. void OpenFile(void *n, char *f);
  654. /* Open an file */
  655.  
  656. void CleanUp(void *n);
  657. /* Both mouse and cursor workaround */
  658.  
  659.  
  660. void CheckCursor(void *n);
  661. /* Check the cursor to do the pageup and pagedown */
  662.  
  663. void DrawCur(void *n);
  664. /*Draw a cursor in the txt*/
  665.  
  666. void FlashCur(void *n);
  667. /*Move the cursor by keyboard*/
  668.  
  669. void ClrCur(void *n);
  670. /*Clear the cursor at last position*/
  671.  
  672. void CursorUp(void *n);
  673. /* Move cursor up*/
  674.  
  675. void CursorDown(void *n);
  676. /* Move cursor down */
  677.  
  678. void CursorLeft(void *n);
  679. /* Move cursor left */
  680.  
  681. void CursorRight(void *n);
  682. /* Move cursor right */
  683.  
  684. void GetCurPos(void *n);
  685. /* Get cursor position by row and column */
  686.  
  687. void MousetoCursor(void *n);
  688. /* left click mouse and then move the cursor to the current position */
  689.  
  690. int LeftHZ(void *n);
  691. /* there is a HZ on the left side of the cursor */
  692.  
  693. int RightHZ(void *n);
  694. /* there is a HZ on the right side of the cursor */
  695.  
  696. int UpHZ(void *n);
  697. /* judge the HZ above the cursor */
  698.  
  699. int FindUpHZPosition(void *n);
  700. /* calculate the HZ positon in the front row */
  701.  
  702. int DownHZ(void *n);
  703. /* there is a HZ on the top side of the cursor */
  704.  
  705. int FindDownHZPosition(void *n);
  706. /* calculate the HZ positon in the next row */
  707.  
  708. int MouseHZ(void *n);
  709. /* there is a HZ under the Mouse */
  710.  
  711. int FindMouseHZPosition(void *n);
  712. /* calculate the HZ positon under the Mouse */
  713.  
  714.  
  715. void OutPutMain(void *n);
  716. void OutPutXY(void *n);
  717. /*put out a txt in a rectangle*/
  718. void PageDown(void *n);
  719. /* move page down by one row */
  720.  
  721. void PageUp(void *n);
  722. /* move page up by one row */
  723.  
  724. void BackSpace(void *n);
  725. /*del the NO.N char in Row M*/
  726.  
  727. void Delete(void *n);
  728. /*del the NO.N + 1 char in Row M*/
  729.  
  730. void HZInsert(void *n);
  731. /*insert the NO.N char in Row M*/
  732.  
  733. void RowCount(void *n);
  734. /* Caculate the total row of the txt */
  735.  
  736. void Insert(void *n,char *hz);
  737. /* Insert a hanzi in front of the cursor */
  738.  
  739. void EnterKey(void *n);
  740. /* Add the function of pressing Enter Key */
  741.  
  742. void InitChildhead(void *n);
  743. /* Init childhead 1 */
  744.  
  745. void InitChildhead2(void *n);
  746. /* Init childhead 2 */
  747.  
  748. void FreeChildhead(void *n);
  749. /* Free childhead 2*/
  750.  
  751. void FreeChildhead2(void *n);
  752. /* Free childhead 2*/
  753.  
  754. char *GetChildText(void *n);
  755. char *GetChildText2(void *n);
  756. /* Get child text */
  757.  
  758. char LeftChar(void *n);
  759. /* Get the chat at the left sid of cursor */
  760.  
  761. void ChosenArea(void *n);
  762. /* chose a string and color it BLUE */
  763.  
  764. void Home(void *n);
  765. /* put the cursor in the first of the currentrow */
  766.  
  767. void CtrlHome(void *n);
  768. /* put the cursor in the first of the firstrow */
  769.  
  770. void End(void *n);
  771. /* put the cursor in the end of the currentrow */
  772.  
  773. void CtrlEnd(void *n);
  774. /* put the cursor in the end of the currentrow */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement