Open Software


codewin

The codewin api defines the codeWindow control.

Requires WIN

 Download codewin

The codeWindow is a multi-line editing window (based on editWindow) with the following features:
 * Custom language definition.
 * Syntax highlighting.
 * Code completion.
 * Code indexing.
 * Auto indenting.
 * Trim end of line spaces.
 * Auto save flag.

The language is defined in a name/value pair file with the following options:

; tab spaces
tab=number

; auto indent on enter
autoindent=boolean

; trim end of line spaces
autotrim=boolean

; auto save
autosave=boolean

; use code completion
autocomplete=boolean

; colors - must be number values
keywords=number
nouns=number
comments=number
strings=number
operators=number
numbers=number

; keywords - as many as needed
keyword=word

; indexes - as many as needed
index=pattern

The codeWindow control has the following methods:

boolean codeWindow:get_auto_indent ()
 Returns the auto indent setting.

nil codeWindow:set_auto_indent (boolean)
 Sets the auto indent setting.

boolean codeWindow:get_auto_trim ()
 Returns the auto trim spaces at end of lines setting.

nil codeWindow:set_auto_trim (boolean)
 Sets the auto trim end of line spaces setting.

boolean codeWindow:get_auto_save ()
 Returns the auto save flag.

nil codeWindow:set_auto_save (boolean)
 Sets the auto save flag.

boolean codeWindow:get_auto_complete ()
 Returns the auto complete setting.

nil codeWindow:set_auto_complete (boolean)
 Sets the auto complete setting.

number codeWindow:get_keyword_color ()
 Returns the definition's keyword color.

number codeWindow:get_noun_color ()
 Returns the definition's noun color.

number codeWindow:get_comment_color ()
 Returns the definition's comment color.

number codeWindow:get_string_color ()
 Returns the definition's string color.

number codeWindow:get_operator_color ()
 Returns the definition's operator color.

number codeWindow:get_number_color ()
 Returns the definition's number color.

boolean codeWindow:load_definition (path)
 Loads the definition from the file at path. Returns true if file was loaded, false if not.

string codeWindow:get_text_with_trim ()
 Returns the full text from the control after stripping end of line spaces if the autotrim setting is set.

table codeWindow:get_indexes ()
 Returns an indexed table with the indexes from the code. Each entry in the returned table has 2 keys;  text and line.
 The text key is a string contains the text from the line matching the index pattern.
 The line key is a number of the line number within the control.
 Typically the text would be displayed to the user as the index, and the line is passed to codeWindow:gotoLine to navigate to the indexed line.

nil codeWindow:goto_line (line)
 Scrolls the contents of the control to bring the given line to the center of the control.

 Download codewin


A part of Open Software