gopher-ui: remember scroll position in history.

db4
John Benediktsson 2014-12-17 14:20:18 -08:00
parent d93eb719c7
commit ac9c983c93
1 changed files with 13 additions and 10 deletions

View File

@ -1,24 +1,27 @@
! Copyright (C) 2014 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: accessors debugger fry gopher gopher.private kernel
models present ui ui.commands ui.gadgets ui.gadgets.borders
ui.gadgets.buttons ui.gadgets.editors ui.gadgets.panes
ui.gadgets.scrollers ui.gadgets.status-bar ui.gadgets.tracks
ui.gestures ui.operations ui.tools.browser
ui.tools.browser.history ui.tools.common urls ;
USING: accessors arrays debugger fry gopher gopher.private
kernel models present sequences ui ui.commands ui.gadgets
ui.gadgets.borders ui.gadgets.buttons ui.gadgets.editors
ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.status-bar
ui.gadgets.tracks ui.gadgets.viewports ui.gestures ui.operations
ui.tools.browser ui.tools.browser.history ui.tools.common urls ;
IN: gopher-ui
TUPLE: gopher-gadget < tool history output url-field ;
TUPLE: gopher-gadget < tool history scroller url-field ;
{ 600 600 } gopher-gadget set-tool-dim
M: gopher-gadget history-value
control-value ;
[ control-value ] [ scroller>> scroll-position ]
bi 2array ;
M: gopher-gadget set-history-value
set-control-value ;
[ first2 ] dip
[ set-control-value ] [ scroller>> set-scroll-position ]
bi-curry bi* ;
M: gopher-gadget model-changed
[ value>> present ]
@ -54,7 +57,7 @@ M: gopher-gadget model-changed
dup <url-field> >>url-field
dup <gopher-toolbar> { 3 3 } <border> { 1 0 } >>fill f track-add
dup <gopher-pane> { 3 3 } <border> { 1 1 } >>fill
<scroller> 1 track-add ;
<scroller> [ >>scroller ] [ 1 track-add ] bi ;
: open-gopher-window ( url -- )
<gopher-gadget>