1 The Window and Tabs
liquibyte edited this page 2026-11-19 16:23:31 -06:00

The Window and Tabs

What the window shows and how its size and title behave, how tabs open, close, move and tell you what their shell is doing, the question before a terminal with a running program closes, the terminal's menu, and the things a program can ask of the window.

1. The window

The parts of Hanshi's window: the tabs at the top, a progress bar under them, the margin with a mark beside each prompt at the left, the text, the scrollbar at the right, and the bar of the search on the last line

A window with three tabs. The tabs, the progress bar and the bar on the last line show only while there is something for them to show; the margin is there when Preferences gives it a width.

The window holds one terminal, or several in tabs. Around the text there is a little padding, at the left a margin for the marks of shell integration (Shell Integration), and at the right a scrollbar for the scrollback. The colors of the scrollbar, the tabs and the menu come from the window theme; the colors of the terminal come from the terminal theme (Themes).

  • Its size. The window opens with the rows and columns of Preferences > Window (24 by 80 at first), or those of -r and -c. It grows and shrinks by whole characters: Hanshi tells the window manager the size of one character, so a drag of the window's edge stops at whole rows and columns. The smallest window is 4 columns wide and 1 row high. The program in the terminal is told the new number of rows and columns each time.
  • A new font keeps the rows and columns. When a choice in Preferences changes the size of a character (another font, size or line spacing), the window changes its size so that it keeps its rows and columns. The font size keys (Ctrl+Plus and Ctrl+Minus) do the opposite: the window keeps its size, and the number of rows and columns changes.
  • Remember the window's size. With this on (Preferences > Window), the rows and columns the window had when Hanshi ended are the size of the next window. A size from the command line is not remembered.
  • Its title is the title the program in the terminal set (a shell's prompt often sets it to the current folder), or "Hanshi" when it set none. With tabs, it is the title of the tab that shows. A program can also set the name of the window's icon.
  • The keyboard. When the window gets the keyboard, Hanshi passes it on to the terminal that shows. The terminal shows that it has the keyboard: its cursor is solid and can blink. Without the keyboard, a block cursor is drawn as an outline, and no cursor blinks.
  • Input methods. Hanshi uses the input method that your locale and the XMODIFIERS variable choose, so you can type in languages that need one.

2. Tabs

Tabs let one window hold up to 64 terminals. They are on at first; Preferences > Window > "More than one terminal in the window, in tabs" switches them off.

To Do this
Open a tab Ctrl+Shift+T, or New Tab in the terminal's menu (the right mouse button). The new tab opens after the last one and shows at once.
Go to another tab Click its tab. Ctrl+Page Up goes to the tab before and Ctrl+Page Down to the tab after; from the last tab, Ctrl+Page Down goes round to the first, and from the first, Ctrl+Page Up goes round to the last. While there is only one terminal, these two keys go to the program in it.
Move a tab Drag it with the mouse to another place among the tabs. The tab follows the pointer, and a gap among the others shows where it will drop: the tab you pass slides over into the gap. Release the button and the tab slides into the gap.
Close a tab Click the small x on its tab, press Ctrl+Shift+W, or choose Close Tab in the terminal's menu. A tab also closes by itself when its program ends, for example when you type exit. With only one terminal, Ctrl+Shift+W and Close Tab close the window.
  • What a new tab runs. A new tab runs the command of Preferences > Programs, or your shell when that is empty. It does not run the program of Hanshi's command line again: hanshi htop shows htop in the first tab and a shell in each new one.
  • Where it starts. A new tab's shell starts in the folder of the shell of the tab that shows. Hanshi knows that folder from shell integration, or else from the shell process itself. When it does not know it, the tab starts in the folder of -d, or in the folder Hanshi was started in.
  • The tabs show only while there are two or more. With one terminal, the window is just the terminal. When a second terminal opens, the window grows by the height of the tabs, so the terminal keeps its rows and columns; when only one is left, the tabs go and the window shrinks again.
  • A tab's label is the title its program set, cut to 24 bytes with "..." after it when it is longer. A tab whose program set no title reads "Terminal".
  • When the tabs do not fit in the window, two arrows show at the right end of the tabs. The left arrow goes to the tab before the one that shows, and the right arrow to the tab after it; the tabs scroll to keep that tab in view. An arrow is dim at the first or the last tab. While the arrows show, the mouse wheel over the tabs scrolls them.
  • Tabs out of view keep running. Hanshi reads what the programs of all tabs write, at all times, also while a dialog is open.
  • With the tabs switched off, New Tab and Close Tab are grey in the menu, and Ctrl+Shift+T, Ctrl+Shift+W, Ctrl+Page Up and Ctrl+Page Down go to the program in the terminal. Tabs that are open already stay open.

The colors of a tab's label

With shell integration on (Preferences > Programs), the label of a tab tells what its shell is doing:

The label What it tells When
Amber Text waits at the prompt: it was typed and not sent. Always, also for the tab that shows.
Blue A command runs. Only for a tab that does not show.
Green A command ended with the status 0. When it ended while the tab did not show, until the tab shows.
Red A command ended with another status. As green.

For a tab that does not show, blue is over green and red, and these are over amber. Text counts as waiting after it has stayed at the prompt for 0.15 seconds, so the moment between Return and the start of a command does not color the label. The colors are the terminal theme's: the yellow (color 3) and the bright blue (color 12) of its palette, and the colors of a prompt's mark, prompt-success and prompt-failure.

To try it: open a second tab, type sleep 15; true and press Return, then go back to the first tab (Ctrl+Page Up). The label of the second tab is blue for 15 seconds, then green. sleep 15; false gives red. A command gives red whenever its exit status is not 0, also when it did its work: grep has the status 1 when it finds nothing.

3. Closing a tab or the window

When you close the window, or a tab, while a program still runs in it, Hanshi asks first:

  • The question is "Close this tab?" for one tab of several, and "Close this terminal?" otherwise. Under it, Hanshi names the program, for example "htop" still runs in it. Quit ends that program. When you close the window, it names the program of the first tab that has one.
  • Quit closes; Cancel keeps the terminal. Enter chooses Cancel, so a key pressed too soon ends nothing. Escape, or closing the question's window, is Cancel too.
  • A program "still runs" when the shell has started a program that now has the terminal, such as an editor or a build. A shell that waits at its prompt closes without a question, and so does a program that runs in the background. A tab that runs the program of Hanshi's command line always asks while that program runs. A tab that runs the command of Preferences > Programs > Command asks while that command runs, also when it is one program such as htop; when the command is a shell, such as bash -l, that shell closes without a question while it waits at its prompt. Hanshi knows a shell by its name in /etc/shells.
  • Preferences > Programs > "Ask before closing while a program runs" switches the question off.

When a terminal closes, its program gets the hangup signal of its terminal, as when you close any terminal. Most programs end then.

4. The terminal's menu

The right mouse button opens the terminal's menu. When the program in the terminal uses the mouse itself (vim with the mouse on, htop, mc), hold Shift while you click to get the menu.

Item Key What it does
Copy Ctrl+Shift+C Copies the selected text to the clipboard. Grey without a selection.
Copy as HTML Copies the selection as HTML, with its colors and styles, for pasting into a document or a mail. Grey without a selection, and for a rectangular selection.
Paste Ctrl+Shift+V Pastes the clipboard into the program. A paste with more than one line can wait for Enter with a question on the last line, such as Paste 3 lines? They can run as commands. (Using the Terminal). Large texts copied in other programs arrive whole.
Select All Selects all the text of the scrollback and the screen (only the screen while a full-screen program runs).
Find... Ctrl+Shift+F Opens the search bar on the last line.
Open Link Ctrl+click Opens the link under the pointer. Grey when there is none.
Copy Link Copies the address, or the file name, of the link under the pointer. Grey when there is none.
Copy Command Output Copies the output of the command under the pointer (shell integration). Grey when the pointer is not on a command with output.
Hide or Show Command Output double-click the mark Hides the output of that command, or shows it again. Only for a command that has ended. A third quick click on the mark does nothing.
Larger Text Ctrl++ Makes the font one pixel larger, for this terminal.
Smaller Text Ctrl+- Makes the font one pixel smaller.
Normal Text Size Ctrl+0 Gives back the font size of Preferences or of the theme.
Clear Scrollback Throws away the lines above the screen. Grey when there are none.
Reset Terminal Resets the terminal to its state at the start: modes, colors, character sets, margins and the screen. Use it when a program left the terminal in a strange state.
New Tab Ctrl+Shift+T Opens a terminal in a new tab. Grey when tabs are off.
Close Tab Ctrl+Shift+W Closes this tab, with the question when a program runs in it. Grey when tabs are off.
Preferences... Ctrl+Shift+P Opens Preferences.

The items down to Reset Terminal are the terminal's own; New Tab, Close Tab and Preferences are Hanshi's, after a line. The menu uses the window theme's menu font, or the terminal's font when the theme names none. It has a thin frame and round corners, and in the built-in window themes the item under the pointer is outlined in the theme's accent color. Grey items cannot be chosen.

5. What a program can ask of the window

The program What Hanshi does
Sets a title (OSC 0 or 2) The tab's label and, for the tab that shows, the window's title.
Sets an icon name (OSC 0 or 1) The name of the window's icon, for the tab that shows.
Rings the bell What Preferences > Programs > Bell says: a sound, a frame around the terminal for a moment, both, or nothing. When the window does not have the keyboard, it also asks the window manager for your attention (the urgency hint); that stops when the window gets the keyboard.
Sends a notification (OSC 9, OSC 99, OSC 777) Runs notify-send with the title and the text, when it is installed; a notification without a title gets the title "Hanshi". A long command that ends while its terminal does not have the keyboard (another window has it, or the command's tab does not show) gives one too (Shell Integration).
Asks for another size in rows and columns (CSI 8 t, DECSLPP, DECSCPP, DECSNLS) Only when Preferences > Programs > "Programs can move and size the window" is on. Then the window takes that size, when the program's tab is the one that shows. With the setting off, the request does nothing. A program that asks how large the text area or a character is always gets an answer.
Asks for a status line (DECSSDT) The status line takes a row under the screen. When the program's tab is the one that shows, the window grows by one row for it, so the screen keeps its rows, and shrinks again when the status line goes. In a tab that does not show, or when the window manager does not let the window grow, the screen gives up one row to it.
Asks to move, size, raise, lower, iconify, maximize or show the window full screen, asks where it is, or asks for its title Only when Preferences > Programs > "Programs can move and size the window" is on; it is off at first. Then Hanshi moves the window, gives it a size in pixels (the size of the text; 0 means the size of the screen), raises or lowers it, iconifies it or shows it again, asks the window manager to maximize it or to show it full screen, and tells the program whether it is iconified, where it is, how large the screen is, and what the title is. With the setting off, these requests do nothing and get no answer.

A link you open (Ctrl+click, Open Link, or a letter of Ctrl+Shift+O) goes to xdg-open, which opens it with your desktop's program for it. A file name such as src/main.c:120 is opened only when the file exists; a name without a folder is looked for in the folder of the shell. xdg-open gets the file alone (src/main.c): the line and the column are not passed on. Hanshi starts xdg-open and notify-send so that it never waits for them.

6. Known limitations

  • One Hanshi is one window. Starting Hanshi again opens another window in a process of its own; there are no split panes.
  • Every tab has the settings of Preferences: a tab cannot have settings (a profile) of its own.
  • The font size keys change one terminal for a while. Apply or OK in Preferences, or a change to the terminal theme file, gives every terminal the font size of the settings again.