# Cheat sheet

The whole language on one page. Studio's Assistant reads this page too.

## A file

```vi fragment
# a comment runs to the end of the line
<# a comment over
   several lines #>
score = 0                                  # a variable
tasks = [{ name: "Milk", done: false }]    # a list of objects

add_task(name):                            # a function: brackets, then statements
  tasks.add({ name: name, done: false })

main home:                                 # the first screen (one per app)
  arrange: column, center                  # attributes: name: value
  children:                                # what is inside, one per line
    title:                                 # a child written here belongs to home
      text: "Tasks ({tasks.count})"
    task_row                               # a container defined elsewhere, by name

task_row:                                  # a container: name, then attributes
  repeat: task in tasks
  text: task.name
  on_tap: task.done = not task.done
```

## Containers

| Attribute | Example | Notes |
|---|---|---|
| `size` | `size: 50, 20` · `size: 30` · `size: max, auto` | out of 100 of the parent; one number = square |
| `color` | `color: blue[600]` · `rgb(1, 2, 3, 0.5)` · `"#FF0000"` | background; shades 50–900 |
| `shape` | `square` · `rounded` · `circle` | |
| `image` | `image: @photo.jpg, fill, blurred` | `fit` (default) or `fill` |
| `shadow` · `see_through` · `outline` | `shadow: true` · `see_through: 50` · `outline: 2, red` | |
| `flip` · `tilt` · `animate` | `flip: 180` · `tilt: 20` · `animate: 0.3` | degrees · degrees · seconds |
| `visible` | `visible: false` | |
| `text` · `text_style` | `text: "Hi {name}"` · `text_style: 28, bold, white, "Georgia"` | style parts in any order; inherited |
| `arrange` | `arrange: row, bottom right, spread, scroll` | direction, spot, spread (`spread`/`even`), `scroll` |
| `place` | `place: bottom right` · `place: 50, 10` | floats on top, pinned to a spot or a point |
| `space_inside` · `space_between` · `space_around` | `space_inside: 16, top 32` | fixed points; name sides as needed |
| `children` | one per line underneath | inline `name:` blocks or names |
| `repeat` | `repeat: task in tasks` · `repeat: 3, 3` | `index`; `x`, `y` in grids; `cell.at(1, 1)` |
| `button` · `input` · `search` · `icon` · `link` | `button: "Save"` · `input: "Your name"` · `icon: heart` · `link: "https://…"` | an input's text is `name.text` |
| `audio` · `video` | `audio: @song.mp3` · `video: @intro.mp4` | with player controls |

## Events

```vi fragment
card:
  on_tap: open()                 # short action on the line
  on_hold:                       # several actions, one per line
    select()
    play(@pop.mp3)
  on_touch: jump()               # the moment a finger lands (games)
  on_swipe:
    left: next()
    right: back()
  on_hit:                        # two containers start to overlap
    ball, wall: bounce()
name_box:
  input: "Name"
  on_change: check()             # as the person types
  on_submit: save()              # Enter / Done
```

## Logic

```vi fragment
if (score > 10 and not game_over):
  level = 2
else if (score > 5):
  level = 1
else:
  level = 0
color: green if (done) else gray           # inline if, in attributes too
for task in tasks:
  print(task.name)
while (n < 3):
  n = n + 1
```

## Changing things

```vi fragment
title.text = "Done"            # one change: a dot
card:                          # several: the name and a block
  color: green
  see_through: 0
form.name_box.text             # an inside container from outside: through its parent
```

## Built-ins

| Function | Does |
|---|---|
| `print(a, b)` | writes a line |
| `wait(2 seconds)` | pauses this function |
| `random(1, 7)` | 1 to 6 |
| `go_to(screen)` · `go_to(details(task), fade)` · `go_back()` | screens; `slide`, `fade`, `none` |
| `t = every(0.5 seconds, step())` · `stop(t)` | repeat an action |
| `play(@ding.mp3)` · `play(@music.mp3, loop)` · `stop(sounds)` · `play(clip)` · `pause(clip)` · `stop(clip)` | sounds and video |
| `visit("https://…")` | opens a web page |
| `items.add(x)` · `.remove(x)` · `.clear()` · `.count` · `.first` · `.last` · `.has(x)` · `.index(x)` · `items[0]` | lists |
| `phone` · `tablet` · `desktop` | `true` on that size of screen |
| `after(2 seconds, action)` · `pause()` · `play()` | once, later · pause or carry on with everything |
| `load(url)` · `send(url, data)` · `last_error()` | the internet (waits by itself; `empty` on failure) |
| `take_photo()` · `choose_photo()` · `record_sound()` · `my_location()` · `vibrate()` · `notify(text, 10 minutes)` | the phone |
| `share(x)` · `copy(t)` · `paste()` · `call(n)` · `write_email(to, subject, text)` · `open_map(place)` | other apps |
| `now()` · `date(2026, 12, 25)` · `.weekday` · `.ago` · `time_until(d).days` · `now() + 3 days` | dates |
| `.upper` · `.tidy` · `.split(",")` · `.round(2)` · `.commas` · `.money("NGN")` · `.total` · `.average` · `number("42")` | text and number helpers |
| `jump(player)` · `shake(screen, 0.3 seconds)` · `flash(player, red)` | games |
| `focus(box)` · `close_keyboard()` · `reset(score)` | forms · start values |
| `buy(p)` · `owns(p)` · `show_ad()` · `watch_ad()` | purchases and ads |
| `use_theme(dark)` · `dark_mode()` · `use_language(yoruba)` · `announce(text)` | themes, languages, screen readers |

| Write | Means |
|---|---|
| `saved best = 0` · `secret token = ""` · `cloud tasks = []` | kept on the phone · locked away · in the online database |
| `move: arrows` · `gravity: normal` · `solid: true` · `on_key:` | games |
| `layer: top` · `appear: slide_up` · `place: below menu` · `on_back:` | popups and menus |
| `arrange: pages` · `go_to(page)` · `pages.page` | pages and tabs |
| `expects: email` · `limit: 200` · `slider: 0 to 100` | forms |
| `camera: scan` · `map: "Lagos"` · `ad: banner` | other kinds of container |
| `themes:` · `spoken: "Delete"` · `text: { english: "Hi", yoruba: "Bawo" }` | themes, screen readers, languages |

## Projects

- Files live in `src/`; the app starts at `main` in `src/main.vi`. Settings: one `config:` block in
  `src/config.vi` (`name`, `id`, `version`, `icon`, `splash:` with `color`, `logo`, `text`, `seconds`).
- Every file sees every name; no imports between your own files. A name is defined in one file only.
- `@name` is a file in `assets/`: `@icon.png`, `@sounds/jump.mp3`.
- A container written inside another belongs to it; top-level containers are reached from anywhere.
- A container can take values like a function: `card(task):`, shown as `card(tasks[0])`.
- `main hello():` (a function marked `main`) is a console program that prints instead of drawing.
