home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / epmmac2.zip / MODIFY.E < prev    next >
Text File  |  1992-12-16  |  8KB  |  227 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. compile if WANT_APPLICATION_INI_FILE
  43. define
  44.  compile if EVERSION >= '5.20'  -- 5.20 adds a HINI to the *Profile calls.
  45.    HINI_PARM = 'app_hini,'
  46.  compile else
  47.    HINI_PARM = ' '
  48.  compile endif
  49. compile endif
  50.  
  51.  
  52. compile if SHOW_MODIFY_METHOD = 'COLOR'
  53.  
  54. defmodify
  55.  compile if EPM
  56.    universal  appname, app_hini
  57.  compile else
  58.    universal comsfileid
  59.  compile endif
  60.    getfileid fileid
  61.    if .autosave and .modify>=.autosave then
  62.  compile if EPM
  63.       if leftstr(.filename,1,1) <> '.' | .filename = UNNAMED_FILE_NAME then
  64.   compile if EVERSION >= '5.50'
  65.          sayerror AUTOSAVING__MSG
  66.   compile else
  67.          sayatbox(AUTOSAVING__MSG)
  68.   compile endif
  69.  compile else
  70.       if fileid <> comsfileid & substr(.filename,1,1) <> '.' then
  71.  compile endif
  72.  compile if EVERSION >= '5.50'
  73.          'xcom save "'MakeTempName()'"'
  74.  compile else
  75.          'xcom save 'MakeTempName()
  76.  compile endif
  77.          .modify=1                  /* Reraise the modify flag. */
  78.  compile if EVERSION >= '5.50'
  79.          sayerror 0
  80.  compile endif
  81.       endif
  82.    endif
  83.  compile if EVERSION < 5
  84.    fids = fileidfromanchorblock(.anchorblock)  -- Get list of fileids
  85.    do while fids <> ''
  86.       parse value fids with fileid fids
  87.       if .modify then
  88.          fileid.markcolor  = MODIFIED_MARKCOLOR
  89.          fileid.windowcolor= MODIFIED_WINDOWCOLOR
  90.       else -- if .modify==0 then
  91.          fileid.markcolor  = MARKCOLOR
  92.          fileid.windowcolor= WINDOWCOLOR
  93.       endif
  94.    end  -- do while
  95.  compile else                   -- EPM
  96.    if .modify then
  97.       .markcolor= MODIFIED_MARKCOLOR
  98.       .textcolor= MODIFIED_WINDOWCOLOR
  99.    else -- if .modify==0 then
  100.       .markcolor= MARKCOLOR
  101.       .textcolor= TEXTCOLOR
  102. compile if WANT_APPLICATION_INI_FILE
  103.       newcmd=queryprofile( $HINI_PARM appname, INI_TEXTCOLOR)
  104.       if newcmd then .textcolor=newcmd endif
  105.       newcmd=queryprofile( $HINI_PARM appname, INI_MARKCOLOR)
  106.       if newcmd then .markcolor=newcmd endif
  107. compile endif
  108.    endif
  109.    refresh
  110.    repaint_window()
  111.  compile endif
  112. compile endif -- COLOR
  113.  
  114.  
  115. compile if SHOW_MODIFY_METHOD = 'TITLE'
  116.  compile if EVERSION >= 5
  117. const
  118.    -- This is what we'll append to the file title.
  119.   compile if not defined(SHOW_MODIFY_TEXT)   -- If user didn't define in MYCNF:
  120.    SHOW_MODIFY_TEXT = ' (mod)'
  121.   compile endif
  122.  
  123. defmodify
  124.    if .autosave and .modify>=.autosave then
  125.       getfileid fileid
  126.       if leftstr(.filename,1,1) <> '.' | .filename = UNNAMED_FILE_NAME then
  127.   compile if EVERSION >= '5.50'
  128.          sayerror AUTOSAVING__MSG
  129.   compile else
  130.          sayatbox(AUTOSAVING__MSG)
  131.   compile endif
  132.   compile if EVERSION >= '5.50'
  133.          'xcom save "'MakeTempName()'"'
  134.   compile else
  135.          'xcom save 'MakeTempName()
  136.   compile endif
  137.          .modify=1                  /* Reraise the modify flag. */
  138.   compile if EVERSION >= '5.50'
  139.           sayerror 0
  140.   compile elseif EPM
  141.          refresh
  142.          call repaint_window()
  143.   compile endif
  144.       endif
  145.    endif
  146.    settitletext(.filename) -- This procedure adds the SHOW_MODIFY_TEXT.
  147.  compile else   -- Not EPM
  148.    -- When the file is modified, change the color of the filename.
  149. defmodify
  150.    universal comsfileid
  151.    if .autosave and .modify>=.autosave then
  152.       getfileid fileid
  153.       if fileid <> comsfileid & substr(.filename,1,1) <> '.' then
  154.          'xcom save 'MakeTempName()
  155.          .modify=1                  /* Reraise the modify flag. */
  156.       endif
  157.    endif
  158.    fids = fileidfromanchorblock(.anchorblock)  -- Get list of fileids
  159.    do while fids <> ''
  160.       parse value fids with fileid fids
  161.       if .modify then
  162.          fileid.filenamecolor= MODIFIED_FILENAMECOLOR
  163.          fileid.monofilenamecolor= MODIFIED_MONOFILENAMECOLOR
  164.       else -- if .modify==0 then
  165.          fileid.filenamecolor= FILENAMECOLOR
  166.          fileid.monofilenamecolor= MONOFILENAMECOLOR
  167.       endif
  168.    end  -- do while
  169.  compile endif  -- not EPM
  170. compile endif  -- title
  171.  
  172.  
  173. compile if SHOW_MODIFY_METHOD = 'FKTEXTCOLOR'
  174. defmodify
  175.    universal comsfileid
  176.    if .autosave and .modify>=.autosave then
  177.       getfileid fileid
  178.       if fileid <> comsfileid & substr(.filename,1,1) <> '.' then
  179.          'xcom save 'MakeTempName()
  180.          .modify=1                  /* Reraise the modify flag. */
  181.       endif
  182.    endif
  183.    fids = fileidfromanchorblock(.anchorblock)  -- Get list of fileids
  184.    do while fids <> ''
  185.       parse value fids with fileid fids
  186.       if .modify then
  187.          fileid.functionkeytextcolor= MODIFIED_FKTEXTCOLOR
  188.       else -- if .modify==0 then
  189.          fileid.functionkeytextcolor= FUNCTIONKEYTEXTCOLOR
  190.       endif
  191.    end  -- do while
  192. compile endif  -- statuscolor
  193.  
  194.  
  195. compile if SHOW_MODIFY_METHOD = ''  -- No change in display, just do AUTOSAVE.
  196. defmodify
  197.  compile if not EPM
  198.    universal comsfileid
  199.  compile endif
  200.    if .autosave and .modify>=.autosave then
  201.       getfileid fileid
  202.  compile if EPM
  203.       if leftstr(.filename,1,1) <> '.' | .filename = UNNAMED_FILE_NAME then
  204.   compile if EVERSION >= '5.50'
  205.          sayerror AUTOSAVING__MSG
  206.   compile else
  207.          sayatbox(AUTOSAVING__MSG)
  208.   compile endif
  209.  compile else
  210.       if fileid <> comsfileid & substr(.filename,1,1) <> '.' then
  211.  compile endif
  212.   compile if EVERSION >= '5.50'
  213.          'xcom save "'MakeTempName()'"'
  214.   compile else
  215.          'xcom save 'MakeTempName()
  216.   compile endif
  217.          .modify=1                  /* Reraise the modify flag. */
  218.  compile if EVERSION >= '5.50'
  219.           sayerror 0
  220.  compile elseif EPM
  221.          refresh
  222.          call repaint_window()
  223.  compile endif
  224.       endif
  225.    endif
  226. compile endif  -- No display change.
  227.