NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
terminal.h File Reference

Set the terminal title/icon. More...

#include <stdbool.h>
+ Include dependency graph for terminal.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool mutt_ts_capability (void)
 Check terminal capabilities.
 
void mutt_ts_status (char *str)
 Set the text of the terminal title bar.
 
void mutt_ts_icon (char *str)
 Set the icon in the terminal title bar.
 
const char * mutt_tigetstr (const char *name)
 Get terminal capabilities.
 

Detailed Description

Set the terminal title/icon.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file terminal.h.

Function Documentation

◆ mutt_ts_capability()

bool mutt_ts_capability ( void )

Check terminal capabilities.

Return values
trueTerminal is capable of having its title/icon set
Note
This must happen after the terminfo has been initialised.

Definition at line 81 of file terminal.c.

82{
83 static const char *known[] = {
84 "color-xterm", "cygwin", "eterm", "kterm", "nxterm",
85 "putty", "rxvt", "screen", "xterm", NULL,
86 };
87
88#ifdef HAVE_USE_EXTENDED_NAMES
89 /* If tsl is set, then terminfo says that status lines work. */
90 const char *tcaps = mutt_tigetstr("tsl");
91 if (tcaps)
92 {
93 /* update the static definitions of tsl/fsl from terminfo */
94 TSL = tcaps;
95
96 tcaps = mutt_tigetstr("fsl");
97 if (tcaps)
98 FSL = tcaps;
99
100 return true;
101 }
102
103 /* If XT (boolean) is set, then this terminal supports the standard escape. */
104 /* Beware: tigetflag returns -1 if XT is invalid or not a boolean. */
105 int tcapi = tigetflag("XT");
106 if (tcapi == 1)
107 return true;
108#endif
109
110 /* Check term types that are known to support the standard escape without
111 * necessarily asserting it in terminfo. */
112 const char *term = mutt_str_getenv("TERM");
113 for (const char **termp = known; *termp; termp++)
114 {
115 if (term && mutt_istr_startswith(term, *termp))
116 return true;
117 }
118
119 return false;
120}
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition string.c:731
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition string.c:246
static const char * FSL
FSL: from_status_line - Sent after the terminal title.
Definition terminal.c:57
static const char * TSL
TSL: to_status_line - Sent before the terminal title.
Definition terminal.c:55
const char * mutt_tigetstr(const char *name)
Get terminal capabilities.
Definition terminal.c:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_ts_status()

void mutt_ts_status ( char * str)

Set the text of the terminal title bar.

Parameters
strText to set
Note
To clear the text, set the title to a single space.

Definition at line 128 of file terminal.c.

129{
130 if (!str || (*str == '\0'))
131 return;
132
133 fprintf(stderr, "%s%s%s", TSL, str, FSL);
134}
+ Here is the caller graph for this function:

◆ mutt_ts_icon()

void mutt_ts_icon ( char * str)

Set the icon in the terminal title bar.

Parameters
strIcon string
Note
To clear the icon, set it to a single space.

Definition at line 142 of file terminal.c.

143{
144 if (!str || (*str == '\0'))
145 return;
146
147 /* icon setting is not supported in terminfo, so hardcode the escape */
148 fprintf(stderr, "\033]1;%s\007", str); // Escape
149}
+ Here is the caller graph for this function:

◆ mutt_tigetstr()

const char * mutt_tigetstr ( const char * name)

Get terminal capabilities.

Parameters
nameName of capability
Return values
strCapability
Note
Do not free the returned string

Definition at line 66 of file terminal.c.

67{
68 char *cap = tigetstr(name);
69 if (!cap || (cap == (char *) -1) || (*cap == '\0'))
70 return NULL;
71
72 return cap;
73}
+ Here is the caller graph for this function: