Author Topic: Buffers/Project/Workspace Files dialog and Opening to Current Window  (Read 2032 times)

Brandon

  • Community Member
  • Posts: 37
  • Hero Points: 5
I use the Workspace Files (project_load) dialog to load and switch between files in my workspace.  When splitting a window, and placing the focus in the new window, the default behavior of the ENTER key is to just activate the tab (if open) but *in the other window*.
Right clicking the file list gives me an option to "Open in Current Window", which does exactly what I need, but obviously using the mouse to do so is very awkward.

Simply put:   I want the default ENTER key behavior to always open in the current window (yes, even if it clones), for all tabs.   This small modification would vastly improve my development workflow.

Back in the day I used to do a good bit of slickc mods, but that was many years ago and I thought it would be much quicker to just ask first :)  So is there a modification that I can make to the macro files that will enable this behavior?

Thanks!

EDIT:   OK, after some experimentation inside tbfilelist.e, I have discovered that this is not entirely going to meet my needs because the context menu option is *replacing* the current tab, instead of adding to the tab group.

I use "One file per window" mode, so that opening files from the project will add them as new tabs.   Let's say I currently have window A with file tabs X,Y,Z.  When I split the window, and put the cursor/focus in the new window B, I simply want the behavior to be the same (or in any new split window).  Currently, if I open the project files and try to open X, I'll just get thrown back into window A with the X tab active.   I instead want it to be added in window B's tab group as a second copy.

As long as the file is not already open, this works fine.   But if it IS, then my window focus changes to wherever it currently is open.   I use split windows all the time to do code comparison and merges, and so the only way to do this is to physically drag and move the tabs where I can have them in the proper leftside/rightside windows.

If I could just get the buffer/project/workspace file load dialog to stay in my current window and just add the tabs there, I think this would be what I am looking for.

I guess this is a bit more complicated than just altering the ENTER key binding :(
« Last Edit: February 03, 2017, 03:45:24 am by Brandon »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6490
  • Hero Points: 507
Re: Buffers/Project/Workspace Files dialog and Opening to Current Window
« Reply #1 on: February 03, 2017, 04:11:08 am »
Seems like a reasonable way to do this would be with shift+enter instead of changing the default behavior.

Brandon

  • Community Member
  • Posts: 37
  • Hero Points: 5
Re: Buffers/Project/Workspace Files dialog and Opening to Current Window
« Reply #2 on: February 11, 2017, 05:30:43 pm »
Well, I had hoped for a little more help here but I think I found how to do this.   Interestingly, it seems that the functionality is already built into SE, but is not enabled by default.
In the file tbfilelist.e, in the function open_selected_files(), there is a comment that says:

Code: [Select]
// Set up edit options to attempt to open the window in the current
   // document tab group rather than moving focus to another window.
   edit_options := "";
   if (def_one_file != "" && p_active_form._find_control("ctl_sstab") <= 0) {
      edit_options = "+wg":+def_document_tab_list_buffers_open_where;
   }

Reading this kindof surprised me a bit, because it sounded exactly like what I needed. 

I located the definition of the def_ variable and saw this comment:

Code: [Select]
* Set to "d" to allow the document tabs drop-down to open the
 * selected file in the default location, which may mean switching
 * focus to another tab group which happens to have the file open,
 * instead of forcing the file to be opened in the current document
 * tab group.  Set to "" to force the file to be opened in the
 * current document tab group, even it it means duplicating the
 * buffer (having it open in two different windows).

Yes, this is exactly what I want.  However, I tried altering the def variable to remove the "d" but it still didn't work.

So, I wound up commenting out the above code completely, and setting edit_options permanently:
Code: [Select]
edit_options := "+wg";
I've been using this for some time now, and I have not (yet) seen any issues (I use one-file-per window, with tab groups on top of each split).

This has greatly increased my development efficiency since I can now open side-by-side windows of the same file, or open an additional copy of a file in another split window without having to drag it where I need it.

I know each person has their own likes, but I wish this behavior was changeable in the Options somewhere.   It is enormously useful.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6490
  • Hero Points: 507
Re: Buffers/Project/Workspace Files dialog and Opening to Current Window
« Reply #3 on: February 12, 2017, 05:10:22 pm »
Your change is realistically good enough. "+wvg,g" is technically better but it only matters if the current tab group has more than one copy of the current file.

There's actually a global setting for exactly how SlickEdit searches for an existing window to activate. It's not exposed in the GUI.

Code: [Select]
    <!-- default setting  "VG,VM,VA,GMA" . see misc.options.cfg.xml -->
    <!-- Add this property setting to your misc.options profile in user.cfg.xml -->
    <misc.options n="misc.options" version="1">
        <default_find_window_options v="VG,G"/>
     </misc.options>

Changing this would effect anything that opens a file. That might be too crazy. I don't use one file per window mode so I never have this issue.