Home | History | Annotate | Download | only in src

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)
139 state->default_fg.red = state->default_fg.green = state->default_fg.blue = 240;
140 state->default_bg.red = state->default_bg.green = state->default_bg.blue = 0;
143 state->colors[col] = ansi_colors[col];
146 INTERNAL void vterm_state_resetpen(VTermState *state)
148 state->pen.bold = 0; setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
149 state->pen.underline = 0; setpenattr_int( state, VTERM_ATTR_UNDERLINE, 0);
150 state->pen.italic = 0; setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
151 state->pen.blink = 0; setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
152 state->pen.reverse = 0; setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
153 state->pen.strike = 0; setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
154 state->pen.font = 0; setpenattr_int( state, VTERM_ATTR_FONT, 0);
156 state->fg_index = -1;
157 state->bg_index = -1;
158 state->pen.fg = state->default_fg; setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->default_fg);
159 state->pen.bg = state->default_bg; setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->default_bg);
162 INTERNAL void vterm_state_savepen(VTermState *state, int save)
165 state->saved.pen = state->pen;
168 state->pen = state->saved.pen;
170 setpenattr_bool(state, VTERM_ATTR_BOLD, state->pen.bold);
171 setpenattr_int( state, VTERM_ATTR_UNDERLINE, state->pen.underline);
172 setpenattr_bool(state, VTERM_ATTR_ITALIC, state->pen.italic);
173 setpenattr_bool(state, VTERM_ATTR_BLINK, state->pen.blink);
174 setpenattr_bool(state, VTERM_ATTR_REVERSE, state->pen.reverse);
175 setpenattr_bool(state, VTERM_ATTR_STRIKE, state->pen.strike);
176 setpenattr_int( state, VTERM_ATTR_FONT, state->pen.font);
177 setpenattr_col( state, VTERM_ATTR_FOREGROUND, state->pen.fg);
178 setpenattr_col( state, VTERM_ATTR_BACKGROUND, state->pen.bg);
182 void vterm_state_get_default_colors(const VTermState *state, VTermColor *default_fg, VTermColor *default_bg)
184 *default_fg = state->default_fg;
185 *default_bg = state->default_bg;
188 void vterm_state_get_palette_color(const VTermState *state, int index, VTermColor *col)
190 lookup_colour_palette(state, index, col);
193 void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg)
195 state->default_fg = *default_fg;
196 state->default_bg = *default_bg;
199 void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col)
202 state->colors[index] = *col;
205 void vterm_state_set_bold_highbright(VTermState *state, int bold_is_highbright)
207 state->bold_is_highbright = bold_is_highbright;
210 INTERNAL void vterm_state_setpen(VTermState *state, const long args[], int argcount)
226 vterm_state_resetpen(state);
230 state->pen.bold = 1;
231 setpenattr_bool(state, VTERM_ATTR_BOLD, 1);
232 if(state->fg_index > -1 && state->fg_index < 8 && state->bold_is_highbright)
233 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, state->fg_index + (state->pen.bold ? 8 : 0));
237 state->pen.italic = 1;
238 setpenattr_bool(state, VTERM_ATTR_ITALIC, 1);
242 state->pen.underline = 1;
243 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 1);
247 state->pen.blink = 1;
248 setpenattr_bool(state, VTERM_ATTR_BLINK, 1);
252 state->pen.reverse = 1;
253 setpenattr_bool(state, VTERM_ATTR_REVERSE, 1);
257 state->pen.strike = 1;
258 setpenattr_bool(state, VTERM_ATTR_STRIKE, 1);
263 state->pen.font = CSI_ARG(args[argi]) - 10;
264 setpenattr_int(state, VTERM_ATTR_FONT, state->pen.font);
268 state->pen.underline = 2;
269 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 2);
273 state->pen.bold = 0;
274 setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
278 state->pen.italic = 0;
279 setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
283 state->pen.underline = 0;
284 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 0);
288 state->pen.blink = 0;
289 setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
293 state->pen.reverse = 0;
294 setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
298 state->pen.strike = 0;
299 setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
305 state->fg_index = value;
306 if(state->pen.bold && state->bold_is_highbright)
308 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
312 state->fg_index = -1;
315 argi += 1 + lookup_colour(state, CSI_ARG(args[argi+1]), args+argi+2, argcount-argi-2, &state->pen.fg, &state->fg_index);
316 setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
320 state->fg_index = -1;
321 state->pen.fg = state->default_fg;
322 setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
328 state->bg_index = value;
329 set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
333 state->bg_index = -1;
336 argi += 1 + lookup_colour(state, CSI_ARG(args[argi+1]), args+argi+2, argcount-argi-2, &state->pen.bg, &state->bg_index);
337 setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
341 state->bg_index = -1;
342 state->pen.bg = state->default_bg;
343 setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
349 state->fg_index = value;
350 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
356 state->bg_index = value;
357 set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
372 INTERNAL int vterm_state_getpen(VTermState *state, long args[], int argcount)
376 if(state->pen.bold)
379 if(state->pen.italic)
382 if(state->pen.underline == 1)
385 if(state->pen.blink)
388 if(state->pen.reverse)
391 if(state->pen.strike)
394 if(state->pen.font)
395 args[argi++] = 10 + state->pen.font;
397 if(state->pen.underline == 2)
400 if(state->fg_index >= 0 && state->fg_index < 8)
401 args[argi++] = 30 + state->fg_index;
402 else if(state->fg_index >= 8 && state->fg_index < 16)
403 args[argi++] = 90 + state->fg_index - 8;
404 else if(state->fg_index >= 16 && state->fg_index < 256) {
407 args[argi++] = state->fg_index;
410 if(state->bg_index >= 0 && state->bg_index < 8)
411 args[argi++] = 40 + state->bg_index;
412 else if(state->bg_index >= 8 && state->bg_index < 16)
413 args[argi++] = 100 + state->bg_index - 8;
414 else if(state->bg_index >= 16 && state->bg_index < 256) {
417 args[argi++] = state->bg_index;
423 int vterm_state_get_penattr(const VTermState *state, VTermAttr attr, VTermValue *val)
427 val->boolean = state->pen.bold;
431 val->number = state->pen.underline;
435 val->boolean = state->pen.italic;
439 val->boolean = state->pen.blink;
443 val->boolean = state->pen.reverse;
447 val->boolean = state->pen.strike;
451 val->number = state->pen.font;
455 val->color = state->pen.fg;
459 val->color = state->pen.bg;