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

Setting the window title on tab switches #186

Open
manveru opened this issue Apr 3, 2021 · 1 comment
Open

Setting the window title on tab switches #186

manveru opened this issue Apr 3, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@manveru
Copy link

manveru commented Apr 3, 2021

So after diving into the source for a bit, i found that one can not only set the custom config, but also custom hooks, and so I came up with this little snippet to set the window title to what the shell desires.

customCreateTermHook :: TMState -> Terminal -> IO ()
customCreateTermHook tmState vteTerm = do
  void $ onTerminalWindowTitleChanged vteTerm $ do
    maybeTitle <- terminalGetWindowTitle vteTerm
    let title = fromMaybe "shell" maybeTitle

    tmState <- readMVar tmState
    let win = tmState ^. lensTMStateAppWin

    windowSetTitle win title

What I couldn't figure out yet is what callback to use to also set the window title to the current tab title when you change tabs. I'd be very thankful for any ideas regarding that.

Also I think the above config might be a good default. I think most other other terminal emulators behave this way.

@cdepillabout cdepillabout added enhancement New feature or request help wanted Extra attention is needed labels Apr 4, 2021
@cdepillabout
Copy link
Owner

Thanks for posting this. This sounds like it would be a good improvement.

I think the above config might be a good default. I think most other other terminal emulators behave this way.

Yeah, that sounds reasonable. Do you want to send a PR for this?

what callback to use to also set the window title to the current tab title when you change tabs

There really aren't that many callbacks yet. I've been adding them on an as-need basis when users request them.

Here's the four functions that deal with changing tabs. Would you want to send a PR adding a new callback here?

focusTerm :: Int -> TMState -> IO ()
focusTerm i mvarTMState = do
note <- tmNotebook . tmStateNotebook <$> readMVar mvarTMState
notebookSetCurrentPage note (fromIntegral i)
altNumSwitchTerm :: Int -> TMState -> IO ()
altNumSwitchTerm = focusTerm
termNextPage :: TMState -> IO ()
termNextPage mvarTMState = do
note <- tmNotebook . tmStateNotebook <$> readMVar mvarTMState
notebookNextPage note
termPrevPage :: TMState -> IO ()
termPrevPage mvarTMState = do
note <- tmNotebook . tmStateNotebook <$> readMVar mvarTMState
notebookPrevPage note

Although it sounds like if the window title functionality was available, you wouldn't personally need this hook here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants