diff options
author | Daniel Lange <DLange@git.local> | 2020-09-03 12:34:39 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2020-09-03 12:34:39 +0200 |
commit | 59eeadec918a955b40427a1b012992161050c939 (patch) | |
tree | 4d3a4708e29a6a2f8807b2843a3cbae99f5dfda3 /htop.c | |
parent | f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4 (diff) | |
download | debian_htop-59eeadec918a955b40427a1b012992161050c939.tar.gz debian_htop-59eeadec918a955b40427a1b012992161050c939.tar.bz2 debian_htop-59eeadec918a955b40427a1b012992161050c939.zip |
New upstream version 3.0.1upstream/3.0.1
Diffstat (limited to 'htop.c')
-rw-r--r-- | htop.c | 39 |
1 files changed, 22 insertions, 17 deletions
@@ -29,14 +29,12 @@ in the source distribution for its full text. //#link m static void printVersionFlag() { - fputs("htop " VERSION " - " COPYRIGHT "\n" - "Released under the GNU GPL.\n\n", - stdout); + fputs("htop " VERSION "\n", stdout); exit(0); } static void printHelpFlag() { - fputs("htop " VERSION " - " COPYRIGHT "\n" + fputs("htop " VERSION "\n" "Released under the GNU GPL.\n\n" "-C --no-color Use a monochrome color scheme\n" "-m --no-mouse Disable the mouse\n" @@ -45,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" @@ -65,6 +64,7 @@ typedef struct CommandLineSettings_ { bool useColors; bool enableMouse; bool treeView; + bool allowUnicode; } CommandLineSettings; static CommandLineSettings parseArguments(int argc, char** argv) { @@ -77,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': @@ -150,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; @@ -200,7 +205,7 @@ int main(int argc, char** argv) { CommandLineSettings flags = parseArguments(argc, argv); // may exit() -#ifdef HAVE_PROC +#ifdef HTOP_LINUX if (access(PROCDIR, R_OK) != 0) { fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR); exit(1); @@ -228,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); |