Lines Matching refs:state

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