!!! ROUGH COMPILATION !!!

The information in this file has not yet been verified for completeness or accuracy. I think, maybe roughly about 20 more new (mostly HTTP related) methods havn't yet been entered into this file.


accessible(filepath)

Returns: Full file path on success, or "" on failure.
Scope:
generic

Determine the accessibility of a file.

Example:

path = accessible("/etc/motd"); if (path != "") print("MOTD:", loadText(path)); else print("MOTD: not accessible.");

See also: loadText(), saveText().


after(milliseconds, object, [ message list ])

Returns: none.
Scope:
generic.

Schedule to send messages to an object after the given time, measured in millisconds.

Example:

/* send a "wakeup" message to self aftr a while */ after(10000, get("name"), "wakeup");

Causes the caller object to receive a message "wakeup" after 10000 milliseconds.


append(string)

Returns: undefined.
Scope:
txtDisp.

Appends text to the end of the text field.

See also: txtDisp.

Bug: it does not work.


argument()

Returns: the string following the -ar option.
Scope:
generic.


ascii(ASCII code)

Returns: the corresponding ASCII character.
Scope:
generic.

Returns the character given the ASCII value.

Example:

print("This program is brought to you by the letter ``", ascii(86), "''.\n"); /* ring terminal bell */ print(ascii(7));

See also: asciiVal().


asciiVal(ASCII character)

Returns: the corresponding ASCII code.
Scope:
generic.

Returns the ASCII value given the character.

Example:

print("The ascii value of ``a'' is ", asciiVal('a'), ".\n");

See also: ascii().


bell()

Returns: unaffected.
Scope:
generic.

Rings audio bell.

See also: bellVolume().


bellVolume(percentage)

Returns: voulume value.
Scope:
generic.

Sets bell volume in percentage (0 to 100).

Example:

bellVolume(0); /* turns off annoying beeps */

See also: bell().


building_maxFontDescent()

Returns: (int) font descent value.
Scope:
txtDisp.

Used to get information about the largest font descent value for the current line that is being built... This needs some explaining, later...

See also: txtDisp, building_maxFontHeight(), building_vspan().


building_maxFontHeight()

Returns: (int) font height value.
Scope:
txtDisp.

Used to get information about the largest font height value for the current line that is being built... This needs some explaining, later...

See also: cl_txtDisp, building_maxFontDescent(), building_vspan().


building_maxFontDescent()

Returns: (int) font descent value.
Scope:
txtDisp.

Used to get information about the largest font descent value for the current line that is being built... This needs some explaining, later...

See also: building_maxFontHeight().


building_vspan()

Returns: (int) font height value.
Scope:
txtDisp.

Used to get information about current vertical span, as the text field is being built... This needs some explaining, later...

See also: cl_txtDisp, building_maxFontDescent(), building_maxFontHeight().


char()

Returns: arguement in char.
Scope: generic. (in lang)

Convert argument to char type.


charButtonMask()

Returns: (int) character button-mask value.
Scope:
txtDisp.

For telling whether this character has the button-drawing mask turned on. If it has, the character (or the group of adjacent characters all have the button-mask turned on) would have a button-looking box drawn around it.

Example:

\name {culmtest} \class {txtDisp} \parent {} \content {Some words dress \b(fancy) and are hyper.} \script { if (arg[0] == "buttonRelease") { if (bmask = charButtonMask()) { print("is a button-decorated char.\n"); } else { print("is not...\n"); } } usual(); } \width {100} \height {50}

See also: cl_txtDisp, charHighLiteMask(), charMask(), charUnderlineMask().


charHighLiteMask()

Returns: (int) character highlite-mask value.
Scope:
txtDisp.

For telling whether this character has the highlite-drawing mask turned on. If it does, the character would appear high-lighted.

To achieve this effect, use the '\r' directive in the text.

Example:

\name {chlmtest} \class {txtDisp} \parent {} \content {Highlighting is done with \r(reverse video).} \script { if (arg[0] == "buttonRelease") { if (umask = charHighLiteMask()) { print("is a highlited char.\n"); } else { print("is not...\n"); } } usual(); } \width {100} \height {50}

See also: txtDisp, charButtonMask(), charMask(), charUnderlineMask().

Bugs

There needs to be a method for setting this mask dynamically.


charMask()

Returns: (int) character tag value.
Scope:
txtDisp.

Low level stuff. To be described later.

See also: cl_txtDisp, charButtonMask(), charHighLiteMask(), charUnderlineMask().


charUnderlineMask()

Returns: (int) character underline-mask value.
Scope:
txtDisp.

For telling whether this character has the underline-drawing mask turned on. If it does, the character would appear underlined.

To achieve this effect, use the '\u' directive in the text.

Example:

\name {culmtest} \class {txtDisp} \parent {} \content {Sometimes we want to \u(underline) text.} \script { if (arg[0] == "buttonRelease") { if (umask = charUnderlineMask()) { print("is underlined char.\n"); } else { print("is not underlined char.\n"); } } usual(); } \width {100} \height {50}

See also: charMask(), charButtonMask(), charHighLiteMask().

Bugs

There needs to be a method for setting this mask dynamically.


clean()

Returns: unaffected.
Scope:
field.

Cleans up the effect of smudge() -- Clears window, then sends self a "render" message.

See also: smudge().


clearSelection()

Returns: unaffected.
Scope:
txtDisp.

Stop being the owner of selection data. Cutting(select) text from a text field makes that object the owner of the selection.

See also: getSelection(), setSelection().


clearWindow()

Returns: unaffected.
Scope:
field.

Clears the object's window.


cli()

Returns: the result of the last evaluation.
Scope:
generic.

Invokes the ASCII Command Line Interface to interpreter on viola's stdin/stdout. (XXX does this still work?)

But, use the GUI and non-blocking version instead. To call it:

send("shell", "render");

See also: shell.v, Chapter 6 on Modal Tools.


clone(name suffix)

Returns: the clone object.
Scope:
cosmic.

Makes a deep copy (object attributes and recursively copying children) of self. The name of all new obejcts have the argument suffix appended.

All attribute values are copied, except for the variables.

[other side effects?]

Example:

This creates a clone of the caller:

new = clone("_evilTwin");

Both of the following two lines do the same thing:

send(new "render"); send(concatenate(get("name"), "_evilTwin"), "render");

See also: Chapter on objects for strategy for copying important variables.


concatenate(argument list)

Returns: combined string.
Scope:
generic.

Returns the string made by all the arguments combination together. Same as concat().

Example:

print(concatenate("1984 was nothing like ", 1984, ".\n"));

Outputs:

1984 was nothing like 1984.
config(x, y [, width, height])

Returns: none.
Scope:
field.

Geometry configuration. Typically used to take care of the "config" message, which is usually caused by window resizing.


copyArea(fromX, fromY, width, height, toX, toY)

Returns: unaffected.
Scope:
field.

Copys a rectangle and paste it at new location within the object's window.


cos(degree)

Returns: cosine at the given degree.
Scope:
generic.

Cosine value at given degree.

See also: sin().


countBCards()

Returns: number of objects in BCardList.
Scope:
stack.

Count the number of objects in the BCardList.

See also: countFCards, BCard, stack.


countChars(string)

Returns: number of characters in string.
Scope:
generic.

Counts the number of characters in string. Alias to strlen().

See also: strlen().


countChildren()

Returns: number of children objects.
Scope:
generic.

Equivalent to objectListCount("children").


countFCards()

Returns: number of objects in FCardList.
Scope:
stack.

Count the number of objects in FCardList. Equivalent to objectListCount("FCardList").

See also: countBCards, FCard, stack.


countItems(string)

Returns: number of items in string.
Scope:
generic.

Comma seperates items.


countLines(string)

Returns: number of lines.
Scope:
generic.

Counts the number of '\n' charcters in the string.


create(attributes list)

Returns: the new object.
Scope:
cosmic.

Creates an object from the list of attributes. The possible attributes depends on the class of the object to be created.

Example:

/* create a ``Hello world'' label */ newObj = create("class", "txtLabel", "name", "hello", "parent", "", /* top level */ "label", "Hello World!", "BGColor", "white", "FGColor", "pink", "BGColor", "grey", "font", "normal", "width", 200, "height", 20); send(newObj, "render");

See also: chapter on objects.


currentChar()

Returns: the character at the cursor point.
Scope:
txtDisp.

The character at the cursor point.

Example:

\name {cctest} \class {txtDisp} \content {abcdefg} \script { if (arg[0] == "buttonRelease") { if (t = currentChar()) { print("currentChar: ", t, ".\n"); } } usual(); } \width {100} \height {100}

See also: currentWord(), currentLine().


currentLine()

Returns: (str) text string.
Scope:
txtDisp.

Returns the line of text which the cursor is on.

Example:

\name {cltest} \class {txtDisp} \content {Line 1 Line 2 Line 3 } \script { if (arg[0] == "buttonRelease") { if (t = currentLine()) { print("currentLine: ", t, ".\n"); } } usual(); } \width {100} \height {100}

See also: currentChar(), currentWord().


currentTag()

Returns: (str) tagged string, or nothing.
Scope:
txtDisp.

Returns the embedded string associated with the character at the cursor point.

Example:

This text field object displays the string "12345".

\name {cttest} \class {txtDisp} \content {1\e(one)234\e(four)5\e(five)} \script { /* If you click on character '1', '4', or '5', you'd get * the corresponding words. */ if (arg[0] == "buttonRelease") { if (es = currentTag()) { print("currentTag: ", es, ".\n"); } else { print("No embedded string detected.\n"); } } usual(); } \width {100} \height {100}

See also: previousTag(), nextTag().


currentWord()

Returns: the word at the cursor point.
Scope:
txtDisp.

The word at the cursor point.

Example:

\name {cwtest} \class {txtDisp} \content {Mary had a little lamb.} \script { if (arg[0] == "buttonRelease") { if (t = currentWord()) print("currentWord: ", t, ".\n"); } usual(); } \width {100} \height {100}

See also: currentChar(), currentLine().


cursorColumn()

Returns: the column number of cursor. -1 if error.
Scope:
txtDisp.

Find out the column of which the cursor is on.

See also: txtDisp, cursorRow().


cursorRow()

Returns: the row number of cursor. -1 if error.
Scope:
txtDisp.

Find out the column of which the cursor is on.

See also: txtDisp, cursorColumn(), cursorRow().


cursorShape(["busy"|"idle"])

Returns: current cursor shape, or "?" if requested shape is not known.
Scope:
generic

Query or Change cursor shape. If no argument is given, the current cursor shape, or "?" is returned.

Recognized cursor shapes are:

"busy"
appears as a watch
"idle"
normal arrow cursor.

Example:

cursorShape("busy"); /* crunch, crunch... */ cursorShape("idle");

Bug

Cursor change is affected only within the window of the method caller.


cycleColors(0|1)

Returns: none.
Scope:
Field.

Cycles the caller object's FGColor, BGColor and BDColor one way or another... Typical use is to provide simple visual feedback for buttons.


date()

Returns: date string.
Scope:
generic.

Sample output: ``Mon Aug 29 21:46:34 PDT 1994''

See also: time().


deHighLight(line number, character count)

Returns: 1 if successful, 0 if error occured.?
Scope:
txtDisp.

De-highlights characters in the line (turns off the REVERSE flag).

Bug

The character count argument is ignored. De-highlights to the end of the line.


debug(option)

Returns: undefined.
Scope:
cosmic.

For debugging purposes. Used to turn on/off various debugging flags.

Options:

pa
print AST right after it's built.
pc
print PCode right after it's built.
pe
PCode execution trace.
dumpPCode
Dump PCode.

Example:

debug("pa");
delay(seconds)

Returns:
Scope: generic.


deleteFile(fileName)

Returns:
Scope: generic.

Deletes file.

the interpreter will not permitted the execution of this method if the calling object's 'security' attribute is non zero.

Example:

deleteFile("junk.txt");
drawCursor()

Returns: undefined.
Scope:
txtDisp.

Draws the text field's cursor, if the attribute ``cursor'' is 1.

See also: txtDisp, eraseCursor().


drawFillOval(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Draws a filled oval that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.

See also: drawOval, eraseFillOval, eraseOval, invertFillOval, invertOval.


drawFillRect(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Fills a fill rectangle that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.


drawLine(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Draws a line from (x0, y0) to (x1, y1). Reference frame in self's window.


drawOval(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Draws oval that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.

See also: drawFillOval, eraseFillOval(), eraseOval, invertFillOval, invertOval.


drawRect(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Draws rectangle that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.


drawText(x, y, fontID, string)

Returns: cleared.
Scope:
field.

Draws text string at (x,y) in the caller's window. The font used is specified in number (lame). You'd have to look it up in res.font.v. The first font listed in res.font is has fontID 0, and so on.

See also: drawText(), invertText(), chapter on resource objects.


environVar(attribute)

Returns: the gotten attribute.
Scope: generic.

Get environment variable.

Example:

homeDir = environVar("HOME");
eraseCursor()

Returns: undefined.
Scope:
txtDisp.

Erases the text field's cursor, if the attribute ``cursor'' is 1.

See also: txtDisp, drawCursor().


drawEraseOval(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Erase a filled oval that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.

See also: drawOval, drawFillOval, eraseOval, invertFillOval, invertOval.


eraseFillRect(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Erases a solid rectangle that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.


eraseLine(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Erases a line from (x0, y0) to (x1, y1). Reference frame in self's window.


eraseOval(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Erases oval that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.

See also: drawFillOval, drawOval, eraseFillOval, invertFillOval, invertOval.


lower()

Returns: 1 if successful, 0 if error occured.
Scope:
field.

Move object to head of list, and visually move window to bottom of window stack.

See also: raise().


eraseText(x, y, fontID, string)

Returns: cleared.
Scope:
field

Erases text (draws with BGColor)string at (x,y) in the caller's window. The font used is specified in number (lame). You'd have to look it up in res.font.v. The first font listed in res.font is has fontID 0, and so on.

See also: drawText(), invertText().


eventMask()
eventMask(mask modifiers)

Returns: the current masks if no argument is given. Otherwise 1 for success, or 0 for failure.
Scope:
field.

Event masks selector. Useful for cutting down overhead of handling messages that an object has no use for.

button1Motion
buttonPress
buttonRelease
enterWindow
keyPress
keyRelease
leaveWindow
mouseMove
exposure

Default event masks are: keyPress keyRelease buttonPress buttonRelease enterWindow leaveWindow leaveWindow button1Motion exposure.

Example:

/* follow the mouse, but loose window enter and leave events */ eventMask("+mouseMove -enterWindow -enterWindow");

See also: txtDisp.


exist(object name)

Returns: 1 if object exists, 0 if not.
Scope:
cosmic.

Checks to see if the named object is instantiated.


exit(code)

Returns: none.
Scope:
cosmic.

Exit program with specified exit value (integer). No automatic saving of objects.

See also: quit().


expose(x, y, width, height)

Returns: cleared.
Scope:
field.

Expose event handling method.

Does almost nothing for field class (internally prepares color context...). But for txtDisp, this method redraws only the text for area that is exposed.

See also: txtDisp.


findPattern(text, pattern)

Returns: position where the matching string pattern ends, or -1 if not found.
Scope:
generic.

String pattern matching.

Example:

print(findPattern("01234", "23"));

Outputs:

3
firstCard()

Returns: first object in FCardList.
Scope:
stack.

First object in FCardList. See stack class for FCardList object list.

See also: nextCard(), lastCard(), stack.


float(int|str|char)

Returns: floating number.
Scope:
generic.

Converts argument to floating point number type.

Example:

x = "57"; y = float(x) * 3.5;

See also: float(), str(), char().


freeSelf()

Returns: unaffected (Untested).
Scope:
cosmic.

Free object attributes and...XXX


get(attribute)

Returns: the attribute value.
Scope:
generic.

Gets the caller object's slot attribute. See the document on individual classes for applicable slots.

To get another object's slot attributes, use the tweak() function to change scope. This kinda tedious, so something like rget() and rset() (remote get and set) will come to being...

Example:

Getting self's attributes...

print("My name is ", get("name"), ".\n");

See also: set(). tweak(), classHierarchy.


getClipBuffer()

Returns: content of the XWindow clip buffer.
Scope: generic.

Fetches the string in the XClipBuffer (buff 0).

See also: setClipBuffer


getCurrentCard()

Returns: current card object.
Scope:
stack.

the ``current'' object in FCardList. See stack class for FCardList object list.

Example:

Take a look at applicaton "roll.v".

See also: stack, setCurrentCard().


getSelection()

Returns: the currently selected data.
Scope:
generic.

See also: setSelection().


getVariable(variabel name)

Returns: variable value.
Scope: generic.

Get a named variable in the object.


highLight(lineNumber, characterCount)

Returns: 1 if successful, 0 if error occured.
Scope: txtDisp.

Highlights characters in the line (turns on the REVERSE flag).

See also: txtDisp.

Bug

Argument characterCount is ignored. Highlights to the end of the line.


info(info flags)

Returns: unaffected.
Scope:
cosmic.

A debugger's friend.

Flags:

listMethods
listNPSlots
listNCSlots
listSlotsRW
listSlotsR
listSlotsW
listAllMethods

Example:

info(); /* spews out all the slot values to stdout */
initialize()

Dignostic purpose.

Returns: unaffected.
Scope: generic.

Initializes object. Typically effected by having an object receive a "init" message. See the classScript. Application script writers should never have to use this -- should be called from the classScript.


input()

Returns: the gotten text.
Scope:
client.

Reads character from a client (via socket or pseudo terminal).

The attribute inDelimStat is affected:

2
if matched with inDelimStr2.
1
If matched with inDelimStr1.
0
Don't use (and if unexpected '\0' is encountered).
-1
If fd is closed (fd == -1).
-2
If fd is if (read() < 1). Are these stats even useful?
-3
If fd is if (read() != 1).

Example:

Inputting self's attributes...

....

See also: inputn(), socket, TTY, classHierarchy.


inputn(n)

Returns: the gotten text.
Scope:
client.

Reads character from a client (via socket or pseudo terminal).

The argument n specifies the number of characters to read from the pipe. If n is more than there is to read, it'll will block (avoid this condition as viola doesn't yet have a way to escape from this).

The attribute inDelimStat is affected:

2
if matched with inDelimStr2.
1
If matched with inDelimStr1.
0
Don't use (and if unexpected '\0' is encountered).
-1
If fd is closed (fd == -1).
-2
If fd is if (read() < 1). Are these stats even useful?
-3
If fd is if (read() != 1).

Example:

Inputting self's attributes...

See also: input(), socket, TTY, classHierarchy.


insert(string)

Returns: undefined.
Scope:
txtDisp.

Inserts text into the text field at the cursor point.

See also: txtDisp.


int(float|str|char)

Returns: integer number.
Scope:
generic.

Converts argument to integer type.

Example:

print(int("2") + 3, '\n');

Output:

5

See also: float(), str(), char().


interpret(script)

Returns: tesult of last statement in script.
Scope:
cosmic.

Interprets the given script string.

the interpreter will not permitted the execution of this method if the calling object's 'security' attribute is non zero.

Example:

interpret("print(loadFile(\"/etc/motd\"));");
invertFillOval(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Inverts the pixels in a filled oval that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.

See also: drawOval, drawFillOval, eraseFillOval, eraseOval, invertOval.


invertFillRect(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Inverts a solid rectangle that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.

See also: drawFillRect(), drawRect(), eraseFillRect().


invertLine(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Invert draws a line from (x0, y0) to (x1, y1). Reference frame in self's window.


invertOval(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Inverts oval that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.

See also: drawOval, drawFillOval. eraseFillOval, eraseOval, invertFillOval.


invertRect(x0, y0, x1, y1)

Returns: unaffected.
Scope:
field.

Inverts rectangle that fits in the given parameters. (x0, y0) defines upper left corner, and (x1, y1) defines the lower right corner.


invertText(x, y, fontID, string)

Returns: cleared.
Scope:
field.

Invert draws text string at (x,y) in the caller's window. The font used is specified in number (lame). You'd have to look it up in res.font.v. The first font listed in res.font is has fontID 0, and so on.

See also: drawText(), eraseText().


isBlank(str)

Returns: 0 (false) or 1 (true).
Scope:
generic.

Determines if the string is more than empty or white space.


key()

Returns: the most recent character in keypress queue.
Scope: generic.

Return the pressed key.


lastCard()

Returns: Last object in FCardList.
Scope:
stack.

Last object in FCardList. See stack class for FCardList object list.

See also: firstCard(), nextCard(), stack.


lineRowOffset()

Returns: the display line offset. -1 if error.
Scope:
txtDisp.

Returns the line offset. Numbering start from 0 (first line displayed).

See also: txtDisp.


listAllObjects()

Returns: undefine.
Scope:

For dianostic purposes. Lists all objects currently loaded (created or otherwise referenced and caused to come to being).


loadFile(fileName)

Returns: file content.
Scope: generic.

Loads and returns content of a file. Error codes???

the interpreter will not permitted the execution of this method if the calling object's 'security' attribute is non zero.

Example:

print(loadFile("/etc/motd")); /* prints MOTD to stdout */

See also: saveFile.


lower()

Returns: 1 if successful, 0 if error occured.
Scope:
field.

Move object to head of list, and visually move window to bottom of window stack.

See also: raise().


makeTempFile()

Returns: unique file path.
Scope:
generic

Makes a temporary file given a file template.

Example:

Sorting content of stuff.

sortFile = makeTempFile("/usr/tmp/XXXXXX"); saveFile(sortFile, stuff); system(concat("sort ", sortFile, " > ", sortFile, ".out")); stuff = loadFile(concat(sortFile, ".out"));
mouse()

Returns: list of two elemenets [0] and [1].
Scope:
field.

Queries the mouse position with respect to the root window.

Example:

pos = mouse(); print("Mouse is at x=", pos[0], " y=", pos[0], "\n");

See also: mouseLocal(), mouseX(), mouseY().


mouseLocal()

Returns: List of two elements 0 and 1.
Scope:
field.

Queries the mouse position with respect to self's window.

Example:

pos = mouseLocal(); print("Mouse is at x=", pos[0], " y=", pos[0], "\n");

See also: mouse(), setMouse().


mouseX()

Returns: x coordinate of mouse's position.
Scope:
field.

Queries the mouse position with respect to the root window, and return the X coordinate.

Example:

print("Mouse is at x=", mouseX(), "\n");

See also: mouse(), mouseY(), mouseLocal(), setMouse().


mouseY()

Returns: y coordinate of mouse's position.
Scope:
field.

Queries the mouse position with respect to the root window, and return the Y coordinate.

Example:

print("Mouse is at y=", mouseY(), "\n");

See also: mouse(), mouseX(), mouseLocal(), setMouse().


nextCard()

Returns: an object in FCardList.
Scope:
stack.

``Next'' object in FCardList. See stack. class for FCardList object list.

See also: firstCard(), lastCard(), stack.


nextTag()

Returns: tagged string, or nothing.
Scope:
txtDisp.

Returns the embedded string associated with the character at the current cursor point. If no embedded string is found here, characters to the right, until the end of the line, is searched.

Example:

This text field object displays the string "12345".

What this demo does: if you click on character '1', you get the string "one". If click on '2', '3' or '4', you get "four". Clicking on '5' gives you "five".

\name {nttest} \class {txtDisp} \content {1\e(one)234\e(four)5\e(five)} \script { if (arg[0] == "buttonRelease") { if (es = nextTag()) { print("nextTag: ", es, ".\n"); } else { print("No embedded string detected.\n"); } } usual(); } \width {100} \height {100}

See also: previousTag(), nextTag().


nthChar(string, n1)
nthChar(string, n1, n2)

Returns: character at n1'th place, or range from n1 to n2.
Scope:
generic.

Example:

print(nthChar("abc", 1));

Outputs:

b

See also: nthItem, nthLine, nthWord.


nthChild(childNumber)

Returns: object.
Scope:
generic.

The n'th object in self's children list.


nthLine(string, n1)
nthLine(string, n1, n2)

Returns: n1'th to n2'th Line(s) in the argument string.
Scope:
generic.

Extracts the specified lines (from line n1 to n2) from the string. Line numbering start from 0.

Example:

print(nthLine("apple pie,\nkiwi soda,\ncherry jam.\n", 1));

Output: kiwi soda,

See also: nthChar, nthItem, nthWord.


nthObjectInList(n, objectList)

Returns: The n'th object in the named object list.
Scope:
generic.

The n'th object in the named object list. Refer to class document for object lists (ie: children, shownNotify...).


nthSibling(n)

Returns: an object.
Scope:
generic.

The n'th object in parent' children list.


nthWord(string, n1)
nthWord(string, n1, n2)

Returns: the word string if successful, or "" if failed.
Scope:
generic

Extracts the specified line(s), at line n1 or from line n1 to n2, from the string. Line numbering start from 0.

Example:

print(nthWord("apple pie, kiwi soda, cherry jam.", 3));

Output;

kiwi

See also: nthChar, nthItem, nthLine.


numberOfLinesDisplayed()

Returns: Number of text lines visible. -1 if error.
Scope:
txtDisp.

Number of text lines that fits into the window, given the current font.

See also: txtDisp.


object(name)

Caution: the object struct pointer is the actual pointer to internal object data structure, as opposed to the string name of the object. Has efficiency benefits, but could raise problems if the object is short lived.

Returns: the named object in object type.
Scope:
cosmic.


objectListAppend(objList, obj)

Returns: object count, -1 if the list is not found.
Scope:
generic.

Append an object to a named object list.


objectListCount(objList)

Returns: object count, -1 if the list is not found.
Scope:
generic.

Count the number of objects in a named object list.


objectListDelete(objList, obj)

Returns: object count, -1 if the list is not found.
Scope:
generic

Delete an object from a named object list.


objectListPrepend(objList, obj)

Returns: object count, -1 if the list is not found.
Scope:
generic.

Prepend an object to a named object list.


objectListSend(objectListName, arg1, arg2, ..., argn)

Returns: undefined.
Scope:
generic.

Send the message to each objects in the object list.


objectPosition(obj, name of obj list)

Returns: Position (starting from 0), -1 if object is not found in list.
Scope:
generic.

Return the position an object in the named object list.

In generic, possible lists are: children


output(str)

Returns: 1 on success, 0 on failure.
Scope:
client.

Outputs characters to a client (via socket or pseudo terminal). The outDelimStr is appended to the output string.

See also: input(), inputn(), socket, TTY, classHierarchy.


previousCard()

Returns: an object in FCardList.
Scope:
stack.

``Previous'' object in FCardList. See stack class for FCardList object list.

See also: firstCard(), lastCard(), stack.


previousCard()

Returns: an object in FCardList.
Scope:
stack.

``Previous'' object in FCardList. See stack class for FCardList object list.

See also: firstCard(), lastCard(), stack.


previousTag()

Returns: tagged string, or nothing.
Scope:
txtDisp.

Returns the embedded string associated with the character at the current cursor point. If no embedded string is found here, characters to the left, until the beginning of the line, is searched.

Example:

This text field object displays the string "12345".

What to expect: If you click on character '1', '2' or '3', you get the string "one". If you click on '4', you get "four". And, clicking on '5' gives you "five".

\name {pttest} \class {txtDisp} \content {1\e(one)234\e(four)5\e(five)} \script { if (arg[0] == "buttonPress") { if (es = previousTag()) { print("previousTag: ", es, ".\n"); } else { print("No embedded string detected.\n"); } } usual(); } \width {100} \height {100}

See also: currentTag(), nextTag().


print(argument list)

Returns: undefined.
Scope:
generic

Prints arguments to stdout.

Example:

print('V', 2, " is verbosely said to be the letter v and numeral two.\n"); Outputs V2 is verbosely said to be the letter v and numeral two.

See also: write(), writeln().


processMouseInput()

Returns: undefined.
Scope:
txtDisp.

Called when mouse events are detected. It takes care of moving cursor to the new position in the text field, and text selection.

See also: txtDisp.


quit()

Returns: undefined.
Scope:
cosmic

Exits program. (BUG: should saves currently loaded objects before exiting. For now, use save() to save objects).

Example:

quit();

See also: exit().


raise()

Returns: 1 if successful, 0 if error occured.
Scope:
field.

Move object to end of list, and visually move window to top of window stack.

See also: lower().


random(seed)

Returns: Random number from 0 to 231 (to 214 on SysV).
Scope:
generic.


render()

Returns: undefined.
Scope:
field.

The standard object rendering method.

Example:

render();

See also: config().


save()

Returns: File name under which the objects were saved in.
Scope:
cosmic.

Saves objects like save(), except that the objects are saved in a file specified by the file path argument (instead of the caller name with ".v" suffix).

Example:

save();

See also: saveAs().


saveAs(filePath)

Returns: File name under which the objects were saved in.
Scope:
cosmic.

Saves objects like save(), except that the objects are saved in a file specified by the file path argument (instead of the caller name with ".v" suffix).

Example:

saveAs("backupPool"); /* save objects into a file "backupPool" */

See also: save().


saveFile(fileName, str)

Returns: 1 if successful, 0 if error occured.
Scope: generic.

Saves and return content of a file.

the interpreter will not permitted the execution of this method if the calling object's 'security' attribute is non zero.

Example:

saveFile("/tmp/foo", "a message for my angel");

See also: loadFile.


send(object, message0, message1, ...)

Returns: Result of executing call object's script.
Scope:
cosmic.

Example:

send("res", "render");

See also: chapter on message passing, tweak().


set(attribute, value)

Returns: The new value.
Scope:
generic.

Set the value of an object attribute. See the class man page for applicable slots in each classes.

Example:

set("name", "foo");

See also: get(), tweak().


setCurrentCard(cardObject)

Returns: current card object.
Scope:
stack.

Sets a pointer to an object in the FCardList. The object is known as the current card.

See also: stack, nextCard(), previousCard(), getCurrentCard().


setMouse(x, y)

Returns: mouse coordinate, relative to root.
Scope: generic.

Warp the mouse position to the specified coordinate.


setSelection(value)

Returns: undefined.
Scope:
generic.

Puts text string in the cut buffer, which can be read by the X-Window cut/paste buffer, and by getSelection().

See also: getSelection().


setVariable(variable name, value)

Returns: Variable value.
Scope: generic.

Set a named variable in the object.


shownDepend()

Returns: undefined.
Scope:
txtDisp.

Sends ``shownInfoV'' (vertical thumb position and position information) to objects (typically a slider) in the "shownDepend" object list.

For example, the slider's thumb size changes if the number of lines in the text field increases, or if its window size decreases...

See also: txtDisp.


sin(degree)

Returns: Sinine at the given degree.
Scope:
generic.

Sine value at given degree.

See also: cos().


sleep(n)

Returns: seconds slept.
Scope: generic.

Do nothing for n seconds.


smudge()

Returns: undefined.
Scope:
field.

Used for visual feedback -- draws a finger print smudge on the caller object's window. Alternative to cycleColors(). Don't take this method seriously.

Example:

... case "buttonPress": smudge(); break; case "buttonRelease": clean(); break; ...

See also: clean(), cycleColors().


str(int|float|char)

Returns: String number.
Scope:
generic.

Converts argument to string type.

See also: float(), str(), char().


strlen(string)

Returns: Number of characters in string.
Scope:
generic.

Counts the number of characters in string.

See also: countChars().


system(command lines)

Returns: Return value from system().
Scope:
generic.

Execute the Unix system() call. The interpreter will not permitted the execution of this method if the calling object's 'security' attribute is non zero.

Example:

system("xclock &");
target()

Returns: (object) Marked object
Scope: generic.

Return the object that was mark()'ed.


time()

Returns: (int) seconds.
Scope: generic.

Returns the elapsed seconds since 00:00:00 GMT, January 1, 1970.

See also: date().


toggle()

Returns: undefined.
Scope:
toggle.

Toggles the object's "toggleState" attributes between 0 and 1. Calls render() as side effect.


tool(toolName)

Returns: current tool.
Scope:
generic.

Select the modal tool. If no argument is given, the name of the current tool is returned.

See also: Chapter 6 on Modal Tools, target(), Chapter 6 on Modal Tools.


totalLineCount()

Returns: Total number of lines in the text field.
Scope:
txtDisp.

Total number of lines in the text field.

See also: txtDisp.


tweak(object, script)

Returns: The last result of interpreting the script argument.
Scope:
cosmic.

Interprets the given script string in context of the specified object. Try not to use this evil method. The interpreter will not permitted execution of this method if calling object's 'security' attribute is non zero.

Don't forget semicolons at the end of statements in the script!

Example:

Tell the object named "stranger" to set a variable, and change its name:

tweak("objStanger", "foo = 10;"); tweak("objStanger", "set(\"name\", \"objBuddy\");");

Make another object think you're its parent:

tweak("objOrphan", concat("set(\"parent\"", get("name"), ");"));
usual()

Returns: undefined.
Scope:
cosmic.

Executes the caller object's classScript. See chapter ____ on more info on the classScript.


version()

Returns: (str) version string.
Scope: generic

Return the Viola version identifier string.


violaPath(str)

Returns: (int) number of paths set.
Scope:
generic.

Set a new path for searching viola object files. The path can also set at start up time using the -path flag. In lieu of -path, the default path comes from the environment variable VIOLA_PATH. In lieu

Example:

violaPath("/usr/tmp/newObjs /usr/lib/viola/objs");
windowName(name)

Returns: window name.
Scope:
field.

Allows you to set a window's name, which is displayed by the window title bar (depending on your window manager). The default window name is the name of the object.

Example:

windowName("Sbiffydyne Application");
windowPosition()

Find the caller window's x and y position in the root window's reference frame.

wp = windowPosition(); print("This window's position is at ", x, ", ", y, "\n");

Returns: two element list ([0],[1]).
Scope:
field.


write(command lines)

Alias to print().

Returns: unaffected.
Scope:
generic.
See also: print().


writeln(command lines)

Same as print(), but also prints a '\n';

Returns: unaffected.
Scope:
generic.
See also: print().