How to refresh a text-list
[1/8] from: atruter:hih:au at: 26-Feb-2002 14:09
Doubtless this has been asked before (no luck after a quick EScribe
search), but how does one refresh a text-list. I thought my code below show
work. Is this a bug? feature? poor coding ;)
rebol []
view layout [
a: area form read %. 'wrap
button "Area" [a/text: read %.. show a]
b: text-list data read %.
button "List" [b/data: read %.. show b]
]
Regards,
Ashley
[2/8] from: carl:cybercraft at: 26-Feb-2002 20:42
On 26-Feb-02, [atruter--hih--com--au] wrote:
> Doubtless this has been asked before (no luck after a quick EScribe
> search), but how does one refresh a text-list. I thought my code
<<quoted lines omitted: 6>>
> button "List" [b/data: read %.. show b]
> ]
Hi Ashley,
You need to clear the data block and then append to it. That way
you're still working with the same block, whereas you're creating a
new block with your above method which is why it won't update. ie...
view layout [
a: area form read %. 'wrap
button "Area" [a/text: read %.. show a]
b: text-list data read %.
button "List" [clear b/data append b/data read %.. show b]
]
You could use the same method with the area text as well - it's just
that for some reason it's not required. (Ask others:)
HTH.
> Regards,
> Ashley
--
Carl Read
[3/8] from: cyphre:seznam:cz at: 26-Feb-2002 9:36
Hi Ashley,
try this:
view layout [
a: area form read %. 'wrap
button "Area" [a/text: read %.. show a]
b: text-list data read %.
button "List" [b/lines: read %.. show b]
]
Using 'lines instead 'data variable looks like little inconsistecy in the
'text-list style ;-)
regards,
Cyphre
[4/8] from: gscottjones:mchsi at: 26-Feb-2002 5:33
> From: "Ashley"
>> Doubtless this has been asked before (no luck after a quick EScribe
>> search), but how does one refresh a text-list.
...
From: "Cyphre"
...
> view layout [
> a: area form read %. 'wrap
<<quoted lines omitted: 4>>
> Using 'lines instead 'data variable looks like little inconsistecy in the
> 'text-list style ;-)
...
Hi, Ashley,
Then, to "fix" the slider. you need to add a handy-dandy function, like
this:
fix-slider: func [faces [object! block!]] [
foreach list to-block faces [
list/sld/redrag list/lc / max 1 length? head list/lines
]
]
view layout [
a: area form read %. 'wrap
button "Area" [a/text: read %.. show a]
b: text-list data read %.
button "List" [
b/lines: read %..
fix-slider b
show b
]
]
--Scott Jones
[5/8] from: reboler:programmer at: 26-Feb-2002 9:30
Hey guys, why do evertything in two steps when you can do it in one! ;)
To change a text-list:
tell-list: func [
"changes data in 'text-list and resets everything. usage: tell-list text-list-face new-data"
fce value
][
append clear fce/data copy value
clear fce/picked
fce/sld/data: 0 ; resets slider position
fce/sn: 0 ; resets display position
fce/line-list: none
fce/sld/redrag fce/lc / max 1 length? head fce/lines ;resets slider size
show fce
]
The above works specifically for text-lists. And is (to my belief) a complete function
for all that must change when you change a text-list's data. Am I missing anything?
For most other faces try the following:
tell: func [
"changes text for various faces. usage: tell face text"
fce value
][
append clear fce/text copy value
fce/line-list: none
show fce
]
In a similar vein, when this question went around before, one of the replies mentioned
that a list was better because you could do more with them. However part of the example
given used 'supply. I can't find documentation on 'supply. Can anyone direct me to such?
[6/8] from: atruter:hih:au at: 27-Feb-2002 10:51
Thanks to all who responded. Of the two solutions that addressed the slider
issue, I believe the "tell-list" solution appears to work better (please
note that this is more a comment on the vagaries of text-list usage than
the code snippets received!). Try the following with the first dir listing
larger than the second (ie. showing what happens when the number of entries
is reduced).
rebol []
tell-list: func [fce value] [
append clear fce/data copy value
clear fce/picked
fce/sld/data: 0
fce/sn: 0
fce/line-list: none
fce/sld/redrag fce/lc / max 1 length? head fce/lines
show fce
]
fix-slider: func [faces [object! block!]] [
foreach list to-block faces [
list/sld/redrag list/lc / max 1 length? head list/lines
]
]
view layout [
a: text-list data read %..
button "Tell" [tell-list a read %.]
b: text-list data read %..
button "Fix" [b/lines: read %. fix-slider b show b]
]
Click on the last row of each list and then press "Tell" followed by "Fix" . . .
Regards,
Ashley
[7/8] from: philb:upnaway at: 27-Feb-2002 16:43
Hi Ashley,
Not too sure about tell-list fro all occasions.
Suppose I had a text list with say 3000 entries
(I have a text-list as part of my emailer reader has at least one folder with this many
enteries).
If I delete a single entry then tell-list will clear the whole list and copy (3000 -1)
items from value back into fce/data.
fix-slider assumes that the face data has been amended.
Of course you could supply a refinment to decide whether to clear & replace the data,
tell-list/replace and get the best of both worlds.
Cheers Phil
=== Original Message ===
Thanks to all who responded. Of the two solutions that addressed the slider
issue, I believe the "tell-list" solution appears to work better (please
note that this is more a comment on the vagaries of text-list usage than
the code snippets received!). Try the following with the first dir listing
larger than the second (ie. showing what happens when the number of entries
is reduced).
rebol []
tell-list: func [fce value] [
append clear fce/data copy value
clear fce/picked
fce/sld/data: 0
fce/sn: 0
fce/line-list: none
fce/sld/redrag fce/lc / max 1 length? head fce/lines
show fce
]
fix-slider: func [faces [object! block!]] [
foreach list to-block faces [
list/sld/redrag list/lc / max 1 length? head list/lines
]
]
view layout [
a: text-list data read %..
button "Tell" [tell-list a read %.]
b: text-list data read %..
button "Fix" [b/lines: read %. fix-slider b show b]
]
Click on the last row of each list and then press "Tell" followed by "Fix" . . .
Regards,
Ashley
[8/8] from: reboler:programmer at: 27-Feb-2002 10:17
If I can make some assumptions here (always a dangerous thing), I think that 'fix-slider
is directed toward showing slightly modified text-list/data, as in appending or deleting
one value from /data. It changes what is shown in the text-list as little as possible.
When you are completely changing the data (as in from one directory listing to another)
then 'tell-list is the way to go, because it resets _everything_.
Using 'fix-slider when the data is completely changed leads to many problems, but is
good when the data is only slightly changed. Using 'tell-list when the data is only slightly
changed may lead to unnecessary work.
Here is a new function that addresses Phil's concerns, but I'll venture that it is still
no good for his purposes because it resets the display to the top of the list.
;*****
update-list: func [fce] [
;you must change fce/data yourself!
clear fce/picked
fce/sld/data: 0
fce/sn: 0
fce/line-list: none
fce/sld/redrag fce/lc / max 1 length? head fce/lines
show fce
]
view layout [
tl: text-list data read %./
button "Update" [;don't go beyond %/ !!!
append clear tl/data read change-dir %../ ;here is where I change the tl/data
;remove find tl/data tl/picked ;alternative, must pick something in the list.
update-list tl
]
]
;*****
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted