[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Default "box" option for ascii driver

From: John Darrington
Subject: Default "box" option for ascii driver
Date: Tue, 9 Apr 2013 09:53:15 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

The (ever increasingly misnamed) ascii driver supports unicode box characters, 
which are
must nicer than the ascii #==--- etc.  It would be good if more people knew 
about it.
Accordingly, I propose the following patch.

It causes the terminal user interface to start as if -O box=unicode had been 
given iff
1. No explicit "box" option was specified; AND
2. The encoding of the locale is UTF-8

condition 2 is not absolutely robust.   It doesn't guarantee that the terminal 
capable of displaying UTF8, but it should work under most environments.

Any objections?

diff --git a/src/ui/terminal/terminal-opts.c b/src/ui/terminal/terminal-opts.c
index 121d89d..95007a0 100644
--- a/src/ui/terminal/terminal-opts.c
+++ b/src/ui/terminal/terminal-opts.c
@@ -20,6 +20,8 @@
 #include <stdbool.h>
 #include <stdlib.h>
+#include <string.h>
 #include "data/settings.h"
 #include "data/file-name.h"
@@ -39,6 +41,7 @@
 #include "output/msglog.h"
 #include "gl/error.h"
+#include "gl/localcharset.h"
 #include "gl/progname.h"
 #include "gl/version-etc.h"
 #include "gl/xmemdup0.h"
@@ -302,6 +305,8 @@ terminal_opts_init (struct argv_parser *ap,
 terminal_opts_done (struct terminal_opts *to, int argc, char *argv[])
+      if (0 == strcmp (locale_charset (), "UTF-8"))
+        string_map_insert (&to->options, "box", "unicode");
   register_output_driver (to);

PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]