javalua
Описание
Lua terminal app for J2ME enviroment
Языки
- Java98,8%
- Lua1,2%
javalua
Lua terminal app for J2ME environment
This app allows execution of Lua code on mobile devices supporting MIDLet.
Changes to Lua
require
The function now requires the full path to the library or local path if opened via filebrowser
Added Functions
HTTP and HTTPS Libraries
Both libraries support and methods.
Example
You can set additional headers by passing a table as the second argument:
To use the method, set the :
io.dirs and io.mkdir
returns the list of files and folders at the specified absolute .
Example
creates a new folder at the specified absolute .
Global Functions: sleep and clear
pauses the program for the given duration in milliseconds.sleep(time)clears the screen.clear()
util.u16
util.u16.makeString(array)
Creates a Unicode-16 string from an array of numbers.
- A table containing numbers representing Unicode code points.array
util.u16.dumpString(string)
Returns an array of numbers representing the Unicode code points of a given string.
- The input string.string
json
json.encode(value)
Encodes a Lua value into a JSON string.
- The Lua value to be encoded (can be table, string, number, boolean or nil).value
json.decode(string)
Decodes a JSON string into a Lua value.
- The JSON string to be decoded.string
json.encodefile(filepath, value)
Encodes a Lua value into a JSON string and saves it to a file.
- The path to the file where the JSON data will be saved.filepath- The Lua value to be encoded.value
json.decodefile(filepath)
Decodes a JSON string from a file and returns it as a Lua value.
- The path to the file containing the JSON data.filepath
LCDUI
All functions are within the namespace.
Library Functions
- Returns the terminal object for interacting with the Lua interpreter.enableTerminal()
- Displays adisplay(Displayable, Alternative).Displayable- The element to be displayed.Displayable- Optional element used for display after an Alert timer expires, only used ifAlternativeis anDisplayable.Alert
Alert, Inherits from Displayable
Methods
- Creates a new Alert element.new(title, atext, atype)- The title.title- The description.atext- The alert type (atype).AlertType
Constants
- Alert typeALARM.AlertType.ALARM- Alert typeCONFIRMATION.AlertType.CONFIRMATION- Alert typeERROR.AlertType.ERROR- Alert typeINFO.AlertType.INFO- Alert typeWARNING.AlertType.WARNING- Special value for Alert timeoutFOREVER.Alert.FOREVER
Element Methods
- Returns the current timeout for the Alert.getTimeout()- Sets the timeout for the Alert.setTimeout(time)- Time in milliseconds.time
- Sets the indicator for the Alert.setIndicator(indicator)- Aindicatorelement that will be used as an indicator.Gauge
- Returns the current indicator of the Alert.getIndicator()- Sets the text for the Alert.setString(text)- The string to be displayed in the Alert.text
- Returns the current text of the Alert.getString()
FileChooser, Inherits from Displayable
Methods
- Creates a new FileChooser element and registers a file selection handler.new(handler)- A function called when a file is selected. It accepts two arguments:handler- The path to the selected file.filePath- The path to the directory containing the selected file.directoryPath
List, Inherits from Displayable
Methods
- Creates a new List element.new(title, listType)- The title of the list.title- The type of list (listType,List.EXCLUSIVE,List.IMPLICIT,List.MULTIPLE).List.POPUP
Constants
- List typeIMPLICIT.List.IMPLICIT- List typeEXCLUSIVE.List.EXCLUSIVE- List typeMULTIPLE.List.MULTIPLE- List typePOPUP.List.POPUP
Element Methods
- Adds an element to the list.append(string)- The text of the list item.string
- Sets the selection command for the list.setSelectCommand(command)- Acommandelement used as a selection command.Command
- Deletes a list element by its index.delete(index)- The index of the element to be deleted.index
- Returns the index of the selected element for list typesgetSelectedIndex()orEXCLUSIVE.IMPLICIT- Returns a table of boolean values indicating which elements are selected for agetSelectedFlags()type list.MULTIPLE- Returns the text of the list element by its index.getString(index)- The index of the element.index
- Removes all elements from the list.clear()
Form, Inherits from Displayable
Methods
- Creates a new Form element.new(formname)- The name of the form.formname
Element Methods
- Adds an element to the form.append(element)- Can be a string or anelementtype element.Item
- Removes all elements from the form.deleteAll()- Returns the number of elements in the form.size()- Inserts an element into the form at a specific position.insert(index, element)- The index at which to insert the element.index- Anelementtype element.Item
TextBox, Inherits from Displayable
Methods
- Creates a new TextBox element.new(title, text, maxSize, constraints)- The title of the text box.title- The default text (optional, defaults to an empty string).text- The maximum text size (optional, defaults to 1024).maxSize- The input constraints (optional, defaults to 0).constraints
Element Methods
- Returns the current text from the TextBox.getText()- Sets the text in the TextBox.setText(text)- The new text to set.text
Command
Methods
- Creates a new Command element.new(commandName, commandType, commandPriority)- The name of the command.commandName- The type of command (e.g.,commandType,Command.OK).Command.CANCEL- The priority of the command.commandPriority
Constants
- Command typeBACK.Command.BACK- Command typeCANCEL.Command.CANCEL- Command typeEXIT.Command.EXIT- Command typeHELP.Command.HELP- Command typeITEM.Command.ITEM- Command typeOK.Command.OK- Command typeSCREEN.Command.SCREEN- Command typeSTOP.Command.STOP
Element Methods
- Returns the type of the command.getType()- Returns the name of the command.getLabel()- Checks if two commands are equal.equals(command)- Thecommandelement to compare with. ReturnsCommandif commands are equal, otherwisetrue.false
Gauge Inherits from Item
Methods
Creates a newnew(name, isInteractive, maxValue, defaultValue)element.Gauge- The name of the element.name- A boolean value defining if element is interactive.isInteractive- The maximum value of the scale.maxValue- (optional) The initial value of the scale (defaults to:defaultValue).0
Element Methods
- Sets the current value of the scale.setValue(value)- The new value of the scale.value
- Returns the current value of the scale.getValue()
ChoiceGroup Inherits from Item
Methods
Creates a newnew(label, choiceType)element.ChoiceGroup- The title of the group.label- The type of choice (e.g.,choiceType,Choice.EXCLUSIVE).Choice.MULTIPLE
Constants
- List typeIMPLICIT.ChoiceGroup.IMPLICIT- List typeEXCLUSIVE.ChoiceGroup.EXCLUSIVE- List typeMULTIPLE.ChoiceGroup.MULTIPLE- List typePOPUP.ChoiceGroup.POPUP
Element Methods
-
- Adds a new element to the group.append(string)- The text of the element.string
-
- Deletes an element by index.delete(index)- The index of the element to delete.index
-
- Inserts an element at the specified position.insert(index, string)- The index of the position to insert at.index- The text of the element.string
-
- Changes the text of an element at the specified index.set(index, string)- The index of the element to change.index- The new text.string
-
- Returns the index of the selected element for typesgetSelectedIndex()andEXCLUSIVE.IMPLICIT -
- Sets the selected element by index.setSelectedIndex(index)- The index of the element to select.index
-
- Returns an array of boolean values indicating which elements are selected (for typegetSelectedFlags()).MULTIPLE -
- Sets which elements are selected (for typesetSelectedFlags(flags)).MULTIPLE- Table of boolean values for the setup.flags
-
- Returns the text of an element at the specified index.getString(index)- The index of the element.index
-
- Returns the number of elements in the group.size()
TextField Inherits from Item
Methods
Creates a newnew(name, text, maxSize, constraints)element.TextField- The name of the text field.name- The text displayed by default.text- The maximum length of the text.maxSize- (optional) Input constraints (defaults to:constraints).0
Constants
- ConstraintANY.TextField.ANY- ConstraintCONSTRAINT_MASK.TextField.CONSTRAINT_MASK- ConstraintEMAILADDR.TextField.EMAILADDR- ConstraintNUMERIC.TextField.NUMERIC- ConstraintPASSWORD.TextField.PASSWORD- ConstraintPHONENUMBER.TextField.PHONENUMBER- ConstraintURL.TextField.URL
Element Methods
-
- Sets the text in the field.setText(text)- The new text.text
-
- Returns the current text in the field.getText() -
- Sets the maximum text length.setMaxLength(length)- The maximum length.length
-
- Returns the current maximum text length.getMaxLength() -
- Returns the current position of the caret (cursor).getCaretPosition() -
- Sets the input constraints.setInputConstraints(constraints)- The new constraints.constraints
-
- Returns the current input constraints.getInputConstraints()
StringItem Inherits from Item
Methods
Creates a newnew(label, text, constraints)element.StringItem- The label for the text.label- The text to display.text- (optional) Display mode (defaults to:constraints).0
Element Methods
-
- Returns the current display mode of the element.getAppearanceMode() -
- Sets the text of the element.setText(text)- The new text.text
-
- Returns the current text of the element.getText()
Displayable
Added Methods
-
Adds a command to theaddCommand(command)element.Displayable- Acommandobject.Command
-
Sets the command handler for thesetCommandHandler(handler)element.Displayable-
- A Lua function for handling command events.handler
-
-
Removes the specified command from theremoveCommand(command)element.Displayable- Acommandobject.Command
-
Returns the title of thegetTitle()element.Displayable -
Checks if twoequals(otherDisplayable)elements are equal.Displayable- The second element for comparison.otherDisplayable
Item
Added Methods
-
Sets the default command for thesetDefaultCommand(command)element.Item- Acommandobject.Command
-
Sets the command handler for thesetCommandListener(listener)element.Item-
- A Lua function for handling command events.listener
-
-
Returns the class name of thegetClassName()element.Item -
Returns the current layout of thegetLayout()element.Item -
Sets the layout for thesetLayout(layout)element.Item- An integer defining the layout.layout
-
Returns the current label of thegetLabel()element.Item -
Sets the label for thesetLabel(label)element.Item- The new label.label
-
Checks if twoequals(otherItem)elements are equal.Item- The second element for comparison.otherItem
Constants
- Element typeBUTTON.Item.BUTTON- Element typeHYPERLINK.Item.HYPERLINK- LayoutLAYOUT_2.Item.LAYOUT_2- LayoutLAYOUT_BOTTOM.Item.LAYOUT_BOTTOM- LayoutLAYOUT_CENTER.Item.LAYOUT_CENTER- LayoutLAYOUT_DEFAULT.Item.LAYOUT_DEFAULT- LayoutLAYOUT_EXPAND.Item.LAYOUT_EXPAND- LayoutLAYOUT_LEFT.Item.LAYOUT_LEFT- LayoutLAYOUT_NEWLINE_AFTER.Item.LAYOUT_NEWLINE_AFTER- LayoutLAYOUT_NEWLINE_BEFORE.Item.LAYOUT_NEWLINE_BEFORE- LayoutLAYOUT_RIGHT.Item.LAYOUT_RIGHT- LayoutLAYOUT_SHRINK.Item.LAYOUT_SHRINK- LayoutLAYOUT_TOP.Item.LAYOUT_TOP- LayoutLAYOUT_VCENTER.Item.LAYOUT_VCENTER- LayoutLAYOUT_VEXPAND.Item.LAYOUT_VEXPAND- LayoutLAYOUT_VSHRINK.Item.LAYOUT_VSHRINK- Element typePLAIN.Item.PLAIN