Revision: 2801
http://tmux.svn.sourceforge.net/tmux/?rev=2801&view=rev
Author: tcunha
Date: 2012-05-22 20:57:47 +0000 (Tue, 22 May 2012)
Log Message:
-----------
Sync OpenBSD patchset 1115:
Move some common code to repeat spaces into a function.
Modified Paths:
--------------
trunk/tty.c
Modified: trunk/tty.c
===================================================================
--- trunk/tty.c 2012-05-22 20:56:35 UTC (rev 2800)
+++ trunk/tty.c 2012-05-22 20:57:47 UTC (rev 2801)
@@ -51,6 +51,7 @@
void tty_redraw_region(struct tty *, const struct tty_ctx *);
void tty_emulate_repeat(
struct tty *, enum tty_code_code, enum tty_code_code, u_int);
+void tty_repeat_space(struct tty *, u_int);
void tty_cell(struct tty *,
const struct grid_cell *, const struct grid_utf8 *);
@@ -546,6 +547,13 @@
}
}
+void
+tty_repeat_space(struct tty *tty, u_int n)
+{
+ while (n-- > 0)
+ tty_putc(tty, ' ');
+}
+
/*
* Is the region large enough to be worth redrawing once later rather than
* probably several times now? Currently yes if it is more than 50% of the
@@ -647,10 +655,8 @@
if (sx != screen_size_x(s) && ox + screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL))
tty_putcode(tty, TTYC_EL);
- else {
- for (i = sx; i < screen_size_x(s); i++)
- tty_putc(tty, ' ');
- }
+ else
+ tty_repeat_space(tty, screen_size_x(s) - sx);
tty_update_mode(tty, tty->mode, s);
}
@@ -735,7 +741,6 @@
{
struct window_pane *wp = ctx->wp;
struct screen *s = wp->screen;
- u_int i;
if (ctx->xoff != 0 || screen_size_x(s) < tty->sx) {
tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff);
@@ -752,8 +757,7 @@
else if (tty_term_has(tty->term, TTYC_SMIR) &&
tty_term_has(tty->term, TTYC_RMIR)) {
tty_putcode(tty, TTYC_SMIR);
- for (i = 0; i < ctx->num; i++)
- tty_putc(tty, ' ');
+ tty_repeat_space(tty, ctx->num);
tty_putcode(tty, TTYC_RMIR);
} else
tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff);
@@ -822,18 +826,15 @@
{
struct window_pane *wp = ctx->wp;
struct screen *s = wp->screen;
- u_int i;
tty_reset(tty);
tty_cursor_pane(tty, ctx, 0, ctx->ocy);
- if (tty_pane_full_width(tty, ctx) && tty_term_has(tty->term, TTYC_EL)) {
+ if (tty_pane_full_width(tty, ctx) && tty_term_has(tty->term, TTYC_EL))
tty_putcode(tty, TTYC_EL);
- } else {
- for (i = 0; i < screen_size_x(s); i++)
- tty_putc(tty, ' ');
- }
+ else
+ tty_repeat_space(tty, screen_size_x(s));
}
void
@@ -841,7 +842,6 @@
{
struct window_pane *wp = ctx->wp;
struct screen *s = wp->screen;
- u_int i;
tty_reset(tty);
@@ -849,17 +849,13 @@
if (tty_pane_full_width(tty, ctx) && tty_term_has(tty->term, TTYC_EL))
tty_putcode(tty, TTYC_EL);
- else {
- for (i = ctx->ocx; i < screen_size_x(s); i++)
- tty_putc(tty, ' ');
- }
+ else
+ tty_repeat_space(tty, screen_size_x(s) - ctx->ocx);
}
void
tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx)
{
- u_int i;
-
tty_reset(tty);
if (ctx->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) {
@@ -867,8 +863,7 @@
tty_putcode(tty, TTYC_EL1);
} else {
tty_cursor_pane(tty, ctx, 0, ctx->ocy);
- for (i = 0; i < ctx->ocx + 1; i++)
- tty_putc(tty, ' ');
+ tty_repeat_space(tty, ctx->ocx + 1);
}
}
@@ -957,12 +952,10 @@
}
}
} else {
- for (i = ctx->ocx; i < screen_size_x(s); i++)
- tty_putc(tty, ' ');
+ tty_repeat_space(tty, screen_size_x(s) - ctx->ocx);
for (j = ctx->ocy + 1; j < screen_size_y(s); j++) {
tty_cursor_pane(tty, ctx, 0, j);
- for (i = 0; i < screen_size_x(s); i++)
- tty_putc(tty, ' ');
+ tty_repeat_space(tty, screen_size_x(s));
}
}
}
@@ -988,12 +981,10 @@
} else {
for (j = 0; j < ctx->ocy; j++) {
tty_cursor_pane(tty, ctx, 0, j);
- for (i = 0; i < screen_size_x(s); i++)
- tty_putc(tty, ' ');
+ tty_repeat_space(tty, screen_size_x(s));
}
}
- for (i = 0; i <= ctx->ocx; i++)
- tty_putc(tty, ' ');
+ tty_repeat_space(tty, ctx->ocx + 1);
}
void
@@ -1019,8 +1010,7 @@
} else {
for (j = 0; j < screen_size_y(s); j++) {
tty_cursor_pane(tty, ctx, 0, j);
- for (i = 0; i < screen_size_x(s); i++)
- tty_putc(tty, ' ');
+ tty_repeat_space(tty, screen_size_x(s));
}
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs