summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2020-09-02 15:09:58 +1000
committerNathan Scott <nathans@redhat.com>2020-09-02 15:09:58 +1000
commitf79591ef1b19384d75449353e0f6bf2e16e85307 (patch)
treef7f74a71a5770ae092b46db6f576514bb0684ff5
parentf5b3e8d2a355e71720cbe3893ddf395dce746572 (diff)
parentdb5adbeae09b8b80587294e4de125af109b8ecdc (diff)
Merge branch 'eworm-de-unicode-runtime'
-rw-r--r--CRT.c6
-rw-r--r--CRT.h2
-rw-r--r--htop.1.in3
-rw-r--r--htop.c31
4 files changed, 27 insertions, 15 deletions
diff --git a/CRT.c b/CRT.c
index 33ee9623..0d83bf42 100644
--- a/CRT.c
+++ b/CRT.c
@@ -667,7 +667,7 @@ void CRT_restorePrivileges() {
// TODO: pass an instance of Settings instead.
-void CRT_init(int delay, int colorScheme) {
+void CRT_init(int delay, int colorScheme, bool allowUnicode) {
initscr();
noecho();
CRT_delay = delay;
@@ -733,10 +733,12 @@ void CRT_init(int delay, int colorScheme) {
setlocale(LC_CTYPE, "");
#ifdef HAVE_LIBNCURSESW
- if(strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
+ if (allowUnicode && strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
CRT_utf8 = true;
else
CRT_utf8 = false;
+#else
+ (void) allowUnicode;
#endif
CRT_treeStr =
diff --git a/CRT.h b/CRT.h
index 80022f70..7d5c8adf 100644
--- a/CRT.h
+++ b/CRT.h
@@ -189,7 +189,7 @@ extern void CRT_restorePrivileges();
// TODO: pass an instance of Settings instead.
-extern void CRT_init(int delay, int colorScheme);
+extern void CRT_init(int delay, int colorScheme, bool allowUnicode);
extern void CRT_done();
diff --git a/htop.1.in b/htop.1.in
index 9ef0761b..c5b131bb 100644
--- a/htop.1.in
+++ b/htop.1.in
@@ -48,6 +48,9 @@ Sort by this column (use \-\-sort\-key help for a column list)
\fB\-u \-\-user=USERNAME\fR
Show only the processes of a given user
.TP
+\fB\-U \-\-no-unicode\fR
+Do not use unicode but ASCII characters for graph meters
+.TP
\fB\-v \-\-version
Output version information and exit
.TP
diff --git a/htop.c b/htop.c
index d9302a0c..bbf3a911 100644
--- a/htop.c
+++ b/htop.c
@@ -43,6 +43,7 @@ static void printHelpFlag() {
"-s --sort-key=COLUMN Sort by COLUMN (try --sort-key=help for a list)\n"
"-t --tree Show the tree view by default\n"
"-u --user[=USERNAME] Show only processes for a given user (or $USER)\n"
+ "-U --no-unicode Do not use unicode but plain ASCII\n"
"-p --pid=PID,[,PID,PID...] Show only the given PIDs\n"
"-v --version Print version info\n"
"\n"
@@ -63,6 +64,7 @@ typedef struct CommandLineSettings_ {
bool useColors;
bool enableMouse;
bool treeView;
+ bool allowUnicode;
} CommandLineSettings;
static CommandLineSettings parseArguments(int argc, char** argv) {
@@ -75,26 +77,28 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
.useColors = true,
.enableMouse = true,
.treeView = false,
+ .allowUnicode = true,
};
static struct option long_opts[] =
{
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {"delay", required_argument, 0, 'd'},
- {"sort-key", required_argument, 0, 's'},
- {"user", optional_argument, 0, 'u'},
- {"no-color", no_argument, 0, 'C'},
- {"no-colour",no_argument, 0, 'C'},
- {"no-mouse", no_argument, 0, 'm'},
- {"tree", no_argument, 0, 't'},
- {"pid", required_argument, 0, 'p'},
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {"delay", required_argument, 0, 'd'},
+ {"sort-key", required_argument, 0, 's'},
+ {"user", optional_argument, 0, 'u'},
+ {"no-color", no_argument, 0, 'C'},
+ {"no-colour", no_argument, 0, 'C'},
+ {"no-mouse", no_argument, 0, 'm'},
+ {"no-unicode", no_argument, 0, 'U'},
+ {"tree", no_argument, 0, 't'},
+ {"pid", required_argument, 0, 'p'},
{0,0,0,0}
};
int opt, opti=0;
/* Parse arguments */
- while ((opt = getopt_long(argc, argv, "hvmCs:td:u::p:", long_opts, &opti))) {
+ while ((opt = getopt_long(argc, argv, "hvmCs:td:u:Up:", long_opts, &opti))) {
if (opt == EOF) break;
switch (opt) {
case 'h':
@@ -148,6 +152,9 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
case 'm':
flags.enableMouse = false;
break;
+ case 'U':
+ flags.allowUnicode = false;
+ break;
case 't':
flags.treeView = true;
break;
@@ -226,7 +233,7 @@ int main(int argc, char** argv) {
if (flags.treeView)
settings->treeView = true;
- CRT_init(settings->delay, settings->colorScheme);
+ CRT_init(settings->delay, settings->colorScheme, flags.allowUnicode);
MainPanel* panel = MainPanel_new();
ProcessList_setPanel(pl, (Panel*) panel);

© 2014-2024 Faster IT GmbH | imprint | privacy policy