Re: tty[1-6]: colors a negative accessibility/usability trend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Karel Zak, le Mon 02 Mar 2015 09:59:29 +0100, a écrit :
> On Sun, Mar 01, 2015 at 01:32:01PM +0000, Pádraig Brady wrote:
> > and I've not heard specific complaints about it.
> > What terminals are not catered for here?
> 
> I don't know, my plan is to do some research to better understand what
> Samuel is talking about.

Mmm, I thought it was well-known, but apparently not :/

I mean using this (see terminfo(5) for the details):

#include <term.h>
#include <stdio.h>
#include <unistd.h>

int main(void) {
  int my_bg_color = 0;
  int my_fg_color = 4;

  setupterm(NULL, STDOUT_FILENO, NULL);
  tputs(enter_bold_mode, 1, putchar);
  tputs(enter_italics_mode, 1, putchar);
  tputs(enter_underline_mode, 1, putchar);
  tputs(enter_blink_mode, 1, putchar);
  tputs(enter_reverse_mode, 1, putchar);
  tputs(tparm(set_a_foreground, my_fg_color), 1, putchar);
  tputs(tparm(set_a_background, my_bg_color), 1, putchar);
  printf("Hello, world!\n");
  tputs(exit_attribute_mode, 1, putchar);
  return 0;
}

On terminals which support it, you can even get rgb colors by using
initialize_color or initialize_pair. If you want a more complete
example, see lstopo-text.c inside the hwloc package, we include ncurses,
but we don't actually need it for this kind of code. Try with

lstopo -.txt

Doing it really properly as exampled above doesn't look terribly
overengineered to me.

Samuel
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux