1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/***************************************************************************
* *
* _____ ____ *
* | __ \ / __ \ _ _ _____ *
* | | \ \ / / \_\ | | | | _ \ *
* | | \ \| | | | | | |_| | *
* | | | || | | | | | ___/ *
* | | / /| | __ | | | | _ \ *
* | |__/ / \ \__/ / | |___| | |_| | *
* |_____/ \____/ |_____|_|_____/ *
* *
* Wiimms source code library *
* *
***************************************************************************
* *
* Copyright (c) 2012-2024 by Dirk Clemens <wiimm@wiimm.de> *
* *
***************************************************************************
* *
* This library 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 library 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. *
* *
* See file gpl-2.0.txt or http://www.gnu.org/licenses/gpl-2.0.txt *
* *
***************************************************************************/
#define _GNU_SOURCE 1
#include <unistd.h>
#include "dclib-basics.h"
#include "dclib-debug.h"
//
///////////////////////////////////////////////////////////////////////////////
/////////////// global commands ///////////////
///////////////////////////////////////////////////////////////////////////////
enumError Command_ARGTEST ( int argc, char ** argv )
{
printf("ARGUMENT TEST: %u arguments:\n",argc);
int idx;
for ( idx = 0; idx < argc; idx++ )
printf("%4u.: |%s|\n",idx,argv[idx]);
return ERR_OK;
}
///////////////////////////////////////////////////////////////////////////////
enumError Command_COLORS
(
int level, // only used, if select==0
// < 0: status message (ignore select)
// >= 1: include names
// >= 2: include alt names
// >= 3: include color names incl bold
// >= 4: include background color names
ColorSelect_t select, // select color groups; if 0: use level
uint format // output format => see PrintColorSet()
)
{
if (!colout)
SetupStdMsg();
if ( level < 0 )
{
ccp term = getenv("TERM");
if (!term)
term = "?";
printf("%s--color=%d [%s], colorize=%d [%s]\n"
"term=%s\n"
"stdout: tty=%d, mode=%d [%s], have-color=%d, n-colors=%u%s\n",
colout->status,
opt_colorize, GetColorModeName(opt_colorize,"?"),
colorize_stdout, GetColorModeName(colorize_stdout,"?"),
term, isatty(fileno(stdout)),
colout->col_mode, GetColorModeName(colout->col_mode,"?"),
colout->colorize, colout->n_colors, colout->reset );
return ERR_OK;
}
if ( !select && level > 0 )
switch (level)
{
case 1: select = COLSEL_NAME; break;
case 2: select = COLSEL_NAME|COLSEL_F_ALT; break;
case 3: select = COLSEL_M_NONAME; break;
default: select = COLSEL_M_ALL; break;
}
if (!format)
{
const ColorMode_t col_mode = colout ? colout->col_mode : COLMD_AUTO;
PrintTextModes( stdout, 4, col_mode );
PrintColorModes( stdout, 4, col_mode, GCM_ALT );
#ifdef TEST
PrintColorModes( stdout, 4, col_mode, GCM_ALT|GCM_SHORT );
#endif
}
if ( select || format )
PrintColorSet(stdout,4,colout,select,format);
return ERR_OK;
}
//
///////////////////////////////////////////////////////////////////////////////
/////////////// END ///////////////
///////////////////////////////////////////////////////////////////////////////
|