contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.37k stars 102 forks source link

Keybind to open an input box where user can change title of terminal window #296

Open whisperity opened 3 years ago

whisperity commented 3 years ago

Abstract

Not every running binary care about setting up a proper terminal title. Especially when Contour is started directly with a TUI application as the inner process, bypassing a shell, such as with contourncspot or contour aptitude. The title of the window will be simply contour which is non-intuitive if you want to switch between windows on the taskbar or something.

Motivation

The ability to open dialog boxes from Contour is already possible, given that we use Qt, and the permission system opens a dialog with some buttons. A similar dialog should be opened via a user-customisable keybind.

Specification

Add a new keybind action (and the related boilerplate and wiring) such as ChangeTitleText or something. When the user presses this, a dialogwindow with an inputbox (I'm going off of Visual Basic 5 terminology here, excuse me) opens, where the user might type in the new title. If clicking on "Okay" or "Save", the title of the window becomes what the user entered.

Optional consideration: keep the user-entered title only until the underlying application (if any) decides to change the title.

In addition to this, contour set should be extended with contour set title [string] which achieves the same thing, in case the user is able to type directly into the terminal. (This can be the case if a stale application borked the title but we have an active shell, but isn't a case with full-size TUI programs like ncspot or aptitude.)

Alternative solutions

This solution is a quick fix to the issue at hand, but offers lesser functionality: in case contour is started directly with a TUI program, make sure the title of the running process matches the cmdline invocation verbatim, i.e. simply show contour ncspot.

christianparpart commented 3 years ago

I like the CLI extension proposal!

With regards to setting title via popup, also possible, but what do you think about extending the CLI for that, too?

such as: contour terminal config /path/to/config.yml title "Your Title Here" /path/to/executable ...? So we'd add a title parameter to have the window title initially set? That at least should make scripts happy. What do you think?

wrt popup, I think that could also go in hand with the command palette idea, so people do not need to remember yet another keybind but just trigger command palette, type in title hit enter, and then the popup would come up. Hm, we would still implement the popup, yes.

data-man commented 3 years ago

Alternative solution 2: :smile: contour.yml

profiles:
    ncspot:
        title: "ncspot"

app_trigger:
    # pattern can be shell-like or regex
    - { pattern: "ncspot",   action: ChangeProfile,   name: "ncspot" }
    #- { pattern: "ncspot",   action: SetTitle,   name: "ncspot" }

that we use Qt

Or via built-in (or in new our repository) TUI-based configuration editor. E.g. using https://github.com/ArthurSonzogni/FTXUI.

christianparpart commented 3 years ago

wrt FTXUI, whenever I see the idea of having some TUI based feature, I feel like that's best of done as a (standalone) TUI executable. (I definitely do like that library's API design choice though)

@whisperity what kind of use-cases do you have in mind. How much would the title differ from the command being executed? To be fair, I currently do not remember but it might make sense to default the title to the shell command (+ parameters), in case the executed command is not setting it explicitely, one at least has something descriptive.

whisperity commented 3 years ago

@christianparpart

what kind of use-cases do you have in mind. How much would the title differ from the command being executed? To be fair, I currently do not remember but it might make sense to default the title to the shell command (+ parameters), in case the executed command is not setting it explicitely, one at least has something descriptive.

To be fair, the two ideas that came to my mind currently are contour ncspot and contour aptitude, both of which are easily fixed if at the startup the title becomes those, instead of just contour.

Other use-cases would be tagging a terminal with things like "debug prompt" or "main editor", but these commands I usually start from a shell anyways so I can -- in theory, at least -- tinker with some escape sequences (or use contour set title to FOO if that gets implemented) before starting such commands.

WSLUser commented 3 years ago

Windows Terminal handles this by allowing users to click on the tab and type another name. You can also define it in the settings for a particular profile or disable the title entirely. This also includes using their cli to change it if a user wants when they launch a profile. Contour can probably do similar but from QT perspective.

christianparpart commented 3 years ago

Exactly. Except that we do not have tabs YET. :)

WSLUser commented 3 years ago

Sounds like tab support is needed first then with this issue as the follow-up.

whisperity commented 3 years ago

How do tabs work when there is only one tab? I'd prefer not to have the ugly tab selector bar or whatever that's always there in Konsole...

A big upside of Contour for now is that the entire terminal is just one huge window with nothing taking up ugly additional space like menu bars (Gnome-Terminal, Konsole) or tab bars (Konsole, but at least Gnome-Terminal only shows that when there is multiple). The only ugly in Contour is the scrollbar but that seems to be more of a bug than a deliberately bad design choice.

christianparpart commented 3 years ago

A big upside of Contour for now is that the entire terminal is just one huge window

It will remain that way for single tab windows of course. At least it will be configurable

WSLUser commented 3 years ago

There are ways to hide tabs altogether and simply use keybindings to switch between them. Not sure how that works in QT but I'm sure it's doable.