[REBOL] editor
From: eillag:worldnet:att at: 26-Jun-2002 19:51
this is a hack:
<code>
REBOL [
title: "example"
file: %example.r
date: "24-Jun-2002/21:37:47-7:00"
comment: {paste to a window at caret position
}
]
paste: func [
"pastes to caret"
][
if not equal? system/view/focal-face a1 [focus a1]
if not series? system/view/caret [
system/view/caret: offset-to-caret a1 caret-xy
]
if series? system/view/caret [
insert system/view/caret copy b1/text
]
system/view/caret: skip system/view/caret length? b1/text
show a1
]
main: layout[
text "timer hanger" rate .1 feel[
engage: func [face action event][
caret-xy: caret-to-offset a1 system/view/caret
]
]
b1: button "paste" [paste]
b2: button "open" [a1/text: read to-file request-file show a1]
a1: area ""
return
my-slider: slider [scroll-para a1 my-slider]
]
focus a1
system/view/caret: head a1/text
view main
<code>
Gabrielle's post got me to thinking. I tried months ago to get
this to work for at least 40 hours. all I could do is paste
at the position of the click when the other way failed.
the caret disappears so you need to put it back where it was.
timer hanger does nothing so redefining its feel wont break any other face.
it saves the caret position in caret-xy. (line 25)
then in line 14 you put it back.
there may be a problem with fast entrys. the rate (line 23)
can be made faster or use
if error? try [this][too bad-do this]
to avoid crashing.
now you need to update the slider in the timer hanger so
when you show the field it doesen't reset at the beginning.
search the list for update-slider.r, I think.
use copy. see the list and rebolforces for more info.
text: a1/text IS a1/text
but
text: copy a1/text is not.
caret-to-offset face object! offset STRING!
offset-to-caret face object! offset PAIR!
confused? i sure was. Rebol is frustrating and
(I think) getting too complicated and ahead of itself.
Gabrielle's post gave me the hint I needed.
I have struggled with this fix since december.
I paint houses for a living and
this is my first post and e-mail.
i will unsuscribe when finished but
will continue to follow the list.
thanks to all for the brain exersize.
please remember that people like us are
interested. discussion is good, code is
better (even eye candy, although it does not display too
good on win 95 256color) and explained code is great.