mtm | Ncurses-based terminal multiplexer |
| download: https://git.y1.nz/archives/mtm.tar.gz | |
| Files | Log | Refs |
pair.c
1 #include <stdbool.h>
2
3 #include "config.h"
4
5 #define COLOR_MAX 256
6 typedef struct PAIR PAIR;
7 struct PAIR{
8 short fg, bg, cp;
9 };
10
11 static PAIR pairs[COLOR_MAX * COLOR_MAX];
12
13 void
14 start_pairs(void)
15 {
16 for (int i = 0; i < COLOR_MAX * COLOR_MAX; i++)
17 pairs[i].fg = pairs[i].bg = pairs[i].cp = -1;
18 }
19
20 short
21 mtm_alloc_pair(int fg, int bg)
22 {
23 #if USE_ALLOC_PAIR
24 return alloc_pair(fg, bg);
25 #else
26 if (fg >= COLOR_MAX || bg >= COLOR_MAX)
27 return -1;
28 for (int i = 0; i < COLOR_MAX * COLOR_MAX; i++){
29 PAIR *p = pairs + i;
30 if (p->cp == -1){
31 p->fg = fg;
32 p->bg = bg;
33 p->cp = init_pair(i + 1, p->fg, p->bg) == OK? i + 1 : -1;
34 }
35 if (p->fg == fg && p->bg == bg && p->cp != -1)
36 return p->cp;
37 }
38 return -1;
39 #endif
40 }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.