home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / apple2 / 24259 < prev    next >
Encoding:
Text File  |  1992-11-19  |  4.7 KB  |  126 lines

  1. Newsgroups: comp.sys.apple2
  2. Path: sparky!uunet!cs.utexas.edu!hermes.chpc.utexas.edu!news.utdallas.edu!corpgate!bnrgate!nott!cunews!revcan!micor!beejay
  3. From: beejay@Micor.OCUnix.on.ca (Basil Johnson)
  4. Subject: Re: Editors
  5. Organization: M.B. Cormier INC.
  6. Date: Fri, 20 Nov 92 01:02:21 EST
  7. Message-ID: <maXiuB1w165w@Micor.OCUnix.on.ca>
  8. References: <9211180618.AA16914@chasm.scar.utoronto.ca>
  9. Sender: view@micor.ocunix.on.ca (View)
  10. Lines: 114
  11.  
  12. 90taobri@CHASM.SCAR.UTORONTO.CA (Brian Tao) writes:
  13.  
  14. >     Now that I've finished my mid-terms (and only one lab report to do
  15. > for the entire week!), I can start some serious pounding at my
  16. > AppleWorks 3.0 script for uemacs 3.11c.  Rather than taking the easy way
  17. > out and simply mimicking the keystrokes, I've started writing procedures
  18. > so that things like search-and-replace comes up with the same prompts.
  19. > There are a few things I can't do easily (like OA-1 thru OA-9 would be a
  20. > bitch to program), but it looks like it will be able to retain most of
  21. > the AppleWorks-style commands.
  22. > --
  23. > -=+ Brian Tao (taob@r-node.pci.on.ca, 90taobri@chasm.scar.utoronto.ca) +=-
  24. >                                    -=+=-
  25. >      -=+ MuGS: The Only Internet Mail Reader For The Apple IIGS! +=-
  26.  
  27.  
  28.  
  29. Not difficult at all, Brian.  I had to implement OA-1/OA-9 
  30. commands this past week-end with HyperC.  Well, I cheated a 
  31. bit.  HyperC doesn't have a function to peek at a memory 
  32. location so I wrote one in assembly for it.  I assume ORCA/C 
  33. has such a function.  If it does, you can port this easily.  
  34. If it doesn't I'm sure someone here will write the code for 
  35. you.  I could write the 8 bit code but I don't know how to 
  36. interface assembly and ORCA/C.
  37.  
  38. The HyperC getkey() function waits indefinitely until the keyboard
  39. is struck and returns the struck character with the high bit 
  40. clear.  The extended getkey function [getekey()] checks the 
  41. Open-Apple key (0xc061); the high bit is set if it is.  Since 
  42. the normal read of the keyboard has high bit low, I simply 
  43. set the high bit if the OA key was also struck.  So, all my 
  44. OA prefixed commands have the high bit set as is evident from 
  45. the defines.
  46.  
  47. This is not a program.  I have cut and paste the relevant 
  48. sections from mine for you.  Good Luck with your reader. 
  49.  
  50. Your compatriot in Ottawa,
  51. Basil
  52.  
  53. beejay@micor.ocunix.on.ca
  54. -- 
  55.                                 /* ASCII control characters */
  56. #define ASCNUL      3
  57. #define ASCBEL      7
  58. #define ASCBS       8
  59. #define ASCTAB      9
  60. #define ASCLF    0x0A
  61. #define ASCFF    0x0C
  62. #define ASCCR    0x0D
  63. #define ASCESC   0x1B
  64. #define ASCDEL   0x7F
  65. #define ASCSPACE 0x20
  66.                                 /* cursor movement Control keys */
  67. #define UPARROW     0x0b
  68. #define DOWNARROW   0x0a
  69. #define LEFTARROW   0x08
  70. #define RIGHTARROW  0x15
  71.  
  72.                                 /* Open-Apple command keys */
  73.                                 /*  (high bit is set) */
  74. #define HOMEKEY     0xb1        /* OA-1 (beginning of text) */
  75. #define ENDKEY      0xb9        /* OA-9 (end of text) */
  76. #define PGDNKEY     0x8a        /* OA-DownArrow (Page down) */
  77. #define PGUPKEY     0x8b        /* OA-UpArrow (Page up) */
  78. #define HELPKEY     0xbf        /* OA-? (Help) */
  79.  
  80. #define INVALIDCMD 999
  81.  
  82. int get_cmd()                   /* get next input command from keyboard 
  83. */
  84. {                               /* returns the command type entered */
  85.     int key ;                   /* the keyboard input value */
  86.                                 /*  (see keyio.h for values) */
  87.     int cmd ;                   /* the command type value */
  88.  
  89.     cmd = INVALIDCMD ;          /* get next keyboard input */
  90.     while(cmd == INVALIDCMD)
  91.         { key = getekey() ;     /* get next keyboard input */
  92.           switch(key)           /* classify the key pressed */
  93.             {
  94.             case PGDNKEY : cmd = NEXTPAGE   ;break ;
  95.             case PGUPKEY : cmd = PREVPAGE   ;break ;
  96.             case ASCESC  : cmd = EXITPGM    ;break ;
  97.             case HOMEKEY : cmd = FIRSTPAGE  ;break ;
  98.             case ENDKEY  : cmd = LASTPAGE   ;break ;
  99.             case UPARROW : cmd = PREVLINE   ;break ;
  100.             case DOWNARROW: cmd = NEXTLINE  ;break ;
  101.             case HELPKEY : cmd = HELPCMD    ;break ;
  102.             default      : cmd = INVALIDCMD ;
  103.             }   /* end of switch statement */
  104.         }
  105.     return(cmd) ;
  106.  }
  107.  
  108.  
  109. /* getekey - waits for and returns the next keystroke input */
  110. /*         - use when expecting OA commands and other commands */
  111. /* Use HyperC's getkey() when OA commands are not expected */
  112.  
  113. int getekey()                       /* get the next key input */
  114.  {
  115.     int c ;
  116.  
  117.     c = getkey(YES) ;                  /* get single ASCII character */
  118.     if(peekb(0xc061) >= 0x80)          /* check for open-apple */
  119.         c = 0x80 + c ;
  120.     return (c) ;
  121.  }
  122.  
  123.  
  124.