Lines Matching refs:state

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;
133 setpenattr_col(state, attr, *colp);
136 void vterm_state_resetpen(VTermState *state)
138 state->pen.bold = 0; setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
139 state->pen.underline = 0; setpenattr_int( state, VTERM_ATTR_UNDERLINE, 0);
140 state->pen.italic = 0; setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
141 state->pen.blink = 0; setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
142 state->pen.reverse = 0; setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
143 state->pen.strike = 0; setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
144 state->pen.font = 0; setpenattr_int( state, VTERM_ATTR_FONT, 0);
146 state->fg_index = -1;
147 state->bg_index = -1;
148 state->pen.fg = state->default_fg; setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->default_fg);
149 state->pen.bg = state->default_bg; setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->default_bg);
152 void vterm_state_savepen(VTermState *state, int save)
155 state->saved.pen = state->pen;
158 state->pen = state->saved.pen;
160 setpenattr_bool(state, VTERM_ATTR_BOLD, state->pen.bold);
161 setpenattr_int( state, VTERM_ATTR_UNDERLINE, state->pen.underline);
162 setpenattr_bool(state, VTERM_ATTR_ITALIC, state->pen.italic);
163 setpenattr_bool(state, VTERM_ATTR_BLINK, state->pen.blink);
164 setpenattr_bool(state, VTERM_ATTR_REVERSE, state->pen.reverse);
165 setpenattr_bool(state, VTERM_ATTR_STRIKE, state->pen.strike);
166 setpenattr_int( state, VTERM_ATTR_FONT, state->pen.font);
167 setpenattr_col( state, VTERM_ATTR_FOREGROUND, state->pen.fg);
168 setpenattr_col( state, VTERM_ATTR_BACKGROUND, state->pen.bg);
172 void vterm_state_get_default_colors(const VTermState *state, VTermColor *default_fg, VTermColor *default_bg)
174 *default_fg = state->default_fg;
175 *default_bg = state->default_bg;
178 void vterm_state_get_palette_color(const VTermState *state, int index, VTermColor *col)
183 void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg)
185 state->default_fg = *default_fg;
186 state->default_bg = *default_bg;
189 void vterm_state_set_bold_highbright(VTermState *state, int bold_is_highbright)
191 state->bold_is_highbright = bold_is_highbright;
194 void vterm_state_setpen(VTermState *state, const long args[], int argcount)
210 vterm_state_resetpen(state);
214 state->pen.bold = 1;
215 setpenattr_bool(state, VTERM_ATTR_BOLD, 1);
216 if(state->fg_index > -1 && state->fg_index < 8 && state->bold_is_highbright)
217 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, state->fg_index + (state->pen.bold ? 8 : 0));
221 state->pen.italic = 1;
222 setpenattr_bool(state, VTERM_ATTR_ITALIC, 1);
226 state->pen.underline = 1;
227 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 1);
231 state->pen.blink = 1;
232 setpenattr_bool(state, VTERM_ATTR_BLINK, 1);
236 state->pen.reverse = 1;
237 setpenattr_bool(state, VTERM_ATTR_REVERSE, 1);
241 state->pen.strike = 1;
242 setpenattr_bool(state, VTERM_ATTR_STRIKE, 1);
247 state->pen.font = CSI_ARG(args[argi]) - 10;
248 setpenattr_int(state, VTERM_ATTR_FONT, state->pen.font);
252 state->pen.underline = 2;
253 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 2);
257 state->pen.bold = 0;
258 setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
262 state->pen.italic = 0;
263 setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
267 state->pen.underline = 0;
268 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 0);
272 state->pen.blink = 0;
273 setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
277 state->pen.reverse = 0;
278 setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
282 state->pen.strike = 0;
283 setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
289 state->fg_index = value;
290 if(state->pen.bold && state->bold_is_highbright)
292 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
296 state->fg_index = -1;
299 argi += 1 + lookup_colour(CSI_ARG(args[argi+1]), args+argi+2, argcount-argi-2, &state->pen.fg, &state->fg_index);
300 setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
304 state->fg_index = -1;
305 state->pen.fg = state->default_fg;
306 setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
312 state->bg_index = value;
313 set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
317 state->bg_index = -1;
320 argi += 1 + lookup_colour(CSI_ARG(args[argi+1]), args+argi+2, argcount-argi-2, &state->pen.bg, &state->bg_index);
321 setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
325 state->bg_index = -1;
326 state->pen.bg = state->default_bg;
327 setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
333 state->fg_index = value;
334 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
340 state->bg_index = value;
341 set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
356 int vterm_state_getpen(VTermState *state, long args[], int argcount)
360 if(state->pen.bold)
363 if(state->pen.italic)
366 if(state->pen.underline == 1)
369 if(state->pen.blink)
372 if(state->pen.reverse)
375 if(state->pen.strike)
378 if(state->pen.font)
379 args[argi++] = 10 + state->pen.font;
381 if(state->pen.underline == 2)
384 if(state->fg_index >= 0 && state->fg_index < 8)
385 args[argi++] = 30 + state->fg_index;
386 else if(state->fg_index >= 8 && state->fg_index < 16)
387 args[argi++] = 90 + state->fg_index - 8;
388 else if(state->fg_index >= 16 && state->fg_index < 256) {
391 args[argi++] = state->fg_index;
394 if(state->bg_index >= 0 && state->bg_index < 8)
395 args[argi++] = 40 + state->bg_index;
396 else if(state->bg_index >= 8 && state->bg_index < 16)
397 args[argi++] = 100 + state->bg_index - 8;
398 else if(state->bg_index >= 16 && state->bg_index < 256) {
401 args[argi++] = state->bg_index;
407 int vterm_state_get_penattr(const VTermState *state, VTermAttr attr, VTermValue *val)
411 val->boolean = state->pen.bold;
415 val->number = state->pen.underline;
419 val->boolean = state->pen.italic;
423 val->boolean = state->pen.blink;
427 val->boolean = state->pen.reverse;
431 val->boolean = state->pen.strike;
435 val->number = state->pen.font;
439 val->color = state->pen.fg;
443 val->color = state->pen.bg;