summaryrefslogtreecommitdiff
path: root/src/mark.c
diff options
context:
space:
mode:
authorGuo Ci <zguoci@gmail.com>2017-06-21 23:29:50 +0200
committerAmadeusz Sławiński <amade@asmblr.net>2017-06-21 23:29:50 +0200
commit6a2f12c28a677ba814575d42825434bfb970e4e9 (patch)
treee9d9418f4d80001c8a44baa0bf2d5ac1e201b3b2 /src/mark.c
parentd23b14f9712f213b7e7faed21e9730001c7fe5b4 (diff)
downloadscreen-6a2f12c28a677ba814575d42825434bfb970e4e9.tar.gz
begin viewing scrollback buffer at the first line of output instead of at the start of the scrollback buffer
This issue has been discussed before: https://bbs.archlinux.org/viewtopic.php?id=108640 Copy mode and “hardcopy -h” always begin at the start of the scrollback buffer. If a user sets a large scrollback limit with little output, then copy mode and the file written by “hardcopy -h” will begin with many blank lines before the first line of output. The attached patch limits the scrollback buffer traversal to begin at the first line of output, instead of the beginning of the scrollback buffer. Also, code for moving to %age of buffer is changed to use float division so that two different rep_cnt will not jump to the same location, except for buffers less than 100 lines. Previously, the computed line number is rounded down to the nearest 100th due to integer division. Bug: 49377
Diffstat (limited to 'src/mark.c')
-rw-r--r--src/mark.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mark.c b/src/mark.c
index eed7675..663cd6e 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -686,7 +686,9 @@ static void MarkProcess(char **inbufp, size_t *inlenp)
rep_cnt = 0;
if (rep_cnt > 100)
rep_cnt = 100;
- revto_line(markdata->left_mar, (rep_cnt * (fore->w_histheight + fore->w_height)) / 100,
+ revto_line(markdata->left_mar,
+ fore->w_histheight - fore->w_scrollback_height +
+ (int)(rep_cnt * (fore->w_scrollback_height + fore->w_height) / 100.0),
(fore->w_height - 1) / 2);
break;
case 0201:
@@ -994,8 +996,8 @@ void revto_line(int tx, int ty, int line)
tx = 0;
else if (tx > fore->w_width - 1)
tx = fore->w_width - 1;
- if (ty < 0)
- ty = 0;
+ if (ty < fore->w_histheight - fore->w_scrollback_height)
+ ty = fore->w_histheight - fore->w_scrollback_height;
else if (ty > fore->w_histheight + fore->w_height - 1)
ty = fore->w_histheight + fore->w_height - 1;