Method of determining width of tab title text-field
By shab... on February 17, 2012 16:40 (imported from Google Code)
NB: Low priority feature request.
When using escape sequences '\e]1;...\a' to set the title of a tab, if the string is too long it will truncate from the right-hand side:
"this is a long long string" => "this is a lon..."
As you create more tabs, the size of each tab changes, making it difficult to know from a title-setting application just how long it can make the title without truncation.
It would be good to have some method of querying the current tab-title width (ideally as a number of characters that will fit) so intelligent truncation can be performed.
I'm not certain a true number-of-characters can be returned, given it uses a proportional font by default. Is this font configurable?
The actual method is also not yet determined. A terminal-reporting escape sequence similar to 'CSI 5 n' to print terminal status might work. Alternatively, an AppleScript property attached to the tab could be used.
A completely different (and maybe more feasible given prop. font issues) approach could be to parse the string from the OSC 1; title... and look for specific "truncate here" markers. If the string must be truncated, the regions marked by these symbols are the first to get the chop.
"this is a[M2][M1] long[/M1] long[/M2] string"
truncates (depth 1) to:
"this is a[M2] long[/M2] string"
and further truncates to:
"this is a string"
and even further, a standard trim-left or trim-right rule is applied:
"this is a s..."
Complicated, but it's the best method I can think of that allows iTerm to do the proportional font size calculation internally, and give the user control over the title truncation.
Any suggestions welcomed.