User:PythonshellDebugwindow/GUI Display Language

From Esolang
Jump to navigation Jump to search

GUI Display Language is an esolang created by User:PythonshellDebugwindow. Its primary use is making GUIs.

Logic

An indentation of 1 space to denote blocks is optional, but is better legible

  • IF-EXECUTE-ELSE-EXECUTE-FIN
  • WHILE-RUN-FIN
  • IF-EXECUTE-FIN
  • IF-EXECUTE-CASE-EXECUTE-FIN (like if/else-if)
  • IF-EXECUTE-CASE-EXECUTE-ELSE-EXECUTE-FIN (like if/else-if/else)
  • FOR-INCLUDES-EXECUTE-REPEAT (used mainly for variadic args; syntax is FOR !varargs INCLUDES @iteration-variable EXECUTE \ncode\n REPEAT)

Textbox and Textline

Textbox is input. Textline is display (output).

textbox (!top-left-x, !top-left-y, !top-right-x, !top-right-y, !bottom-left-x, !bottom-left-y, !bottom-right-x, !bottom-right-y)
textline (!top-left-x, !top-left-y, !top-right-x, !top-right-y, !bottom-left-x, !bottom-left-y, !bottom-right-x, !bottom-right-y)

Events

Event listeners can be set: on-tb-change and on-tb-enter.

on-tb-change (!handler-function, !!path-to-tb)
on-tb-enter (!handler-function, !!path-to-tb)

Here are the events.

  • Press any key with a textbox selected to trigger on-tb-change for the selected textbox.
  • Press enter with a textbox selected to trigger on-tb-enter for the selected textbox.

Other

Tilde (~) starts a line comment. At (@) denotes a variable. Exclamation mark (!) denotes a function argument. Two exclamation marks (!!) before an argument in a function means variadic args (the argument is multiple of them?). Backquote (`) denotes a function (also variable), body is wrapped in "double quotes" for single-line and ""double double quotes"" for multi-line. Section sign (§) represents the null value.

More

Equality operator is $$.

Examples

Hello World

@tb = textbox(100, 100, 300, 100, 100, 300, 300, 300)
@d = display(400, 400, @tb)
tb-write('Hello World', @d, @tb)
render(@d, @tb, @tl)

Infinite live cat program

@tb = textbox(100, 50, 300, 50, 200, 150, 300, 150) ~200 by 100
@tl = textline(100, 250, 300, 250, 100, 350, 300, 350) ~200 by 100
@d = display(400, 400, @tb, 2tl)
`copy () ""
tl-clear(@d, @tb)
tl-write(tb-read(@d, @tb), @d, @tl)
""
on-tb-change(`copy, @d, @tb)
render(@d, @tb, @tl)

Truth-machine

Shows off IF-EXECUTE-ELSE-EXECUTE-FIN and WHILE-RUN-FIN logic.

@has-entered = '0'
@tb = textbox(100, 50, 300, 50, 200, 150, 300, 150) ~200 by 100
@tl = textline(100, 250, 300, 250, 100, 350, 300, 350) ~200 by 100
`truth () ""
IF @has-entered $$ '0' EXECUTE
 IF tb-read(@d, @tb) $$ '1' EXECUTE
  WHILE '1' $$ '1' RUN
   tl-write('1', @d, @tb)
  FIN
 ELSE EXECUTE
  tl-write('0', @d, @tb)
 FIN
ELSE EXECUTE
 @has-entered = '1'
FIN
""
on-tb-change(`truth, @d, @tb)
render(@d, @tb, @tl)

Standard libraries

ArrayLib.guidl

`array (!!items) "items"
`len (!arr) ""
@count = 0
FOR !arr INCLUDES @i EXECUTE
 @count = inc(@count)
REPEAT
@count
""
`array-at (!arr, !idx) ""
@item = §
@i = 0
FOR !arr INCLUDES @x EXECUTE
 IF @i $$ !idx EXECUTE
  @item = x
 FIN
 @i = inc(@i)
REPEAT
@item
""
`arr-cat-item (!arr, !item) "array(!!arr, item)"

To include its functions and use them:

@* = include("ArrayLib")
@two = array-at(array(1, 2, 3), 1)
`str-to-array (!str) "array(!!str)"
    • todo: set-arr-item (arr, i, x) -> arr[:i] + [x] + arr[i + 1:]

Jumplang interpreter

The function takes code as a string and a display and textline for output (no input here). Numeric output. UB if CP<0. [WIP]

@* = include("ArrayLib")
`brainfuck (!code, @d-out, @tb-out) ""
@cells = array(0)
@cp = 0

FOR str-to-array(!code) INCLUDES @c EXECUTE
 IF @c $$ '+' EXECUTE
 CASE @c $$ '-' EXECUTE
 CASE @c $$ '<' EXECUTE
  @cp = dec(@cp)
 CASE @c $$ '>' EXECUTE
  @cp = inc(@p)
  IF @cp $$ len(@cells) EXECUTE
   @cells = arr-cat-item(@cells, 0)
  FIN
 CASE @c $$ '.' EXECUTE
  tb-write(array-at(@cells, @cp), @d-out, @tb-out)
 CASE @c $$ '?' EXECUTE
 CASE @c $$ '!' EXECUTE
 FIN
REPEAT
""