zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Support for 256 colors in zsh/curses
Date: Fri, 29 Apr 2016 13:35:33 +0200	[thread overview]
Message-ID: <CAKc7PVCa+pvuPojO29Rrj9AfE6LwC9n7YYdKhmnz2R-MwXMYpg@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVDAUh=he-N+s1ZSGS8JfuCJ+66EB+bpkmOBhFaKXX-k=A@mail.gmail.com>

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


      reply	other threads:[~2016-04-29 11:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29 11:34 Sebastian Gniazdowski
2016-04-29 11:35 ` Sebastian Gniazdowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKc7PVCa+pvuPojO29Rrj9AfE6LwC9n7YYdKhmnz2R-MwXMYpg@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).