Re: axlisten: colors for command line

2018-11-26 Thread folkert
> > 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.

I don't see what advantage that will give. Those sequences are only used
when you explicitly enable them (using the -C command line switch).


Folkert van Heusden

-- 
MultiTail รจ uno flexible tool per seguire di logfiles e effettuazione
di commissioni. Feltrare, provedere da colore, merge, 'diff-view',
etc. http://www.vanheusden.com/multitail/
--
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com


Re: axlisten: colors for command line

2018-11-19 Thread jj
Would it be possible to have just ^M (enter) to exit listen/axlisten, 
because if it is invoked via telnet for a ham app it wants ctrl-c to 
exit...cannot exit...


On 2018-11-19 9:30 a.m., folkert wrote:

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.


diff --git a/AUTHORS b/AUTHORS
index 7b91e72..d0d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -17,6 +17,7 @@ Heikki Hannikainen OH7LZB 
  Alan Cox GW4PTS 
  Jean-Paul for rose decoding
  Jeroen Vreeken for INP decoding
+Folkert van Heusden 
  
  call:

  Alexander Tietzel DG6XA 
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



Re: axlisten: colors for command line

2018-11-19 Thread folkert
Hi David,

I don't have a before here but it looks like plain ascii.
The after is e.g. https://imgur.com/a/ybTWzle

On Mon, Nov 19, 2018 at 07:51:54AM -0800, David Ranch wrote:
> Hello Folkert,
> 
> Thanks for the patch!  Any chance of posting a before and after screen
> capture to see what it looks like?
> 
> --David
> KI6ZHD
> 
> 
> 
> On 11/19/2018 05:30 AM, folkert wrote:
> > 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.
> > 
> > 
> > diff --git a/AUTHORS b/AUTHORS
> > index 7b91e72..d0d 100644
> > --- a/AUTHORS
> > +++ b/AUTHORS
> > @@ -17,6 +17,7 @@ Heikki Hannikainen OH7LZB 
> >   Alan Cox GW4PTS 
> >   Jean-Paul for rose decoding
> >   Jeroen Vreeken for INP decoding
> > +Folkert van Heusden 
> >   call:
> >   Alexander Tietzel DG6XA 
> > 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
> > 
> 


Folkert van Heusden

-- 
www.vanheusden.com/multitail - multitail is tail on steroids. multiple
   windows, filtering, coloring, anything you can think of
--
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com


Re: axlisten: colors for command line

2018-11-19 Thread David Ranch

Hello Folkert,

Thanks for the patch!  Any chance of posting a before and after screen 
capture to see what it looks like?


--David
KI6ZHD



On 11/19/2018 05:30 AM, folkert wrote:

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.


diff --git a/AUTHORS b/AUTHORS
index 7b91e72..d0d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -17,6 +17,7 @@ Heikki Hannikainen OH7LZB
  Alan Cox GW4PTS
  Jean-Paul for rose decoding
  Jeroen Vreeken for INP decoding
+Folkert van Heusden
  
  call:

  Alexander Tietzel DG6XA
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