screen update improvements

This commit is contained in:
cy384 2021-01-23 12:32:17 -05:00
parent 0f5bddf103
commit 51c41578e7
2 changed files with 51 additions and 33 deletions

View File

@ -266,6 +266,23 @@ size_t get_selection(char** selection)
return len; return len;
} }
// TODO: find a way to render this once and then just paste it on
inline void draw_resize_corner(void)
{
// draw the grow icon in the bottom right corner, but not the scroll bars
// yes, this is really awkward
MacRegion bottom_right_corner = { 10, con.win->portRect};
MacRegion* brc = &bottom_right_corner;
MacRegion** old = con.win->clipRgn;
bottom_right_corner.rgnBBox.top = bottom_right_corner.rgnBBox.bottom - 15;
bottom_right_corner.rgnBBox.left = bottom_right_corner.rgnBBox.right - 15;
con.win->clipRgn = &brc;
DrawGrowIcon(con.win);
con.win->clipRgn = old;
}
void draw_screen_color(Rect* r) void draw_screen_color(Rect* r)
{ {
// get the intersection of our console region and the update region // get the intersection of our console region and the update region
@ -341,28 +358,41 @@ void draw_screen_color(Rect* r)
for (pos.col = minCol; pos.col < maxCol; pos.col++) for (pos.col = minCol; pos.col < maxCol; pos.col++)
{ {
vtsc = vterm_screen_unsafe_get_cell(con.vts, pos); vtsc = vterm_screen_unsafe_get_cell(con.vts, pos);
c = (char)vtsc->chars[0];
if (vtsc->pen.reverse)
{
qd.thePort->bkColor = idx2qd(vtsc->pen.fg);
qd.thePort->fgColor = idx2qd(vtsc->pen.bg);
}
else
{
qd.thePort->fgColor = idx2qd(vtsc->pen.fg); qd.thePort->fgColor = idx2qd(vtsc->pen.fg);
qd.thePort->bkColor = idx2qd(vtsc->pen.bg); qd.thePort->bkColor = idx2qd(vtsc->pen.bg);
}
cr = cell_rect(pos.col, pos.row, *r); cr = cell_rect(pos.col, pos.row, *r);
EraseRect(&cr); EraseRect(&cr);
if (c == '\0' || c == ' ')
{
if (i < select_end && i >= select_start)
{
InvertRect(&cr);
}
i++;
continue;
}
face = normal; face = normal;
if (vtsc->pen.bold) face |= (condense|bold); if (vtsc->pen.bold) face |= (condense|bold);
if (vtsc->pen.italic) face |= (condense|italic); if (vtsc->pen.italic) face |= (condense|italic);
if (vtsc->pen.underline) face |= underline; if (vtsc->pen.underline) face |= underline;
if (face != normal) TextFace(face); if (face != normal) TextFace(face);
c = (char)vtsc->chars[0];
if (c == '\0') c = ' ';
draw_char(pos.col, pos.row, r, c); draw_char(pos.col, pos.row, r, c);
if (face != normal) TextFace(normal); if (face != normal) TextFace(normal);
if (vtsc->pen.reverse)
{
InvertRect(&cr);
}
if (i < select_end && i >= select_start) if (i < select_end && i >= select_start)
{ {
InvertRect(&cr); InvertRect(&cr);
@ -385,18 +415,7 @@ void draw_screen_color(Rect* r)
qd.thePort->fgColor = save_font_fg; qd.thePort->fgColor = save_font_fg;
qd.thePort->bkColor = save_font_bg; qd.thePort->bkColor = save_font_bg;
// draw the grow icon in the bottom right corner, but not the scroll bars draw_resize_corner();
// yes, this is really awkward
MacRegion bottom_right_corner = { 10, con.win->portRect};
MacRegion* brc = &bottom_right_corner;
MacRegion** old = con.win->clipRgn;
bottom_right_corner.rgnBBox.top = bottom_right_corner.rgnBBox.bottom - 15;
bottom_right_corner.rgnBBox.left = bottom_right_corner.rgnBBox.right - 15;
con.win->clipRgn = &brc;
DrawGrowIcon(con.win);
con.win->clipRgn = old;
} }
@ -447,6 +466,7 @@ void draw_screen_fast(Rect* r)
} }
} }
} }
ScreenCell* vtsc = NULL; ScreenCell* vtsc = NULL;
VTermPos pos = {.row = 0, .col = 0}; VTermPos pos = {.row = 0, .col = 0};
@ -479,7 +499,7 @@ void draw_screen_fast(Rect* r)
} }
// do the cursor if needed // do the cursor if needed
if (con.cursor_state == 1 && con.cursor_visible == 1) if (con.cursor_state && con.cursor_visible)
{ {
Rect cursor = cell_rect(con.cursor_x, con.cursor_y, con.win->portRect); Rect cursor = cell_rect(con.cursor_x, con.cursor_y, con.win->portRect);
InvertRect(&cursor); InvertRect(&cursor);
@ -490,21 +510,19 @@ void draw_screen_fast(Rect* r)
TextFace(save_font_face); TextFace(save_font_face);
qd.thePort->fgColor = save_font_fg; qd.thePort->fgColor = save_font_fg;
qd.thePort->bkColor = save_font_bg; qd.thePort->bkColor = save_font_bg;
//draw_resize_corner();
} }
void draw_screen(Rect* r) void draw_screen(Rect* r)
{ {
switch (prefs.display_mode) if (prefs.display_mode == FASTEST)
{ {
case FASTEST:
draw_screen_fast(r); draw_screen_fast(r);
break; }
case COLOR: else
{
draw_screen_color(r); draw_screen_color(r);
break;
default:
draw_screen_color(r);
break;
} }
} }

View File

@ -498,8 +498,8 @@ resource 'MENU' (MENU_TERM_TYPE) {
allEnabled, enabled; allEnabled, enabled;
"Type"; "Type";
{ {
"Fastest", noIcon, noKey, noMark, plain; "Monochrome (faster)", noIcon, noKey, noMark, plain;
"Color", noIcon, noKey, noMark, plain; "Color (slower)", noIcon, noKey, noMark, plain;
} }
}; };