home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / comprgs / term232.lha / Source_Code / termSource / termData.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-18  |  18.5 KB  |  792 lines

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