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