Adjusting a text-list starting point

Discussion in 'Rebol' started by swhite, Apr 4, 2012.

  1. swhite

    swhite Member

    I know that one can make a text field and a scroller, and use the scroller to control the text field. I have done that and captured the code in a little demo.

    I know that one can fill a text-list with data and use the associated scroller to move around in the data.

    What I am wondering is, in a text-list, is it possible to fill it with data and set some attribute so that the associated scroller starts at some place besides the top? I have tried the ideas in the sample below without success.

    What I am trying to accomplish is to fill up a text list with a large amount of data sorted in alphabetical order, and then provide a way to jump down the list to some starting point somewhere in the middle, to reduce the amount of scrolling.

    I realize that this might not be possible. I have found the REBOL/View documentation obscure enough so that I am not quite sure of the possibilities.

    Thank you. Sample follows.


    Code:
    REBOL [
     
    ]
     
    SHOW-SELECTED: does [
     
    SELECTED-ITEM/text: mold FILE-NAMES/picked
     
    show SELECTED-ITEM
     
    SELECTED-TYPE/text: to-string type? FILE-NAMES/picked
     
    show SELECTED-TYPE
     
    ]
     
    view layout [
     
    vh2 "File List:"
     
    ;; Code in question:
     
    FILE-NAMES: text-list
     
    font [name: font-fixed]
     
    data read %.
     
    ;; Is there an attribute I can use to start the text-list scroller
     
    ;; somewhere besides the beginning?
     
    ;; para [scroll: 0x0] ;; no syntax error but no effect
     
    ;; para [scroll: 10x10] ;; messes up the data--bunches of hyphens
     
    ;; para [scroll/y 10] ;; no syntax error but no effect
     
    ;; para [scroll/y: 10] ;; messes up the data--bunches of hyphens
     
    ;; scroll/y 10 ;; invalid syntax
     
    ;; para/scroll/y 10 ;; invalid syntax
     
    button "Show selected" [SHOW-SELECTED]
     
    SELECTED-ITEM: text 200x200 ""
     
    across
     
    label "FILE-NAMES/picked is of type: "
     
    SELECTED-TYPE: text 100x20 ""
     
    ]
  2. Graham

    Graham Developer Staff Member

    Never tried this, but I would tend to use Henrik's list-view for complicated things
  3. Graham

    Graham Developer Staff Member

    From Altme, Marco

  4. swhite

    swhite Member

    Thank you. I have captured that solution in my little demo so I won't forget it.

    This episode shows three things that amaze me about the whole REBOL scene.

    One: That REBOL can do some of the stuff it does.

    Two: How you people (who know REBOL so well) can find out this stuff.

    Three: That I will stare at that ONE line of code for hours, reread the View documentation, and, probably, still be unable to understand that ONE line of code.

    Sometimes I wonder if REBOL is too sophisticated for its own good. I remember having an easier time with IBM 370 assembler.
  5. MaxV

    MaxV Member

    Why don't you use the do command?
    Look at this:
    Code:
    view layout [
     
    vh2 "File List:"
     
    ;; Code in question:
     
    FILE-NAMES: text-list font [name: font-fixed] data read %.
     
    button "Show selected" [SHOW-SELECTED]
     
    SELECTED-ITEM: text 200x200 ""
     
    across
     
    label "FILE-NAMES/picked is of type: "
     
    SELECTED-TYPE: text 100x20 ""
     
    do [
    file-names/picked:  file-names/data/3 
    show file-names
    ]
     
    ]
  6. swhite

    swhite Member

    Thank you. I did not know I could put a "do" in a layout like that.

    Your idea does indeed highlight file-names/data/3, and if you change the "3" to, for example, "20," it highlights file-name/data/20, BUT, it does not move the list down to item 20 if item 20 is not initially visible in the text-list.

    As for the particular problem I am working on, I am thinking now of moving to a web-browser interface with my "text list" being an html page generated by a REBOL CGI program. I am really liking the web browser as a "GUI" because of the ease of deployment; I sit at my desk and write programs, and everyone can use them immediately without any "installation."
  7. MaxV

    MaxV Member

Share This Page