Comments (25)
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.
from shoes3.
ruby.c:441 shoes_place_decide() seems to be good place to start investigation (called twice from canvas.c
from shoes3.
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
from shoes3.
FEATURES
- Autoscroll enabled by default
- Autoscroll checkbox on top
- keyboard shortcut alt-s to toggle autoscroll
- Readjusted buttons to fit with a scrollbar
- Shoes Console stack width changed
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
from shoes3.
In normal programs on normal systems, alt-s would be 'Save' and mapped to the save button code.
from shoes3.
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
from shoes3.
hi
may i suggest
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)
one needs to switch back to autoscroll = false by means of shortcut, not a big deal though
not sure about the right strategy to adress this (every time something is added to console make it autoscroll, then disable ?)
from shoes3.
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)
from shoes3.
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.
from shoes3.
@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
from shoes3.
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
from shoes3.
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.
from shoes3.
"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.
from shoes3.
"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.
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.
I haven't seen a scroll lock key for 25 years.
FreeBSD still uses scroll lock. :)
I'd like to set autoscroll to true by default but as currently written its a very annoying user experience on Linux.
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.
from shoes3.
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?
from shoes3.
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"
from shoes3.
Why should Shoes need to know any of that? Or accommodate the how many buttons on your mouse?
@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!
from shoes3.
btw, mouse is scrolling the stack now ! (Linux-Ubuntu)
from shoes3.
@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).
from shoes3.
Teletype? I am not that old. o_O
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).
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 app.slot.scroll_top = app.slot.scroll_max if @auto_scroll.checked?
because the current log.rb does not implement the feature on @log
yet due to issue #42.
from shoes3.
Ok will do as soon as possible ! AFK now !
But as i said, at least on my system, issue #42 is gone
Looks like problems arise due to elements not beeing fully available at invocation time which is resolved by the timer trick, could you confirm it works, here, or not, (falling back to app.slot instead of @log)on windows or mac systems ?
from shoes3.
@passenger94 your fix does work well on both Windows and MacOS X, regardless it is on app.slot
or @log
.
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 app.slot
for the time being until issue #42 is effectively resolved.
from shoes3.
@passenger94 thank you for the pull request.
from shoes3.
Excellent. Congratulations. Thank you.
from shoes3.
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.
from shoes3.
Related Issues (20)
- Packaging with an icon causes invalid bit count HOT 2
- Cannot load ZIP gem under certain conditions HOT 42
- Windows 7 mouse offset on 3.3.7 HOT 5
- Image is disappearing upon setting its path back to the original path HOT 4
- Progress bar fractions HOT 2
- Button colors HOT 2
- Image Clearing in Shoes 3 HOT 2
- Window resize HOT 4
- Menu trim for windows HOT 2
- Video player becomes transparent on sides after playing a video file HOT 7
- Iframes in app? HOT 2
- keyup and keydown not working on masOs HOT 3
- Text styles in buttons HOT 4
- Display unicode emoji in UI HOT 6
- icon HOT 9
- install old version of a gem? HOT 2
- download link to mac version offline HOT 15
- Possible logic error in code HOT 2
- Replace hacked website mvmanila.com HOT 3
- Question Wasm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shoes3.