summaryrefslogtreecommitdiffstats
path: root/fish/fish.c
diff options
context:
space:
mode:
Diffstat (limited to 'fish/fish.c')
-rw-r--r--fish/fish.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/fish/fish.c b/fish/fish.c
index c535e062..c4ade8c2 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -30,6 +30,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <locale.h>
+#include <langinfo.h>
#include <termios.h>
#ifdef HAVE_LIBREADLINE
@@ -69,6 +70,7 @@ struct mp {
char *mountpoint;
};
+static void set_up_terminal (void);
static char add_drives (struct drv *drv, char next_drive);
static void prepare_drives (struct drv *drv);
static void mount_mps (struct mp *mp);
@@ -96,6 +98,8 @@ int command_num = 0;
int keys_from_stdin = 0;
const char *libvirt_uri = NULL;
int inspector = 0;
+int utf8_mode = 0;
+int have_terminfo = 0;
static void __attribute__((noreturn))
usage (int status)
@@ -159,6 +163,8 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, LOCALEBASEDIR);
textdomain (PACKAGE);
+ set_up_terminal ();
+
enum { HELP_OPTION = CHAR_MAX + 1 };
static const char *options = "a:c:d:Df:h::im:nN:rv?Vx";
@@ -509,6 +515,35 @@ main (int argc, char *argv[])
exit (EXIT_SUCCESS);
}
+/* The <term.h> header file which defines this has "issues". */
+extern int tgetent (char *, const char *);
+
+static void
+set_up_terminal (void)
+{
+ /* http://www.cl.cam.ac.uk/~mgk25/unicode.html#activate */
+ utf8_mode = STREQ (nl_langinfo (CODESET), "UTF-8");
+
+ char *term = getenv ("TERM");
+ if (term == NULL) {
+ //fprintf (stderr, _("guestfish: TERM (terminal type) not defined.\n"));
+ return;
+ }
+
+ int r = tgetent (NULL, term);
+ if (r == -1) {
+ fprintf (stderr, _("guestfish: could not access termcap or terminfo database.\n"));
+ return;
+ }
+ if (r == 0) {
+ fprintf (stderr, _("guestfish: terminal type \"%s\" not defined.\n"),
+ term);
+ return;
+ }
+
+ have_terminfo = 1;
+}
+
void
pod2text (const char *name, const char *shortdesc, const char *str)
{