> folkert <folk...@vanheusden.com> hat am 19. November 2018 um 14:30
> geschrieben:
>
>
> Hi,
>
> Below you'll find a patch against ax25-apps. It adds the '-C' command
> line switch (uppercase c). -c (lowercase) gave you an ncurses colored
> listing of all packets received. -C (uppercase) does the same but
> without ncurses, e.g. directly on the commandline. It does this with
> ANSI-escape codes. You may want this if you want to be able to more
> easily scroll back (which can be problematic for ncurses applications)
> and to redirect the output (colored) to a file.
>
I am not sure that this is the way to go. placing hardcoded ctrl sequences
is asking for trouble. I would suggest using a compile time switch to enable
this option that is off by default.
just my 2 cents,
re,
wh
>
> diff --git a/AUTHORS b/AUTHORS
> index 7b91e72..deeee0d 100644
> --- a/AUTHORS
> +++ b/AUTHORS
> @@ -17,6 +17,7 @@ Heikki Hannikainen OH7LZB <oh7...@sral.fi>
> Alan Cox GW4PTS <a...@cymru.net>
> Jean-Paul for rose decoding
> Jeroen Vreeken for INP decoding
> +Folkert van Heusden <m...@vanheusden.com>
>
> call:
> Alexander Tietzel DG6XA <tietz...@etech.fh-hamburg.de>
> diff --git a/listen/listen.c b/listen/listen.c
> index 6504ed5..c922fe1 100644
> --- a/listen/listen.c
> +++ b/listen/listen.c
> @@ -203,7 +203,7 @@ int main(int argc, char **argv)
> int proto = ETH_P_AX25;
> int exit_code = EXIT_SUCCESS;
>
> - while ((s = getopt(argc, argv, "8achip:rtv")) != -1) {
> + while ((s = getopt(argc, argv, "8acChip:rtv")) != -1) {
> switch (s) {
> case '8':
> sevenbit = 0;
> @@ -214,6 +214,9 @@ int main(int argc, char **argv)
> case 'c':
> color = 1;
> break;
> + case 'C':
> + a_color = 1;
> + break;
> case 'h':
> dumpstyle = HEX;
> break;
> diff --git a/listen/listen.h b/listen/listen.h
> index 46ec397..72c185e 100644
> --- a/listen/listen.h
> +++ b/listen/listen.h
> @@ -36,6 +36,7 @@
>
> /* In utils.c */
> extern int color; /* Colorized mode */
> +extern int a_color; /* ANSI-colorized mode */
> extern int sevenbit; /* Are we on a 7-bit terminal? */
> extern int ibmhack; /* IBM mapping? */
>
> diff --git a/listen/utils.c b/listen/utils.c
> index 4d99e10..26653a4 100644
> --- a/listen/utils.c
> +++ b/listen/utils.c
> @@ -16,6 +16,7 @@
> #include "listen.h"
>
> int color = 0; /* Colorized? */
> +int a_color = 0; /* ANSI-colorized mode */
> int sevenbit = 1; /* Are we on a 7-bit terminal? */
> int ibmhack = 0; /* IBM mapping? */
>
> @@ -45,7 +46,7 @@ void lprintf(int dtype, char *fmt, ...)
> vsnprintf(str, 1024, fmt, args);
> va_end(args);
>
> - if (color) {
> + if (color || a_color) {
> for (p = str; *p != '\0'; p++) {
> ch = *p;
>
> @@ -63,9 +64,20 @@ void lprintf(int dtype, char *fmt, ...)
> || (dtype == T_TIMESTAMP))
> ch |= A_BOLD;
>
> - ch |= COLOR_PAIR(dtype);
> + if (color) {
> + ch |= COLOR_PAIR(dtype);
> + addch(ch);
> + }
> + else { /* a_color */
> + if (ch & A_BOLD)
> + printf("\x1b[1m");
> + if (ch & A_REVERSE)
> + printf("\x1b[7m");
>
> - addch(ch);
> + printf("\x1b[%dm%c", 30 + (dtype & 7), ch &
> 255);
> +
> + printf("\x1b[0m");
> + }
> }
> } else {
> for (p = str; *p != '\0'; p++)
>
>
> Folkert van Heusden
>
> --
> Multitail est un outil permettant la visualisation de fichiers de
> journalisation et/ou le suivi de l'exécution de commandes. Filtrage,
> mise en couleur de mot-clé, fusions, visualisation de différences
> (diff-view), etc. http://www.vanheusden.com/multitail/
> ----------------------------------------------------------------------
> Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com