home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / p2demo21.exe / PEL / MINSAVE.PEL < prev    next >
Text File  |  1995-03-31  |  3KB  |  114 lines

  1. # $Header:   P:\source\wmacros\minsave.pev   1.15   31 Mar 1995 12:58:54   PFHCFV0  $
  2. ## $Tabs:4 7$
  3.  
  4. ##############################################################################
  5. #
  6. #       Compuware Corporation
  7. #         31440 Northwestern Highway
  8. #           Farmington Hills, Michigan 48334-2564
  9. #
  10. #   This source code listing contains information that is
  11. #   proprietary to Compuware Corporation and may not be copied
  12. #   duplicated, translated, transmitted, stored, retrieved
  13. #   or in any manner or by any method conveyed or disclosed
  14. #   to a third party or parties without express written
  15. #   permission from Compuware Corporation.
  16. #
  17. #  
  18. ##############################################################################
  19.  
  20.  
  21. #### $Workfile:   minsave.pel  $: 
  22.  
  23.  
  24. global function minimize_and_save()
  25. {
  26.    local buf
  27.    local i         = buffers_modified
  28.    local oldBuffer = current_buffer
  29.    local c, curr_win
  30.  
  31.    # check to see if any files need saving
  32.    if ( i )
  33.    {       
  34.       buf = sprintf( "%d %s been modified, Minimize[ynw]? ", \
  35.                      i, i > 1 ? "buffers have" : "buffer has")
  36.  
  37.       c = tolower( confirm(buf, "yYnNwW") )
  38.  
  39.       if (c == "w") 
  40.       {        
  41.          if ( write_all_buffers() ) 
  42.          {
  43.             current_buffer = oldBuffer
  44.          }
  45.          else
  46.          {
  47.             warning("Could not write all buffers!")
  48.             return;
  49.          }
  50.       }
  51.    }
  52.    
  53.    if (!i || (c && (c != "n")) )
  54.       set_editwin_property(EWC_MINIMIZE)
  55.  
  56.    # if in detached mode must minimize all text windows also
  57.    if ( mdi_mode == 2 )
  58.    {
  59.       curr_win = current_window
  60.       collapse_window()
  61.  
  62.       while ( curr_win != next_window("", 0, 1) )
  63.       {
  64.          collapse_window()
  65.       }
  66.    }
  67. }
  68.  
  69. local FILE_REGEX = "[a-zA-Z0-9_:\\\\./]+"
  70.  
  71. global function open_file_under_cursor( filename, path, isDirs )
  72. {
  73.    local fn = filename ? filename : file_under_cursor()
  74.    local fn2
  75.    local status = ""
  76.    local env_vars = path ? path : "INCLUDE;PATH;DPATH"
  77.  
  78.    if ( !fn )
  79.    {
  80.       warning("No file under cursor" )
  81.       return status;
  82.    }
  83.  
  84.    # check for the file in the current directory
  85.    if ( filemode(fn) == -1 )
  86.    {
  87.       # get the directory of the currently loaded buffer
  88.       # WGN 3/38/95 - added path_ext() to 3rd parameter so that files with
  89.       # no extension are handled properly.
  90.       fn2 = bld_fnam(buffer_filename, fn, path_ext(fn) )
  91.       if ( filemode(fn2) != -1  || (fn2 = search_path(fn, env_vars, isDirs)) != "" ) 
  92.       {
  93.          create_buf_and_win_key(fn2)
  94.          update_current_view()
  95.          status = fn2
  96.       }
  97.       else
  98.          warning("Cannot open file " fn )
  99.    }
  100.    else
  101.    {
  102.       create_buf_and_win_key(fn)
  103.       update_current_view()
  104.       status = fn
  105.    }
  106.  
  107.    return status
  108. }
  109.  
  110. global function file_under_cursor()
  111. {
  112.    return symbol_under_cursor(FILE_REGEX)
  113. }
  114.