Scrolling list of lines
Inherits from Browser_
Subclasses: Hold_Browser Multi_Browser Select_Browser
column_char | format_char | topline | ||
column_widths | size | value | ||
add | hide | middleline | selected | visible |
bottomline | insert | move | set_text | |
clear | load | remove | show | |
displayed | make_visible | select | text | |
type | name | summary |
readonly integer | size | Number of lines |
integer | value | Currently selected line |
integer | topline | Top line number visible |
type | name | summary |
void | add(string s) | Add an line at end |
void | remove(integer n) | Remove an line |
string | text(integer n) | Text of line |
void | load(string filename) | Load contents from file |
The Browser widget displays a scrolling list of text lines. This is not a text editor or spreadsheet! But it is useful for showing a vertical list of named objects to the user.
Each line in the browser is identified by number. The numbers start at one; zero is reserved for "no line" in the selective browsers. Unless otherwise noted, the methods do not check to see if the passed line number is in range and legal. It must always be greater than zero and <= size.
The base class does nothing when the user clicks on it. The subclasses Select_Browser, Hold_Browser, and Multi_Browser react to user clicks to select lines in the browser and do callbacks.
The base class called Browser_ provides the scrolling and selection mechanisms of this and all the subclasses, but the dimensions and appearance of each item are determined by the subclass. Subclasses of Browser_ could display information other than text, or text that is dynamically produced from your own data structures. If you find that loading the browser is a lot of work or is inefficient, you may want to make a subclass of _Browser_.
Formatting codes at the beginning of each line modify how the rest of the line is printed:@.
Print rest of line, don't look for more '@' signs @@
Print rest of line starting with '@' @l
Use a large (24 point) font @m
Use a medium large (18 point) font @s
Use a small (11 point) font @b
Use a bold font (adds FL_BOLD to font) @i
Use an italic font (adds FL_ITALIC to font) @f
or @t
Use a fixed-pitch
font (sets font to FL_COURIER) @c
Center the line horizontally @r
Right-justify the text @B0, @B1, ... @B255
Fill the backgound with
fl_color(n) @C0, @C1, ... @C255
Use fl_color(n) to draw the text @F0, @F1, ...
Use fl_font(n) to draw the text @S1, @S2, ...
Use point size n to draw the text @u
or @_
Underline the text. @-
draw an engraved line through the middle. @.
command can be used to reliably
terminate the parsing. To print a random string in a random color, use
sprintf("@C%d@.%s", color, string) and it will work even if the
string starts with a digit or has the format character in it.
The format character @ may be changed with the format_char property, or all formatting can be disabled with clear_format_char()
Browsers support the display of multiple columns, if the column_widths property is set. Each line is split into columns by the column_char; it defaults to the tab character. See column_widths for more information.
Remove line n and make the browser one line shorter.
Add a string to the end of the lines.
Insert a new line before line n. If n >
size then the line is added to the end.
Line from is removed and reinserted at to;
to is calculated after the line is removed.
Clears the browser and reads the file, adding each line from the
file to the browser. If the filename is nil or a zero-length
string then this just clears the browser. This returns nil
if there was any error in opening or reading the file
Remove all the lines in the browser.
Returns how many lines are in the browser. The last line number is
equal to this.
The current top line in the browser. Setting topline will
scroll the browser such that the top line is this value.
If there is no vertical scrollbar then this will always return
1.
Scrolls the browser so the bottom line in the browser is n.
Scrolls the browser so the middle line in the browser is n.
Sets the selection state of line n to value.
Note that subclasses other than Multi_Browser will behave
unpredictably if more than one line is selected.
Returns true if line n is selected; otherwise nil.
Makes line n visible for selection. This undoes the effect of hide().
Makes line n invisible, preventing selection by the
user. The line can still be selected under program control.
Returns true if line n is visible. See hide() for more information.
The currently selected line number; 0 if no line is selected.
You should not change this on instances of Browser; it's
only relevant to its subclasses.
Returns the text of line n. If n is out of range, it returns nil.
Sets the text of line n to s
Sets the character used for format codes. See the class description for more information.
Sets the character used to separate columns. See the class
description and column_widths()for more information.
Specifies the widths in pixels of each column. The text is split at
each column_char and each part is formatted into it's own
column. After the last column any remaining text is formatted into
the space between the last column and the right edge of the browser,
even if the text contains instances of column_char . The
default value is an empty list, which specifies no columns.
Returns true of line n is visible in the list.
Displays line n, scrolling the list as necessary.
add(string s): void
insert(integer n, string s): void
move(integer to, integer from): void
load(string filename): void
clear(): void
size: readonly integer
topline: integer
bottomline(integer n): void
middleline(integer n): void
select(integer n, boolean value=1): boolean
selected(integer n): boolean
show(integer n): void
hide(integer n): void
visible(integer n): boolean
value: integer
text(integer n): string
set_text(integer n, string s): void
format_char: string
column_char: string
column_widths: list
displayed(integer n): boolean
make_visible(integer n): void
doctool generated at Sun Aug 12 22:23:18 2001