Sublime Forum

Cloning a view into new window

#1

I’m aware of the clone_file command, but what are the steps to clone the file into different window via plugin code?

I have a scratch view in Window 1 which has a distinctive name “output view”. Then I open another Sublime Text window. When Window 2 opens, my plugin queries if any of the other open Sublime Text windows have a view called “output view”. I find one from Window 1 and get a handle to it. What I should do next in order to show it in window 2?

The desired functionality is possible to do by cloning a view and then dragging it to the other window, but I’d like to do all this in plugin code.

0 Likes

#2

You could create a new view, set scratch, insert the text from output view and scroll to the desired viewport.

0 Likes

#3

That is exactly what I am doing right now. However, if I want to insert a new text to both views, I have to do it separately for each view. If I have multiple views to same text buffer, one update would be enough.

0 Likes

#4

Yeah… sublime text doesn’t seem to offer an api to access the buffer or to move a view from one window to another.

Basically, yes. But you could always do some abstraction that handles operations on your view by creating a class that creates the panels and manages the view operations (insert, clear, etc.). You could even create your own buffer and use the outpanels as dummy views.

0 Likes