Skip to content

Commit

Permalink
configurable display speedup by skipping refresh intervals (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Dec 19, 2018
1 parent 9260a20 commit 383d349
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/mintty.1
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,13 @@ The following settings appear neither in the options dialog nor as command line
options, which means they can only be set in config files or using the
\fB--option\fP or \fB-o\fP command line option.

.TP
\fBAccelerate display speed\fP (DisplaySpeedup=6)
If mintty processes high volume of output, it will skip up to the given
number of refresh intervals (of 16ms each) in order to save output that
is visually scrolled off right away, so effectively increasing output speed.
The maximum value is 9.

.TP
\fBClear selection highlighting on input\fP (ClearSelectionOnInput=true)
When this is disabled, keyboard input or pasting does not clear selection highlighting.
Expand Down
2 changes: 2 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const config default_cfg = {
// "Hidden"
.bidi = 2,
.disable_alternate_screen = false,
.display_speedup = 6,
.suppress_sgr = "",
.suppress_dec = "",
.suppress_win = "",
Expand Down Expand Up @@ -389,6 +390,7 @@ options[] = {
// "Hidden"
{"Bidi", OPT_INT, offcfg(bidi)},
{"NoAltScreen", OPT_BOOL, offcfg(disable_alternate_screen)},
{"DisplaySpeedup", OPT_INT, offcfg(display_speedup)},
{"SuppressSGR", OPT_STRING, offcfg(suppress_sgr)},
{"SuppressDEC", OPT_STRING, offcfg(suppress_dec)},
{"SuppressWIN", OPT_STRING, offcfg(suppress_win)},
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ typedef struct {
// "Hidden"
int bidi;
bool disable_alternate_screen;
int display_speedup;
string suppress_sgr;
string suppress_dec;
string suppress_win;
Expand Down
2 changes: 2 additions & 0 deletions src/term.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,8 @@ term_do_scroll(int topline, int botline, int lines, bool sb)
bool down = lines < 0; // Scrolling downwards?
lines = abs(lines); // Number of lines to scroll by

lines_scrolled += lines;

botline++; // One below the scroll region: easier to calculate with

// Don't try to scroll more than the number of lines in the scroll region.
Expand Down
6 changes: 6 additions & 0 deletions src/termout.c
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,12 @@ term_do_write(const char *buf, uint len)
if (hwc) // Previous high surrogate not followed by low one
write_error();

// ASCII shortcut for some speedup (~5%), earliest applied here
if (wc >= ' ' && wc <= 0x7E && cset == CSET_ASCII) {
write_char(wc, 1);
continue;
}

if (is_high_surrogate(wc)) {
term.high_surrogate = wc;
continue;
Expand Down
1 change: 1 addition & 0 deletions src/winpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extern int per_monitor_dpi_aware;

extern bool click_focus_token;
extern pos last_pos;
extern int lines_scrolled;

extern void win_flush_background(bool clearbg);
extern void win_paint(void);
Expand Down
18 changes: 17 additions & 1 deletion src/wintext.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,9 @@ static HDC dc;
static enum { UPDATE_IDLE, UPDATE_BLOCKED, UPDATE_PENDING } update_state;
static bool ime_open;

static int update_skipped = 0;
int lines_scrolled = 0;

#define dont_debug_cursor 1

static struct charnameentry {
Expand Down Expand Up @@ -1105,14 +1108,27 @@ do_update(void)
#if defined(debug_cursor) && debug_cursor > 1
printf("do_update cursor_on %d @%d,%d\n", term.cursor_on, term.curs.y, term.curs.x);
#endif
show_curchar_info('u');
if (update_state == UPDATE_BLOCKED) {
update_state = UPDATE_IDLE;
return;
}

update_skipped++;
int output_speed = lines_scrolled / term.rows;
lines_scrolled = 0;
if (update_skipped < cfg.display_speedup && cfg.display_speedup < 10
&& output_speed > update_skipped
)
{
win_set_timer(do_update, 16);
return;
}
update_skipped = 0;

update_state = UPDATE_BLOCKED;

show_curchar_info('u');

dc = GetDC(wnd);

win_paint_exclude_search(dc);
Expand Down

0 comments on commit 383d349

Please sign in to comment.