[wingide-users] Close-tab without history

Wingware Support support at wingware.com
Tue Jul 3 08:37:21 MDT 2012


Ernest French wrote:
> Could there be a keyboard combination for "close current file, and 
> *don't* jump to the previously open file - just drop to the next file 
> to the left of the one being closed?  It's a real pain sometimes 
> always having to keep track of the files you've been in - but without 
> keeping that list mentally, you never know where you are going to end 
> up when closing a file.

Looks like there isn't a way to do this now.  I've attached below kind 
of a hack of a script that will do it, if you drop that into scripts in 
your User Settings Directory (listed 5th in Wing's About box) and bind a 
key to close-without-history.  However, it only works if you have the 
Editor > Split Reuse Policy set to Use Current Split (the default) and 
in Wing 4.1.6 I think it will act strangely in some cases if you have 
multiple editor splits (but that should be fixed in Wing 4.1.7+).

You may also be interested in hiding the editor notebook tabs by 
right-clicking on them.  That replaces them with a popup menu, which can 
be less confusing overall with large numbers of files.  Also, try using 
Open From Project to easily switch between files by name.

- Stephan

----------------------------------------

import wingapi
import os
from wingutils import textutils
import guimgr.prefs
app = wingapi.gApplication

def close_without_history():
     open_files = app.GetAllFiles()
     open_files = [(os.path.basename(f), f) for f in open_files]
     if app.GetPreference(guimgr.prefs.kSortCaseSensitive):
         textutils.NaturalTupleSort(open_files)
     else:
         textutils.NaturalTupleSortIgnoreCase(open_files)

     app.ExecuteCommand('close')

     remaining_files = app.GetAllFiles()
     remaining_files = [(os.path.basename(f), f) for f in remaining_files]
     if app.GetPreference(guimgr.prefs.kSortCaseSensitive):
         textutils.NaturalTupleSort(remaining_files)
     else:
         textutils.NaturalTupleSortIgnoreCase(remaining_files)

     if len(remaining_files) == 0:
         return

     for i, (fn, fpath) in enumerate(open_files):
         if i > len(remaining_files) - 1:
             rfn, rfpath = remaining_files[-1]
             app.OpenEditor(rfpath)
             break
         rfn, rfpath = remaining_files[i]
         if rfpath != fpath:
             app.OpenEditor(rfpath)
             break





More information about the wingide-users mailing list