Skip to content

Commit

Permalink
fix suspend-output-while-selecting buffer, made size configurable (#816
Browse files Browse the repository at this point in the history
…, ~#799)
  • Loading branch information
mintty committed Nov 10, 2018
1 parent fdde2aa commit 0f8cc9e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
7 changes: 7 additions & 0 deletions docs/mintty.1
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,13 @@ options, which means they can only be set in config files or using the
\fBClear selection highlighting on input\fP (ClearSelectionOnInput=true)
When this is disabled, keyboard input or pasting does not clear selection highlighting.

.TP
\fBSuspend output while selecting\fP (SuspendWhileSelecting=8080)
During drag-selects, the user may want the screen to hold still
to be selected from. Mintty can suspend processing of terminal output
for a while; if the buffer exceeds the size configured with this parameter
(in bytes), output is flushed. Setting it to 0 disables the feature.

.TP
\fBTrim trailing space from selection on copy\fP (TrimSelection=true)
When this is disabled, trailing space that was written to the terminal
Expand Down
2 changes: 2 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const config default_cfg = {
.suppress_wheel = "",
.filter_paste = "",
.input_clears_selection = true,
.suspbuf_max = 8080,
.trim_selection = true,
.charwidth = 0,
.emojis = 0,
Expand Down Expand Up @@ -390,6 +391,7 @@ options[] = {
{"SuppressMouseWheel", OPT_STRING, offcfg(suppress_wheel)},
{"FilterPasteControls", OPT_STRING, offcfg(filter_paste)},
{"ClearSelectionOnInput", OPT_BOOL, offcfg(input_clears_selection)},
{"SuspendWhileSelecting", OPT_INT, offcfg(suspbuf_max)},
{"TrimSelection", OPT_BOOL, offcfg(trim_selection)},
{"Charwidth", OPT_CHARWIDTH, offcfg(charwidth)},
{"Emojis", OPT_EMOJIS, offcfg(emojis)},
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ typedef struct {
string suppress_wheel;
string filter_paste;
bool input_clears_selection;
int suspbuf_max;
bool trim_selection;
char charwidth;
char emojis;
Expand Down
16 changes: 7 additions & 9 deletions src/termout.c
Original file line number Diff line number Diff line change
Expand Up @@ -2998,22 +2998,20 @@ void
term_write(const char *buf, uint len)
{
/*
During drag-selects, we do not wish to process terminal output,
because the user will want the screen to hold still to be selected.
During drag-selects, some people do not wish to process terminal output,
because the user may want the screen to hold still to be selected.
Therefore, we maintain a suspend-output-on-selection buffer which
can grow up to a moderate size.
can grow up to a configurable size.
*/
if (term_selecting()) {
#define suspmax 88800
#define suspdelta 888
if (term_selecting() && cfg.suspbuf_max > 0) {
// if buffer size would be exceeded, flush; prevent uint overflow
if (len > suspmax - term.suspbuf_pos)
if (len > cfg.suspbuf_max - term.suspbuf_pos)
term_flush();
// if buffer length does not exceed max size, append output
if (len <= suspmax - term.suspbuf_pos) {
if (len <= cfg.suspbuf_max - term.suspbuf_pos) {
// make sure buffer is large enough
if (term.suspbuf_pos + len > term.suspbuf_size) {
term.suspbuf_size += suspdelta;
term.suspbuf_size = term.suspbuf_pos + len;
term.suspbuf = renewn(term.suspbuf, term.suspbuf_size);
}
memcpy(term.suspbuf + term.suspbuf_pos, buf, len);
Expand Down
2 changes: 2 additions & 0 deletions wiki/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Appearance
* Option Background== for floating window effect (using desktop wallpaper as background) (#18, ~#666, ~~#501).

Window handling
* Fixed suspend-output-while-selecting buffer, size is configurable (#816, ~#799).
* Consider glyph width for font width determination (#808).
* Do not start process to construct process list for exit confirmation (~#448).
* Enhanced taskbar icon grouping behaviour (#784, mintty/wsltty#96, ?#495, ?#420, ??#801).
Expand All @@ -16,6 +17,7 @@ Window handling

Configuration
* AppID supports placeholders for flexible customization of taskbar icon grouping behaviour (#784, mintty/wsltty#96, ?#495, ?#420, ??#801).
* Option SuspendWhileSelecting to set the max size of the suspend-output-while-selecting buffer (#816, ~#799).

### 2.9.3 (4 October 2018) ###

Expand Down

0 comments on commit 0f8cc9e

Please sign in to comment.