home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODEM / UWPC201.ZIP / UW-SRC.ZIP / ANSI.CAP < prev    next >
Encoding:
Text File  |  1991-08-04  |  8.3 KB  |  371 lines

  1. //-------------------------------------------------------------------------
  2. //
  3. // ANSI.CAP - Capability file for the ANSI terminal type.  This is sort
  4. //          of a combination of ANSI and VT102.
  5. // 
  6. //  This file is part of UW/PC - a multi-window comms package for the PC.
  7. //  Copyright (C) 1990-1991  Rhys Weatherley
  8. //
  9. //  This program is free software; you can redistribute it and/or modify
  10. //  it under the terms of the GNU General Public License as published by
  11. //  the Free Software Foundation; either version 1, or (at your option)
  12. //  any later version.
  13. //
  14. //  This program is distributed in the hope that it will be useful,
  15. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. //  GNU General Public License for more details.
  18. //
  19. //  You should have received a copy of the GNU General Public License
  20. //  along with this program; if not, write to the Free Software
  21. //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. //
  23. // Revision History:
  24. // ================
  25. //
  26. //  Version  DD/MM/YY  By  Description
  27. //  -------  --------  --  --------------------------------------
  28. //    1.0    25/05/91  RW  Original Version of ANSI.CAP
  29. //    1.1    25/07/91  RW  Add support for client escapes.
  30. //    1.2    04/08/91  RW  Attempt to fix it and make it work. :-(
  31. //
  32. // You may contact the author by:
  33. // =============================
  34. //
  35. //  e-mail: rhys@cs.uq.oz.au
  36. //    mail: Rhys Weatherley
  37. //          5 Horizon Drive
  38. //          Jamboree Heights
  39. //          Queensland 4074
  40. //        Australia
  41. //
  42. //-------------------------------------------------------------------------
  43.  
  44.         name    "ANSI"        // Name of the terminal type.
  45.  
  46. start:        reset    0        // Reset insert mode flag.
  47.         setattr    0        // Reset current attribute.
  48. loop:        getch            // Get next character from remote.
  49. loop2:        switch            // Determine top-level action.
  50.           0x00,loop        // Ignore NUL characters
  51.           '\r',crproc
  52.           '\n',lfproc
  53.           '\b',bsproc
  54.           '\t',tabproc
  55.           0x07,bellproc
  56.           0x1B,escproc
  57.         endsw
  58.         test    0        // Test the insertion flag.
  59.         jne    insert
  60.         send            // Send the character direct.
  61.         jmp    loop
  62. insert:        inschar            // Insert the received character.
  63.         jmp    loop        // Back around for another character.
  64. crproc:        cr
  65.         jmp    loop
  66. lfproc:        lf
  67.         jmp    loop
  68. bsproc:        bs
  69.         jmp    loop
  70. tabproc:    tab
  71.         jmp    loop
  72. dotabs:        geta    1,1        // Get number of tabs to do.
  73.         cmp    0
  74.         je    loop
  75.         setc
  76. tabloop:    tab
  77.         dec
  78.         jne    tabloop
  79.         jmp    loop
  80. bellproc:    bell
  81.         jmp    loop
  82. ignorearg:    dec            // This is not nice to the
  83.         jmp    getnums        // abstract emulation machine!!
  84. escproc:    getch            // Get the escape character.
  85.         cmp    '['        // Check for ESC [ sequences
  86.         jne    singles
  87.         resarr            // Prepare to fill the argument array.
  88. getnums:    getarg            // Get a numeric argument.
  89.         cmp    ';'        // Check if another is to follow.
  90.         je    getnums
  91.         cmp    '?'        // If '?' then ignore it (for now).
  92.         je    ignorearg
  93.         cmp    '>'
  94.         je    ignorearg    // Ignore '>'s as well.
  95.         cmp    0x1B        // If ESC then get another sequence.
  96.         je    escproc
  97.         switch            // Test escape action wanted.
  98.           '@',doinschar
  99.           'A',upline
  100.           'B',dnline
  101.           'C',right
  102.           'D',left
  103.           'E',crlf
  104.           'F',upscroll
  105.           'G',setcolumn
  106.           'H',domove
  107.           'I',dotabs
  108.           'J',doclear
  109.           'K',doclrln
  110.           'L',doinsline
  111.           'M',dodelline
  112.           'P',dodelchar
  113.           'Z',loop        // Backtab - ignored for now.
  114.           'a',right
  115.           'b',loop        // Repeat char - ignored for now.
  116.           'd',setrow
  117.           'e',dnline
  118.           'f',domove
  119.           'g',loop        // Clear tabs - don't worry.
  120.           'h',chkins
  121.           'l',chkins2
  122.           'm',attrs
  123.           'r',loop        // No scrolling margins yet.
  124.           's',saveall
  125.           'u',restall
  126.           '|',doclient        // UW/PC client escapes.
  127.         endsw
  128.         jmp    loop        // Ignore the escape sequence.
  129. doclient:    getch            // Get the client operation character.
  130.         client
  131.         jmp    loop
  132. chkins:        geta    1,0
  133.         cmp    4        // Check to see if insert mode is req.
  134.         je    enterins
  135.         jmp    loop
  136. chkins2:    geta    1,0
  137.         cmp    4        // Check for normal mode request.
  138.         je    exitins
  139.         jmp    loop
  140. saveall:    savexy            // Save the terminal statistics.
  141.         saveattr
  142.         jmp    loop
  143. restall:    restxy            // Restore the terminal statistics.
  144.         restattr
  145.         jmp    loop    
  146. singles:    resarr            // Reset arg array for cursor moves.
  147.         switch            // Test single code after ESC.
  148.           '7',saveall
  149.           '8',restall
  150.           'D',dnline
  151.           'E',crlf
  152.           'H',loop        // Set tab - ignored here.
  153.           'M',upscroll
  154.           'c',hardreset
  155.           '#',dummy        // Ignore character size requests.
  156.         endsw
  157.         jmp    loop
  158. dummy:        getch
  159.         jmp    loop
  160. hardreset:    clear            // Reset terminal characteristics.
  161.         load    0
  162.         setx
  163.         sety
  164.         move
  165.         jmp    start
  166. right:        geta    1,1        // Get number of places to move right.
  167.         cmp    0
  168.         je    loop        // Ignore move if 0
  169.         setc            // Set argument counter
  170. rightloop:    getxy
  171.         getx
  172.         add    1
  173.         cmp    width
  174.         jae    docrlf
  175.         setx
  176.         move
  177.         dec
  178.         jne    rightloop
  179.         jmp    loop
  180. docrlf:        cr
  181.         lf
  182.         dec
  183.         jne    rightloop
  184.         jmp    loop
  185. left:        geta    1,1        // Get number of places to move left.
  186.         cmp    0
  187.         je    loop        // Ignore move if 0
  188.         setc            // Set argument counter
  189. leftloop:    getxy
  190.         getx
  191.         cmp    0
  192.         je    loop
  193.         sub    1
  194.         setx
  195.         move
  196.         dec
  197.         jne    leftloop
  198.         jmp    loop
  199. setcolumn:    geta    1,1        // Get first argument (def is 1)
  200.         sub    1
  201.         getxy
  202.         setx
  203.         move
  204.         jmp    loop
  205. setrow:        geta    1,1        // Get first argument (def is 1)
  206.         sub    1
  207.         getxy
  208.         sety
  209.         move
  210.         jmp    loop
  211. crlf:        geta    1,1        // Get number of CRLF's to do.
  212.         cmp    0
  213.         je    loop
  214.         setc
  215. crlfloop:    cr
  216.         lf
  217.         dec
  218.         jne    crlfloop
  219.         jmp    loop
  220. upline:        geta    1,1        // Get number of places to move up.
  221.         cmp    0
  222.         je    loop        // Ignore move if 0
  223.         setc            // Set argument counter
  224. uploop:        getxy
  225.         gety
  226.         cmp    0
  227.         je    loop
  228.         sub    1
  229.         sety
  230.         move
  231.         dec
  232.         jne    uploop
  233.         jmp    loop
  234. upscroll:    geta    1,1        // Get number of times to scroll up.
  235.         cmp    0
  236.         je    loop
  237.         setc
  238. upscloop:    getxy
  239.         gety
  240.         cmp    0
  241.         je    doscrollup
  242.         sub    1
  243.         sety
  244.         move
  245.         dec
  246.         jne    upscloop
  247.         jmp    loop
  248. doscrollup:    insline
  249.         jmp    loop
  250. dnline:        geta    1,1        // Get number of places to move down.
  251.         cmp    0
  252.         je    loop        // Ignore move if 0
  253.         setc            // Set argument counter
  254. dnloop:        lf
  255.         dec
  256.         jne    dnloop
  257.         jmp    loop
  258. doclear:    geta    1,0        // get clear code (def is 0)
  259.         switch
  260.           0,clrend
  261.           1,clrhome
  262.           2,clrall
  263.         endsw
  264. clrend:        clreos
  265.         jmp    loop
  266. clrhome:    clrsos
  267.         jmp    loop
  268. clrall:        clear
  269.         jmp    loop
  270. doclrln:    geta    1,0        // get clear code (def is 0)
  271.         switch
  272.           0,clrendln
  273.           1,clrstart
  274.           2,clrline
  275.         endsw
  276. clrendln:    clreol
  277.         jmp    loop
  278. clrline:    clreol
  279. clrstart:    clrsol
  280.         jmp    loop
  281. home:        load    0
  282.         setx
  283.         sety
  284.         move
  285.         jmp    loop
  286. domove:        geta    1,1
  287.         sub    1
  288.         sety
  289.         geta    2,1
  290.         sub    1
  291.         setx
  292.         move
  293.         jmp    loop
  294. doinsline:    geta    1,1        // Get number of lines to insert.
  295.         cmp    0
  296.         je    loop
  297.         setc
  298. insloop:    insline
  299.         dec
  300.         jne    insloop
  301.         jmp    loop
  302. doinschar:    geta    1,1        // Get number of chars to insert.
  303.         cmp    0
  304.         je    loop
  305.         setc
  306. insloop2:    insblank
  307.         dec
  308.         jne    insloop2
  309.         jmp    loop
  310. attrs:        setattr    0        // Go to the normal attribute first
  311.         dec
  312.         jb    loop        // No arguments - ignore rest.
  313. attrloop:    geta    1,0        // Get next attribute indicator
  314.         cmp    0        // Check for normal attr.
  315.         je    normattr
  316.         cmp    11        // Exit graphics mode on Heath-19.
  317.         je    normattr
  318.         cmp    1        // Check for the "bold" attribute.
  319.         je    bold
  320.         setattr    1        // Set inverse for everything else.
  321.         shift
  322.         dec
  323.         jae    attrloop
  324.         jmp    loop
  325. normattr:    shift
  326.         jmp    attrs
  327. bold:        setattr    2        // Set bold as the highlighted attr.
  328.         shift
  329.         dec
  330.         jae    attrloop
  331.         jmp    loop
  332. normal:        setattr    0
  333.         jmp    loop
  334. standout:    setattr 1
  335.         jmp    loop
  336. dodelline:    geta    1,1        // Get number of lines to delete.
  337.         cmp    0
  338.         je    loop
  339.         setc
  340. delloop:    delline
  341.         dec
  342.         jne    delloop
  343.         jmp    loop
  344. dodelchar:    delchar
  345.         jmp    loop
  346. dodelchar:    geta    1,1        // Get number of chars to delete.
  347.         cmp    0
  348.         je    loop
  349.         setc
  350. delloop2:    delchar
  351.         dec
  352.         jne    delloop2
  353.         jmp    loop
  354. enterins:    set    0            // Enter insert mode.
  355.         jmp    loop
  356. exitins:    reset    0            // Exit insert mode.
  357.         jmp    loop
  358. //
  359. // Define the keyboard translations to be performed.
  360. //
  361. keys:        key    0x4800,"\033[A"        // Cursor Up key
  362.         key    0x5000,"\033[B"        // Cursor Down key
  363.         key    0x4D00,"\033[C"        // Cursor Right key
  364.         key    0x4B00,"\033[D"        // Cursor Left key
  365.         key    0x4700,"\033[H"        // Cursor Home key
  366.         key    0x3B00,"\033OP"        // F1 (VT100)
  367.         key    0x3C00,"\033OQ"        // F2 (VT100)
  368.         key    0x3D00,"\033OR"        // F3 (VT100)
  369.         key    0x3E00,"\033OS"        // F4 (VT100)
  370.         endkeys
  371.