Skip to content
raziman edited this page Feb 20, 2021 · 3 revisions

Module

For now, gomu only has three modules Keybinds, Event and List. We will add more module to the language when it is needed.

List

List module contains useful functions for List.

module List {
    func collect(list, func(T) V)
    func reduce(list, V, func(T) V)
    func filter(list, func(T) bool)
}

Example:

ls = [1, 2, 3]

println(List.map(ls, func(x) { x + 100 })) // [101, 102, 103]

Event

Event module provides interface to subscribe to an event that is emitted by gomu. With this, you can execute a function which will be called once the event happens. Event module has two functions add_hook and run_hooks and both accept callback function.

// execute function when you enter gomu
Event.add_hook("enter", func() {
    info_popup("Welcome back !")
})

// force run all hooks of an event
Event.run_hooks("new_song")

Below is the list of events that you can subscribe to.

  • enter
  • new_song
  • skip
  • play
  • pause
  • exit

REPL

You also can use built-in REPL to test and try anko script. The REPL is bounded to m keybind.

![](./repl.png =550x)

Built-ins

> range(min[,max[,step]])

range with 1 argument returns list of [0..max]

range with 2 argument returns list of [min..max]

range with 3 argument returns list of [min, step..max]

> keys(map)

keys returns keys of type map.

> type_of(interface{})

type_of returns type of a value. It uses reflect.ValueOf under the hood.

> kind_of(interface{})

kind_of returns kind of a value. It uses reflect.KindOf under the hood.

> defined(string)

defined returns true if symbol is defined.

> load(string)

load loads other anko script.

> print(interface{}...)

Same as Go's print

> prinln(interface{}...)

Same as Go's println

> printf(interface{}...)

Same as Go's printf

> debug_popup(interface{}...)

Shows debug popup and log debug info. Mainly used when scripting.

> info_popup(string)

Shows info popup and does not log anything. Prefer this when making simple popup.

> input_popup(string, func(string))

Ask input from user and handle input string with callback.

> show_popup(string, string)

Popup with title and description. Does not log anything.

> search_popup([]interface{}, func(T))

Opens finder interface and waits for input from user. Handles result in callback.

> shell(string)

Execute shell command and returns stdout and stderr output.