Skip to content

Commit

Permalink
true-color/direct support
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyg committed Oct 15, 2024
1 parent 7a711e9 commit f36a3b4
Show file tree
Hide file tree
Showing 56 changed files with 2,898 additions and 2,191 deletions.
15 changes: 9 additions & 6 deletions gr/cmain.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <edidentifier.h>
__CIDENT_RCSID(gr_cmain_c,"$Id: cmain.c,v 1.67 2024/10/02 16:24:52 cvsuser Exp $")
__CIDENT_RCSID(gr_cmain_c,"$Id: cmain.c,v 1.68 2024/10/06 17:01:22 cvsuser Exp $")

/* -*- mode: c; indent-width: 4; -*- */
/* $Id: cmain.c,v 1.67 2024/10/02 16:24:52 cvsuser Exp $
/* $Id: cmain.c,v 1.68 2024/10/06 17:01:22 cvsuser Exp $
* Main body, startup and command-line processing.
*
*
Expand Down Expand Up @@ -130,8 +130,8 @@ static struct argoption options[] = {

{ "noscroll", arg_none, NULL, 2, "Disable xterm scrolling" },

{ "color", arg_optional, NULL, 3, "Force color mode",
"=<depth>" },
{ "color", arg_optional, NULL, 3, "Color depth/mode",
"=<depth>|<truecolor>|<none>" },

{ "nocolor", arg_none, NULL, 3, "Force black and white display" },

Expand Down Expand Up @@ -1014,8 +1014,11 @@ argv_process(const int doerr, int argc, const char **argv)

case 3: /* tty - [no]color=[depth] */
if ('c' == args.opt) {
if (! args.val ||
(xf_color = atoi(args.val)) <= 0) {
if (args.val && 0 == strcmp(args.val, "none")) {
xf_color = 0;
} else if (args.val && (0 == strcmp(args.val, "truecolor") || 0 == strcmp(args.val, "24bit"))) {
xf_color = INT_MAX;
} else if (! args.val || (xf_color = atoi(args.val)) <= 0) {
xf_color = 1;
}
} else {
Expand Down
18 changes: 11 additions & 7 deletions gr/color.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef GR_COLOR_H_INCLUDED
#define GR_COLOR_H_INCLUDED
#include <edidentifier.h>
__CIDENT_RCSID(gr_color_h,"$Id: color.h,v 1.14 2024/10/02 16:24:52 cvsuser Exp $")
__CIDENT_RCSID(gr_color_h,"$Id: color.h,v 1.15 2024/10/06 17:01:22 cvsuser Exp $")
__CPRAGMA_ONCE

/* -*- mode: c; indent-width: 4; -*- */
/* $Id: color.h,v 1.14 2024/10/02 16:24:52 cvsuser Exp $
/* $Id: color.h,v 1.15 2024/10/06 17:01:22 cvsuser Exp $
* Color configuration.
*
*
Expand All @@ -32,7 +32,7 @@ __CBEGIN_DECLS
#define ANSICOLOR_BG(col) ((0x7f & col) & 0x07)
#define ANSICOLOR_MK(fg,bg) (ATTR_ANSI128 + ((fg * ANSIBG_MAX) + bg))

#define COLVALUE_INIT { COLOR_UNKNOWN, COLORSOURCE_NONE, 0 }
#define COLVALUE_INIT { COLOR_UNKNOWN, 0, COLORSOURCE_NONE, 0 }

enum {
/*--export--enum--*/
Expand Down Expand Up @@ -228,6 +228,7 @@ enum {

typedef struct {
int color; /* color value, -1 == undefined */
unsigned rgbcolor; /* RGB */
unsigned char source; /* definition source (see below) */
unsigned char type; /* source specific type information */

Expand All @@ -239,10 +240,10 @@ typedef struct {
#define COLORSOURCE_RGBLABEL 5 /* <name> == RGB */
#define COLORSOURCE_RGBCVT 6 /* converted RGB value to current color depth */

#define COLOR_RGB(_r, _g, _b) ((int)((unsigned char)(_r) | ((int)(unsigned char)(_g) << 8) | ((int)(unsigned char)(_b) << 16)))
#define COLOR_RVAL(_rgb) ((_rgb) & 0xff)
#define COLOR_GVAL(_rgb) ((_rgb) >> 8) & 0xff)
#define COLOR_BVAL(_rgb) ((_rgb) >> 16) & 0xff)
#define COLOR_RGB(_r, _g, _b) (((unsigned)((unsigned char)(_r) << 0) | ((unsigned)(unsigned char)(_g) << 8) | ((unsigned)(unsigned char)(_b) << 16)))
#define COLOR_RVAL(_rgb) (((_rgb) >> 0) & 0xff)
#define COLOR_GVAL(_rgb) (((_rgb) >> 8) & 0xff)
#define COLOR_BVAL(_rgb) (((_rgb) >> 16) & 0xff)

} colvalue_t;

Expand Down Expand Up @@ -271,6 +272,7 @@ typedef struct {
#define COLORSTYLE_UNDERDOTTED 0x0800
#define COLORSTYLE_UNDERDASHED 0x1000

#define COLORSTYLE_STRIKEOUT 0x2000
#define COLORSTYLE_ISBOLD 0x4000 /* BOLD has been applied */
#define COLORSTYLE_ISDIM 0x8000 /* DIM has been applied */
colstyles_t sf;
Expand All @@ -291,3 +293,5 @@ extern int attribute_new(const char *name, const char *spec);
__CEND_DECLS

#endif /*GR_COLOR_H_INCLUDED*/


6 changes: 3 additions & 3 deletions gr/keyboard.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <edidentifier.h>
__CIDENT_RCSID(gr_keyboard_c,"$Id: keyboard.c,v 1.81 2024/10/02 16:24:52 cvsuser Exp $")
__CIDENT_RCSID(gr_keyboard_c,"$Id: keyboard.c,v 1.82 2024/10/09 15:55:48 cvsuser Exp $")

/* -*- mode: c; indent-width: 4; -*- */
/* $Id: keyboard.c,v 1.81 2024/10/02 16:24:52 cvsuser Exp $
/* $Id: keyboard.c,v 1.82 2024/10/09 15:55:48 cvsuser Exp $
* Manipulate key maps and bindings.
*
*
Expand Down Expand Up @@ -461,7 +461,7 @@ key_init(void)
x_push_ref = r_string("");

#if !defined(DOSISH)
ttkeys(); /* termcap bindings */
ttkeybind(); /* termcap bindings */
#endif
}

Expand Down
Loading

0 comments on commit f36a3b4

Please sign in to comment.