vty icon indicating copy to clipboard operation
vty copied to clipboard

Bright colors printed as non-bright

Open mnn opened this issue 6 years ago • 7 comments

Selection_050

module Main where

import Lib
import Graphics.Vty

main = do
   cfg <- standardIOConfig
   vty <- mkVty cfg
   let line0 = string (defAttr `withForeColor` green `withBackColor` brightGreen) "first line"
       line0d = string defAttr " <- green on brightGreen"
       line1 = string (defAttr `withForeColor` brightBlack `withBackColor` black) "second line"
       line1d = string defAttr " <- brightBlack on black"
       img = line0 <|> line0d <-> line1 <|> line1d
       pic = picForImage img
   update vty pic
   e <- nextEvent vty
   shutdown vty
   print ("Last event was: " ++ show e)

Terminal emulator is Terminology 1.2.1 and it supports bright colors (screenshot of colortest-16): Selection_049

Library version is 5.25.1 (I am using Stack).

mnn avatar Apr 21 '19 07:04 mnn

Thanks for the report! What produced the second image?

jtdaugherty avatar Apr 21 '19 15:04 jtdaugherty

It's colortest-16 from colortest package in Ubuntu. I wasn't able to find exact same version online, so here's a gist - https://gist.github.com/mnn/f8a6e2b1b3e938f08cd2ebce36f85d28.

mnn avatar Apr 21 '19 16:04 mnn

Thanks. Have you reproduced this with any other terminal emulators?

jtdaugherty avatar Apr 21 '19 16:04 jtdaugherty

I am experiencing same issue with konsole and xterm. gnome-terminal is ok. All of them render the colortest-16 correctly.

Selection_051 From top: terminology, konsole, xterm, gnome-terminal (white is mapped to green, it's not a bug)

mnn avatar Apr 21 '19 17:04 mnn

While my color scheme is solarized and things look a little different than you might expect, vty successfully distinguishes the bright and non-bright colors on Terminal.app. What TERM value are you using?

When I'm using TERM=xterm-256color I get the following image:

Screen Shot 2019-04-25 at 2 18 08 PM

When I'm using TERM=xterm, however, I get:

Screen Shot 2019-04-25 at 2 21 06 PM

glguy avatar Apr 25 '19 21:04 glguy

Yes, TERM=xterm seems to be the cause. According to this it is not possible in many terminal emulators to get info about supported colors. Script from comments returns in terminology with default settings 8. After enabling option Set TERM to xterm-256color bright colors work.

Is is possible in vty enforce using 16 colors (ignoring TERM env var)?

mnn avatar Apr 26 '19 06:04 mnn

@mnn It is possible to force Vty into 16-color mode:

vty <- mkVty defaultConfig
let vty16ColorMode = vty { outputIface = (outputIface vty) { contextColorCount = 16 } }

jtdaugherty avatar Feb 27 '20 18:02 jtdaugherty

I'm going to close this due to inactivity, but please re-open this or file a more specific issue if needed. Thanks!

jtdaugherty avatar Jul 18 '23 20:07 jtdaugherty