Sublime Forum

Terminus Panel in a group

#1

Hello I want open a 2 terminus panel in distinct groups I have this code:

    def run(self):
        self.window.run_command('set_layout', {
            "cols": [0.0, 0.5, 1.0 ],
            "rows": [0.0, 0.5, 1.0 ],
            "cells": [
                [0, 0, 1, 1 ],
                [1, 0, 2, 1 ],
                [0, 1, 1, 2 ],
                [1, 1, 2, 2 ]
            ]
        })
     
        self.window.focus_group(1)
        self.window.run_command('terminus_open', {"cmd": "python3","cwd": "${file_path:${folder}}"})
        self.window.focus_group(2)
        self.window.run_command('terminus_open')

but no works, both terminus panels opens on Group 2

Any ideas?

0 Likes

#2

I’m not sure if this is a problem in the core or related to how Terminus opens views, but the easiest solution here would be to use the pre_window_hooks argument to terminus_open to have it execute the command that focuses the correct view right before it is about to open the view, to ensure that things are timed out correctly:

        self.window.run_command('terminus_open', {
            "pre_window_hooks": [["focus_group", {"group": 1}]],
            "cmd": "python3","cwd": "${file_path:${folder}}"}
            )
        self.window.run_command('terminus_open', {
            "pre_window_hooks": [["focus_group", {"group": 2}]]
            })

If you happen to also use Origami you could use its commands to do a similar thing, but focus_group is in the core and doesn’t require anything else to be installed to work.

1 Like

#3

Thanks

This works perfectly

0 Likes