Lines Matching defs:s
56 screen_free_titles(struct screen *s)
60 if (s->titles == NULL)
63 while ((title_entry = TAILQ_FIRST(s->titles)) != NULL) {
64 TAILQ_REMOVE(s->titles, title_entry, entry);
69 free(s->titles);
70 s->titles = NULL;
75 screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit)
77 s->grid = grid_create(sx, sy, hlimit);
78 s->saved_grid = NULL;
80 s->title = xstrdup("");
81 s->titles = NULL;
82 s->path = NULL;
84 s->cstyle = SCREEN_CURSOR_DEFAULT;
85 s->default_cstyle = SCREEN_CURSOR_DEFAULT;
86 s->mode = MODE_CURSOR;
87 s->default_mode = 0;
88 s->ccolour = -1;
89 s->default_ccolour = -1;
90 s->tabs = NULL;
91 s->sel = NULL;
93 s->write_list = NULL;
94 s->hyperlinks = NULL;
96 screen_reinit(s);
101 screen_reinit(struct screen *s)
103 s->cx = 0;
104 s->cy = 0;
106 s->rupper = 0;
107 s->rlower = screen_size_y(s) - 1;
109 s->mode = MODE_CURSOR|MODE_WRAP|(s->mode & MODE_CRLF);
112 s->mode = (s->mode & ~EXTENDED_KEY_MODES)|MODE_KEYS_EXTENDED;
114 if (SCREEN_IS_ALTERNATE(s))
115 screen_alternate_off(s, NULL, 0);
116 s->saved_cx = UINT_MAX;
117 s->saved_cy = UINT_MAX;
119 screen_reset_tabs(s);
121 grid_clear_lines(s->grid, s->grid->hsize, s->grid->sy, 8);
123 screen_clear_selection(s);
124 screen_free_titles(s);
125 screen_reset_hyperlinks(s);
130 screen_reset_hyperlinks(struct screen *s)
132 if (s->hyperlinks == NULL)
133 s->hyperlinks = hyperlinks_init();
135 hyperlinks_reset(s->hyperlinks);
140 screen_free(struct screen *s)
142 free(s->sel);
143 free(s->tabs);
144 free(s->path);
145 free(s->title);
147 if (s->write_list != NULL)
148 screen_write_free_list(s);
150 if (SCREEN_IS_ALTERNATE(s))
151 grid_destroy(s->saved_grid);
152 grid_destroy(s->grid);
154 if (s->hyperlinks != NULL)
155 hyperlinks_free(s->hyperlinks);
156 screen_free_titles(s);
161 screen_reset_tabs(struct screen *s)
165 free(s->tabs);
167 if ((s->tabs = bit_alloc(screen_size_x(s))) == NULL)
169 for (i = 8; i < screen_size_x(s); i += 8)
170 bit_set(s->tabs, i);
175 screen_set_default_cursor(struct screen *s, struct options *oo)
180 s->default_ccolour = c;
183 s->default_mode = 0;
184 screen_set_cursor_style(c, &s->default_cstyle, &s->default_mode);
225 screen_set_cursor_colour(struct screen *s, int colour)
227 s->ccolour = colour;
232 screen_set_title(struct screen *s, const char *title)
236 free(s->title);
237 s->title = xstrdup(title);
243 screen_set_path(struct screen *s, const char *path)
245 free(s->path);
246 utf8_stravis(&s->path, path, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
251 screen_push_title(struct screen *s)
255 if (s->titles == NULL) {
256 s->titles = xmalloc(sizeof *s->titles);
257 TAILQ_INIT(s->titles);
260 title_entry->text = xstrdup(s->title);
261 TAILQ_INSERT_HEAD(s->titles, title_entry, entry);
269 screen_pop_title(struct screen *s)
273 if (s->titles == NULL)
276 title_entry = TAILQ_FIRST(s->titles);
278 screen_set_title(s, title_entry->text);
280 TAILQ_REMOVE(s->titles, title_entry, entry);
288 screen_resize_cursor(struct screen *s, u_int sx, u_int sy, int reflow,
291 u_int cx = s->cx, cy = s->grid->hsize + s->cy;
293 if (s->write_list != NULL)
294 screen_write_free_list(s);
296 log_debug("%s: new size %ux%u, now %ux%u (cursor %u,%u = %u,%u)",
297 __func__, sx, sy, screen_size_x(s), screen_size_y(s), s->cx, s->cy,
305 if (sx != screen_size_x(s)) {
306 s->grid->sx = sx;
307 screen_reset_tabs(s);
311 if (sy != screen_size_y(s))
312 screen_resize_y(s, sy, eat_empty, &cy);
315 screen_reflow(s, sx, &cx, &cy, cursor);
317 if (cy >= s->grid->hsize) {
318 s->cx = cx;
319 s->cy = cy - s->grid->hsize;
321 s->cx = 0;
322 s->cy = 0;
325 log_debug("%s: cursor finished at %u,%u = %u,%u", __func__, s->cx,
326 s->cy, cx, cy);
328 if (s->write_list != NULL)
329 screen_write_make_list(s);
334 screen_resize(struct screen *s, u_int sx, u_int sy, int reflow)
336 screen_resize_cursor(s, sx, sy, reflow, 1, 1);
340 screen_resize_y(struct screen *s, u_int sy, int eat_empty, u_int *cy)
342 struct grid *gd = s->grid;
347 oldy = screen_size_y(s);
366 available = oldy - 1 - s->cy;
381 available = s->cy;
421 s->rupper = 0;
422 s->rlower = screen_size_y(s) - 1;
427 screen_set_selection(struct screen *s, u_int sx, u_int sy,
430 if (s->sel == NULL)
431 s->sel = xcalloc(1, sizeof *s->sel);
433 memcpy(&s->sel->cell, gc, sizeof s->sel->cell);
434 s->sel->hidden = 0;
435 s->sel->rectangle = rectangle;
436 s->sel->modekeys = modekeys;
438 s->sel->sx = sx;
439 s->sel->sy = sy;
440 s->sel->ex = ex;
441 s->sel->ey = ey;
446 screen_clear_selection(struct screen *s)
448 free(s->sel);
449 s->sel = NULL;
454 screen_hide_selection(struct screen *s)
456 if (s->sel != NULL)
457 s->sel->hidden = 1;
462 screen_check_selection(struct screen *s, u_int px, u_int py)
464 struct screen_sel *sel = s->sel;
568 screen_select_cell(struct screen *s, struct grid_cell *dst,
571 if (s->sel == NULL || s->sel->hidden)
574 memcpy(dst, &s->sel->cell, sizeof *dst);
584 screen_reflow(struct screen *s, u_int new_x, u_int *cx, u_int *cy, int cursor)
589 grid_wrap_position(s->grid, *cx, *cy, &wx, &wy);
590 log_debug("%s: cursor %u,%u is %u,%u", __func__, *cx, *cy, wx,
594 grid_reflow(s->grid, new_x);
597 grid_unwrap_position(s->grid, cx, cy, wx, wy);
598 log_debug("%s: new cursor is %u,%u", __func__, *cx, *cy);
602 *cy = s->grid->hsize;
611 screen_alternate_on(struct screen *s, struct grid_cell *gc, int cursor)
615 if (SCREEN_IS_ALTERNATE(s))
617 sx = screen_size_x(s);
618 sy = screen_size_y(s);
620 s->saved_grid = grid_create(sx, sy, 0);
621 grid_duplicate_lines(s->saved_grid, 0, s->grid, screen_hsize(s), sy);
623 s->saved_cx = s->cx;
624 s->saved_cy = s->cy;
626 memcpy(&s->saved_cell, gc, sizeof s->saved_cell);
628 grid_view_clear(s->grid, 0, 0, sx, sy, 8);
630 s->saved_flags = s->grid->flags;
631 s->grid->flags &= ~GRID_HISTORY;
636 screen_alternate_off(struct screen *s, struct grid_cell *gc, int cursor)
638 u_int sx = screen_size_x(s), sy = screen_size_y(s);
644 if (SCREEN_IS_ALTERNATE(s))
645 screen_resize(s, s->saved_grid->sx, s->saved_grid->sy, 0);
651 if (cursor && s->saved_cx != UINT_MAX && s->saved_cy != UINT_MAX) {
652 s->cx = s->saved_cx;
653 s->cy = s->saved_cy;
655 memcpy(gc, &s->saved_cell, sizeof *gc);
659 if (!SCREEN_IS_ALTERNATE(s)) {
660 if (s->cx > screen_size_x(s) - 1)
661 s->cx = screen_size_x(s) - 1;
662 if (s->cy > screen_size_y(s) - 1)
663 s->cy = screen_size_y(s) - 1;
668 grid_duplicate_lines(s->grid, screen_hsize(s), s->saved_grid, 0,
669 s->saved_grid->sy);
675 if (s->saved_flags & GRID_HISTORY)
676 s->grid->flags |= GRID_HISTORY;
677 screen_resize(s, sx, sy, 1);
679 grid_destroy(s->saved_grid);
680 s->saved_grid = NULL;
682 if (s->cx > screen_size_x(s) - 1)
683 s->cx = screen_size_x(s) - 1;
684 if (s->cy > screen_size_y(s) - 1)
685 s->cy = screen_size_y(s) - 1;