[REBOL] Re: Scroll text area?
From: agem:crosswinds at: 6-Jul-2001 22:31
RE: [REBOL] Scroll text area?
[hijim--pronet--net] wrote:
>
> Volker showed me how to move the cursor position, but can I scroll the text
> in the text area? All I want is page up and down and top and end of file to
> be displayed with buttons. There must be a way to scroll the display.
>
> Anyone?
>
[rebol []
protect-system
???: func ['word value] [
print [mold :word mold type? :value ":" mold :value]
word :value]
{Hi Jim. lets look at}
source scroll-para
[;the source:
scroll-para: func [tf sf /local tmp] [
if none? tf/para [exit]
tmp: min 0x0 tf/size - (size-text tf) - 0x30
either sf/size/x > sf/size/y [tf/para/scroll/x: sf/data * first tmp] [
tf/para/scroll/y: sf/data * second tmp]
show tf
]
]
{this nice function is usually used like}
context [
view center-face layout [
title "simple slider"
across
my-slider: slider 16x480 [scroll-para my-area my-slider]
my-area: area para [] 640x480 (read first request-file)
]
]
{for the hand-made way, we see 'tf/para/scroll/y and 'size-text tf
the first lets you set a position for your text, the 'size-text
gives you the size of the full text.
this is used to make scrolling relativ there.
its nice to play with it.}
{but we have a slider! it can do the work!
set 'my-slider/data between 0 .. 1}
context [
view center-face layout [
title "we jump!"
across
button "1/2" [
my-slider/data: 0.5
scroll-para my-area my-slider
show [my-slider]
]
return
my-slider: slider 16x480 [scroll-para my-area my-slider]
my-area: area para [] 640x480 (read first request-file)
]
]
{so we can set slider & cursor together, now we have to
do something with pages.
has vid something ready? hm.
http://www.cs.unm.edu/~whip/objview.r is always a nice tool.
(on jeffs reb), but it does not work to look in 'system/view here?!
trick 2: to get an overview for faces i use
}
layout [my-area: area do [probe my-area/feel]]
{and we see somewhere
key [edit-text face event get in face 'action]
'edit-text ? grumbling.
must be somewhere..
trick 3: to get an overview of objects:}
probe first system/view ;this one is where you find caret and that
probe first system/view/vid
probe first system/view/vid/vid-feel ; no..
{well, long not looked at. /view 1.2 now..}
help ctx-
probe first ctx-text ;lalala :)
{but psst! its a function! do not wake!}
probe get in ctx-text 'edit-text ;not probe ctx-text/edit-text !
{ AHA!
set-caret: [view*/caret: offset-to-caret face tmp]
page-up: [
tmp/y: tmp/y - face/size/y
if not head? view*/line-info/start set-caret
]
page-down: [
tmp/y: tmp/y + face/size/y
if not tail? offset-to-caret face tmp set-caret
]
but then it gets complicated.. nono.
i calculate a bit myself:
}
context [
face: none
view center-face layout [
title "page-jumper"
across
button "down" [
my-slider/data: my-slider/data +
(my-area/size/y / second size-text my-area)
scroll-para my-area my-slider
show [my-slider]
]
button "up" [
my-slider/data: my-slider/data -
(my-area/size/y / second size-text my-area)
scroll-para my-area my-slider
show [my-slider]
]
return
my-slider: slider 16x480 [scroll-para my-area my-slider]
my-area: area para [] 640x480 (read first request-file)
]
]
{seems, i misunderstood something. it jumps only part of pages.
needs more work..
}
]
;-) Volker