Add Enable/Disable actions alongside "Toggle pane read-only mode" #18928

Closed
opened 2026-01-31 06:28:40 +00:00 by claunia · 5 comments
Owner

Originally created by @ev-dev on GitHub (Nov 20, 2022).

Description of the new feature/enhancement

Two additional terminal actions:

  • Enable pane read-only mode
  • Disable pane read-only mode

Reasoning

I make use of the Read-Only mode occasionally, usually whenever I have multiple terminal windows open and a long-running command running in one which prevents me from accidentally hitting "Ctrl+C" in the unintended window.

Read-Only mode has the nice feature of showing a padlock icon next to the pane's title whenever Read-Only mode is active, but of course this helpful hint is not visible if the terminal is in Full-Screen mode.

Whenever that scenario (toggling read-only mode in a fullscreen window) comes up for me, I'll usually just hit space, which will show a pop-up if the pane is in Read-Only mode, and if no pop-up is shown, I'll know to run the action to toggle read-only mode.

I think it would be helpful to have the 2 actions I proposed above, neither of which should care whether Read-Only mode is already active or not, and then internally either perform the toggle of read-only mode, or noop. These actions would provide a more assured method of setting the intended mode for a pane and don't need to prompt the user.

Proposed technical implementation details (optional)

My current workaround is a custom terminal action (defined in my settings.json):

"actions": [
    {
        "name": "Toggle pane read-only mode (w/check)",
        "keys": "alt+r",
        "command": {
            "action": "multipleActions",
            "actions": [
                { "action": "toggleReadOnlyMode" },
                { "action": "sendInput", "input": " " }
            ]
        }
    },
]

This gives action provides an indication of the Read-Only mode state of a pane by forcefully showing the "Read-only mode is enabled" pop-up after sending a space, and if nothing happens when I run the action, I know I need to run it again.

I couldn't find any mechanism of setting/retrieving the current state of a pane's read-only mode, so I wasn't able to figure out an alternative solution for myself (for instance, defining a PowerShell function to check/toggle the read-only mode state, which could maybe be used in a Terminal action)

Given that the "Toggle pane read-only mode" is a pretty stable feature, it may be pretty simple to add these additional actions within the source code here. I'll give it my best shot and report back but I wanted to see if anyone had an opinion/suggestion as well.

Thanks to all the contributors for all the great work you do on this project!

Originally created by @ev-dev on GitHub (Nov 20, 2022). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Two additional terminal actions: - `Enable pane read-only mode` - `Disable pane read-only mode` ### Reasoning <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> I make use of the Read-Only mode occasionally, usually whenever I have multiple terminal windows open and a long-running command running in one which prevents me from accidentally hitting "Ctrl+C" in the unintended window. Read-Only mode has the nice feature of showing a padlock icon next to the pane's title whenever Read-Only mode is active, but of course this helpful hint is not visible if the terminal is in Full-Screen mode. Whenever that scenario (toggling read-only mode in a fullscreen window) comes up for me, I'll usually just hit `space`, which will show a pop-up if the pane is in Read-Only mode, and if no pop-up is shown, I'll know to run the action to toggle read-only mode. I think it would be helpful to have the 2 actions I proposed above, neither of which should care whether Read-Only mode is already active or not, and then internally either perform the toggle of read-only mode, or noop. These actions would provide a more assured method of setting the intended mode for a pane and don't need to prompt the user. # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. --> My current workaround is a custom terminal action (defined in my `settings.json`): ```json "actions": [ { "name": "Toggle pane read-only mode (w/check)", "keys": "alt+r", "command": { "action": "multipleActions", "actions": [ { "action": "toggleReadOnlyMode" }, { "action": "sendInput", "input": " " } ] } }, ] ``` This gives action provides an indication of the Read-Only mode state of a pane by forcefully showing the "Read-only mode is enabled" pop-up after sending a `space`, and if nothing happens when I run the action, I know I need to run it again. I couldn't find any mechanism of setting/retrieving the current state of a pane's read-only mode, so I wasn't able to figure out an alternative solution for myself (for instance, defining a PowerShell function to check/toggle the read-only mode state, which could maybe be used in a Terminal action) Given that the "Toggle pane read-only mode" is a pretty stable feature, it may be pretty simple to add these additional actions within the source code here. I'll give it my best shot and report back but I wanted to see if anyone had an opinion/suggestion as well. > Thanks to all the contributors for all the great work you do on this project!
Author
Owner

@zadjii-msft commented on GitHub (Nov 28, 2022):

This is such a reasonable and well written proposal, I can't help but say "sure, why not". The code wouldn't be hard to write (just a lot of plumbing) nor maintain.

@zadjii-msft commented on GitHub (Nov 28, 2022): This is such a reasonable and well written proposal, I can't help but say "sure, why not". The code wouldn't be hard to write (just a lot of plumbing) nor maintain.
Author
Owner

@Swinkid commented on GitHub (Mar 14, 2023):

@zadjii-msft I think I am confident to be able to contribute to this. Would be my first contribution so bare with while I figure things out!

@Swinkid commented on GitHub (Mar 14, 2023): @zadjii-msft I think I am confident to be able to contribute to this. Would be my first contribution so bare with while I figure things out!
Author
Owner

@zadjii-msft commented on GitHub (Mar 14, 2023):

Absolutely, go for it! Lemme know if you need any pointers.

Note

Walkthrough

  • #14549 is a great example of where to start - that's another PR that adds an action and plumbs it through the settings model and hooks up the implementation from TerminalPage -> TermControl
  • Except, instead of "RestartConnection", it'd be like two actions EnableReadOnlyMode and DisableReadOnlyMode.
@zadjii-msft commented on GitHub (Mar 14, 2023): Absolutely, go for it! Lemme know if you need any pointers. > **Note** > ## Walkthrough * #14549 is a great example of where to start - that's another PR that adds an action and plumbs it through the settings model and hooks up the implementation from `TerminalPage` -> `TermControl` * Except, instead of "RestartConnection", it'd be like two actions `EnableReadOnlyMode` and `DisableReadOnlyMode`.
Author
Owner

@Swinkid commented on GitHub (Mar 15, 2023):

Changes made in https://github.com/microsoft/terminal/pull/14995

Working locally - just need to update docs and what not

@Swinkid commented on GitHub (Mar 15, 2023): Changes made in https://github.com/microsoft/terminal/pull/14995 Working locally - just need to update docs and what not
Author
Owner

@Swinkid commented on GitHub (Mar 15, 2023):

Added documentation in https://github.com/MicrosoftDocs/terminal/pull/645

@Swinkid commented on GitHub (Mar 15, 2023): Added documentation in https://github.com/MicrosoftDocs/terminal/pull/645
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18928