SAS spec
NOTE: an overview of SAS is available here. this page details the spec itself.
@justify left
button 50 50 400 50 I'm a button
label 50 150 400 50 I'm a label
textinput 50 100 400 50 I'm a textinput
[paragraph 80 450 800 200 I'm multi-line text, I'm multi-line text, I'm
multi-line text, I'm multi-line text, I'm multi-line text, I'm multi-line text,
I'm multi-line text, I'm multi-line text, I'm multi-line text, I'm multi-line
text, I'm multi-line text, I'm multi-line text, I'm multi-line text, I'm
multi-line text, I'm multi-line text, I'm multi-line text,]
simple app script is read line by line and parsed. it’s expected that each line contains either a directive or a widget. a widget may span multiple lines if it uses square brackets to enclose itself.
widgets
all widgets are placed using absolute positioning and require their upper left corner and width and height to be passed when creating the widget.
there are several core widgets: label, paragraph, button, textinput, textarea, image, range.
- label displays a single line of text
- paragraph displays multiple lines
- button displays text and can be clicked
- textinput accepts a single line of text as input through the onscreen keyboard
- textarea accepts multiple lines of text as input through the onscreen keyboard
- image displays an image
- range is a slider that lets one select between a low and high integer value
- canvas is a simple area that can be drawn to and is then saved as a png file
a widget can be given an ID by supplying it after the widget type, like
widget:ID
, for example: button:r2
is a button called r2. the labels are
useful for figuring out what buttons or widgets were interacted with.
widgets are specified as their x, y, width and height parameters, followed by zero or more values.
x and y must be an integer or a percentage value or a keyword
w and h must be an integer or a percentage value or a keyword
supported keywords for x and y are:
- same - keep the same value as the previous item
- step - previous item’s coord + the previous item’s size
supported keywords for width and height are:
- w - full width
- h - full height
directives
directives are a way of giving meta-instructions to the simple interpreter, controlling things like the font size, padding and other attributes.
-
noclear: do not clear the screen before drawing to it
-
justify: enum { left, center, right} - affects single line text labels and inputs
-
timeout: int k - quit simple after X seconds if no input is given
-
fontsize: int k - set the fontsize to k for all text elements
output
simple will run until a button is clicked or an input’s value is changed, at which points it prints out the the components’s id and updated value. if a timeout is supplied, simple will exit if there is no input within K seconds
if there are no components that accept input and no timeout is supplied, then simple will exit after drawing to screen.
when a textinput is edited:
input: $id : $value
where $id is the id supplied when creating the textinput
when a button is clicked:
selected: $id
where $id is the id supplied when creating the button or the text of the button if no id is supplied.
contact
want to discuss the spec or implement a backend? see some bugs? get in touch on github! or reach out on discord / reddit