Lines Matching refs:state

36 static void lookup_colour_ansi(const VTermState *state, long index, VTermColor *col)
39 *col = state->colors[index];
43 static void lookup_colour_palette(const VTermState *state, long index, VTermColor *col)
47 lookup_colour_ansi(state, index, col);
67 static int lookup_colour(const VTermState *state, int palette, const long args[], int argcount, VTermColor *col, int *index)
84 lookup_colour_palette(state, argcount ? CSI_ARG_OR(args[0], -1) : -1, col);
96 static void setpenattr(VTermState *state, VTermAttr attr, VTermValueType type, VTermValue *val)
105 if(state->callbacks && state->callbacks->setpenattr)
106 (*state->callbacks->setpenattr)(attr, val, state->cbdata);
109 static void setpenattr_bool(VTermState *state, VTermAttr attr, int boolean)
112 setpenattr(state, attr, VTERM_VALUETYPE_BOOL, &val);
115 static void setpenattr_int(VTermState *state, VTermAttr attr, int number)
118 setpenattr(state, attr, VTERM_VALUETYPE_INT, &val);
121 static void setpenattr_col(VTermState *state, VTermAttr attr, VTermColor color)
124 setpenattr(state, attr, VTERM_VALUETYPE_COLOR, &val);
127 static void set_pen_col_ansi(VTermState *state, VTermAttr attr, long col)
129 VTermColor *colp = (attr == VTERM_ATTR_BACKGROUND) ? &state->pen.bg : &state->pen.fg;
131 lookup_colour_ansi(state, col, colp);
133 setpenattr_col(state, attr, *colp);
136 INTERNAL void vterm_state_newpen(VTermState *state)
140 state->default_fg.red = state->default_fg.green = state->default_fg.blue = 240;
141 state->default_bg.red = state->default_bg.green = state->default_bg.blue = 0;
144 state->colors[col] = ansi_colors[col];
147 INTERNAL void vterm_state_resetpen(VTermState *state)
149 state->pen.bold = 0; setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
150 state->pen.underline = 0; setpenattr_int( state, VTERM_ATTR_UNDERLINE, 0);
151 state->pen.italic = 0; setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
152 state->pen.blink = 0; setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
153 state->pen.reverse = 0; setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
154 state->pen.strike = 0; setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
155 state->pen.font = 0; setpenattr_int( state, VTERM_ATTR_FONT, 0);
157 state->fg_index = -1;
158 state->bg_index = -1;
159 state->pen.fg = state->default_fg; setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->default_fg);
160 state->pen.bg = state->default_bg; setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->default_bg);
163 INTERNAL void vterm_state_savepen(VTermState *state, int save)
166 state->saved.pen = state->pen;
169 state->pen = state->saved.pen;
171 setpenattr_bool(state, VTERM_ATTR_BOLD, state->pen.bold);
172 setpenattr_int( state, VTERM_ATTR_UNDERLINE, state->pen.underline);
173 setpenattr_bool(state, VTERM_ATTR_ITALIC, state->pen.italic);
174 setpenattr_bool(state, VTERM_ATTR_BLINK, state->pen.blink);
175 setpenattr_bool(state, VTERM_ATTR_REVERSE, state->pen.reverse);
176 setpenattr_bool(state, VTERM_ATTR_STRIKE, state->pen.strike);
177 setpenattr_int( state, VTERM_ATTR_FONT, state->pen.font);
178 setpenattr_col( state, VTERM_ATTR_FOREGROUND, state->pen.fg);
179 setpenattr_col( state, VTERM_ATTR_BACKGROUND, state->pen.bg);
183 void vterm_state_get_default_colors(const VTermState *state, VTermColor *default_fg, VTermColor *default_bg)
185 *default_fg = state->default_fg;
186 *default_bg = state->default_bg;
189 void vterm_state_get_palette_color(const VTermState *state, int index, VTermColor *col)
191 lookup_colour_palette(state, index, col);
194 void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg)
196 state->default_fg = *default_fg;
197 state->default_bg = *default_bg;
200 void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col)
203 state->colors[index] = *col;
206 void vterm_state_set_bold_highbright(VTermState *state, int bold_is_highbright)
208 state->bold_is_highbright = bold_is_highbright;
211 INTERNAL void vterm_state_setpen(VTermState *state, const long args[], int argcount)
227 vterm_state_resetpen(state);
231 state->pen.bold = 1;
232 setpenattr_bool(state, VTERM_ATTR_BOLD, 1);
233 if(state->fg_index > -1 && state->fg_index < 8 && state->bold_is_highbright)
234 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, state->fg_index + (state->pen.bold ? 8 : 0));
238 state->pen.italic = 1;
239 setpenattr_bool(state, VTERM_ATTR_ITALIC, 1);
243 state->pen.underline = 1;
244 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 1);
248 state->pen.blink = 1;
249 setpenattr_bool(state, VTERM_ATTR_BLINK, 1);
253 state->pen.reverse = 1;
254 setpenattr_bool(state, VTERM_ATTR_REVERSE, 1);
258 state->pen.strike = 1;
259 setpenattr_bool(state, VTERM_ATTR_STRIKE, 1);
264 state->pen.font = CSI_ARG(args[argi]) - 10;
265 setpenattr_int(state, VTERM_ATTR_FONT, state->pen.font);
269 state->pen.underline = 2;
270 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 2);
274 state->pen.bold = 0;
275 setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
279 state->pen.italic = 0;
280 setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
284 state->pen.underline = 0;
285 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 0);
289 state->pen.blink = 0;
290 setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
294 state->pen.reverse = 0;
295 setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
299 state->pen.strike = 0;
300 setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
306 state->fg_index = value;
307 if(state->pen.bold && state->bold_is_highbright)
309 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
313 state->fg_index = -1;
316 argi += 1 + lookup_colour(state, CSI_ARG(args[argi+1]), args+argi+2, argcount-argi-2, &state->pen.fg, &state->fg_index);
317 setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
321 state->fg_index = -1;
322 state->pen.fg = state->default_fg;
323 setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
329 state->bg_index = value;
330 set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
334 state->bg_index = -1;
337 argi += 1 + lookup_colour(state, CSI_ARG(args[argi+1]), args+argi+2, argcount-argi-2, &state->pen.bg, &state->bg_index);
338 setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
342 state->bg_index = -1;
343 state->pen.bg = state->default_bg;
344 setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
350 state->fg_index = value;
351 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
357 state->bg_index = value;
358 set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
373 INTERNAL int vterm_state_getpen(VTermState *state, long args[], int argcount)
377 if(state->pen.bold)
380 if(state->pen.italic)
383 if(state->pen.underline == 1)
386 if(state->pen.blink)
389 if(state->pen.reverse)
392 if(state->pen.strike)
395 if(state->pen.font)
396 args[argi++] = 10 + state->pen.font;
398 if(state->pen.underline == 2)
401 if(state->fg_index >= 0 && state->fg_index < 8)
402 args[argi++] = 30 + state->fg_index;
403 else if(state->fg_index >= 8 && state->fg_index < 16)
404 args[argi++] = 90 + state->fg_index - 8;
405 else if(state->fg_index >= 16 && state->fg_index < 256) {
408 args[argi++] = state->fg_index;
411 if(state->bg_index >= 0 && state->bg_index < 8)
412 args[argi++] = 40 + state->bg_index;
413 else if(state->bg_index >= 8 && state->bg_index < 16)
414 args[argi++] = 100 + state->bg_index - 8;
415 else if(state->bg_index >= 16 && state->bg_index < 256) {
418 args[argi++] = state->bg_index;
424 int vterm_state_get_penattr(const VTermState *state, VTermAttr attr, VTermValue *val)
428 val->boolean = state->pen.bold;
432 val->number = state->pen.underline;
436 val->boolean = state->pen.italic;
440 val->boolean = state->pen.blink;
444 val->boolean = state->pen.reverse;
448 val->boolean = state->pen.strike;
452 val->number = state->pen.font;
456 val->color = state->pen.fg;
460 val->color = state->pen.bg;