Bug 205486 - [terminal] create a switch for scroll locking
Summary: [terminal] create a switch for scroll locking
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: Terminal (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.2 RC4   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks: 316981 315529
  Show dependency tree
 
Reported: 2007-10-04 13:25 EDT by Michael Scharf CLA
Modified: 2010-06-15 17:16 EDT (History)
5 users (show)

See Also:
mober.at+eclipse: pmc_approved+
eclipse: review+
aleherb+eclipse: review+
uwe.st: review+


Attachments
Fix terminal view jumping to first line if Scroll Lock is activated (1.25 KB, patch)
2010-06-02 11:51 EDT, Uwe Stieber CLA
no flags Details | Diff
Patch with Copyright Contributor Line (1.80 KB, patch)
2010-06-03 00:00 EDT, Martin Oberhuber CLA
no flags Details | Diff
Complete patch, also enabling the Scroll Lock toolbar button (9.64 KB, patch)
2010-06-03 01:53 EDT, Martin Oberhuber CLA
no flags Details | Diff
patch v3 (13.64 KB, patch)
2010-06-03 02:20 EDT, Martin Oberhuber CLA
no flags Details | Diff
move code into scrollToEnd() (1.61 KB, patch)
2010-06-04 09:06 EDT, Martin Oberhuber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Scharf CLA 2007-10-04 13:25:06 EDT
When the terminal produces output it always makes the cursor visible (by scrolling to the end). There should be a mode where auto-scroll is disabled. Similar to the eclipse Console.
Comment 1 Martin Oberhuber CLA 2010-06-02 09:14:28 EDT
CQ:WIND00215180
Comment 2 Martin Oberhuber CLA 2010-06-02 09:19:26 EDT
Some implementation for scroll lock is there, but the corresponding "Scroll Lock" button in the UI has never been activated since the feature does not fully work as expected. For instance, when scroll lock is chosen, then rather than locking the CURRENT line of output, it jumps to line #1.

Contributions are welcome for addressing this.
Comment 3 Uwe Stieber CLA 2010-06-02 11:51:00 EDT
Created attachment 170823 [details]
Fix terminal view jumping to first line if Scroll Lock is activated
Comment 4 Michael Scharf CLA 2010-06-02 17:21:37 EDT
This patch looks like a low risk patch. Since it does not change the behavior whe scroll lock mode is disabled.

Uwe, does this fix make scroll lock usable?
Comment 5 Martin Oberhuber CLA 2010-06-02 23:59:28 EDT
From looking at the patch, I agree that it's low-risk. 

While I can see no impact of this on Open Source (because we don't expose the TerminalActionScrollLock in the TerminalView), I also see that the fix won't harm us since fScrollLock should always be false. 

I have gotten direct confirmation from Uwe that this does solve the problem. So based on Michael's statement (which I interpret as a +1) and Uwe's statement that it does help, I'm OK with committing it. I will schedule it for 3.2.1 though in order to minimize risk with the release ongoing (I cannot prove for sure that fScrollLock will always be false in open source).
Comment 6 Martin Oberhuber CLA 2010-06-03 00:00:20 EDT
Created attachment 170909 [details]
Patch with Copyright Contributor Line
Comment 7 Uwe Stieber CLA 2010-06-03 00:21:39 EDT
(In reply to comment #4)
> This patch looks like a low risk patch. Since it does not change the behavior
> whe scroll lock mode is disabled.
> 
> Uwe, does this fix make scroll lock usable?

Yes, it does. The result of the patch is that the
  - Visible area of the widget stays at the same scrolling position and
  - The vertical scroll bar does not jump. It stays in position and is
    updated while the output is appended below the visible area.
Comment 8 Uwe Stieber CLA 2010-06-03 00:24:15 EDT
The fix is imported for the Wind River commercial product. We have a customer report for this (WR internal reference CQ:WIND00215180) and our guidelines request fixing the issue in the next possible release vehicle. To achieve this, we require to put this into TM-Terminal 3.2.
Comment 9 Martin Oberhuber CLA 2010-06-03 01:22:20 EDT
Thanks Uwe - I have opened bug 315529 requesting a backport of this for the Wind River commercial product. For the Helios Stream though, I would still prefer waiting with this for 3.2.1.

I've been bitten by late-binding fixes before, and in this case I don't see the value of pushing this into Helios.
Comment 10 Martin Oberhuber CLA 2010-06-03 01:53:47 EDT
Created attachment 170914 [details]
Complete patch, also enabling the Scroll Lock toolbar button

Attached patch includes Uwe's original fix, and also enables the "Scroll Lock" toolbar and menu contributions (including the necessary docs update to do so).

I found that there is still one inconsistency with this:

When I have multiple terminal connections open inside one terminal view, and I enable "scroll lock" on connection 1, then it only applies to connection 1; but when switching to connection 2, the state of the button/menu still indicate scroll lock on (although it is off).
Comment 11 Martin Oberhuber CLA 2010-06-03 01:57:07 EDT
Given that this is a new UI contribution which we better have in 3.2 than in 3.2.1, I might be pursuaded allowing this into Helios if

  - other committers agree (review+)

The feature seems to work fine from my testing. It would be great if we could fix the minor inconsistency I mentioned. The value of having this in Helios seems to outweigh the risk putting it in - there is no API involved, it looks good so far, and in case we run into minor bugs these can be fixed in 3.2.1.
Comment 12 Martin Oberhuber CLA 2010-06-03 02:20:19 EDT
Created attachment 170915 [details]
patch v3

This patch fixes the state of the scroll lock action when switching connections inside one view instance; it also updates some copyright dates in the documentation.

I also thought that since this is a user-visible new feature, we need to increase the "minor" version of the terminal.view plugin and feature. The terminal widget plugin remains at a micro increment only, since only bug fixes were made.

By now, I really believe that this should go into 3.2RC4. 
Committers (Uwe, Michael), please review and approve the patch.
Comment 13 Uwe Stieber CLA 2010-06-03 02:52:54 EDT
Looks good and works fine. I've tested it integrated with our product.
Comment 14 Martin Oberhuber CLA 2010-06-03 04:35:36 EDT
Released, please verify with I20100603-0700.

Michael and Toni, I'd still like to get your opinion on the fix.
Comment 15 Michael Scharf CLA 2010-06-03 10:04:03 EDT
looks good for me
Comment 16 Anton Leherbauer CLA 2010-06-04 04:00:47 EDT
Looks reasonable.
For simplicity and consistency, I would have put the 

  scrollY(getVerticalBar());
  scrollX(getHorizontalBar());

inside scrollToEnd() which already tests for fScrollLock, but that's just cosmetics.
Comment 17 Martin Oberhuber CLA 2010-06-04 09:06:02 EDT
Created attachment 171097 [details]
move code into scrollToEnd()

Thanks Toni - if attached additional patch is what you had in mind, I'll commit it.
Comment 18 Anton Leherbauer CLA 2010-06-04 09:11:01 EDT
(In reply to comment #17)
> Thanks Toni - if attached additional patch is what you had in mind, I'll commit
> it.

Yes, that's what I had in mind.
Comment 19 Martin Oberhuber CLA 2010-06-04 09:38:26 EDT
Released Toni's cleanup / simplification.
Comment 20 Martin Oberhuber CLA 2010-06-15 17:14:11 EDT
CQ:WIND00215180

We have found an understandable but unexpected issue with the scroll lock feature, by exposing it via SSH to the following shell script:

#!/bin/sh
X=1
while true ; do
  X=`expr $X + 1`
  echo "Hello $X"
done

Running this script, the "scroll lock" feature does not work - - the problem with the test case is that new lines are printed so quickly, that the Terminal Widget's buffer runs over.

Fix:
Window > Preferences > Terminal : Set "Terminal Buffer" to 100000 lines

Now, scroll lock works as expected even with this case (until 100000 lines are reached). The point is that when the terminal buffer size is exhausted, new lines are being added to the buffer and removed at its beginning, since we have a ring buffer. As a consequence, the "locked scroll location" always remains at the same place while the buffer under it gets rotated.

Is this expected behavior, or should the scroll lock position rotate with its underlying source line when the buffer runs over ... up until the time when the "locked line" is expelled from the buffer? 

What do others think?
Comment 21 Martin Oberhuber CLA 2010-06-15 17:16:03 EDT
I have filed bug 316981 to track the "scroll lock when buffer runs over".