home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d8xx / d832 / term.lha / Term / term-3.1-Source.lha / termData.c < prev    next >
C/C++ Source or Header  |  1993-02-11  |  20KB  |  825 lines

  1. /*
  2. **    termData.c
  3. **
  4. **    Global data structures.
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* Libraries. */
  13.  
  14. struct ExecBase        *SysBase;
  15. struct DosLibrary    *DOSBase;
  16.  
  17. struct IntuitionBase    *IntuitionBase;
  18. struct GfxBase        *GfxBase;
  19. struct RxsLib        *RexxSysBase;
  20. struct LocaleBase    *LocaleBase;
  21. struct Library        *GadToolsBase,
  22.             *TimerBase,
  23.             *ConsoleDevice,
  24.             *DiskfontBase,
  25.             *UtilityBase,
  26.             *AslBase,
  27.             *IFFParseBase,
  28.             *CxBase,
  29.             *IconBase,
  30.             *TranslatorBase,
  31.             *WorkbenchBase,
  32.             *AmigaGuideBase,
  33.             *XEmulatorBase,
  34.             *XProtocolBase,
  35.             *OwnDevUnitBase;
  36.  
  37.     /* Timer device. */
  38.  
  39. struct timerequest    *TimeRequest;
  40. struct MsgPort        *TimePort;
  41.  
  42.     /* Console device. */
  43.  
  44. struct IOStdReq        *ConsoleRequest;
  45. struct KeyMap        *KeyMap;
  46. BPTR             KeySegment;
  47.  
  48.     /* Screen & Windows. */
  49.  
  50. struct Screen        *Screen,
  51.             *DefaultPubScreen;
  52. struct Window        *Window;
  53. LONG             WindowWidth,
  54.              WindowHeight,
  55.              WindowLeft,
  56.              WindowTop;
  57. struct Window        *StatusWindow;
  58. struct Gadget        *StatusGadget;
  59. UWORD             StatusOffset;
  60. APTR             OldWindowPtr;
  61. struct BitMap        *InterleavedBitMap;
  62. struct Requester    *RequesterList;
  63. UBYTE             ScreenTitle[80];
  64. UBYTE             DepthMask;
  65. LONG             RenderPens[4],
  66.              MappedPens[2][16],
  67.              SafeTextPen;
  68. struct DrawInfo        *DrawInfo;
  69. LONG             ScreenWidth,
  70.              ScreenHeight;
  71. BYTE             UseMasking;
  72.  
  73. struct BlockMarker    *WindowMarker;
  74. ULONG             ClickSecs,ClickMicros;
  75. BYTE             FirstClick = TRUE,HoldClick = FALSE;
  76. LONG             ClickX,ClickY;
  77.  
  78.     /* Workbench AppWindow support. */
  79.  
  80. struct AppWindow    *WorkbenchWindow;
  81. struct MsgPort        *WorkbenchPort;
  82.  
  83.     /* Graphics rendering. */
  84.  
  85. struct ViewPort        *VPort;
  86. struct RastPort        *RPort;
  87. struct TextFont        *GFX,
  88.             *CurrentFont,
  89.             *UserTextFont;
  90. WORD             UserFontHeight,
  91.              UserFontWidth,
  92.              UserFontBase;
  93. UBYTE             UserFontName[40];
  94. struct TextFont        *TextFont;
  95. WORD             TextFontHeight,
  96.              TextFontWidth,
  97.              TextFontBase;
  98. struct TextAttr         TextAttr;
  99. UBYTE             TextFontName[40];
  100. struct TextAttr         UserFont;
  101. APTR             VisualInfo;
  102.  
  103. ULONG            (* __regargs ReadAPen)(struct RastPort *RPort);
  104. ULONG            (* __regargs ReadBPen)(struct RastPort *RPort);
  105. ULONG            (* __regargs ReadDrMd)(struct RastPort *RPort);
  106. ULONG            (* __regargs SetWrMsk)(struct RastPort *RPort,ULONG Mask);
  107.  
  108. UWORD StandardPens[] =
  109. {
  110.     (UWORD)~0
  111. };
  112.  
  113. UWORD ANSIPens[] =
  114. {
  115.     0,4,7,7,4,6,7,0,6,    0,7,0,(UWORD)~0
  116. };
  117.  
  118. UWORD EGAPens[] =
  119. {
  120.     0,8,15,15,8,7,15,0,7,    0,15,0,(UWORD)~0
  121. };
  122.  
  123. UWORD AtomicColours[16] =
  124. {
  125.     0x000,
  126.     0xDDD,
  127.     0x000,
  128.     0x000,
  129.     0x000,
  130.     0x000,
  131.     0x000,
  132.     0x000,
  133.     0x000,
  134.     0x000,
  135.     0x000,
  136.     0x000,
  137.     0x000,
  138.     0x000,
  139.     0x000,
  140.     0x000
  141. };
  142.  
  143. UWORD EGAColours[16] =
  144. {
  145.     0x000,    /* Black. */
  146.     0xA00,    /* Dark red. */
  147.     0x0A0,    /* Dark green. */
  148.     0xA60,    /* Dark yellow (orange). */
  149.     0x00A,    /* Dark blue. */
  150.     0xA0A,    /* Dark magenta.*/
  151.     0x0AA,    /* Dark cyan. */
  152.     0xBBB,    /* Light grey. */
  153.     0x666,    /* Dark grey. */
  154.     0xF00,    /* Red. */
  155.     0x0F0,    /* Green. */
  156.     0xFF0,    /* Yellow. */
  157.     0x00F,    /* Blue. */
  158.     0xF0F,    /* Magenta. */
  159.     0x0FF,    /* Cyan. */
  160.     0xFFF    /* White. */
  161. };
  162.  
  163. UWORD ANSIColours[16] =
  164. {
  165.     0x000,    /* Black. */
  166.     0xF00,    /* Red. */
  167.     0x0F0,    /* Green. */
  168.     0xFF0,    /* Yellow. */
  169.     0x00F,    /* Blue. */
  170.     0xF0F,    /* Magenta. */
  171.     0x0FF,    /* Cyan. */
  172.     0xFFF,    /* White. */
  173.  
  174.     0x000,    /* Black. */
  175.     0xF00,    /* Red. */
  176.     0x0F0,    /* Green. */
  177.     0xFF0,    /* Yellow. */
  178.     0x00F,    /* Blue. */
  179.     0xF0F,    /* Magenta. */
  180.     0x0FF,    /* Cyan. */
  181.     0xFFF    /* White. */
  182. };
  183.  
  184. UWORD             DefaultColours[16],
  185.              BlinkColours[16],
  186.              StandardColours[16];
  187.  
  188.     /* Line/Column offset tables. */
  189.  
  190. LONG            *OffsetXTable,
  191.             *OffsetYTable;
  192.  
  193.     /* DOS data. */
  194.  
  195. struct Process        *ThisProcess;
  196. struct Process        *StatusProcess;
  197. struct Process        *BufferProcess;
  198. struct Process        *RexxProcess,
  199.             *RexxBackgroundProcess;
  200. struct MsgPort        *TermRexxPort;
  201. struct WBStartup    *WBenchMsg;
  202. BPTR             WBenchLock;
  203. struct TermPort        *TermPort;
  204. BYTE             ClipBit    = -1,
  205.              CheckBit    = -1;
  206. BYTE             InRexx;
  207.  
  208.     /* Character conversion. */
  209.  
  210. struct InputEvent    *FakeInputEvent;
  211.  
  212.     /* Serial I/O. */
  213.  
  214. struct IOExtSer        *ReadRequest;
  215. struct IOExtSer        *WriteRequest;
  216. struct MsgPort        *ReadPort;
  217. APTR             ReadBuffer,
  218.              HostReadBuffer;
  219. UBYTE            *SerialMessage;
  220. ULONG             DTERate;
  221.  
  222. UBYTE             NewDevice[MAX_FILENAME_LENGTH];
  223. LONG             NewUnit;
  224. BYTE             UseNewDevice,
  225.              UseNewUnit;
  226.  
  227. LONG BaudRates[] =
  228. {
  229.     110,300,600,1200,2400,4800,7200,9600,12000,14400,19200,31250,38400,57600,64000,76800,115200
  230. };
  231.  
  232. LONG             NumBaudRates = sizeof(BaudRates) / sizeof(LONG);
  233.  
  234.     /* Localization support. */
  235.  
  236. struct Catalog        *Catalog;
  237. struct Locale        *Locale;
  238.  
  239.     /* Hotkeys. */
  240.  
  241. struct Hotkeys         Hotkeys;
  242.  
  243. struct NewBroker NewTermBroker =
  244. {
  245.     NB_VERSION,
  246.     "term",
  247.     "term © 1990-1993 by MXM",
  248.     "Terminal program",
  249.     0,0,0,NULL,0
  250. };
  251.  
  252.     /* Static default fonts. */
  253.  
  254. struct TextAttr DefaultFont =
  255. {
  256.     (UBYTE *)"topaz.font",
  257.     8,
  258.     FS_NORMAL,
  259.     FPF_ROMFONT | FPF_DESIGNED
  260. };
  261.  
  262. struct TextAttr GFXFont =
  263. {
  264.     (UBYTE *)"GFX.font",
  265.     8,
  266.     FS_NORMAL,
  267.     FPF_DISKFONT
  268. };
  269.  
  270.     /* Audio data. */
  271.  
  272. UBYTE AnyChannel[4] =
  273. {
  274.     LEFT0F,
  275.     LEFT1F,
  276.     RIGHT0F,
  277.     RIGHT1F,
  278. };
  279.  
  280. UBYTE __chip SineWave[8] =
  281. {
  282.     90,
  283.     127,
  284.     90,
  285.     0,
  286.     (UBYTE)-90,
  287.     (UBYTE)-127,
  288.     (UBYTE)-90,
  289.     0
  290. };
  291.  
  292. struct IOAudio    *AudioBlock;
  293.  
  294.     /* Character lookup tables. */
  295.  
  296. BYTE IsPrintable[256] =
  297. {
  298.     0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,
  299.     0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,
  300.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  301.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  302.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  303.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  304.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  305.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
  306.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  307.     0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,
  308.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  309.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  310.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  311.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  312.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  313.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  314. };
  315.  
  316.     /* IBM <-> ISO font conversion. */
  317.  
  318. UBYTE IBMConversion[256] =
  319. {
  320.     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x00,0x00,
  321.     0x00,0x11,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x00,0x00,0x00,0x00,
  322.     0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
  323.     0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
  324.     0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
  325.     0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
  326.     0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
  327.     0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
  328.     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  329.     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  330.     0x00,0xAD,0x9B,0x9C,0x00,0x9D,0x00,0x15,0x00,0x00,0xA6,0x00,0x00,0x00,0xAE,0x00,
  331.     0xF8,0xF1,0xFD,0x00,0x00,0xE6,0x14,0xF9,0x00,0x00,0xA7,0xAF,0xAC,0xAB,0x00,0xA8,
  332.     0x00,0x00,0x00,0x00,0x8E,0x8F,0x92,0x80,0x00,0x90,0x00,0x00,0x00,0x00,0x00,0x00,
  333.     0x00,0xA5,0x00,0x00,0x00,0x00,0x99,0x00,0x00,0x00,0x00,0x00,0x9A,0x00,0x00,0xE1,
  334.     0x85,0xA0,0x83,0x00,0x84,0x86,0x91,0x87,0x8A,0x82,0x88,0x89,0x8D,0xA1,0x8C,0x00,
  335.     0x00,0xA4,0x95,0xA2,0x93,0x00,0x94,0x00,0x00,0x97,0xA3,0x96,0x81,0x00,0x00,0x98
  336. };
  337.  
  338.     /* Table of graphics characters. */
  339.  
  340. BYTE GfxTable[256] =
  341. {
  342.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  343.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  344.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  345.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  346.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  347.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  348.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  349.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  350.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  351.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  352.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  353.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  354.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  355.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  356.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  357.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  358. };
  359.  
  360.     /* Special character treatment. */
  361.  
  362. struct SpecialKey SpecialKeys[13] =
  363. {
  364.     BEL,    DoBeep,        /* Ring the bell. */
  365.     XON,    DoxON,        /* Flow control - stop output. */
  366.     BKS,    DoBackspace,    /* Erase a character. */
  367.     ENT,    DoLF_FF_VT,    /* Enter key. */
  368.     FFD,    DoFF,        /* Form feed. */
  369.     VTB,    DoLF_FF_VT,    /* Vertical tab (huh?). */
  370.     RET,    DoCR,        /* Return key. */
  371.     TAB,    DoTab,        /* Move to next tab stop. */
  372.     SI,    DoShiftIn,    /* Change to graphics mode */
  373.     SO,    DoShiftOut,    /* Change out of graphics mode. */
  374.     ENQ,    DoEnq,        /* Transmit answerback message. */
  375.     ESC,    DoEsc,        /* Start new control sequence. */
  376.     CSI,    DoCsi        /* Start new control sequence. */
  377. };
  378.  
  379. JUMP *SpecialTable;
  380.  
  381. BYTE AbortMap[256] =
  382. {
  383.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  384.     0,0,0,0,0,0,0,0,1,0,1,2,0,0,0,0,
  385.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  386.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  387.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  388.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  389.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  390.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  391.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  392.     0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,
  393.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  394.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  395.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  396.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  397.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  398.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  399. };
  400.  
  401. JUMP *AbortTable;
  402.  
  403. VOID (* __regargs ConDump)(STRPTR,LONG);
  404. VOID (* __regargs ConOutput)(STRPTR,LONG);
  405. VOID (* __regargs ConProcessData)(register STRPTR,register LONG);
  406.  
  407.     /* Shared global string formatting buffer. */
  408.  
  409. UBYTE SharedBuffer[512];
  410.  
  411.     /* Screen pull-down-menu. */
  412.  
  413. struct NewMenu TermMenu[] =
  414. {
  415.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  416.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)0},
  417.     {   NM_SUB, NULL,         0 , 0,        0, (APTR)MEN_SAVE_AS_PICTURE},
  418.     {   NM_SUB, NULL,         0 , 0,        0, (APTR)MEN_SAVE_AS_TEXT},
  419.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  420.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)0},
  421.     {   NM_SUB, NULL,         0 , 0,        0, (APTR)MEN_PRINT_SCREEN},
  422.     {   NM_SUB, NULL,         0 , 0,        0, (APTR)MEN_PRINT_CLIP},
  423.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  424.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)0},
  425.     {   NM_SUB, NULL,         0 , TICK,    0, (APTR)MEN_CAPTURE_TO_FILE},
  426.     {   NM_SUB, NULL,         0 , TICK,    0, (APTR)MEN_CAPTURE_TO_PRINTER},
  427.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  428.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_ICONIFY},
  429.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  430.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_ABOUT},
  431.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  432.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_QUIT},
  433.  
  434.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  435.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_COPY},
  436.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_PASTE},
  437.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLEAR},
  438.  
  439.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  440.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_EXECUTE_DOS_COMMAND},
  441.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_EXECUTE_REXX_COMMAND},
  442.  
  443.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  444.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_PHONEBOOK},
  445.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_REDIAL},
  446.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DIAL_NUMBER},
  447.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  448.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SEND_BREAK},
  449.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_HANG_UP},
  450.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  451.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_WAIT},
  452.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  453.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_FLUSH_BUFFER},
  454.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_RELEASE_DEVICE},
  455.  
  456.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  457.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_UPLOAD_ASCII},
  458.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DOWNLOAD_ASCII},
  459.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  460.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_UPLOAD_TEXT},
  461.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DOWNLOAD_TEXT},
  462.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_EDIT_AND_UPLOAD_TEXT},
  463.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  464.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_UPLOAD_BINARY},
  465.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DOWNLOAD_BINARY},
  466.  
  467.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  468.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLEAR_BUFFER},
  469.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DISPLAY_BUFFER},
  470.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLOSE_BUFFER},
  471.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  472.     {  NM_ITEM, NULL,         0 , TICK,    0, (APTR)MEN_FREEZE_BUFFER},
  473.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  474.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_OPEN_BUFFER},
  475.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SAVE_BUFFER_AS},
  476.  
  477.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  478.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLEAR_SCREEN},
  479.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_RESET_FONT},
  480.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_RESET_STYLES},
  481.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_RESET_TERMINAL},
  482.  
  483.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  484.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SERIAL},
  485.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_MODEM},
  486.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SCREEN},
  487.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_TERMINAL},
  488.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SET_EMULATION},
  489.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLIPBOARD},
  490.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CAPTURE},
  491.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_COMMANDS},
  492.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_MISC},
  493.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_PATH},
  494.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_TRANSFER_PROTOCOL},
  495.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  496.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_TRANSFER},
  497.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_TRANSLATION},
  498.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_MACROS},
  499.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CURSORKEYS},
  500.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_FAST_MACROS},
  501.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_HOTKEYS},
  502.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SPEECH},
  503.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SET_CONSOLE},
  504.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  505.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_OPEN_SETTINGS},
  506.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SAVE_SETTINGS},
  507.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SAVE_SETTINGS_AS},
  508.  
  509.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  510.     {  NM_ITEM, NULL,         0 , TICK,    0, (APTR)MEN_STATUS_WINDOW},
  511.     {  NM_ITEM, NULL,         0 , TICK,    0, (APTR)MEN_REVIEW_WINDOW},
  512.     {  NM_ITEM, NULL,         0 , CHECKIT,    0, (APTR)MEN_PACKET_WINDOW},
  513.     {  NM_ITEM, NULL,         0 , TICK,    0, (APTR)MEN_FAST_MACROS_WINDOW},
  514.     {   NM_END, 0,             0 , 0,        0, (APTR)0}
  515. };
  516.  
  517. struct Menu *Menu;
  518.  
  519.     /* Pointer. */
  520.  
  521. UWORD __chip Stopwatch[(1 + 16 + 1) * 2] =
  522. {
  523.     0x0000,0x0000,
  524.  
  525.     0x0400,0x07C0,
  526.     0x0000,0x07C0,
  527.     0x0100,0x0380,
  528.     0x0000,0x07E0,
  529.     0x07C0,0x1FF8,
  530.     0x1FF0,0x3FEC,
  531.     0x3FF8,0x7FDE,
  532.     0x3FF8,0x7FBE,
  533.     0x7FFC,0xFF7F,
  534.     0x7EFC,0xFFFF,
  535.     0x7FFC,0xFFFF,
  536.     0x3FF8,0x7FFE,
  537.     0x3FF8,0x7FFE,
  538.     0x1FF0,0x3FFC,
  539.     0x07C0,0x1FF8,
  540.     0x0000,0x07E0,
  541.  
  542.     0x0000,0x0000
  543. };
  544.  
  545.     /* Cross-hatch pattern. */
  546.  
  547. ULONG __chip Crosshatch = 0x5555AAAA;
  548.  
  549.     /* Configuration. */
  550.  
  551. struct Configuration    *Config,
  552.             *PrivateConfig,
  553.             *BackupConfig;
  554. struct SpeechConfig     SpeechConfig;
  555. BYTE             English = TRUE;
  556. BYTE             Status;
  557. BYTE             Online,WasOnline;
  558. ULONG             OnlineMinutes;
  559. UWORD             PublicModes;
  560.  
  561. UBYTE             LastConfig[MAX_FILENAME_LENGTH];
  562. UBYTE             DefaultPubScreenName[MAXPUBSCREENNAME + 1],
  563.              SomePubScreenName[MAXPUBSCREENNAME + 1];
  564.  
  565.     /* Capture file. */
  566.  
  567. struct Buffer        *FileCapture;
  568. BPTR             PrinterCapture;
  569. UBYTE             CaptureName[MAX_FILENAME_LENGTH];
  570. BYTE             StandardPrinterCapture,
  571.              ControllerActive;
  572.  
  573.     /* Buffer. */
  574.  
  575. UBYTE            **BufferLines;
  576. LONG             Lines;
  577. struct SignalSemaphore    *BufferSemaphore;
  578. LONG             MaxLines = 100;
  579. LONG             BufferSpace;
  580. BYTE             BufferClosed;
  581. BYTE             BufferFrozen;
  582.  
  583.     /* Phonebook. */
  584.  
  585. struct PhoneEntry    **Phonebook;
  586. LONG             PhoneSize;
  587. LONG             NumPhoneEntries;
  588. UBYTE             PhonePassword[256];
  589. BYTE             PhonePasswordUsed;
  590. UBYTE             Password[100];
  591. UBYTE             UserName[100];
  592. UBYTE             GlobalPassword[256];
  593.  
  594. UBYTE             CurrentBBSName[40],
  595.              CurrentBBSNumber[100],
  596.              CurrentBBSComment[100];
  597.  
  598. UBYTE             LastPhone[MAX_FILENAME_LENGTH];
  599. UBYTE             LastKeys[MAX_FILENAME_LENGTH];
  600. UBYTE             LastMacros[MAX_FILENAME_LENGTH];
  601. UBYTE             LastCursorKeys[MAX_FILENAME_LENGTH];
  602. UBYTE             LastTranslation[MAX_FILENAME_LENGTH];
  603. UBYTE             LastSpeech[MAX_FILENAME_LENGTH];
  604.  
  605. struct MacroKeys    *MacroKeys;
  606. struct CursorKeys    *CursorKeys;
  607.  
  608.     /* Console stuff. */
  609.  
  610. UBYTE            *StripBuffer;
  611. UWORD             LastLine,LastColumn,LastPixel;
  612. BYTE             Charset,Attributes,FgPen,BgPen;
  613. WORD             CursorX,CursorY,Top,Bottom;
  614. BYTE             UseRegion,RegionSet,InSequence,Quiet,Blocking;
  615. BYTE            *TabStops;
  616. UWORD             TabStopMax;
  617. BYTE             CharMode[2];
  618.  
  619. BYTE             ResetDisplay,DisplayReopened,FixPubScreenMode,FixScreenSize;
  620.  
  621.     /* Flow filter. */
  622.  
  623. STRPTR             AttentionBuffers[SCAN_COUNT];
  624. BYTE             BaudPending,FullCheck,UseFlow;
  625. UBYTE             BaudBuffer[80],BaudCount;
  626.  
  627. struct FlowInfo         FlowInfo;
  628.  
  629.     /* Transfer data. */
  630.  
  631. BYTE             BinaryTransfer;
  632. LONG             TransferBits;
  633.  
  634. VOID            (* __regargs ConTransfer)(STRPTR,LONG);
  635.  
  636. UBYTE            *DownloadPath;
  637. BYTE             Uploading;
  638. BYTE             DidTransfer;
  639.  
  640. struct Window        *TransferWindow;
  641. struct Menu        *TransferMenu;
  642. struct Gadget        *TransferGadgetArray[GAD_TRANSFER_SKIP + 1];
  643. struct List         TransferInfoList;
  644. struct TextBox        *TransferBoxArray[BOX_TRANSFER_RIGHT2 + 1],
  645.             *TransferBoxList;
  646. struct List         TransferInfoList;
  647.  
  648. struct FileTransferInfo    *FileTransferInfo;
  649.  
  650. struct XPR_IO        *XprIO;
  651.  
  652. UBYTE             ProtocolOptsBuffer[256];
  653. BYTE             NewLibrary,NewOptions;
  654. UBYTE             LastXprLibrary[MAX_FILENAME_LENGTH];
  655. UBYTE             ConvNumber[30],ConvNumber10[30];
  656. BYTE             UsesZModem,SendAbort,TransferAborted,TransferFailed;
  657.  
  658.     /* The standard ZModem cancel sequence
  659.      * (ten CAN chars followed by ten
  660.      * BS chars).
  661.      */
  662.  
  663. UBYTE ZModemCancel[] =
  664. {
  665.     24,24,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8
  666. };
  667.  
  668.     /* Pay per minute. */
  669.  
  670. LONG             CurrentPay;
  671. LONG             PayPerUnit[2];
  672. LONG             SecPerUnit[2];
  673. LONG             WhichUnit;
  674. struct PhoneEntry    *ChosenEntry;
  675. BYTE             ChosenInUse;
  676.  
  677.     /* Execute a command/script. */
  678.  
  679. UBYTE             WindowName[256];
  680.  
  681. BYTE             WeAreBlocking;
  682.  
  683.     /* Dial list. */
  684.  
  685. struct List        *DialList;
  686.  
  687. BYTE             SendStartup;
  688.  
  689.     /* TermMain data. */
  690.  
  691. BYTE             ReleaseSerial;
  692. BYTE             ResetSerial;
  693. BYTE             MainTerminated,
  694.              IconTerminated = TRUE,
  695.              DoIconify = FALSE,
  696.              DoDial = DIAL_IGNORE;
  697.  
  698. BYTE             ConfigChanged,PhonebookChanged,TranslationChanged,
  699.              MacroChanged,CursorKeysChanged,FastMacrosChanged,
  700.              HotkeysChanged,SpeechChanged,BufferChanged;
  701.  
  702.     /* Upload/Download paths. */
  703.  
  704. UBYTE             LastDownload[MAX_FILENAME_LENGTH];
  705. UBYTE             LastUpload[MAX_FILENAME_LENGTH];
  706.  
  707.     /* String gadget hooks. */
  708.  
  709. struct Hook         CommandHook,
  710.              PasswordHook;
  711. BYTE             DontActivate;
  712.  
  713. struct Window        *CommandWindow;
  714. struct Gadget        *CommandGadget;
  715. struct Gadget        *ActiveGadget;
  716.  
  717. struct Process        *ClipProcess;
  718. struct MsgPort        *ClipPort;
  719. BYTE             ClipInput,
  720.              ClipXerox,
  721.              ClipPrefix;
  722.  
  723.     /* Packet window. */
  724.  
  725. struct Window        *PacketWindow;
  726. struct Gadget        *PacketGadgetArray[2];
  727. struct Menu        *PacketMenu;
  728. struct Gadget        *PacketGadgetList;
  729. struct List         PacketHistoryList;
  730.  
  731.     /* Some more colour control flags. */
  732.  
  733. BYTE             Initializing,LoadColours;
  734.  
  735.     /* The character raster. */
  736.  
  737. UBYTE            *Raster,*RasterAttr;
  738. LONG             RasterWidth,RasterHeight;
  739. BYTE             Marking;
  740. struct SignalSemaphore    *RasterSemaphore;
  741. BYTE             RasterEnabled = TRUE;
  742.  
  743.     /* Generic lists. */
  744.  
  745. struct GenericList    *GenericListTable[GLIST_COUNT];
  746.  
  747.     /* File version test. */
  748.  
  749. ULONG VersionProps[2] =
  750. {
  751.     ID_TERM,
  752.     ID_VERS
  753. };
  754.  
  755.     /* Window stack. */
  756.  
  757. struct Window        *TopWindow;
  758.  
  759. struct Window        *WindowStack[5];
  760. WORD             WindowStackPtr;
  761.  
  762.     /* Global term ID. */
  763.  
  764. LONG             TermID;
  765. UBYTE             TermIDString[MAXPUBSCREENNAME + 1];
  766. UBYTE             RexxPortName[256];
  767.  
  768.     /* Fast! macros. */
  769.  
  770. struct List         FastMacroList;
  771. LONG             FastMacroCount;
  772. UBYTE             LastFastMacros[MAX_FILENAME_LENGTH];
  773. struct Window        *FastWindow;
  774. struct Gadget        *FastGadget;
  775.  
  776.     /* Double-buffered file locking. */
  777.  
  778. struct List         DoubleBufferList;
  779. struct SignalSemaphore     DoubleBufferSemaphore;
  780.  
  781.     /* XEM interface. */
  782.  
  783. struct XEM_IO        *XEM_IO;
  784. ULONG             XEM_Signal;
  785. struct XEmulatorHostData XEM_HostData;
  786. UBYTE            *OptionTitle;
  787. struct List         XEM_MacroList;
  788. struct XEmulatorMacroKey *XEM_MacroKeys;
  789. UBYTE             EmulationName[40];
  790.  
  791. struct List         EmptyList;
  792.  
  793.     /* Screen scrolling support. */
  794.  
  795. UWORD             ScrollLineFirst,ScrollLineLast,
  796.              ScrollLineCount;
  797. struct ScrollLineInfo    *ScrollLines;
  798.  
  799.     /* term review buffer. */
  800.  
  801. struct MsgPort        *ReviewPort;
  802. struct Window        *ReviewWindow;
  803.  
  804.     /* Background information. */
  805.  
  806. ULONG             BytesIn,
  807.              BytesOut;
  808. struct DateStamp     SessionStart;
  809. struct Window        *InfoWindow;
  810.  
  811.     /* Gadget support routines */
  812.  
  813. LONG             InterWidth,
  814.              InterHeight;
  815.  
  816.     /* Beep sound information */
  817.  
  818. struct SoundInfo     SoundInfo;
  819. BYTE             HasSound,SoundPlayed;
  820.  
  821.     /* Character translation. */
  822.  
  823. struct TranslationEntry    **SendTable,
  824.             **ReceiveTable;
  825.