Sublime Forum

Switching focus in Terminus

#1

Hello there,
I’ve started using terminus and tried a custom build ( with a custom plugin) to get a side-by-side output panel. I followed odatnurds’ videos and things have gone well. But when I run my code, the focus goes to the output panel, and to get it back on the editor panel I need to click on it or just press ctrl+1. But I just don’t want the focus to automatically switch to the output panel whenever I run my code. Here I’m attaching my build codes.

0 Likes

#2

You want to add "focus": false to the build to stop it from focusing.

Both terminus_open and terminus_exec take the same arguments, but the default values for some of them are different. In terminus_open this argument defaults to being set to true so that the focus goes to the terminal, whereas termnus_exec defaults is to false to mimic the standard exec command, which doesn’t give the panel focus because it doesn’t accept input.

1 Like

#3

Thanks for your reply but I’ve tried it and it’s not working.

0 Likes

#4

Ahh sorry I couldn’t read the image on my phone (pro tip, when sharing config/code samples, actual text is superior because it scales, and people can use it for their own testing which can incite people into helping you out).

Are you using Sublime Text 4? The plugin needs to be slightly different in that case because the way focus changes happens is slightly different in that version.

If you’re using ST3, then something else is interfering.

1 Like

#5

Yes, I’m using ST4 and used the plugin you mentioned in your video [QT08].
Plugin: https://gist.github.com/OdatNurd/2aeb8f753a053d9b927a8f125a8e456d

0 Likes

#6

The pre and post windows hooks that you want for this look like:

    "pre_window_hooks": [
        ["window_focus", {"store": true}],
        ["close_terminus_view_by_title", {"title": "Void"}],
    ],

    "post_window_hooks": [
        ["carry_file_to_pane", {"direction": "right"}],
        ["window_focus", {"store": false}]
    ],

That is, before the build runs save the tab that has the focus and close any existing Terminus tab that already exists.

Once that’s done, the build starts, and then the post hooks run, which use Origami to carry the build to a rightmost pane and restore the focus back to the file that was focused when the build started.

I misspoke earlier; no plugin changes are required for this; it’s just the focus rules changing slightly that required a change here.

1 Like

#7

My build codes:

"target": "terminus_open",
"timeit": true,
"auto_close": false,
"title": "Void",


"pre_window_hooks": [
    ["window_focus", {"store": true}],
    ["close_terminus_view_by_title", {"title": "Void"}],
],

"post_window_hooks": [
    ["carry_file_to_pane", {"direction": "right"}],
    ["window_focus", {"store": false}]
],

What happens now is when I run this build, the focus changes to a different file. I just closed all the other files and tried running this but nothing changes. The focus automatically switched to the terminus tab.

0 Likes

#8

Hmm… we verified on stream this evening that this build works as expected with the plugin as originally distributed.

Specifically, the entire build was this:

{
    "target": "terminus_open",
    "shell_cmd": "echo it worked",

    "timeit": true,
    "auto_close": false,
    "title": "Void",

    "pre_window_hooks": [
        ["window_focus", {"store": true}],
        ["close_terminus_view_by_title", {"title": "Void"}],
    ],

    "post_window_hooks": [
        ["carry_file_to_pane", {"direction": "right"}],
        ["window_focus", {"store": false}]
    ],
}

If you have more than one build, you might want to verify that you’ve selected the correct one.

0 Likes