text-list questions (probably answered before)
[1/7] from: peoyli:algonet:se at: 17-Apr-2001 15:45
Hello there,
Here is a collection of text-list related problems I have gotten so
far:
1. how do I set the slider to the 'correct' position on a rebuild ?
2. is there a way to disable multi-selection of items in the list ?
3. how do I get rid of the white area below the last entry ?
see the example for solutions on how to keep the previous
item selection, and to have the same visible items in the list after
the rebuild.
-------------
[
REBOL []
list-items: {some items to play around with in the list. Specific problems I
have is all related to rebuilding the list}
list-block: parse list-items " "
build-layout: func [
{Build the test layout}
][
l: layout [
tl: text-list 100x140 data list-block [
if not none? tl/picked [ print first tl/picked ]
]
button "Rebuild" [
old-picked: tl/picked ; save old selection
old-sn: tl/sn ; save old visible area
build-layout ; rebuild
tl/picked: old-picked ; initial selection is what was before
tl/sn: old-sn ; make what was visible before visible again
; how do I set the slider to the same position as before, or to match the tl/sn value
?
view center-face l ; view the layout
]
]
]
build-layout
view center-face l
]
/PeO
[2/7] from: gjones05:mail:orion at: 17-Apr-2001 9:50
From: "P-O Yliniemi"
> Here is a collection of text-list related problems I have gotten so
> far:
>
> 1. how do I set the slider to the 'correct' position on a rebuild ?
Sterling's /View beta fix was:
fix-slider: func [faces [object! block!]] [
foreach list to-block faces [
either 0 = length? list/data [
list/sld/redrag 1
][
list/sld/redrag list/lc / length? list/data
]
]
]
As was addressed two emails ago, I modified his for reasons that I don't
precisely recall, but if his doesn't work at some point, try:
; modification based on original by Sterling
; updates the bar on the side of a text-list or group of text-lists
fix-slider: func [faces [object! block!]] [
foreach list to-block faces [
either 0 = length? list/lines [
list/sld/redrag 1
][
list/sld/redrag list/lc / length? list/lines
]
]
]
These are used as such:
view layout [
tl: text-list 100x50 "a" "b" "c" [
tl/lines: ["new" "values" "for" "you"]
fix-slider tl
show tl
]
]
I don't recall the answer to #2 and I don't recall ever knowing how to do
#3, but I suspect it will require a custom face based on list, instead of
text-list.
Hope others know the answers.
--Scott Jones
[3/7] from: agem::crosswinds::net at: 17-Apr-2001 17:57
an older fix by me (works in 1.0 too).
extract the style somehow from the demo ;-)
Volker
[REBOL [
Title: "Korrigiert Text-list, Demo"
Date: 27-Jan-2001/23:39:17+1:00
Name: "text-list'"
Version: 0.9
File: %textlist-patch1.r
Home: http://jove.prohosting.com/~screbol/
Author: "volker"
Owner: "volker"
Rights: "gpl"
Needs: [view 0.10.38]
Tabs: none
Usage: none
Purpose: none
Comment: none
History: [27-Jan-2000 ""]
Language: "german"
]
patched: context [
l: last-shown-lines: styles: text-list': update-slider:
none
[
]
[
%tlp2.r
]
styles: stylize [
text-list': text-list with [
"add size-change scrolling"
last-shown-lines: -1
update-slider: does [
either 0 = length? data [sld/redrag 1] [
sld/redrag lc / length? data]
]
append init [
sub-area/feel/redraw: does [
l: length? data
if l <> last-shown-lines [
last-shown-lines: l
update-slider
]
]
]
"leere liste erlauben."
words/data:
func [new args] [
if not empty? second args [
new/text: first new/texts: second args
]
next args
]
]
]]
test:
func [
/local fix-slider lo my-styles tl1 tl2 tl3
] [
[
%tlp.r
]
fix-slider: func [faces [object! block!]] [
foreach list to-block faces [
either 0 = length? list/data [list/sld/redrag 1] [
list/sld/redrag list/lc / length? list/data]
]
]
my-styles: patched/styles
lo: layout [backdrop gold / 2
styles my-styles
text 600 wrap { die text-list hat zwei fehler:
bei datena&nderungen wird der scrollbereich nicht vera&ndert
und leere listen funktionieren nicht.
hier ist eine Korrektur}
guide
text "original-textlist"
tl1: text-list data [1 2 3 4 5]
button "add" [append tl1/lines [7 8 9 0]
show tl1]
return
text "textlist mit workaround"
tl2: text-list data [1 2 3 4 5]
button "add" [append tl2/lines [7 8 9 0]
fix-slider tl2 show tl2]
return
text "text-list', korrigiert"
tl3: text-list' data [1 2 3 4 5]
button "add" [append tl3/lines [7 8 9 0]
show tl3]
]
view lo]
test
]
[4/7] from: peoyli:algonet:se at: 17-Apr-2001 19:23
Hi,
I have earlier found these fixes for the text-list (/View FAQ, and mailing
list), but that's not what I'm looking for. The size of the slider is updated
as it should, since I rebuild the whole layout before redisplaying (which is
stupid to do in the example I supplied, but I am working on another project
that requires this to be done).
What I want to do is _position_ the slider knob at the same place as it was
before the rebuild, not at the top of the container..
Actually, calling the fix-slider function (which is using list/lines instead
of list/data) in my example broke the slider (it filled the whole container
for some reason). The list/data version did nothing, since it had no reason to
change the size of the slider knob.
/PeO
[5/7] from: peoyli:algonet:se at: 17-Apr-2001 19:48
> > From: "P-O Yliniemi"
> > > Here is a collection of text-list related problems I have gotten so
> > > far:
> > >
> > > 1. how do I set the slider to the 'correct' position on a rebuild ?
> >
ah.. almost there (by poking around in the text-list object).. now.. how
do stop the slider knob from jumping from the top of the container to the
position I want it in ?
The value I poke at is:
tl/sld/pane/offset
where 'tl' is my text-list in the layout.
I want the initial position to be set to the old position..
[
REBOL []
list-items: {some items to play around with in the list. Specific problems I
have is all related to rebuilding the list}
list-block: parse list-items " "
build-layout: func [
{Build the test layout}
][
l: layout [
tl: text-list 100x140 data list-block [
if not none? tl/picked [ print first tl/picked ]
print tl/sld/pane/offset
]
button "Rebuild" [
old-picked: tl/picked ; save old selection
old-sn: tl/sn ; save old visible area
old-sld-offset: tl/sld/pane/offset
build-layout ; rebuild
tl/picked: old-picked ; initial selection is what was before
tl/sn: old-sn ; make what was visible before visible again
view center-face l ; view the layout
tl/sld/pane/offset: old-sld-offset
show tl
]
]
]
build-layout
view center-face l
]
/PeO
[6/7] from: carl:rebol at: 17-Apr-2001 12:21
It would probably be a lot easier to use a List rather than
a text-list. Once you get the hang of a list, there's a lot
more you can do with them.
Here's example of a list... this one has alternating
row colors. For data, it uses files in local dir.
REBOL [
Title: "Example List"
Date: 14-Mar-2000
Author: "Carl Sassenrath"
]
cnt: 0
files: load %./
out: layout [
across
image logo.gif
text 233x24 bold middle no-wrap reform ["File List" now/date now/time]
return space 0
txt snow black "Size" 77 center bold
txt snow black "Time" 55 center bold
txt snow black "File" 266 bold
return
lst: list 380x300 [
origin 0 space 0x0 across
txt 75 center para [origin: margin: 0x2]
txt 55 center para [origin: margin: 0x2]
txt bold 240
txt 10
] supply [
count: count + cnt
face/color: ivory
face/text: none
face/font/color: black
if even? count [face/color: ivory - 50.50.50]
if none? file: pick files count [exit]
face/text: do pick [
[either dir? file ["dir"][size? file]]
[if date: modified? file [date/time]]
[file]
] index
]
sld: slider lst/size * 0x1 + 16x0 [
c: to-integer value * .5 * length? files
if c <> cnt [cnt: c show lst]
] return
]
view out
-Carl
[7/7] from: agem:crosswinds at: 17-Apr-2001 23:53
I like this one a lot.
did some ugly hacking to use lists by my own.
doesn't know it can look so clean.
Great Carl(toh inventing and using it:)!
Volker