home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / editor / epmtools / epmmac / modify.e < prev    next >
Encoding:
Text File  |  1993-07-15  |  7.9 KB  |  231 lines

  1. ;  MODIFY.E                                              Bryan Lewis 12/31/88
  2. ;
  3. ;  New in EPM.  This DEFMODIFY event is triggered when a file's number of
  4. ;  modifications (.modify):
  5. ;  -  goes from zero to nonzero (first modification, so we can change the
  6. ;     textcolor or title to indicate that the file needs to be saved;
  7. ;  -  goes from nonzero to zero (so we can return to the safe textcolor,
  8. ;     usually after a save);
  9. ;  -  goes from less than .autosave to greater than or equal to .autosave.
  10. ;
  11. ;
  12. ;  Note:  .modify does not always increase smoothly, one increment at a time.
  13. ;  For instance, changing a line and hitting Enter increases .modify by 2,
  14. ;  because it registers the change to the previous line as well as the new
  15. ;  line.  So we can't expect .modify to be exactly 1; we have to look for
  16. ;  a transition from zero to nonzero.
  17. ;
  18. ;  Note 2:  E will not retrigger this event while the event is in
  19. ;  progress, to protect against infinite recursion.  So if you make a lot
  20. ;  of changes to a file in the process of autosaving it, it won't get autosaved
  21. ;  twice.
  22. ;
  23. ;  We've provided three methods of showing the modified status.
  24. ;  1. The COLOR method changes the window color, for a very obvious indicator.
  25. ;  2. The FKTEXTCOLOR method changes the color of the bottom line of the
  26. ;     screen, for EOS2 only.
  27. ;  3. The TITLE method does one of two things.  For EOS2 it changes the color
  28. ;     of the filename.  For EPM it adds the string " (mod)" to the title bar.
  29. ;     This isn't as obvious as COLOR, but you can check it even when the file
  30. ;     is shrunk to an icon by clicking on the icon.
  31. ;
  32. ;  You, the macro writer, can add to or replace this behavior.
  33. ;  1. You can write defmodify procedures anywhere in your MYSTUFF.E or
  34. ;     MYKEYS.E files.  All defmodify procedures will be executed in sequence,
  35. ;     just as definit preocedures are.  The pieces can be anywhere.
  36. ;  2. Or you can write a DEFMODIFY event in a linked module, and it will
  37. ;     replace this one entirely.  For example, create a file NEWMOD.E with
  38. ;     your defmodify proc; compile it separately (ETPM NEWMOD); add a link
  39. ;     statement (link 'newmod') to your MYKEYS.E or MYSTUFF.E file.
  40. ;
  41.  
  42. define
  43. compile if EVERSION >= '5.20'  -- 5.20 adds a HINI to the *Profile calls.
  44.    HINI_PARM = 'app_hini,'
  45. compile else
  46.    HINI_PARM = ' '
  47. compile endif
  48.  
  49.  
  50. compile if SHOW_MODIFY_METHOD = 'COLOR'
  51.  
  52. defmodify
  53.  compile if EPM
  54.    universal  appname, app_hini
  55.  compile else
  56.    universal comsfileid
  57.  compile endif
  58.    getfileid fileid
  59.    if .autosave and .modify>=.autosave then
  60.  compile if EPM
  61.       if leftstr(.filename,1,1) <> '.' | .filename = UNNAMED_FILE_NAME then
  62.   compile if EVERSION >= '5.50'
  63.          sayerror AUTOSAVING__MSG
  64.   compile else
  65.          sayatbox(AUTOSAVING__MSG)
  66.   compile endif
  67.  compile else
  68.       if fileid <> comsfileid & substr(.filename,1,1) <> '.' then
  69.  compile endif
  70.  compile if EVERSION >= '5.50'
  71.          'xcom save "'MakeTempName()'"'
  72.  compile else
  73.          'xcom save 'MakeTempName()
  74.  compile endif
  75.          .modify=1                  /* Reraise the modify flag. */
  76.  compile if EVERSION >= '5.50'
  77.          sayerror 0
  78.  compile endif
  79.       endif
  80.    endif
  81.  compile if EVERSION < 5
  82.    fids = fileidfromanchorblock(.anchorblock)  -- Get list of fileids
  83.    do while fids <> ''
  84.       parse value fids with fileid fids
  85.       if .modify then
  86.          fileid.markcolor  = MODIFIED_MARKCOLOR
  87.          fileid.windowcolor= MODIFIED_WINDOWCOLOR
  88.       else -- if .modify==0 then
  89.          fileid.markcolor  = MARKCOLOR
  90.          fileid.windowcolor= WINDOWCOLOR
  91.       endif
  92.    end  -- do while
  93.  compile else                   -- EPM
  94.    if .modify then
  95.       .markcolor= MODIFIED_MARKCOLOR
  96.       .textcolor= MODIFIED_WINDOWCOLOR
  97.    else -- if .modify==0 then
  98.       .markcolor= MARKCOLOR
  99.       .textcolor= TEXTCOLOR
  100. compile if WANT_APPLICATION_INI_FILE
  101.       newcmd=queryprofile( $HINI_PARM appname, INI_TEXTCOLOR)
  102.       if newcmd then .textcolor=newcmd endif
  103.       newcmd=queryprofile( $HINI_PARM appname, INI_MARKCOLOR)
  104.       if newcmd then .markcolor=newcmd endif
  105. compile endif
  106.    endif
  107.    refresh
  108.    repaint_window()
  109.  compile endif
  110. compile endif -- COLOR
  111.  
  112.  
  113. compile if SHOW_MODIFY_METHOD = 'TITLE'
  114.  compile if EVERSION >= 5
  115. const
  116.    -- This is what we'll append to the file title.
  117.   compile if not defined(SHOW_MODIFY_TEXT)   -- If user didn't define in MYCNF:
  118.    SHOW_MODIFY_TEXT = ' (mod)'
  119.   compile endif
  120.  
  121. defmodify
  122.    if .autosave and .modify>=.autosave then
  123.       getfileid fileid
  124.       if leftstr(.filename,1,1) <> '.' | .filename = UNNAMED_FILE_NAME then
  125.   compile if EVERSION >= '5.50'
  126.          sayerror AUTOSAVING__MSG
  127.   compile else
  128.          sayatbox(AUTOSAVING__MSG)
  129.   compile endif
  130.   compile if EVERSION >= '5.50'
  131.          'xcom save "'MakeTempName()'"'
  132.   compile else
  133.          'xcom save 'MakeTempName()
  134.   compile endif
  135.          .modify=1                  /* Reraise the modify flag. */
  136.   compile if EVERSION >= '5.50'
  137.           sayerror 0
  138.   compile elseif EPM
  139.          refresh
  140.          call repaint_window()
  141.   compile endif
  142.       endif
  143.    endif
  144.    settitletext(.filename) -- This procedure adds the SHOW_MODIFY_TEXT.
  145.  compile else   -- Not EPM
  146.    -- When the file is modified, change the color of the filename.
  147. defmodify
  148.    universal comsfileid
  149.    if .autosave and .modify>=.autosave then
  150.       getfileid fileid
  151.       if fileid <> comsfileid & substr(.filename,1,1) <> '.' then
  152.          'xcom save 'MakeTempName()
  153.          .modify=1                  /* Reraise the modify flag. */
  154.       endif
  155.    endif
  156.    fids = fileidfromanchorblock(.anchorblock)  -- Get list of fileids
  157.    do while fids <> ''
  158.       parse value fids with fileid fids
  159.       if .modify then
  160.          fileid.filenamecolor= MODIFIED_FILENAMECOLOR
  161.          fileid.monofilenamecolor= MODIFIED_MONOFILENAMECOLOR
  162.       else -- if .modify==0 then
  163.          fileid.filenamecolor= FILENAMECOLOR
  164.          fileid.monofilenamecolor= MONOFILENAMECOLOR
  165.       endif
  166.    end  -- do while
  167.  compile endif  -- not EPM
  168. compile endif  -- title
  169.  
  170.  
  171. compile if SHOW_MODIFY_METHOD = 'FKTEXTCOLOR'
  172. defmodify
  173.    universal comsfileid
  174.    if .autosave and .modify>=.autosave then
  175.       getfileid fileid
  176.       if fileid <> comsfileid & substr(.filename,1,1) <> '.' then
  177.          'xcom save 'MakeTempName()
  178.          .modify=1                  /* Reraise the modify flag. */
  179.       endif
  180.    endif
  181.    fids = fileidfromanchorblock(.anchorblock)  -- Get list of fileids
  182.    do while fids <> ''
  183.       parse value fids with fileid fids
  184.       if .modify then
  185.          fileid.functionkeytextcolor= MODIFIED_FKTEXTCOLOR
  186.       else -- if .modify==0 then
  187.          fileid.functionkeytextcolor= FUNCTIONKEYTEXTCOLOR
  188.       endif
  189.    end  -- do while
  190. compile endif  -- statuscolor
  191.  
  192.  
  193. compile if SHOW_MODIFY_METHOD = ''  -- No change in display, just do AUTOSAVE.
  194. defmodify
  195.  compile if not EPM
  196.    universal comsfileid
  197.  compile endif
  198.    if .autosave and .modify>=.autosave then
  199.       getfileid fileid
  200.  compile if EPM
  201.       if leftstr(.filename,1,1) <> '.' | .filename = UNNAMED_FILE_NAME then
  202.   compile if EVERSION >= '5.50'
  203.          sayerror AUTOSAVING__MSG
  204.   compile else
  205.          sayatbox(AUTOSAVING__MSG)
  206.   compile endif
  207.  compile else
  208.       if fileid <> comsfileid & substr(.filename,1,1) <> '.' then
  209.  compile endif
  210.   compile if EVERSION >= '5.50'
  211.          'xcom save "'MakeTempName()'"'
  212.   compile else
  213.          'xcom save 'MakeTempName()
  214.   compile endif
  215.          .modify=1                  /* Reraise the modify flag. */
  216.  compile if EVERSION >= '5.50'
  217.           sayerror 0
  218.  compile elseif EPM
  219.          refresh
  220.          call repaint_window()
  221.  compile endif
  222.       endif
  223.    endif
  224. compile endif  -- No display change.
  225.  
  226. compile if INCLUDE_BMS_SUPPORT  -- Put this at the end, so it will be included in any of the above
  227.    if isadefproc('BMS_defmodify_exit') then
  228.       call BMS_defmodify_exit()
  229.    endif
  230. compile endif
  231.