1 --- util.c.orig	2016-11-04 21:41:21 UTC
2 +++ util.c
3 @@ -36,6 +36,7 @@
4 
5  #include <stdio.h>
6 
7 +static void ClearInLine(TScreen *screen, int row, int col, int len);
8  static void horizontal_copy_area();
9  static void vertical_copy_area();
10 
11 @@ -706,6 +707,54 @@ register TScreen *screen;
12  /*
13   * Clear last part of cursor's line, inclusive.
14   */
15 +ClearRightN (screen, n)
16 +register TScreen *screen;
17 +register int     n;
18 +{
19 +        int i;
20 +	int len = (screen->max_col - screen->cur_col + 1);
21 +
22 +	if (n < 0)      /* the remainder of the line */
23 +		n = screen->max_col + 1;
24 +	if (n == 0)     /* default for 'ECH' */
25 +		n = 1;
26 +
27 +	if (len > n)
28 +		len = n;
29 +
30 +        ClearInLine(screen, screen->cur_row, screen->cur_col, len);
31 +}
32 +
33 +/*
34 + * Clear the given row, for the given range of columns.
35 + */
36 +static void
37 +ClearInLine(TScreen *screen, int row, int col, int len)
38 +{
39 +	if (col + len >= screen->max_col + 1) {
40 +		len = screen->max_col + 1 - col;
41 +	}
42 +
43 +	if (screen->cursor_state)
44 +		HideCursor();
45 +
46 +	screen->do_wrap = 0;
47 +
48 +	if (row - screen->topline <= screen->max_row) {
49 +		if (!AddToRefresh(screen)) {
50 +			if (screen->scroll_amt)
51 +				FlushScroll(screen);
52 +			XClearArea(screen->display,
53 +				VWindow(screen),
54 +				CursorX (screen, col),
55 +				CursorY (screen, row),
56 +                                len * FontWidth(screen),
57 +                                FontHeight(screen),
58 +				FALSE);
59 +                }
60 +        }
61 +}
62 +
63  ClearRight (screen)
64  register TScreen *screen;
65  {
66