Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API to set/change/move views between different windows #1794

Closed
evandrocoan opened this issue Jul 1, 2017 · 1 comment
Closed

API to set/change/move views between different windows #1794

evandrocoan opened this issue Jul 1, 2017 · 1 comment

Comments

@evandrocoan
Copy link

evandrocoan commented Jul 1, 2017

Looking on:

  1. https://www.sublimetext.com/docs/3/api_reference.html#sublime.Window

I could not find a method on the Window class, which allow to set a View to a given window. The API should work like this:

view_id = view.id()
window = sublime.active_window()
window.attach_view( view_id )

It would move the view from any window it is on, to the active window. A documentation to this method would be like:

    """
        Moves a view from its current window to this window object. It does nothing if the view 
        is already on the current window.

        @return bool True when the view is moved, otherwise False.
    """

So is useful to solve the problem on:

  1. Forum$25346 Combine Windows?

Currently to move all views to the current window I need to drag them one by one:

puvi7nr

I could write a plugin which creates the command gather_all_windows_here:

import sublime
import sublime_plugin


class GatherAllWindowsHereCommand( sublime_plugin.TextCommand ):

    def run( self, edit ):
        windows        = sublime.windows()
        current_window = sublime.active_window()
        windows.remove( current_window )

        for window in windows:

                for view in window.views()
                    current_window.attach_view( view.id() )

8dba0939db4b2dbe0de7e0ef581968286567c8f7_1_690x396


Related issues:

  1. "View.clones()" addition #11 "View.clones()" addition
  2. Add API method to set the active view in a group (without switching focus to it) #1320 Add API method to set the active view in a group (without switching focus to it)
@keith-hall
Copy link
Collaborator

duplicate of #331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants