Author |
Topic: Auto scroll to the top of main window? (Read 809 times) |
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Auto scroll to the top of main window?
« Thread started on: Aug 23rd, 2015, 7:48pm » |
|
If I print a list in main window that causes the page to scroll up, how can I get my program to display the top of the list/page again?
I know I can use the LOCATE command to re-position the carrot, but the screen doesn't seem to scroll back up unless I include an INPUT at the new position. Even using CLS doesn't scroll back to the top of the page.
I'm sure there must be a simple solution to this and I am just being thick as usual.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Auto scroll to the top of main window?
« Reply #1 on: Aug 23rd, 2015, 8:14pm » |
|
on Aug 23rd, 2015, 7:48pm, Monkfish wrote:I'm sure there must be a simple solution to this and I am just being thick as usual. ??? |
|
LOCATE 1 1 does in fact cause the mainwin to scroll fully down, so that the topmost line is displayed. You can demonstrate that using this code:
Code:for i = 1 to 80
print i, "Hello world!"
next
locate 1 1 What, I think, has led you to a different conclusion is that in LBB, unlike LB, the mainwin can only hold a limited number of lines (typically about 84, but it depends on the DPI value; item 7 in the Compatibility section of the LBB docs). If you output more, the oldest ones are 'scrolled off the top' and are lost for good.
So whilst it may seem that it hasn't scrolled back fully, in fact it has: the earlier lines are just not there any more. If this limitation is a problem you may find that a text window meets your needs better than the mainwin.
Richard.
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Auto scroll to the top of main window?
« Reply #2 on: Aug 23rd, 2015, 9:15pm » |
|
That's weird. I tested it using the following and it didn't work...
Code:n=100
[back]
for i = 1 to n
print i, "Hello world!"
next i
input a
cls
locate 1 1
n=10
goto [back]
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Auto scroll to the top of main window?
« Reply #3 on: Aug 23rd, 2015, 10:41pm » |
|
on Aug 23rd, 2015, 9:15pm, Monkfish wrote:That's weird. I tested it using the following and it didn't work... |
|
What LBB is trying to do is to keep the mainwin caret (text cursor) visible. So if you do a LOCATE 1 1 followed by an INPUT or a WAIT you will find that it indeed does scroll to the top.
But that's not what you are doing. You are issuing a LOCATE 1 1 and immediately afterwards you are outputting another ten lines, leaving the caret on line 11. So in that case it doesn't need to scroll to the top to make the caret visible, so it doesn't!
If you want to force it to scroll to the top you will need to leave the caret on the top line, for example:
Code:n=100
[back]
for i = 1 to n
print i, "Hello world!"
next i
locate 1 1
a$ = input$(1)
cls
n=10
goto [back] Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Auto scroll to the top of main window?
« Reply #4 on: Aug 24th, 2015, 09:07am » |
|
That is a really weird and unexpected behavior. Liberty Basic appears to wait a short while to see where the carrot is going to end up, instead of scrolling to the top immediately. The following program demonstrates this. Whether the second 10 lines appear in the window or not is entirely dependent on the length of the timer. If the timer is set below 100 then the lines don't appear, if the timer is set above 200 then the lines appear. No wonder I was getting confused.
Code:n=100
[back]
for i = 1 to n
print i, "Hello world!"
next i
input a$
cls
timer 200, [skip]
wait
[skip]
timer 0
n=10
goto [back]
|
« Last Edit: Aug 24th, 2015, 09:16am by Monkfish » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Auto scroll to the top of main window?
« Reply #5 on: Aug 24th, 2015, 10:11am » |
|
on Aug 24th, 2015, 09:07am, Monkfish wrote:That is a really weird and unexpected behavior. |
|
I entirely disagree. It is perfectly sensible for there to be a temporal component.
Consider this scenario: you output a 'document' which has lines longer than the width of the mainwin. If LBB were to react 'instantaneously' to the caret (text cursor) leaving the visible region, the mainwin would be furiously scrolling to the left and right. As soon as the text being output passed beyond the right-hand edge it would scroll to keep the caret 'in view'; at the end of the line, when a CRLF is received, it would scroll back again.
This would all happen far too quickly for the user's eyes to follow, and the end result would be a flickering mess. Try this in LB and in LBB and decide which you think has the nicer output:
Code:mainwin 40 24
for i = 1 to 80
print "The quick brown fox jumps over the lazy dog."
next Since the whole purpose of scrolling to keep the caret in view is so that a human observer can read the output, and since the human eye/brain system cannot follow very rapid scrolls, it makes perfect sense (to me) for there to be a short delay before the scrolling takes place.
But if you still think that LBB's behaviour is weird and confusing you can always use LB instead.
Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Auto scroll to the top of main window?
« Reply #6 on: Aug 24th, 2015, 1:02pm » |
|
I wasn't having a go at LBB specifically because I didn't realise it was just a function of LBB and not LB. I'm quite sure it is the most sensible way of handling carrot repositioning. I just wasn't expecting to encounter a temporal function, hence my confusion. No offence intended :)
It would be nice to have a way to disable the timing though to allow for situations that I encountered.
I implemented what I was after using the following code instead of a straight CLS instruction.
Code:[clear]
CLS
timer 200, [skip]
wait
[skip]
timer 0
return
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Auto scroll to the top of main window?
« Reply #7 on: Aug 24th, 2015, 1:52pm » |
|
on Aug 24th, 2015, 1:02pm, Monkfish wrote: None taken.
Quote:It would be nice to have a way to disable the timing though to allow for situations that I encountered. |
|
I don't think there's any practical way to disable it. You could speed up the timer, and hence reduce the delay (to a minimum of about 10 milliseconds), but not eliminate it:
Code: Bear in mind that the mainwin is intended primarily as a debugging aid - its principal purpose is as somewhere to output diagnostic messages during software development. Normally one would expect a nomainwin statement to be added before the program is finally deployed.
Using the mainwin as the main user interface is discouraged, although it can be convenient in 'quick and dirty' applications. As a rule a text window will be a better choice for that purpose. Is there a specific reason why you don't want to do it that way?
Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Auto scroll to the top of main window?
« Reply #8 on: Aug 24th, 2015, 6:43pm » |
|
Quote:Is there a specific reason why you don't want to do it that way? |
|
Well, when I started to write this program a year ago I didn't know how to mimic the action of the main window in another window. I could probably work out how to do that now, but it would just be too much work to go through and change everything. My program was intended to work like a terminal interface anyway... although I would probably do it differently if I was starting over.
It seems to work okay which is the main thing (with a lot of help from yours truly )
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Auto scroll to the top of main window?
« Reply #9 on: Aug 25th, 2015, 11:41am » |
|
on Aug 24th, 2015, 6:43pm, Monkfish wrote:It seems to work okay which is the main thing (with a lot of help from yours truly ) |
|
Looking at my code, it would be possible to make CLS reset the scroll position 'immediately' rather than after a delay, and with hindsight I should probably have done that. I will make a note of it for a future version, if any.
Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Auto scroll to the top of main window?
« Reply #10 on: Aug 25th, 2015, 1:28pm » |
|
Great ;D
Code:
Does this instruction affect the timer function in general? I'm using the timer function quite a bit in my code.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Auto scroll to the top of main window?
« Reply #11 on: Aug 25th, 2015, 3:47pm » |
|
on Aug 25th, 2015, 1:28pm, Monkfish wrote:Does this instruction affect the timer function in general? |
|
As far as I'm aware it affects only the maximum delay before the mainwin scrolls.
If this issue is a major inconvenience I will make a 'custom' version of LBB for you that scrolls immediately on a CLS.
Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Auto scroll to the top of main window?
« Reply #12 on: Aug 25th, 2015, 9:54pm » |
|
No that seems to work fine Richard. Thanks for the offer though
|
|
Logged
|
|
|
|
|