1 /* Public Domain Curses */
13 /* COLOR_PAIR to attribute encoding table. */
15 unsigned char *pdc_atrtab
= (unsigned char *)NULL
;
17 short curstoreal
[16], realtocurs
[16] =
19 COLOR_BLACK
, COLOR_BLUE
, COLOR_GREEN
, COLOR_CYAN
, COLOR_RED
,
20 COLOR_MAGENTA
, COLOR_YELLOW
, COLOR_WHITE
, COLOR_BLACK
+ 8,
21 COLOR_BLUE
+ 8, COLOR_GREEN
+ 8, COLOR_CYAN
+ 8, COLOR_RED
+ 8,
22 COLOR_MAGENTA
+ 8, COLOR_YELLOW
+ 8, COLOR_WHITE
+ 8
25 /* close the physical screen -- may restore the screen to its state
26 before PDC_scr_open(); miscellaneous cleanup */
28 void PDC_scr_close(void)
30 PDC_LOG(("PDC_scr_close() - called\n"));
34 if (SP
->visibility
!= 1)
37 /* Position cursor to the bottom left of the screen. */
39 PDC_gotoyx(PDC_get_rows() - 2, 0);
42 void PDC_scr_free(void)
49 pdc_atrtab
= (unsigned char *)NULL
;
52 /* open the physical screen -- allocate SP, miscellaneous intialization,
53 and may save the existing screen for later restoration */
55 int PDC_scr_open(int argc
, char **argv
)
59 PDC_LOG(("PDC_scr_open() - called\n"));
61 SP
= calloc(1, sizeof(SCREEN
));
62 pdc_atrtab
= calloc(PDC_COLOR_PAIRS
* PDC_OFFSET
, 1);
64 if (!SP
|| !pdc_atrtab
)
67 for (i
= 0; i
< 16; i
++)
68 curstoreal
[realtocurs
[i
]] = i
;
70 SP
->orig_attr
= FALSE
;
72 SP
->lines
= PDC_get_rows();
73 SP
->cols
= PDC_get_columns();
75 #if CONFIG(LP_SPEAKER)
82 /* the core of resize_term() */
84 int PDC_resize_screen(int nlines
, int ncols
)
86 PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
92 void PDC_reset_prog_mode(void)
94 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
97 void PDC_reset_shell_mode(void)
99 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
102 void PDC_restore_screen_mode(int i
)
106 void PDC_save_screen_mode(int i
)
110 void PDC_init_pair(short pair
, short fg
, short bg
)
112 unsigned char att
, temp_bg
;
118 for (i
= 0; i
< PDC_OFFSET
; i
++)
120 att
= fg
| (bg
<< 4);
122 if (i
& (A_REVERSE
>> PDC_ATTR_SHIFT
))
123 att
= bg
| (fg
<< 4);
124 if (i
& (A_UNDERLINE
>> PDC_ATTR_SHIFT
))
126 if (i
& (A_INVIS
>> PDC_ATTR_SHIFT
))
129 att
= temp_bg
<< 4 | temp_bg
;
131 if (i
& (A_BOLD
>> PDC_ATTR_SHIFT
))
133 if (i
& (A_BLINK
>> PDC_ATTR_SHIFT
))
136 pdc_atrtab
[pair
* PDC_OFFSET
+ i
] = att
;
140 int PDC_pair_content(short pair
, short *fg
, short *bg
)
142 *fg
= realtocurs
[pdc_atrtab
[pair
* PDC_OFFSET
] & 0x0F];
143 *bg
= realtocurs
[(pdc_atrtab
[pair
* PDC_OFFSET
] & 0xF0) >> 4];
148 bool PDC_can_change_color(void)
153 int PDC_color_content(short color
, short *red
, short *green
, short *blue
)
158 int PDC_init_color(short color
, short red
, short green
, short blue
)