| 1 |
|
| 2 |
|
| 3 |
#include "lppdc.h" |
| 4 |
|
| 5 |
#include <stdlib.h> |
| 6 |
|
| 7 |
#ifdef CHTYPE_LONG |
| 8 |
# define PDC_OFFSET 32 |
| 9 |
#else |
| 10 |
# define PDC_OFFSET 8 |
| 11 |
#endif |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
unsigned char *pdc_atrtab = (unsigned char *)NULL; |
| 16 |
|
| 17 |
short curstoreal[16], realtocurs[16] = |
| 18 |
{ |
| 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 |
| 23 |
}; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
void PDC_scr_close(void) |
| 29 |
{ |
| 30 |
PDC_LOG(("PDC_scr_close() - called\n")); |
| 31 |
|
| 32 |
reset_shell_mode(); |
| 33 |
|
| 34 |
if (SP->visibility != 1) |
| 35 |
curs_set(1); |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
PDC_gotoyx(PDC_get_rows() - 2, 0); |
| 40 |
} |
| 41 |
|
| 42 |
void PDC_scr_free(void) |
| 43 |
{ |
| 44 |
if (SP) |
| 45 |
free(SP); |
| 46 |
if (pdc_atrtab) |
| 47 |
free(pdc_atrtab); |
| 48 |
|
| 49 |
pdc_atrtab = (unsigned char *)NULL; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
int PDC_scr_open(int argc, char **argv) |
| 56 |
{ |
| 57 |
int i; |
| 58 |
|
| 59 |
PDC_LOG(("PDC_scr_open() - called\n")); |
| 60 |
|
| 61 |
SP = calloc(1, sizeof(SCREEN)); |
| 62 |
pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1); |
| 63 |
|
| 64 |
if (!SP || !pdc_atrtab) |
| 65 |
return ERR; |
| 66 |
|
| 67 |
for (i = 0; i < 16; i++) |
| 68 |
curstoreal[realtocurs[i]] = i; |
| 69 |
|
| 70 |
SP->orig_attr = FALSE; |
| 71 |
|
| 72 |
SP->lines = PDC_get_rows(); |
| 73 |
SP->cols = PDC_get_columns(); |
| 74 |
|
| 75 |
#if CONFIG(LP_SPEAKER) |
| 76 |
SP->audible = TRUE; |
| 77 |
#endif |
| 78 |
|
| 79 |
return OK; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
int PDC_resize_screen(int nlines, int ncols) |
| 85 |
{ |
| 86 |
PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n", |
| 87 |
nlines, ncols)); |
| 88 |
|
| 89 |
return ERR; |
| 90 |
} |
| 91 |
|
| 92 |
void PDC_reset_prog_mode(void) |
| 93 |
{ |
| 94 |
PDC_LOG(("PDC_reset_prog_mode() - called.\n")); |
| 95 |
} |
| 96 |
|
| 97 |
void PDC_reset_shell_mode(void) |
| 98 |
{ |
| 99 |
PDC_LOG(("PDC_reset_shell_mode() - called.\n")); |
| 100 |
} |
| 101 |
|
| 102 |
void PDC_restore_screen_mode(int i) |
| 103 |
{ |
| 104 |
} |
| 105 |
|
| 106 |
void PDC_save_screen_mode(int i) |
| 107 |
{ |
| 108 |
} |
| 109 |
|
| 110 |
void PDC_init_pair(short pair, short fg, short bg) |
| 111 |
{ |
| 112 |
unsigned char att, temp_bg; |
| 113 |
chtype i; |
| 114 |
|
| 115 |
fg = curstoreal[fg]; |
| 116 |
bg = curstoreal[bg]; |
| 117 |
|
| 118 |
for (i = 0; i < PDC_OFFSET; i++) |
| 119 |
{ |
| 120 |
att = fg | (bg << 4); |
| 121 |
|
| 122 |
if (i & (A_REVERSE >> PDC_ATTR_SHIFT)) |
| 123 |
att = bg | (fg << 4); |
| 124 |
if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT)) |
| 125 |
att = 1; |
| 126 |
if (i & (A_INVIS >> PDC_ATTR_SHIFT)) |
| 127 |
{ |
| 128 |
temp_bg = att >> 4; |
| 129 |
att = temp_bg << 4 | temp_bg; |
| 130 |
} |
| 131 |
if (i & (A_BOLD >> PDC_ATTR_SHIFT)) |
| 132 |
att |= 8; |
| 133 |
if (i & (A_BLINK >> PDC_ATTR_SHIFT)) |
| 134 |
att |= 128; |
| 135 |
|
| 136 |
pdc_atrtab[pair * PDC_OFFSET + i] = att; |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
int PDC_pair_content(short pair, short *fg, short *bg) |
| 141 |
{ |
| 142 |
*fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F]; |
| 143 |
*bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4]; |
| 144 |
|
| 145 |
return OK; |
| 146 |
} |
| 147 |
|
| 148 |
bool PDC_can_change_color(void) |
| 149 |
{ |
| 150 |
return FALSE; |
| 151 |
} |
| 152 |
|
| 153 |
int PDC_color_content(short color, short *red, short *green, short *blue) |
| 154 |
{ |
| 155 |
return ERR; |
| 156 |
} |
| 157 |
|
| 158 |
int PDC_init_color(short color, short red, short green, short blue) |
| 159 |
{ |
| 160 |
return ERR; |
| 161 |
} |