postpone.o query.o recvattach.o recvcmd.o resize.o rfc1524.o \
rfc2047.o rfc2231.o rfc3676.o safe_asprintf.o score.o send.o \
sendlib.o sidebar.o smtp.o sort.o state.o status.o system.o \
- tags.o thread.o url.o version.o
+ tags.o terminal.o thread.o url.o version.o
@if !HAVE_WCSCASECMP
NEOMUTTOBJS+= wcscasecmp.o
#include "protos.h"
#include "sort.h"
#include "tags.h"
+#include "terminal.h"
#include "thread.h"
-#ifdef HAVE_NCURSESW_NCURSES_H
-#include <ncursesw/term.h>
-#elif defined(HAVE_NCURSES_NCURSES_H)
-#include <ncurses/term.h>
-#elif !defined(USE_SLANG_CURSES)
-#include <term.h>
-#endif
#ifdef USE_SIDEBAR
#include "sidebar.h"
#endif
#define CAN_COLLAPSE(header) \
((CollapseUnread || !UNREAD(header)) && (CollapseFlagged || !FLAGGED(header)))
-/* de facto standard escapes for tsl/fsl */
-static char *tsl = "\033]0;";
-static char *fsl = "\007";
-
/**
* collapse/uncollapse all threads
* @param menu current menu
return 0;
}
-/**
- * mutt_ts_capability - Check terminal capabilities
- *
- * terminal status capability check. terminfo must have been initialized.
- */
-bool mutt_ts_capability(void)
-{
- const char *term = mutt_str_getenv("TERM");
- char *tcaps = NULL;
-#ifdef HAVE_USE_EXTENDED_NAMES
- int tcapi;
-#endif
- char **termp = NULL;
- char *known[] = {
- "color-xterm", "cygwin", "eterm", "kterm", "nxterm",
- "putty", "rxvt", "screen", "xterm", NULL,
- };
-
- /* If tsl is set, then terminfo says that status lines work. */
- tcaps = tigetstr("tsl");
- if (tcaps && tcaps != (char *) -1 && *tcaps)
- {
- /* update the static defns of tsl/fsl from terminfo */
- tsl = tcaps;
-
- tcaps = tigetstr("fsl");
- if (tcaps && tcaps != (char *) -1 && *tcaps)
- fsl = tcaps;
-
- return true;
- }
-
-/* If XT (boolean) is set, then this terminal supports the standard escape. */
-/* Beware: tigetflag returns -1 if XT is invalid or not a boolean. */
-#ifdef HAVE_USE_EXTENDED_NAMES
- use_extended_names(true);
- tcapi = tigetflag("XT");
- if (tcapi == 1)
- return true;
-#endif /* HAVE_USE_EXTENDED_NAMES */
-
- /* Check term types that are known to support the standard escape without
- * necessarily asserting it in terminfo. */
- for (termp = known; termp; termp++)
- {
- if (term && *termp && (mutt_str_strncasecmp(term, *termp, strlen(*termp)) != 0))
- return true;
- }
-
- /* not supported */
- return false;
-}
-
-void mutt_ts_status(char *str)
-{
- /* If empty, do not set. To clear, use a single space. */
- if (str == NULL || *str == '\0')
- return;
- fprintf(stderr, "%s%s%s", tsl, str, fsl);
-}
-
-void mutt_ts_icon(char *str)
-{
- /* If empty, do not set. To clear, use a single space. */
- if (str == NULL || *str == '\0')
- return;
-
- /* icon setting is not supported in terminfo, so hardcode the escape - yuck */
- fprintf(stderr, "\033]1;%s\007", str);
-}
-
/**
* index_make_entry - Format a menu item for the index list
* @param[out] buf Buffer in which to save string
mutt_draw_statusline(MuttStatusWindow->cols, buf, sizeof(buf));
NORMAL_COLOR;
menu->redraw &= ~REDRAW_STATUS;
- if (TsEnabled && TSSupported)
+ if (TsEnabled && TsSupported)
{
menu_status_line(buf, sizeof(buf), menu, NONULL(TSStatusFormat));
mutt_ts_status(buf);
WHERE struct ListHead Muttrc INITVAL(STAILQ_HEAD_INITIALIZER(Muttrc));
-WHERE short TSSupported;
WHERE char *Username;
WHERE char *CurrentFolder;
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "protos.h"
+#include "terminal.h"
#include "url.h"
#include "version.h"
#ifdef ENABLE_NLS
goto main_curses; // TEST08: can't test -- fake term?
/* check whether terminal status is supported (must follow curses init) */
- TSSupported = mutt_ts_capability();
+ TsSupported = mutt_ts_capability();
}
/* set defaults and read init files */
#endif
void menu_redraw_status(struct Menu *menu);
void menu_status_line(char *buf, size_t buflen, struct Menu *menu, const char *p);
-bool mutt_ts_capability(void);
-void mutt_ts_status(char *str);
-void mutt_ts_icon(char *str);
void menu_top_page(struct Menu *menu);
void mutt_menu_current_redraw(void);
#include "options.h"
#include "protos.h"
#include "sort.h"
+#include "terminal.h"
#ifdef USE_SIDEBAR
#include "sidebar.h"
#endif
mutt_draw_statusline(rd->pager_status_window->cols, bn, sizeof(bn));
}
NORMAL_COLOR;
- if (TsEnabled && TSSupported && rd->index)
+ if (TsEnabled && TsSupported && rd->index)
{
menu_status_line(buffer, sizeof(buffer), rd->index, NONULL(TSStatusFormat));
mutt_ts_status(buffer);
--- /dev/null
+/**
+ * @file
+ * Set the terminal title/icon
+ *
+ * @authors
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * 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/>.
+ */
+
+#include "config.h"
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include "mutt/mutt.h"
+#include "mutt_curses.h"
+#ifdef HAVE_NCURSESW_NCURSES_H
+#include <ncursesw/term.h>
+#elif defined(HAVE_NCURSES_NCURSES_H)
+#include <ncurses/term.h>
+#elif !defined(USE_SLANG_CURSES)
+#include <term.h>
+#endif
+
+bool TsSupported; /**< Terminal Setting is supported */
+
+/* de facto standard escapes for tsl/fsl */
+static char *tsl = "\033]0;";
+static char *fsl = "\007";
+
+/**
+ * mutt_ts_capability - Check terminal capabilities
+ * @retval true Terminal is capable of having its title/icon set
+ *
+ * @note This must happen after the terminfo has been initialised.
+ */
+bool mutt_ts_capability(void)
+{
+ char *known[] = {
+ "color-xterm", "cygwin", "eterm", "kterm", "nxterm",
+ "putty", "rxvt", "screen", "xterm", NULL,
+ };
+
+ /* If tsl is set, then terminfo says that status lines work. */
+ char *tcaps = tigetstr("tsl");
+ if (tcaps && tcaps != (char *) -1 && *tcaps)
+ {
+ /* update the static definitiions of tsl/fsl from terminfo */
+ tsl = tcaps;
+
+ tcaps = tigetstr("fsl");
+ if (tcaps && (tcaps != (char *) -1) && *tcaps)
+ fsl = tcaps;
+
+ return true;
+ }
+
+#ifdef HAVE_USE_EXTENDED_NAMES
+ /* If XT (boolean) is set, then this terminal supports the standard escape. */
+ /* Beware: tigetflag returns -1 if XT is invalid or not a boolean. */
+ use_extended_names(true);
+ int tcapi = tigetflag("XT");
+ if (tcapi == 1)
+ return true;
+#endif
+
+ /* Check term types that are known to support the standard escape without
+ * necessarily asserting it in terminfo. */
+ const char *term = mutt_str_getenv("TERM");
+ for (char **termp = known; termp; termp++)
+ {
+ if (term && *termp && (mutt_str_strncasecmp(term, *termp, strlen(*termp)) != 0))
+ return true;
+ }
+
+ /* not supported */
+ return false;
+}
+
+/**
+ * mutt_ts_status - Set the text of the terminal title bar
+ * @param str Text to set
+ *
+ * @note To clear the text, set the title to a single space.
+ */
+void mutt_ts_status(char *str)
+{
+ if (!str || (*str == '\0'))
+ return;
+
+ fprintf(stderr, "%s%s%s", tsl, str, fsl);
+}
+
+/**
+ * mutt_ts_icon - Set the icon in the terminal title bar
+ * @param str Icon string
+ *
+ * @note To clear the icon, set it to a single space.
+ */
+void mutt_ts_icon(char *str)
+{
+ if (!str || (*str == '\0'))
+ return;
+
+ /* icon setting is not supported in terminfo, so hardcode the escape */
+ fprintf(stderr, "\033]1;%s\007", str);
+}
--- /dev/null
+/**
+ * @file
+ * Set the terminal title/icon
+ *
+ * @authors
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * 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/>.
+ */
+
+#ifndef _MUTT_TERMINAL_H
+#define _MUTT_TERMINAL_H
+
+#include <stdbool.h>
+
+extern bool TsSupported;
+
+bool mutt_ts_capability(void);
+void mutt_ts_status(char *str);
+void mutt_ts_icon(char *str);
+
+#endif /* _MUTT_TERMINAL_H */