Re: Simple Colors?

2020-02-24 Thread Cameron Simpson

On 24Feb2020 20:15, Paul Gilmartin  wrote:

On 2020-02-24, at 18:24:36, Cameron Simpson wrote:
The colours are requested with escape sequences and the colour 
displayed are thus dependent on your terminal emulator; the names 
"white" etc map to a palette. So you want to start with the settings 
in your terminal emulator.


For reference, here are some colours from my ancient ANSI colour python module, 
where you can see 0, 7, 4 etc embedded.

  # the known colour names and their escape sequences
  COLOURS = {
  ...
  'green': '\033[32m',
  ...

Isn't terminfo supposed to add an abstractlon layer
so I can just say "green" and not memorize " '\033[32m'"?


Absolutely. That's what mutt does. I was just demoing some hardwired 
ANSI colour escape sequences as examples to show the low and numeric 
nature - they basicly specify an index into a palette.



And I still prefer "#00FF00".


If your terminal has full colour and there's an escape sequence for RGB 
values, yes indeed. Bypasses weird palettes and says what you want.


Cheers,
Cameron Simpson 


Re: Simple Colors?

2020-02-24 Thread Paul Gilmartin
On 2020-02-24, at 18:24:36, Cameron Simpson wrote:
> 
> The colours are requested with escape sequences and the colour displayed are 
> thus dependent on your terminal emulator; the names "white" etc map to a 
> palette. So you want to start with the settings in your terminal emulator.
> 
> For reference, here are some colours from my ancient ANSI colour python 
> module, where you can see 0, 7, 4 etc embedded.
> 
>   # the known colour names and their escape sequences
>   COLOURS = {
>   ...
>   'green': '\033[32m',
>   ...
Isn't terminfo supposed to add an abstractlon layer
so I can just say "green" and not memorize " '\033[32m'"?

And I still prefer "#00FF00".

Thanks,
gil



Re: Simple Colors?

2020-02-24 Thread Cameron Simpson

On 24Feb2020 15:43, Paul Gilmartin  wrote:

On 2020-02-24, at 14:40:52, Cameron Simpson wrote:

On 24Feb2020 13:55, Paul Gilmartin wrote:

With my failing eyes, I'd like everything high contrast,
mostly black on white.


What's the natural colour scheme of your terminal?


Foreground black; background white.


When I do in .mutt/muttrc
color normalblack white
... I seem to get black on gray.


Odd. What about other colours than "white", as a test?


E.g. brightyellow works.  brightwhite is whiter than white,
but still somewhat gray.  Is there something like #FFF?
Is there a "realwhite"?

When I do:
color normalwhite black
... I get white (or maybe gray) on black.


What if you switch out "white" for "default"?


Ah!  "color normaldefault default" works.  "default" is
whiter than white.  Who woulda thunk it.

Where should I have found this in the Ref.?


Maybe nowhere, though it could probably use some discussion there.

The colours are requested with escape sequences and the colour displayed 
are thus dependent on your terminal emulator; the names "white" etc map 
to a palette. So you want to start with the settings in your terminal 
emulator.


For reference, here are some colours from my ancient ANSI colour python 
module, where you can see 0, 7, 4 etc embedded.


   # the known colour names and their escape sequences
   COLOURS = {
   'normal': '\033[0m',
   'reverse': '\033[7m',
   'underline': '\033[4m',
   'bold': '\033[1m',
   'black': '\033[30m',
   'red': '\033[31m',
   'green': '\033[32m',
   'yellow': '\033[33m',
   'blue': '\033[34m',
   'magenta': '\033[35m',
   'cyan': '\033[36m',
   'white': '\033[37m',
   }

That palette used to be about 8 colours, then there were terminals with 
256 colours (eg support from things like xterm-256) and maybe there's an 
arbitrary #RGB format these days.


I also attach my script "colour_echo" and the "with-colour" script it 
calls. Usage:


   colour_echo white message...

which you might use to fiddle around with the standard colour names to 
see what your terminal produces.


I'd be happy to be further educated about modern colour escape 
sequences.


Cheers,
Cameron Simpson 
#!/bin/sh
#
# Perform command with output in particular colour.
# - Cameron Simpson  08jul2007
#

set -ue

: ${WITH_COLOUR_ON:=''}

cmd=$0
usage="Usage: $cmd colour command [args...]"

badopts=

if [ $# = 0 ]
then
  echo "$cmd: missing colour" >&2
  badopts=1
else
  colour=$1
  shift

  if [ $# = 0 ]
  then
echo "$cmd: missing command" >&2
badopts=1
  fi
fi

[ $badopts ] && { echo "$usage" >&2; exit 2; }

exec 3>&2 2>/dev/null
on= off=
case $colour in
  normal)   on= ;;
  bold) on=`tput bold`&& off=`tput sgr0` ;;
  reverse)  on=`tput rev` && off=`tput sgr0` ;;
  standout) on=`tput smso` && off=`tput rmso` ;;
  it|italic)on=`tput sitm` && off=`tput ritm` ;;
  ul|underline)
on=`tput smul` && off=`tput rmul` ;;
  sl|status)on=`tput tsl` && off=`tput fsl` ;;
  black)on=`tput setaf 0 || tput setaf 0 0 0 || tput setf 0` ;;
  red)  on=`tput setaf 1 || tput setaf 1 0 0 || tput setf 4` ;;
  green)on=`tput setaf 2 || tput setaf 2 0 0 || tput setf 2` ;;
  yellow)   on=`tput setaf 3 || tput setaf 3 0 0 || tput setf 6` ;;
  blue) on=`tput setaf 4 || tput setaf 4 0 0 || tput setf 1` ;;
  magenta)  on=`tput setaf 5 || tput setaf 5 0 0 || tput setf 5` ;;
  cyan) on=`tput setaf 6 || tput setaf 6 0 0 || tput setf 3` ;;
  white)on=`tput setaf 7 || tput setaf 7 0 0 || tput setf 7` ;;
  *)echo "$cmd: warning: unsupported colour: $colour" >&2 ;;
esac || on=
exec 2>&3 3>&-

# no "on" sequence? just run the command
[ -n "$on" ] || exec "$@"
# no "off"? restore original colour pair
[ -n "$off" ] || off=`tput op`

xit=0
printf "%s" "$on"
env "WITH_COLOUR_ON=$on" "$@" || xit=$?
printf "%s%s" "$off$WITH_COLOUR_ON"
exit $xit
#!/bin/sh
#
# Echo in colour.   - Cameron Simpson 
#

set -ue

cmd=$0
usage="Usage: $cmd [-n] colour message..."

badopts=

echo=echo

while [ $# -gt 0 ]
do
  case $1 in
-n) echo=necho; shift ;;
--) shift; break ;;
-?*)echo "$cmd: unrecognised option: $1" >&2
badopts=1
;;
*)  break ;;
  esac
  shift
done

if [ $# = 0 ]
then
  echo "$cmd: missing colour" >&2
  badopts=1
else
  colour=$1
  shift
fi

[ $badopts ] && { echo "$usage" >&2; exit 2; }

exec with-colour "$colour" "$echo" ${1+"$@"}


Re: Simple Colors?

2020-02-24 Thread Paul Gilmartin
On 2020-02-24, at 14:40:52, Cameron Simpson wrote:
> 
> On 24Feb2020 13:55, Paul Gilmartin wrote:
>> With my failing eyes, I'd like everything high contrast,
>> mostly black on white.
> 
> What's the natural colour scheme of your terminal?
>  
Foreground black; background white.

>> When I do in .mutt/muttrc
>> color normal black white
>> ... I seem to get black on gray.
> 
> Odd. What about other colours than "white", as a test?
>  
E.g. brightyellow works.  brightwhite is whiter than white,
but still somewhat gray.  Is there something like #FFF?
Is there a "realwhite"?

>> When I do:
>> color normal white black
>> ... I get white (or maybe gray) on black.
> 
> What if you switch out "white" for "default"?
> 
Ah!  "color normaldefault default" works.  "default" is
whiter than white.  Who woulda thunk it.

Where should I have found this in the Ref.?

Thanks,
gil



Re: Simple Colors?

2020-02-24 Thread Fred Smith
On Tue, Feb 25, 2020 at 08:40:52AM +1100, Cameron Simpson wrote:
> On 24Feb2020 13:55, Paul Gilmartin  wrote:
> >With my failing eyes, I'd like everything high contrast,
> >mostly black on white.
> 
> What's the natural colour scheme of your terminal?
> 
> >When I do in .mutt/muttrc
> >color normal black white
> >... I seem to get black on gray.
> 
> Odd. What about other colours than "white", as a test?
> 
> >When I do:
> >color normal white black
> >... I get white (or maybe gray) on black.
> 
> What if you switch out "white" for "default"?

just a wild guess... try "brightwhite" ??

-- 
 Fred Smith -- fre...@fcshome.stoneham.ma.us -
"Not everyone who says to me, 'Lord, Lord,' will enter the kingdom of
 heaven, but only he who does the will of my Father who is in heaven."
-- Matthew 7:21 (niv) -


Re: Simple Colors?

2020-02-24 Thread Cameron Simpson

On 24Feb2020 13:55, Paul Gilmartin  wrote:

With my failing eyes, I'd like everything high contrast,
mostly black on white.


What's the natural colour scheme of your terminal?


When I do in .mutt/muttrc
color normalblack white
... I seem to get black on gray.


Odd. What about other colours than "white", as a test?


When I do:
color normalwhite black
... I get white (or maybe gray) on black.


What if you switch out "white" for "default"?

Cheers,
Cameron Simpson