Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to;
        bh=cvQuF0a7gkA5VN5xLDkAlKXBKTMUff5gnDMEmlw8o9I=;
        b=FAy0q9rS8bcxsllYkTmbhNYxiCSpdaeVx8bEDAkzFShPZBTNZ6SPeeW8xWfvwPK16t
         Q1Vjx7unpA6uzsRtqfSMlnTR0UX2qceoAFm3Gfjw/3OKT0S5Awg1VfTmnz9TBCb7djoy
         8rQlsGnHuMzvPnvClwQJ7lwNVonnI87KkOtSjyNoHCP4YArssy5CWaeSqEY+7EYLi5m8
         MmEXbOFXLXnf89zj/SW0N8bi9swhFxLF2D5STTaEgO51t8rTDBgrVM8SBNudoGwfE8WU
         C6Y9Z0dX2MJSyRnDwvacGP+keV7OqgUHf4wJ5T0LugqNsixlPR0dNQyxko31y5JV1u3x
         aFeg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to;
        bh=cvQuF0a7gkA5VN5xLDkAlKXBKTMUff5gnDMEmlw8o9I=;
        b=WgscHJiZfou4RHBPuZB9XPIvir/br3glYVbRn2bPmD/Fpc0BFqoTpfPi4N+0ULs+Dm
         ssvjFQtG4IXLHwcW66Tk/iMsLgGNqpAIj217tlR49Qn8gduCkrDjiik6JtIf7k0gvuJm
         gmNCLSvCy/VAObo9kL2X0zuobMFqxF3W80/dAoVVPW7BdPKZuWWGRVSsLkErJm7+aZ1w
         XYDo5fgkubVDE7ZyaFWzZ941Akm6Gs7wqQPPLh8mAVzg//ypftlQduEvXZrjXS3K0isJ
         A7phwNN7CNbcK1lKq5ZBgA/O1UCZK09VqYjqE4rMGIRssASnDIYtg2IMEgbefUyA2Rjp
         kZGA==
X-Gm-Message-State: AOPr4FW7dFuk01KgJavJAYXqQqQzqMRhJIZ+NkTWNn52fruKiJziyY5PdEyNNUHFtS1TJfgKSD7OCQ3CSOwJMA==
X-Received: by 10.112.142.7 with SMTP id rs7mr4965575lbb.53.1461929753075;
 Fri, 29 Apr 2016 04:35:53 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <CAKc7PVDAUh=he-N+s1ZSGS8JfuCJ+66EB+bpkmOBhFaKXX-k=A@mail.gmail.com>
References: <CAKc7PVDAUh=he-N+s1ZSGS8JfuCJ+66EB+bpkmOBhFaKXX-k=A@mail.gmail.com>
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Fri, 29 Apr 2016 13:35:33 +0200
Message-ID: <CAKc7PVCa+pvuPojO29Rrj9AfE6LwC9n7YYdKhmnz2R-MwXMYpg@mail.gmail.com>
Subject: Re: Support for 256 colors in zsh/curses
To: Zsh hackers list <zsh-workers@zsh.org>
Content-Type: text/plain; charset=UTF-8
X-Seq: zsh-workers 38357

The "a/b" should be "x/y", so:

Hello,
the existing infrastructure in zsh/curses is quite nice. If user
requests color pair "x/y", it is first looked up in a hash table:

!(cpn = (Colorpairnode) gethashnode2(zcurses_colorpairs, colorpair))) {

if it doesn't exist, then "x/y" (e.g. "red/black") is translated to
corresponding integers, and init_pair is called:

if (next_cp >= COLOR_PAIRS || init_pair(next_cp, f, b) == ERR)  {

where "f" and "b" are the translated integers. The color pair is put
into the hash under "x/y" for future reuse.

On 29 April 2016 at 13:34, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> Hello,
> the existing infrastructure in zsh/curses is quite nice. If user
> requests color pair "a/b", it is first looked up in a hash table:
>
> !(cpn = (Colorpairnode) gethashnode2(zcurses_colorpairs, colorpair))) {
>
> if it doesn't exist, then "x/y" (e.g. "red/black") is translated to
> corresponding integers, and init_pair is called:
>
> if (next_cp >= COLOR_PAIRS || init_pair(next_cp, f, b) == ERR)  {
>
> where "f" and "b" are the translated integers. The color pair is put
> into the hash under "x/y" for future reuse.
>
>
> To support 256 colors, all I had to do is translate num1/num2 into
> f=num1, b=num2, i.e. just directly (classic atoi) translate color
> number into integer to be passed to curses as its color number. Not
> sure what else can I write, reading the code will reveal how
> transparent the change is. Any questions maybe?
>
> Best regards,
> Sebastian Gniazdowski

