Discussion:
[PATCH] Hide cursor while drawing borders
(too old to reply)
George Nachman
2015-04-30 05:03:18 UTC
Permalink
The attached patch hides the cursor while drawing borders between window
panes.

Most programs hide the cursor while redrawing their chrome because it's
ugly to see the cursor jumping around the screen. Better for it to
disappear for a moment.

Here is a video demonstrating the issue:
https://dl.dropboxusercontent.com/u/33889723/iterm2.9.20150429-nightly.mov
Nicholas Marriott
2015-04-30 07:38:42 UTC
Permalink
Hi

We should do it for all redraw functions. Does this work instead? Also
fixes tty_draw_line.

Index: server-client.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/server-client.c,v
retrieving revision 1.136
diff -u -p -r1.136 server-client.c
--- server-client.c 25 Apr 2015 18:33:59 -0000 1.136
+++ server-client.c 30 Apr 2015 07:37:23 -0000
@@ -875,14 +875,16 @@ void
server_client_check_redraw(struct client *c)
{
struct session *s = c->session;
+ struct tty *tty = &c->tty;
struct window_pane *wp;
int flags, redraw;

if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
return;

- flags = c->tty.flags & TTY_FREEZE;
- c->tty.flags &= ~TTY_FREEZE;
+ flags = tty->flags & (TTY_FREEZE|TTY_NOCURSOR);
+ tty->flags = (tty->flags & ~TTY_FREEZE) | TTY_NOCURSOR;
+ tty_update_mode(tty, tty->mode, NULL);

if (c->flags & (CLIENT_REDRAW|CLIENT_STATUS)) {
if (options_get_number(&s->options, "set-titles"))
@@ -918,7 +920,8 @@ server_client_check_redraw(struct client
if (c->flags & CLIENT_STATUS)
screen_redraw_screen(c, 0, 1, 0);

- c->tty.flags |= flags;
+ tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags;
+ tty_update_mode(tty, tty->mode, NULL);

c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS|CLIENT_BORDERS);
}
Index: tty.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/tty.c,v
retrieving revision 1.180
diff -u -p -r1.180 tty.c
--- tty.c 29 Apr 2015 15:59:08 -0000 1.180
+++ tty.c 30 Apr 2015 07:37:23 -0000
@@ -500,7 +500,7 @@ tty_update_mode(struct tty *tty, int mod
{
int changed;

- if (strcmp(s->ccolour, tty->ccolour))
+ if (s != NULL && strcmp(s->ccolour, tty->ccolour))
tty_force_cursor_colour(tty, s->ccolour);

if (tty->flags & TTY_NOCURSOR)
@@ -517,7 +517,7 @@ tty_update_mode(struct tty *tty, int mod
} else
tty_putcode(tty, TTYC_CIVIS);
}
- if (tty->cstyle != s->cstyle) {
+ if (s != NULL && tty->cstyle != s->cstyle) {
if (tty_term_has(tty->term, TTYC_SS)) {
if (s->cstyle == 0 &&
tty_term_has(tty->term, TTYC_SE))
@@ -667,8 +667,11 @@ tty_draw_line(struct tty *tty, const str
struct grid_cell tmpgc;
struct utf8_data ud;
u_int i, sx;
+ int flags;

- tty_update_mode(tty, tty->mode & ~MODE_CURSOR, s);
+ flags = tty->flags & TTY_NOCURSOR;
+ tty->flags |= TTY_NOCURSOR;
+ tty_update_mode(tty, tty->mode, s);

sx = screen_size_x(s);
if (sx > s->grid->linedata[s->grid->hsize + py].cellsize)
@@ -703,18 +706,20 @@ tty_draw_line(struct tty *tty, const str
tty_cell(tty, gc, wp);
}

- if (sx >= tty->sx) {
- tty_update_mode(tty, tty->mode, s);
- return;
+ if (sx < tty->sx) {
+ tty_attributes(tty, &grid_default_cell, wp);
+
+ tty_cursor(tty, ox + sx, oy + py);
+ if (sx != screen_size_x(s) &&
+ ox + screen_size_x(s) >= tty->sx &&
+ tty_term_has(tty->term, TTYC_EL) &&
+ !tty_fake_bce(tty, wp))
+ tty_putcode(tty, TTYC_EL);
+ else
+ tty_repeat_space(tty, screen_size_x(s) - sx);
}
- tty_attributes(tty, &grid_default_cell, wp);

- tty_cursor(tty, ox + sx, oy + py);
- if (sx != screen_size_x(s) && ox + screen_size_x(s) >= tty->sx &&
- tty_term_has(tty->term, TTYC_EL) && !tty_fake_bce(tty, wp))
- tty_putcode(tty, TTYC_EL);
- else
- tty_repeat_space(tty, screen_size_x(s) - sx);
+ tty->flags = (tty->flags & ~TTY_NOCURSOR) | flags;
tty_update_mode(tty, tty->mode, s);
}
Post by George Nachman
The attached patch hides the cursor while drawing borders between window
panes.
Most programs hide the cursor while redrawing their chrome because it's
ugly to see the cursor jumping around the screen. Better for it to
disappear for a moment.
[1]https://dl.dropboxusercontent.com/u/33889723/iterm2.9.20150429-nightly.mov
References
Visible links
1. https://dl.dropboxusercontent.com/u/33889723/iterm2.9.20150429-nightly.mov
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Loading...