Skip to content

GUI Example Text file browser

Christopher Ross-Gill edited this page Aug 1, 2016 · 1 revision

Here is a very simple text file browser.

Table of Contents

Script

files: read %*.r

view/across [
    text-list files do [set-face ca read-string pick files value]
    ca: code-area
]

Screenshot

Note: uses development skin, not the final skin.

Resizing is automatic. If you change the window size, the text-list and code-area will change.

Description

The READ function returns a block of all .r filenames from the current directory.

VIEW/across forces the layout to be horizontal.

The TEXT-LIST style displays the file names in a list. Clicking on a name will do the SET-FACE block, setting the code-area to display the text.

Within the DO block, the file name is obtained by picking it using the VALUE as an index number. This method is different from R2 VID. An index is used to allow the text list to contain more than one entry of the same name. The index number is unique.

CODE-AREA is a minor variation of the AREA style that displays using a monospaced (fixed width) font, allowing for proper indentation and spacing of the code.

Notes

  1. The READ-STRING function is a temporary function used to read files and convert them from binary (and possibly in Unicode format) into a string datatype.
  2. Although the Rebol kernel does support Unicode, the graphics library does not yet handle unicode strings.
Clone this wiki locally
You can’t perform that action at this time.