-
Notifications
You must be signed in to change notification settings - Fork 19
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shoes Console should support autoscroll down #34
Comments
This would be nice for all windows, edit_box and anywhere a vertical scroll bar is allowed. An optional style argument would be required and of course and convincing gtk.c and cocoa.m to do it or is it just a matter of shifting the top origin in the view rect so the bottom is always visible. |
ruby.c:441 shoes_place_decide() seems to be good place to start investigation (called twice from canvas.c |
The solution is fairly simple : add app.slot.scroll_top = app.slot.scroll_max at the end of the update method in https://github.com/Shoes3/shoes3/blob/master/lib/shoes/log.rb. Each window creates its own app, added to Shoes.APPS, so it doesn't interfere with other windows. Shall we consider adding a checkbox to enable/disable autoscroll? def update
...
app.slot.scroll_top = app.slot.scroll_max
end |
FEATURES
module Shoes::LogWindow
def setup
...
stack :width => -380 do
tagline "Shoes Console", :stroke => white
end
flow :margin => 6, :width => 120 do
@auto_scroll = check
@auto_scroll.checked = true
para "auto", :stroke => white, :margin_right => 0
para "s", :stroke => white, :underline => "low", :margin_right => 0
para "croll?", :stroke => white
end
keypress { |n| @auto_scroll.checked ^= true if n.eql?(:alt_s) }
...
end
def update
...
app.slot.scroll_top = app.slot.scroll_max if @auto_scroll.checked?
end
end |
In normal programs on normal systems, alt-s would be 'Save' and mapped to the save button code. |
Sure, let's change it to something else. alt-t maybe? para "au", :stroke => white, :margin_right => 0
para "t", :stroke => white, :underline => "low", :margin_right => 0
para "oscroll?", :stroke => white |
hi para span("au", :margin_right => 0),
span("t", :underline => "low", :margin_right => 0),
span("oscroll?"), :stroke => white also actually the autoscroll makes it awkward to review what's on top of the console window (scroll back) (Linux-Ubuntu) |
putting app.slot.scroll_top = app.slot.scroll_max if @auto_scroll.checked? inside the if @hash != Shoes.log.hash block in the update method, works fine except the scroll widget is not updated in the scrollbar !? (Linux-Ubuntu) |
Hi @passenger94, Thanks for the feedback. @ccoupe made autoscroll = false by default. I am using the console every day and it does seem better to me with autoscroll = true but the awkwardness you mention is present. The issue is that we have no way to hook certain events, such as mouse scroll, which could in turn disable the autoscroll when happening. The following is the latest and best to display the text (latest log.rb is not yet committed, @ccoupe?): para "au", ins("t"), "oscroll?", :stroke => white The strategy is based on *NIX terminals. You would have to press scroll lock to scroll back up and down on such terminal, then press scroll lock again to let it scroll away again. |
@passenger94 are you up for a some fun? _This is my experimental version of log.rb._ The appealing feature is that the banner on top is always displayed. This version is unlikely to be committed anytime soon because of issue #42, it's hard to scroll up and down with the mouse (you'd have to be on top of the scroll bar). Still, your feedback is meaningful to us. module Shoes::LogWindow
def setup
@header = stack do
flow do
background black
stack :width => -380 do
tagline "Shoes Console", :stroke => white
end
flow :margin => 6, :width => 120 do
@auto_scroll = check
@auto_scroll.checked = true
para "au", ins("t"), "oscroll?", :stroke => white
click { @auto_scroll.checked ^= true }
end
keypress { |n| @auto_scroll.checked ^= true if n.eql?(:alt_t) }
button "Clear", :margin => 6, :width => 80, :height => 40 do
Shoes.log.clear
end
button "Copy", :margin => 6, :width => 80, :height => 40 do
self.clipboard = Shoes.log.collect { |typ, msg, at, mid, rbf, rbl|
"#{typ.to_s.capitalize} in #{rbf} line #{rbl} | #{at}\n" +
"#{msg.to_s.force_encoding "UTF-8"}\n"
}.join("\n")
end
button "Save", :margin => 6, :width => 80, :height => 40 do
filename = ask_save_file
File.open(filename, "w") { |f|
f.write(Shoes.log.collect { |typ, msg, at, mid, rbf, rbl|
"#{typ.to_s.capitalize} in #{rbf} line #{rbl} | #{at}\n" +
"#{msg.to_s.force_encoding "UTF-8"}\n"
}.join("\n"))
} if filename
end
end
end
@hash = nil
@log = stack(:height => app.slot.height - @header.height - 50, :scroll => true) { }
timer(0) { update }
every(0.2) do
update
end
end
def update
if @hash != Shoes.log.hash
@hash = Shoes.log.hash
@log.clear do
i = 0
Shoes.log.each do |typ, msg, at, mid, rbf, rbl|
stack do
background "#f1f5e1" if i % 2 == 0
inscription strong(typ.to_s.capitalize, :stroke => "#05C"), " in ",
span(rbf, " line ", rbl, :stroke => "#335"), " | ",
span(at, :stroke => "#777"),
:stroke => "#059", :margin => 4, :margin_bottom => 0
flow do
stack :margin => 6, :width => 20 do
image "#{DIR}/static/icon-#{typ}.png"
end
stack :margin => 4, :width => -20 do
s = msg.to_s.force_encoding "UTF-8"
s << "\n#{msg.backtrace.join("\n")}" if msg.kind_of?(Exception)
para s, :margin => 4, :margin_top => 0
end
end
click do
self.clipboard =
"#{typ.to_s.capitalize} in #{rbf} line #{rbl} | #{at}\n" +
"#{msg.to_s.force_encoding "UTF-8"}\n"
end
end
i += 1
end
end
end
@log.scroll_top = @log.scroll_max if @auto_scroll.checked?
end
end |
yes works fine to me tried again with your version of log.rb when "@log.scroll_top = @log.scroll_max if @auto_scroll.checked?" is inside the if block, the stack is updated and scrolled down but the scroll widget is not PS I would be very glad to help as much as i can (inside time and personal knowledge frame of course) so yes i'm up for some fun !!! :-D |
You are correct. Leaving it outside the if, as in the log.rb above, allows the multiple refresh to catch on and scroll way down. The way Shoes does thing is sometimes a little latent. Thanks for testing. |
"The following is the latest and best to display the text (latest log.rb is not yet committed, @ccoupe?):" my log.rb matches what's on github: autoscroll = false. Nothing for me to commit. "The strategy is based on *NIX terminals. You would have to press scroll lock to scroll back up and down on such terminal, then press scroll lock again to let it scroll away again. " I haven't seen a scroll lock key for 25 years. If you mean ^S/^Q . it's got to be ten years since I've done that because if you have a scroll buffer you don't need it. A modern machine can spit out a thousand lines of text in a second . Shoes Console log has a scroll buffer - up to the amount of memory that Ruby can use or your page swapping device and tolerance can handle. I'd like to set autoscroll to true by default but as currently written its a very annoying user experience on Linux. The solution is fix to the scroll bar code, not in log.rb @passenger94 must have cloned/forked/pulled the repo when log.rb was in flux. It happens. |
Check the log.rb I sent you on Jan, 24th. It contains few changes such as three para's became one, ability to click on the whole flow for better usability, etc.
FreeBSD still uses scroll lock. :)
No problem for now. Totally understandable. We also mention having a preferences window (cobbler?) in the future. That could be something to set it up with. |
Turns out I do have a keyboard with a scroll lock key on the raspberry pi! My apple keyboard has F14 in the same place. Is that scroll lock? What does a notebook user type? My main Linux machine keyboard doesn't have a scroll lock or an F14 key. What do I press on a thinkpad? In a freebsd VM? Why should Shoes need to know any of that? Or accommodate the how many buttons on your mouse? |
i might have found a workaround (well an old song ...) timer(0) { @log.scroll_top = @log.scroll_max if @auto_scroll.checked? } does the trick if placed at the end of the "if @hash != Shoes.log.hash" block, after the "@log.clear block" |
@ccoupe It doesn't need to know. My point was that the behaviour is mimicking what you get on *NIX terminal. @passenger94 This is working great on Windows! |
btw, mouse is scrolling the stack now ! (Linux-Ubuntu) |
@passenger94 - can you commit your changes to log.rb? Thanks. @backorder My point was that the scroll lock key is DOS (no keyboard before IBM PC had that key). Before DOS and *NIX, back when even a 30 cps teletype could output faster than some people could read there were key strokes to 'halt the output'. Back then the console paper really did wrap in a scroll and you had to unroll it to see the older console log messages. That DOS scroll lock key was also problematic. Don't emulate that. Shoes console should be freely scrollable, up and down by the user. If they want to look at the middle of the log then any new shoes message should not scroll them to bottom (or any where else). |
Teletype? I am not that old. o_O
That would be fairly easy to do if we could hook mouse scroll and scroll bar events, such as, if it is scrolled by the user, stop autoscroll. The next best thing is what we have got now. @passenger94 remember, if you submit a pull request, you should use |
Ok will do as soon as possible ! AFK now ! |
@passenger94 your fix does work well on both Windows and MacOS X, regardless it is on Issue #42 may be due to unavailability at the invocation time, as it happens time and time again, but using a timer on the scroll bar hardly fixes the stack. It is a big flaw in usability affecting all systems (except yours?!). If you have time, please, try the first code snippet on issue #42 and see if you can fix it. Then report on the page of the issue. For the pull request, it is best to use |
@passenger94 thank you for the pull request. |
Excellent. Congratulations. Thank you. |
Fully implemented feature available for 3.2.21 release. Possibility for an update with Shoes Console panel always on top when issue #42 is fixed. |
Shoes Console will not scroll down automatically when a new entry is displayed, which would be what one expects from a terminal-like debugging window.
The following code snippet behaves interestingly.
TEST SCENARIO
For a moment it will scroll down automatically.
The text was updated successfully, but these errors were encountered: