Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Ability to change what key/key sequence reopens or closes a profile session #16581

Open
datdamnmachine opened this issue Jan 21, 2024 · 4 comments
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@datdamnmachine
Copy link

Description of the new feature/enhancement

This feature request is related to this feature request:

#4379

Essentially, the ability to customize what key/key sequences reopens or closes a profile session. Currently Ctrl+D will close the terminal after exit and "Enter" will restart it. I would like to customize it so that "r" will restart the session and "" or "" will close the session for good. This is what MobaXterm uses and it would be nice to have it consistent as I use both regularly.

Proposed technical implementation details (optional)

Something like this in the json file:

"closeOnExit": "never",
{
"closeKey": "",
"reopenKey": "r"
}

@datdamnmachine datdamnmachine added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jan 21, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jan 21, 2024
@lhecker lhecker added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. labels Jan 22, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Tag-Fix Doesn't match tag requirements label Jan 22, 2024
@carlos-zamora carlos-zamora added this to the Icebox ❄ milestone Jan 24, 2024
@carlos-zamora carlos-zamora added Help Wanted We encourage anyone to jump in on these. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jan 24, 2024
@carlos-zamora
Copy link
Member

Good catch! Thanks for filing this.

@skywalker290
Copy link

Can i help on this one?

@zadjii-msft zadjii-msft mentioned this issue Feb 1, 2024
Closed
@zadjii-msft
Copy link
Member

@skywalker290 We probably won't get to this ourselves, so we'd definitely appreciate the help!

I'd caveat all this with the fact that we'll need to brainstorm what the settings would look like in the actual json, so we may change how the setting is parsed on review. I'd guess something like the following would be a good start:

    "profiles": 
    {
        "defaults": 
        {
            "closeOnExit": "never",
            "closeKey": "ctrl+alt+q",
            "reopenKey": "r"
  • MTSM_PROFILE_SETTINGS in https://github.com/microsoft/terminal/blob/main/src/cascadia/TerminalSettingsModel/MTSMSettings.h#L78 already contains all the per-profile settings.
  • That'd need to get plumbed down to ControlCore:
    const wchar_t CtrlD = 0x4;
    const wchar_t Enter = '\r';
    if (_connection.State() >= winrt::Microsoft::Terminal::TerminalConnection::ConnectionState::Closed)
    {
    if (ch == CtrlD)
    {
    _CloseTerminalRequestedHandlers(*this, nullptr);
    return true;
    }
    if (ch == Enter)
    {
    // Ask the hosting application to give us a new connection.
    _RestartTerminalRequestedHandlers(*this, nullptr);
    return true;
    }
    }
  • More tricky: we'd have to find a way to also plumb those keys (or the stringification of them) into:
    void ConptyConnection::_indicateExitWithStatus(unsigned int status) noexcept
    {
    try
    {
    // GH#11556 - make sure to format the error code to this string as an UNSIGNED int
    winrt::hstring exitText{ fmt::format(std::wstring_view{ RS_(L"ProcessExited") }, fmt::format(_errorFormat, status)) };
    _TerminalOutputHandlers(L"\r\n");
    _TerminalOutputHandlers(exitText);
    _TerminalOutputHandlers(L"\r\n");
    _TerminalOutputHandlers(RS_(L"CtrlDToClose"));
    _TerminalOutputHandlers(L"\r\n");
    }
    CATCH_LOG();
    }
    which is where the message is actually printed

@skywalker290
Copy link

Json format would help with this we can put data into one json structure and send it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

5 participants