home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / kl.zip / KLRing.kex < prev    next >
Text File  |  1997-03-17  |  4KB  |  113 lines

  1. ** (c) Copyright International Business Machines Corporation 1997.
  2. *                  All Rights Reserved.
  3. *
  4. *   KLRING (KEDIT Ring List for KL macro)          Version 1.0   1997-03-17
  5. *
  6. *   Command Syntax:   KLRING
  7. *                     (No argements are required.)
  8. *   Function:
  9. *     This macro lists files on the KEDIT ring and displays filespec for
  10. *     the files in a new file(Ring List file) on the KEDIT ring.
  11. *
  12. *     A KL list file opened by KL macro is displayed with a mark "<KL>"
  13. *     followed by file specifier for the KL list.
  14. *
  15. *     To select a file on the KEDIT ring, locate the cursor on the line in
  16. *     the Ring List file and press the Ctrl-ENTER keys, or type the number
  17. *     prefixed to the file in the KEDIT command line and press the Ctrl-ENTER
  18. *     keys.
  19. *
  20. *     To issue QUIT command for a file on Ring List, locate the cursor on
  21. *     the line and press F3. QQUIT command is issued by pressing S-F3.
  22. *
  23. *     To quit from Ring List, press ESC key or just press the Ctrl-ENTER keys.
  24. *
  25. *     Note that this macro can be used without KL macro.
  26. *
  27. *   Customization: Edit the first KEXX instruction of this macro.
  28. *
  29. *   Author: Shintaro  Hori
  30. */
  31. parse value 'ESC C-ENTER F3 S-F3 A-ENTER' with rExit rSel rQ rQQ rCmdL
  32.  
  33. title= center('KEDIT Ring List for KL macro',80)
  34. help =rExit'=Exit  'rSel'=Slect File  'rQ'=Quit File/List  'rQQ'=QQuit  'rCmdL'=CmdLine'
  35. 'extract /ring'
  36. do i=1 to ring.0
  37.    RL.i = right(i,3)'|' BldFileID(ring.i)
  38. end
  39. 'EDITV GET KLDIR'; xx = kldir'_K_L_R~I.N~G'
  40.  
  41. 'kedit' xx '(nomsg new'; 'set msgmode on'
  42. 'set idline off'; 'set scale off'; 'set autosave off';'set prefix off'
  43. 'set reserved  1 blue on light green' title
  44. 'set reserved -2 blue on light green' help
  45. do i = 1 to ring.0
  46.    'input' RL.i
  47. end
  48. 'sos tabcmd';':1'
  49. do forever
  50.    if size.1() = 0 then do; 'qquit'; leave; end
  51.    'readv key noignoremouse'; key = readv.1
  52.    if rc \= 0 then do
  53.       'dialog /Mouse input ignored, use Esc key to Exit/ TITLE /Ring List/'
  54.       iterate
  55.    end
  56.    q =0 /* quit flag */
  57.    'extract /curline/cmdline/'
  58.    parse value strip(curline.3) with rid '|' mark . /* Ring ID */
  59.  
  60.    if key=rExit   then do; q=1; rid=1; end
  61.    else if key=rSel | key='NUMENTER' then do
  62.       if command() then do
  63.          if datatype(cmdline.3,'W') then do; q=1; rid=cmdline.3; end
  64.          else if cmdline.3=''       then do; q=1; rid=1        ; end
  65.          else 'macro' key  /* Execute Command Line */
  66.       end
  67.       else do; if rid \='' then q=1; end
  68.    end
  69.    else if key=rQ  | key=rQQ     then  call DelList
  70.    else if key=rCmdL     then do
  71.       if command() then 'cursor home'
  72.                    else 'sos tabcmd'
  73.    end
  74.    else 'macro' key
  75.  
  76.    if q then do;
  77.         fid = ring.rid
  78.        'QQuit';'kedit' fid '(nodefext';leave
  79.    end
  80. end
  81. 'nomsg cursor cmdline'
  82. Return /* Exit */
  83.  
  84. BldFileID:
  85.   parse arg fid .
  86.   'KEDIT' fid; 'EDITV GETF KLIND KLSPEC.0'
  87. * if klind \=1 then return copies(' ',7) fid
  88.   if klind \=1 then return copies(' ',7) asisfid(fid)   /* use case-respected fid */
  89.   list = '<KL>'
  90.   do j=1 to klspec.0
  91.      'EDITV GETF KLSPEC.'j ; parse var klspec.j fid '/' opt
  92.      list=list '#'j'='fid  ; if opt \='' then list=list '/'opt
  93.   end
  94. Return list
  95. DelList:
  96.   'kedit' ring.rid '(nodefext'
  97.   if mark='<KL>' then do;'macro KL /Q';rc=0;end
  98.   else if key=rQ   then 'Quit'; else 'QQUIT'
  99.   saverc = rc
  100.   'kedit' xx '(nodefext'
  101.   if saverc =0 then do; 'cursor home'; 'sos delline'; end
  102.   else 'MSG This file has been modified.'
  103. Return
  104.  
  105. asisfid: procedure
  106.   parse arg fid
  107.  
  108.    /* get file id of mixed case */
  109.   'modify fileid' ; if rc\=0 then return fid
  110.   parse value cmdline.3() with . . fid
  111.   'sos tabcmd delend' /* delete contents */
  112. Return fid
  113.