home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / include / global.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-01  |  12.0 KB  |  318 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     $Id: global.h 1.3 1994/09/09 12:28:04 digulla Exp digulla $
  5.  
  6.     DESCRIPTION
  7.     Defines/structs that mostly all sources depend on.
  8.  
  9.     $Log: global.h $
  10.  * Revision 1.3  1994/09/09  12:28:04  digulla
  11.  * Moved config struct into config.h
  12.  * added support for title fg and bg pens
  13.  *
  14.  * Revision 1.2  1994/08/19  14:02:34  digulla
  15.  * Renamed Wdisable to Saveicons and added WindowTitles
  16.  *
  17.  * Revision 1.1  1994/08/14  14:26:15  digulla
  18.  * Initial revision
  19.  *
  20.  
  21. ******************************************************************************/
  22.  
  23. #ifndef GLOBAL_H
  24. #define GLOBAL_H
  25.  
  26. /**************************************
  27.         Includes
  28. **************************************/
  29.  
  30. #include "HL.h"
  31.  
  32. /**************************************
  33.         Globale Variable
  34. **************************************/
  35.  
  36.  
  37. /**************************************
  38.     Defines und Strukturen
  39. **************************************/
  40. typedef LONG            Line;
  41. typedef LONG            Column;
  42.  
  43. typedef struct Node        NODE;
  44. typedef struct MinNode        MNODE;
  45. typedef struct List        LIST;
  46. typedef struct MinList        MLIST;
  47. typedef struct MsgPort        PORT;
  48. typedef struct Window        WIN;
  49. typedef struct Screen        SCREEN;
  50. typedef struct Message        MSG;
  51. typedef struct TextAttr     TA;
  52. typedef struct TextFont     FONT;
  53. typedef struct RastPort     RP;
  54. typedef struct IntuiMessage    IMESS;
  55. typedef struct IntuitionBase    IBASE;
  56. typedef struct Menu        MENU;
  57. typedef struct MenuItem     ITEM;
  58. typedef struct IntuiText    ITEXT;
  59. typedef struct Process        PROC;
  60. typedef UBYTE              * LINE;
  61.  
  62. /* as long as DAS doesn't align after const strings don't define const */
  63. #define CONST        const
  64.  
  65.  
  66. #if 0
  67. New def. for line:
  68.  
  69. typedef struct {
  70.      UWORD   flags;    /* flags        */
  71.      UBYTE   lvl;    /* folding level    */
  72.      VString text;    /* text         */
  73. } LINE;
  74. #endif
  75.  
  76. /* Config */
  77. #include "config.h"
  78.  
  79. struct GlobalFlags
  80. {
  81.     ULONG _debug : 1;         /* Do debugging */
  82.     ULONG _NoRequest : 1;     /* PATCH_NULL: disable requestors         */
  83.     ULONG _Showtitle : 1;     /* Used by untitle to disable some title calls  */
  84.     ULONG _Msgchk : 1;         /* Force message queue check for break      */
  85.     ULONG _Windowcycling : 1;     /* PATCH_NULL : SELECT last SELECT next == SELECT first */
  86.     ULONG _ActivateToFront : 1;  /* PATCH_NULL : SELECTed windows are moved to front     */
  87.     ULONG _SourceBreaks : 1;     /* PATCH_NULL : errors in source abort the read     */
  88.     ULONG _Savetabs : 1;     /* SaveTabs mode?                 */
  89.  
  90.     ULONG _SimpleTabs : 1;     /* PATCH_NULL [25 Jan 1993] : SaveTabs mode only until firstnb ? */
  91.     ULONG _memoryfail : 1;     /* out of memory flag                 */
  92.     ULONG _Comlinemode : 1;     /* Is commandline active ?             */
  93.     ULONG _Abortcommand : 1;     /* Should loop-command (while/repeat) abort ?   */
  94.     ULONG _global_search : 1;     /* Do a global search ?             */
  95.     ULONG _Quitflag : 1;     /* Should DME close actual window ?         */
  96.     ULONG _QuitAll : 1;      /* Should DME quit ?                 */
  97.     ULONG _Overide : 1;      /* Quit even if file was modified         */
  98.  
  99.     ULONG _Saveicons : 1;     /* Save Icons with files             */
  100.     ULONG _MForceTitle : 1;     /* Force refresh of title             */
  101.     ULONG _FollowCursor : 1;     /* Make sure cursor is visible          */
  102.     ULONG _WindowTitles : 1;     /* PATCH_NULL 16-08-94 Decide to use SetWindowTitles or not */
  103.     ULONG _SLine : 1;         /* PATCH_NULL 14-06-93 enable movement after EoL */
  104.  
  105.     ULONG pad : 11;
  106. };
  107.  
  108. #define GETF_DEBUG(ed)              globalflags._debug
  109. #define SETF_DEBUG(ed,f)            (globalflags._debug = (f))
  110. #define GETF_NOREQUEST(ed)          globalflags._NoRequest
  111. #define SETF_NOREQUEST(ed,f)        (globalflags._NoRequest = (f))
  112. #define GETF_SHOWTITLE(ed)          globalflags._Showtitle
  113. #define SETF_SHOWTITLE(ed,f)        (globalflags._Showtitle = (f))
  114. #define GETF_MSGCHECK(ed)           globalflags._Msgchk
  115. #define SETF_MSGCHECK(ed,f)         (globalflags._Msgchk = (f))
  116. #define GETF_WINDOWCYCLING(ed)      globalflags._Windowcycling
  117. #define SETF_WINDOWCYCLING(ed,f)    (globalflags._Windowcycling = (f))
  118. #define GETF_ACTIVATETOFRONT(ed)    globalflags._ActivateToFront
  119. #define SETF_ACTIVATETOFRONT(ed,f)  (globalflags._ActivateToFront = (f))
  120. #define GETF_SOURCEBREAKS(ed)       globalflags._SourceBreaks
  121. #define SETF_SOURCEBREAKS(ed,f)     (globalflags._SourceBreaks = (f))
  122. #define GETF_SAVETABS(ed)           globalflags._Savetabs
  123. #define SETF_SAVETABS(ed,f)         (globalflags._Savetabs = (f))
  124. #define GETF_SIMPLETABS(ed)         globalflags._SimpleTabs
  125. #define SETF_SIMPLETABS(ed,f)       (globalflags._SimpleTabs = (f))
  126. #define GETF_MEMORYFAIL(ed)         globalflags._memoryfail
  127. #define SETF_MEMORYFAIL(ed,f)       (globalflags._memoryfail = (f))
  128. #define GETF_COMLINEMODE(ed)        globalflags._Comlinemode
  129. #define SETF_COMLINEMODE(ed,f)      (globalflags._Comlinemode = (f))
  130. #define GETF_ABORTCOMMAND(ed)       globalflags._Abortcommand
  131. #define SETF_ABORTCOMMAND(ed,f)     (globalflags._Abortcommand = (f))
  132. #define GETF_GLOBALSEARCH(ed)       globalflags._global_search
  133. #define SETF_GLOBALSEARCH(ed,f)     (globalflags._global_search = (f))
  134. #define GETF_QUITFLAG(ed)           globalflags._Quitflag
  135. #define SETF_QUITFLAG(ed,f)         (globalflags._Quitflag = (f))
  136. #define GETF_QUITALL(ed)            globalflags._QuitAll
  137. #define SETF_QUITALL(ed,f)          (globalflags._QuitAll = (f))
  138. #define GETF_OVERIDE(ed)            globalflags._Overide
  139. #define SETF_OVERIDE(ed,f)          (globalflags._Overide = (f))
  140. #define GETF_SAVEICONS(ed)          globalflags._Saveicons
  141. #define SETF_SAVEICONS(ed,f)        (globalflags._Saveicons = (f))
  142. #define GETF_MFORCETITLE(ed)        globalflags._MForceTitle
  143. #define SETF_MFORCETITLE(ed,f)      (globalflags._MForceTitle = (f))
  144. #define GETF_FOLLOWCURSOR(ed)       globalflags._FollowCursor
  145. #define SETF_FOLLOWCURSOR(ed,f)     (globalflags._FollowCursor = (f))
  146. #define GETF_WINDOWTITLES(ed)       globalflags._WindowTitles
  147. #define SETF_WINDOWTITLES(ed,f)     (globalflags._WindowTitles = (f))
  148. #define GETF_SLINE(ed)              globalflags._SLine
  149. #define SETF_SLINE(ed,f)            (globalflags._SLine = (f))
  150.  
  151. typedef struct _ED
  152. {
  153.     struct HNode    node;    /* for list */
  154.     APTR        textvars;    /* list of localized vars  */
  155.     ULONG        pad;    /* hnode private data */
  156.  
  157.     WIN       * win;    /* actual window */
  158.     struct Gadget * propgad;    /* Pointer to our PropGadget */
  159.     FONT      * font;    /* actual font! */
  160.     Line        topline;
  161.     Column        topcolumn;    /* top left edge of window in the text */
  162.     Line        line;
  163.     Column        column;    /* actual cursor position */
  164.     long        lines,
  165.             maxlines;    /* number of text-lines we use and how much we
  166.                    have at most */
  167.     LINE      * list;    /* list of text-lines */
  168.     UBYTE        name[64];
  169.     UBYTE        wtitle[130];
  170.     ULONG        _modified : 1;   /* is text modified ? */
  171.     ULONG        _iconmode : 1;   /* window in icon mode */
  172.     ULONG        _viewmode : 1;   /* PATCH_NULL: disable changes to text */
  173.     BPTR        dirlock;    /* directory lock */
  174.  
  175. #define MAX_TEXTFLAGS 32
  176.     char        textflags[(MAX_TEXTFLAGS+7)/8];
  177.     APTR        package;        /* PATCH_NULL: ptr to current Package  */
  178. /* --- I have decided not to use Packages but multiple Menues and Keytables */
  179.     APTR        menustrip;        /* PATCH_NULL: ptr to current MenuStrip */
  180.     APTR        keytable;        /* PATCH_NULL: ptr to current KeyTable  */
  181.  
  182.     /*
  183.      *    CONFIG INFORMATION
  184.      */
  185.     struct Config config;
  186.  
  187. } ED;
  188.  
  189.  
  190. /* config flags */
  191. #define GETF_INSERTMODE(ed)         (ed)->config._insertmode
  192. #define SETF_INSERTMODE(ed,f)       ((ed)->config._insertmode = (f))
  193. #define GETF_IGNORECASE(ed)         (ed)->config._ignorecase
  194. #define SETF_IGNORECASE(ed,f)       ((ed)->config._ignorecase = (f))
  195. #define GETF_WORDWRAP(ed)           (ed)->config._wordwrap
  196. #define SETF_WORDWRAP(ed,f)         ((ed)->config._wordwrap = (f))
  197. #define GETF_AUTOSPLIT(ed)          (ed)->config._autosplit
  198. #define SETF_AUTOSPLIT(ed,f)        ((ed)->config._autosplit = (f))
  199. #define GETF_AUTOINDENT(ed)         (ed)->config._autoindent
  200. #define SETF_AUTOINDENT(ed,f)       ((ed)->config._autoindent = (f))
  201. #define GETF_AUTOUNBLOCK(ed)        (ed)->config._autounblock
  202. #define SETF_AUTOUNBLOCK(ed,f)      ((ed)->config._autounblock = (f))
  203. #define GETF_DOBACK(ed)             (ed)->config._doback
  204. #define SETF_DOBACK(ed,f)           ((ed)->config._doback = (f))
  205. #define GETF_NICEPAGING(ed)         (ed)->config._nicepaging
  206. #define SETF_NICEPAGING(ed,f)       ((ed)->config._nicepaging = (f))
  207. #define GETF_ICONACTIVE(ed)         (ed)->config._iconactive
  208. #define SETF_ICONACTIVE(ed,f)       ((ed)->config._iconactive = (f))
  209. #define GETF_BLOCKENDSFLOAT(ed)     (ed)->config._blockendsfloat
  210. #define SETF_BLOCKENDSFLOAT(ed,f)   ((ed)->config._blockendsfloat = (f))
  211.  
  212. /* ed flags */
  213. #define GETF_MODIFIED(ed)           (ed)->_modified
  214. #define SETF_MODIFIED(ed,f)         ((ed)->_modified = (f))
  215. #define GETF_ICONMODE(ed)           (ed)->_iconmode
  216. #define SETF_ICONMODE(ed,f)         ((ed)->_iconmode = (f))
  217. #define GETF_VIEWMODE(ed)           (ed)->_viewmode
  218. #define SETF_VIEWMODE(ed,f)         ((ed)->_viewmode = (f))
  219.  
  220.  
  221. #define beginconfig        config
  222. #define CONFIG_SIZE        (sizeof(struct Config))
  223. #define XDME_CONFIG        "S:XDME.prefs"
  224.  
  225.  
  226. /* Define Colors */
  227. #define TEXT_FPEN(ed)   (ed)->config.fgpen
  228. #define TEXT_BPEN(ed)   (ed)->config.bgpen
  229. #define BLOCK_FPEN(ed)  (ed)->config.hgpen
  230. #define BLOCK_BPEN(ed)  (ed)->config.bbpen
  231. #define TITLE_FPEN(ed)  (ed)->config.tfpen
  232. #define TITLE_BPEN(ed)  (ed)->config.tbpen
  233. #define TEXT_MASK(ed)   (TEXT_FPEN(ed) | TEXT_BPEN(ed))
  234. #define BLOCK_MASK(ed)  (TEXT_MASK(ed) | BLOCK_FPEN(ed) | BLOCK_BPEN(ed))
  235. #define ALL_MASK    0xFF
  236.  
  237.  
  238. /* Block-Types
  239.     note:   BSxxx is invalid if BSline < 0,
  240.         BExxx is invalid if BEline < 0
  241.     If BlockType == BT_NONE, one must not check any other values.
  242. */
  243. #define BT_NONE     0        /* No current block */
  244. #define BT_LINE     1        /* Block is full-line */
  245. #define BT_NORMAL   2        /* Block starts at BScolumn/BSline and ends at
  246.                    BEcolumn/BEline */
  247. #define BT_VERTICAL 3        /* Block is a rectangle from BScolumn/BSline to
  248.                    BEcolumn/BEline */
  249. #define BT_HORIZONTAL 4     /* Block is a rectangle from BScolumn/BSline to
  250.                    BEcolumn/BEline */
  251.  
  252. /* Result of lineflags(line): */
  253. #define LINE_ABOVE    1    /* line < Ep->Topline */
  254. #define LINE_VISIBLE    2    /* line >= Ep->Topline && line < Ep->Topline + Rows */
  255. #define LINE_BELOW    4    /* line >= Ep->Topline + Rows */
  256.  
  257. /* Where in the block am I actually ?
  258.  
  259.    BP_INSIDE+BP_START    - Inside 1. line of block
  260.    BP_START        - In the same line in which block starts but not inside
  261.               block.
  262.    BP_START+END+INSIDE    - I am in the only line the block has.
  263.    BP_START+BP_END    - dito but not INSIDE the block
  264. */
  265. #define BP_OUTSIDE        0        /* No part of block on this line    */
  266. #define BP_BESIDE        1        /* There is some block on this line */
  267. #define BP_INSIDE        2        /* Inside block.  We never have    */
  268.                     /* BP_INSIDE without BP_BESIDE    */
  269. #define BP_START        4        /* line == BSline */
  270. #define BP_END            8        /* line == BEline */
  271.  
  272. /* Defines for the block flags */
  273. #define BF_START_SET        1L
  274. #define BF_END_SET        2L
  275. #define BF_SET_MASK        (BF_START_SET|BF_END_SET)
  276. #define BF_LINE_SWAPPED     4L
  277. #define BF_COLUMN_SWAPPED   8L
  278. #define BF_SWAPPED_MASK     (BF_LINE_SWAPPED|BF_COLUMN_SWAPPED)
  279.  
  280. typedef struct
  281. {
  282.     ED     * ep;            /* the editor the block is in */
  283.     UWORD  type;        /* BT_xxx */
  284.     UWORD  flags;
  285.     Line   start_line;        /* start- and endline */
  286.     Line   end_line;
  287.     Column start_column;    /* start- and endcolumn */
  288.     Column end_column;
  289.     Column col[3][2];        /* First  line  start, First  line    end */
  290.                 /* Middle lines start, Middle lines end */
  291.                 /* Last   line  start, Last   line    end */
  292. } Block;
  293.  
  294.  
  295. struct TextMarker
  296. {
  297.     ED     * ep;            /* The editor the marker is for */
  298.     Line   line;        /* line and column */
  299.     Column column;
  300. };
  301.  
  302.  
  303. /* Macros */
  304.  
  305. #define redraw_textline(ed,line)  redraw_textlineseg((line),(ed)->topcolumn,(ed)->topcolumn+Columns)
  306.  
  307.  
  308. /**************************************
  309.            Prototypes
  310. **************************************/
  311.  
  312.  
  313. #endif /* GLOBAL_H */
  314.  
  315. /******************************************************************************
  316. *****  ENDE global.h
  317. ******************************************************************************/
  318.