Terminus icon indicating copy to clipboard operation
Terminus copied to clipboard

How NOT to hide panel on ESCAPE press?

Open agilesteel opened this issue 6 years ago • 16 comments

Hi,

sorry this might be a question related to sublime itself, but I can't seem to find a way to disable the closing of the panel every time I press ESCAPE. I do so quite frequently and the panel with the terminal inside closes. It can be easily reopened or even used in a VIEW rather than in a PANEL, however I do prefer the panel.

I've found the following in the default key bindings but could only figure out how to "unbind" the ESCAPE key entirely which prevents anything from being escaped.

{ 
  "keys": ["escape"],
  "command": "hide_panel",
  "args": {"cancel": true},
  "context":
    [
      { "key": "panel_visible", "operator": "equal", "operand": true }
    ]
}

Any hints?

Apologies if this is the wrong place to ask.

agilesteel avatar Oct 10 '18 18:10 agilesteel

Just put the following in your keybind

    { "keys": ["escape"], "command": "terminus_keypress", "args": {"key": "escape"},
        "context": [
            { "key": "terminus_view" }
        ] },

randy3k avatar Oct 10 '18 20:10 randy3k

Didn't help :(

agilesteel avatar Oct 10 '18 21:10 agilesteel

It should work unless another package has overrided it. Run sublime.log_commands(True) in the sublime console to see what command was executed.

randy3k avatar Oct 10 '18 22:10 randy3k

command: hide_panel {"cancel": true}

agilesteel avatar Oct 11 '18 19:10 agilesteel

Did you copy the hide_panel escape keybind?

randy3k avatar Oct 11 '18 19:10 randy3k

No I'm only using the one you gave me. Here are all my keybindings:

[
  { "keys": ["ctrl+b"], "command": "goto_definition" },
  { "keys": ["ctrl+`"], "command": "toggle_terminus_panel" },
  { "keys": ["escape"], "command": "terminus_keypress", "args": {"key": "escape"},
    "context": [
        { "key": "terminus_view" }
    ]
  }
]

agilesteel avatar Oct 11 '18 19:10 agilesteel

Btw ESC does not close terminus when terminus is in focus, but I believe this is the default behavior. However as soon as it looses focus and I have a reason to press ESC it does what I wanted it to do but has a side effect of closing terminus.

agilesteel avatar Oct 11 '18 19:10 agilesteel

Oh, I may have misunderstood you. I thought escape closes Terminus panel when it is in focus. It is an issue of Sublime Text. escape will hide any output panel when escape is hit.

It is currently impossible because there is no context to tell if a Terminus panel is visible. Terminus could do something in this direction though.

randy3k avatar Oct 12 '18 03:10 randy3k

Yeah I was afraid you would say that. Let's hope that you can figure out something magical to make it happen ;) Thx for your work on this btw. It's working really great! Also thx for the time you put into answering my questions. FYI I only prefer the panel over the view because it takes less space and kinda looks cooler :)

agilesteel avatar Oct 12 '18 11:10 agilesteel

Let’s keep it open

randy3k avatar Oct 12 '18 15:10 randy3k

Because a similar issue brought me here and incase anyone else has the same problem as me in often accidentally closing the console view....

If you are using open-in-view, then over-riding the close tab keyboard shortcut can save you a lot of pain. Add this to your Keymap file.

 {
        "keys": ["command+w"],
        "command": "terminus_keypress",
        "args":
        {
            "key": ""
        },
        "context": [
        {
            "key": "terminus_view"
        }]
    },

dwkns avatar Oct 28 '18 11:10 dwkns

Even though this never happened to me (yet) I do see value in it, thx ;) Btw it's ctrl+w for windows/linux.

agilesteel avatar Oct 28 '18 12:10 agilesteel

Very Recently I started using the terminus extensively, so I did this, here's the solution, this Safely ONLY removes the Panel Close from the Escape Key Functions, the rest work the same way in the same order. If you have any Queries how this works please ask,

All you have to do is copy this to your sublime key map files

If you actually want to close the panel you can use shift+escape.

This behaviour applies to all panels. If you want to limit to only preventing terminus closing, then add { "key": "terminus_view"} in the context list of the pass command.

    { "keys": ["escape"], "command": "pass", "context": [
		{ "key": "panel_visible", "operator": "equal", "operand": true },
		{ "key": "panel_has_focus", "operator": "equal", "operand": false},
		{ "key": "num_selections", "operator": "equal", "operand": 1 },
		{ "key": "has_next_field", "operator": "equal", "operand": false },
		{ "key": "has_prev_field", "operator": "equal", "operand": false },
		{ "key": "overlay_visible", "operator": "equal", "operand": false },
		{ "key": "popup_visible", "operator": "equal", "operand": false },
		{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
	]},
	{ "keys": ["escape"], "command": "single_selection", "context": [
		{ "key": "num_selections", "operator": "not_equal", "operand": 1 },
		{ "key": "panel_visible", "operator": "equal", "operand": true },
		{ "key": "panel_has_focus", "operator": "equal", "operand": false }
	]},
	{ "keys": ["escape"], "command": "clear_fields", "context": [
		{ "key": "has_next_field", "operator": "equal", "operand": true },
		{ "key": "panel_visible", "operator": "equal", "operand": true },
		{ "key": "panel_has_focus", "operator": "equal", "operand": false }
	]},
	{ "keys": ["escape"], "command": "clear_fields", "context": [
		{ "key": "has_prev_field", "operator": "equal", "operand": true },
		{ "key": "panel_visible", "operator": "equal", "operand": true },
		{ "key": "panel_has_focus", "operator": "equal", "operand": false }
	]},
	{ "keys": ["shift+escape"],
		"command": "hide_panel",
		"args":  {"cancel": true},
		"context":	[
			{ "key": "panel_visible", "operator": "equal", "operand": true },
		]
	},

Penguin98kStudio avatar Oct 17 '20 21:10 Penguin98kStudio

Thanks for sharing the key binding config. It was flawlessly. When i was looking for a solution I've put together something similar but instead of command "pass" I've used "noop". Anyone knows what would be a difference?

{ "keys": ["escape"], "command": "pass", "context": [
		{ "key": "panel_visible", "operator": "equal", "operand": true },
...

vs

{ "keys": ["escape"], "command": "noop", "context": [
		{ "key": "panel_visible", "operator": "equal", "operand": true },
...

rtomaszewski avatar Jan 05 '21 22:01 rtomaszewski

When i was looking for a solution I've put together something similar but instead of command "pass" I've used "noop". Anyone knows what would be a difference?

There is no difference whether you write noop or pass , as both essentially refer to a command that doesn't exist in sublime, hence no operation is performed on pressing escape .

Penguin98kStudio avatar Jan 06 '21 09:01 Penguin98kStudio

If you are using open-in-view, then over-riding the close tab keyboard shortcut can save you a lot of pain. Add this to your Keymap file. { "keys": ["command+w"], "command": "terminus_keypress", "args": { "key": "" }, "context": [ { "key": "terminus_view" }] },

Building on this, I am often trying to close the current tab that Terminus is overlaid on when I hit cmd+w. If Terminus has focus it will close it, sometimes while it is running a long running process, which is a pain. Instead of just noop, I use the following to close the tab as intended.

{
    "keys": ["command+w"],
    "command": "close",
    "context": [
        {
            "key": "terminus_view"
        }
    ]
},

willrowe avatar Feb 03 '21 14:02 willrowe