fix types for ARM support; fix errno handling; minor fixes; license GPL3 or later fix
[guish.git] / man / guish.1
blobf99831826d59f9fb7ebd041a8cfe0f2d052c10de
1 .TH "guish" "1" 
2 .SH NAME
3 .BR
4 .P
5 guish - A language to make and modify GUIs
7 .SH SYNOPSIS
8 .BR
9 .P
10 .B guish 
11 [\fB-c\fR <code>][\fB-s\fR][\fB-q\fR][\fB-k\fR][\fB-t\fR][\fB-f\fR][\fB-v\fR][\fB-b\fR][\fB-h\fR][<file>][<arguments>]
14 .SH DESCRIPTION
15 .BR
17 .B guish
18 is a language to create and modify GUIs; it can be used to tie different programs together by embedding, or to make simple GUIs.
20 This is version 2.x, which depends just on Xlib as all toolkits have been removed (there are some optional dependencies).
22 .SH OPTIONS
23 .BR
25 .TP
26 .B -c <code>
27 read and execute commands from command line.
28 .TP
29 .B -s
30 display elements when created.
31 .TP
32 .B -q
33 quit when closing last element/window.
34 .TP
35 .B -k
36 terminate all external programs when quitting.
37 .TP
38 .B -t
39 fallback on tty after reading data from other inputs.
40 .TP
41 .B -f
42 show available X11 fonts.
43 .TP
44 .B -v
45 show version.
46 .TP
47 .B -b
48 show build (compiled in) options.
49 .TP
50 .B -h
51 guess.
53 .SH INPUTS AND SOURCES
54 .BR
56 guish reads commands from multiple source sequentially; these source are:
57 command line (with \fB-c\fR option), file, standard input, and if \fB-t\fR option is given, controlling terminal. 
58 After reading commands from a source, it tries to switch to another one, and when there are no more sources, it simply stays idle.
60 After executing from file or command line or standard input,
61 then finally it switchs to controlling terminal (if \fB-t\fR option is given)
62 and executes from there.
64 If the file given is a named pipe, then
65 it will be opened in non-blocking mode, allowing to issue
66 commands from the other end of the pipe.
68 .SH SYNTAX OVERVIEW
69 .BR
71 Being a command interpreter, guish has a little set of syntax rules. 
72 They comprises expressions, commands, quotes and special operators.
73 Generic commands and signals are common to all elements,
74 while there are ones which are specific to each element.
75 A phrase is the execution unit, and ends if
76 the program encounters a newline-like character, or a semicolon (";").
78 .SS Comments
79 .BR
81 Single line comments begin with a \fB#\fR, and end at newline like character:
83 .EX
84  a = 4 # this is a comment
85 .EE
87 Multiline comments instead are embedded inside \fB#[\fR and \fB]#\fR (or
88 end at the end of source):
90 .EX
91  a = 4 #[ This,
92  is a multiline comment,
93  ending here. ]# puts "a: @{a}"
94 .EE
96 .SS Elements and element expressions
97 .BR
99 Elements are basically widgets and have some commands and signals associated with them;
100 they can be created using element expressions, enclosing element name within
101 \fB||\fR:
104  |b|+
107 In this example, "|b|" is an expression which creates an element
108 of type button, and returns its X11 window id (ex, "65011718").
110 The \fB+\fR command will then show the button (all elements are hidden by default
111 unless \fB-s\fR option is given).
113 .SS Subject and implied subject
116 To refer to the last created/modified element, you can use
117 it without naming it explicitly, for example:
120  |i|;+
123 The "+" command will by applied to element created
124 by "|i|" expression automatically.
126 .SS Variables and variable substitution
130 We can refer to elements by using variable substitution, instead of using their window ids:
133  bt = |b|
136 and then:
138  @bt < "new button"
141 .SS Commands
145 Commands instead can be of three distinct types: special, generic and normal.
147 Special commands are meant to change guish behaviour, generic ones are meant to modify an element of any type and normal ones are for a specific element type (every element can have specialized commands).
149 .SS Signals
153 Signals make it possible to run actions on UI changes (or,
154 more generally, on some events).
157  |b|=>c{run free}
160 Here, the user creates a button
161 that when clicked will make guish execute a system command (free in this case)
162 (see \fBrun\fR in SPECIAL COMMANDS).
165  |b|<generator =>c{|b|<clone}
168 A button which is a factory of buttons (run this with \fB-s\fR option).
170 Here the evaluation of the code block is done when
171 the click signal is triggered.
173 .SS Scopes and closures
176 All variables (functions too, as blocks can be assigned to variables) have a specific scope:
179  a = 1
180  {b = 2}()
181  puts "@{a}:@{b}"
184 Here the variable "a" is defined in the global scope, while
185 "b" is defined in a temporarily block scope; hence just "a"
186 is printed to stdout.
188 When accessing reading/defining a variable in a local scope, if
189 the variable is already defined in the enclosing scope
190 then that variable is picked to be read/modified:
193  a = 1
195      a = 5
196      puts@a
197  }()
198  puts@a
201 Here "a" is defined in the global scope, then modified from block scope
202 and printed from there, and its value doesn't change.
204 If a variable is defined inside a block, then
205 all embedded blocks that reference that variable
206 will get its value at definition time (a closure):
210      a = 1
211      return {
212          puts @a
213      }
214  }()()
217 .SS Quotes, blocks and functions
221 There are single and double quoting: anything embedded inside
222 single quotes '', is treated literally (no escaping takes place) and as a single token. 
224 Variable and function interpolations (respectively via "\fB@{...}\fR" and "\fB@(...)\fR")
225 are used inside double quotes "", external command substitution quotes ``
226 and external window id substitution \fB<(...)\fR.
228 Escaping ("\\n\\t\\r\\f\\v\\b") takes place only inside double quotes "".
231  a = 'my string'; puts "this is:\t @{a}"
232  puts "sum of 1 + 5 is: @(add(1, 5))"
235 Anything embedded inside \fB{}\fR is treated as a code block
236 and no variable substitution is done at definition time.
238 To "execute" a block, simply use parens \fB()\fR.
239 If arguments are given, they can be referenced inside block by using \fB@n\fR, where "n" is a number
240 which represents a specific argument by position, with indexes starting at 1 (works with command line parameters too).
241 To refer to all arguments (at once) given to the block use \fB@*\fR operator
242 (when in string interpolation, argument separator is a space).
245  v = myvar
246  a = {puts "here is @{v}"}
247  a()
250 Here the variable "v" is not substituted when assigning the block
251 to "a"; it's substituted later, when function "a" is called.
255      puts join("string length is: ", len(@1))
256  }("home")
259 Here instead, the block is defined and executed immediately, using "home"
260 as the first argument.
262 Being a block a piece of code, it can be used to define functions
263 by simply being assigned to a variable:
266  fn = {return add(@1, @2)}
267  puts join("my func res:", fn(2, 4)) 
270 In addition, when defining a new function, it's possible
271 to "overwrite" the builtin functions in the current scope.
273 When returning from a function, instead, it's possible to
274 return multiple arguments (the remaining phrase) to the caller:
277  fn = {return 1 2 3}
278  puts join(fn())
281 .SS Conditionals
284 Anything equal to 0, "0" or empty (like \fB''\fR, \fB""\fR, \fB{}\fR) is false, true otherwise.
285 This is useful with \fBif\fR and \fBelse\fR commands:
288  if 1 { |b|<text } else { |b|<neverhere }
292  if ge(@a,4) { |l|<4 }
295 .SS Loops and iteration
298 Here an example of a \fBwhile\fR loop:
301  a = 1
302  after 4 {a = 0}
303  while {eq(@a, 1)} {
304      wait 1 puts 'true'
306  puts 'end'
309 And here another one using \fBeach\fR function:
312  each({puts @1}, 1, 2, 3, 4, 5})
315 And another one of a \fBfor\fR loop:
318  for x in 1 2 3 4: { puts @x }
321 .SS Tail recursion optimization (TCO)
324 Since \fB2.2.1\fR version, guish supports tail recursion optimization too,
325 effectively turning a tail recursive function into a loop:
328  upto = {
329      if gt(@1, @2) {
330          return
331      }
332      puts @1
333      return upto(add(@1, 1), @2)
335  upto(1, 7)
338 To use TCO, the last phrase of a function must use \fBreturn\fF command
339 directly (not inside another block like if-else).
341 .SS External window id substitution
344 Everything inside \fB<( )\fR is recognized as an
345 external command (X11 GUI), forked and executed, and its window id
346 is substituted (using _NET_WM_PID).
348 Note that this method will not work with programs that fork.
350 For example:
353  a = <(xterm)
356 xterm program is spawn, and can be driven (almost) like
357 a normal element.
359 .SS External command substitution
362 Everything inside \fB``\fR is recognized as an
363 external command and executed.
364 Then the command output (STDOUT) is substituted inside
365 source code and interpreted after that.
367 For example:
370  |b|<`echo clickme`
373 .SS Slicing
376 Anything inside \fB[]\fR  is trated as a slice expression.
377 The usage is \fB[<n>[,<x>]]\fR, when <n> is an index, and <x>
378 is an optional end index (always inclusive); if the preceding
379 argument is a regular token, then the expression will return
380 its characters as specified by index(es), otherwise if it's
381 a block, the expression will return its tokens:
384  puts {1, 2, 3, 4, {a, b}, cat}[4][1]
387 The output of this example is 'b'.
389 If the index(es) given are out of range, an empty token
390 is returned.
392 .SH SPECIAL VARIABLES
396 .B SW
397 primary screen width, in pixels.
399 .B SH
400 primary screen height, in pixels.
402 .B X
403 pointer's x coord.
405 .B Y
406 pointer's y coord.
408 .B self
409 variable holding the window id when in signal code.
411 .B args
412 refers to the block in which there are positional arguments and
413 function arguments (alternative syntax).
415 .B FILE
416 variable holding the path of current source file.
418 .B LINE
419 variable holding current line number at "that" point in source code.
421 .SH ENVIRONMENT VARIABLES
425 .B GUISH_MAXWIDWAIT
426 the maximum number of seconds to wait when applying external window id substitution
427 (defaults to 3 seconds)
429 .SH ELEMENTS
433 Available elements are:
436 .B b
437 A button.
439 .B i
440 An input box.
442 .B l
443 A label.
445 .B p
446 A page (container of other elements; show and hide are applied to all subelements).
448 .B c
449 A checkbox.
451 .B t
452 A label with a totally transparent background (requires a compositor).
454 .SH SPECIAL COMMANDS
457 Special commands are not tied to elements, they are like statements.
460 .B => <signal> <subcmd> 
461 register a sub-command <subcmd> to run when <signal> triggers.
462 For normal signals (eg. signals tied to elements), there must
463 exist an implied subject.
465 .B !> <signal>
466 unregister a sub-command <subcmd> previously registered on signal <signal>.
468 .B q
469 quit guish (exit status 0).
471 .B exit <status>
472 quit guish (exit status <status>).
474 .B cd <path>
475 change current working directory using <path>.
477 .B run <cmd>
478 execute shell command <cmd>.
480 .B puts [<...>]
481 prints remaining phrase to stdout with a newline added.
483 .B p [<...>]
484 prints remaining phrase to stdout.
486 .B e [<...>]
487 prints remaining phrase to stderr.
489 .B unset <name|num|wid> [<attr>]
490 unsets a variable (<name>) or timed scheduled procedure registered with <num>, see
491 .B every
492 command.
493 If, instead of <name|num>, an element id <wid> is given and
494 a name attribute <attr> is given, deletes that element attribute.
496 .B source <file>
497 execute commands from file.
499 .B vars [<wid>]
500 shows all variables present in the current scope or,
501 if <wid> element id is given, shows all element attributes
502 (uses stderr).
504 .B ls
505 display all existing widgets (stderr).
507 .B del <wid>
508 delete a widget with id <wid>.
510 .B every <seconds> <block>
511 schedule <code> to run after <seconds> seconds are elapsed.
513 .B after <seconds> <block>
514 schedule <block> to run once after <seconds> seconds are elapsed.
516 .B wait <seconds>
517 stop command execution and wait <seconds> seconds before resuming (accepts decimal values too).
518 XEvent handling, schedules actions and signal execution are unaffected by this option.
520 .B if <condition> <block>
521 executes <block> if condition evaluates to true (see Conditionals).
523 .B unless <condition> <block>
524 executes <block> if condition evaluates to false (see Conditionals).
526 .B else <block>
527 executes <block> if last conditional command was successful (see Conditionals).
529 .B return <phrase>
530 when used inside a function, returns all its arguments (the remaining phrase)
531 to the caller.
533 .B while <condition> <block>
534 executes <block> until <condition> evaluates to true (see Conditionals).
536 .B until <condition> <block>
537 executes <block> until <condition> evaluates to true (see Conditionals).
539 .B for [<var1>, <var2>, ...] in [<val1>, <val2>, ...] : <block>
540 executes the block <block> for each group of variables.
542 .B break
543 exit from current loop.
545 .B rel <element1> <element2> <alignment>
546 relates <element1> to <element2>, moving <element1> near <element2> using <alignment> (see alignment in STYLE AND ATTRIBUTES
547 section, as <alignment> opts are similar) every time <element2> is moved.
548 If "0" is specified as alignment, the relation is deleted.
550 .B pass [<args>]
551 do nothing, consuming remaining arguments.
553 .B send <wid> <keysequence>
554 send a keysequence to an element whose id si <wid> (must be enabled at compilation time).
556 .B ctrl <wid> <keysequence>
557 send control key sequence to an element whose id si <wid> (must be enabled at compilation time).
559 .SH GENERIC COMMANDS
562 Generic commands are applicable to any element, regardless
563 of its type (there are exceptions though).
566 .B G
567 element is undetectable in taskbar.
569 .B F
570 resize the element to fit the entire screen.
572 .B d
573 restore element's default window attributes.
575 .B !
576 bypass window manager.
578 .B !!
579 follow window manager as default.
581 .B n
582 center element in its parent.
584 .B -
585 hide element.
587 .B +
588 show element.
590 .B c
591 click element.
593 .B f
594 focus element.
596 .B t
597 make element stay at top.
599 .B b
600 make element stay at bottom.
602 .B x
603 hide element, or quit guish if quit-on-last-close is on and the element is the last closed one.
605 .B l
606 lower the element.
608 .B r
609 raise the element.
611 .B M
612 maximize the element.
614 .B D
615 disable the element.
617 .B E
618 enable the element.
620 .B o
621 fits element's size to its content.
623 .B w
624 resize an element in right-bottom directions to fit its parent, respecting limits of other elements.
626 .B nfill
627 resize an element in right-bottom directions to fit its parent.
629 .B rfill
630 resize an element in right direction to fit its parent, respecting limits of other elements.
632 .B nrfill
633 resize an element in right direction to fit its parent.
635 .B bfill
636 resize an element in bottom direction to fit its parent, respecting limits of other elements.
638 .B nbfill
639 resize an element in bottom direction to fit its parent.
641 .B L
642 clear element's data.
644 .B : <title>
645 set element title.
647 .B s <text>
648 set element style (see STYLE AND ATTRIBUTES section).
650 .B z <w> <h>
651 resize element by width and height.
653 .B m <x> <y>
654 move element to coords <x> <y>.
656 .B / [<l|L|a|A|p|x|n> [<...>]]
657 draws/fills lines, points and arcs depending on operation (See Drawing operations subsection).
658 Origin coordinates correspond to the bottom-left corner as default Cartesian axes
659  (instead of upper-left one used for windows/elements).
660 If no operation is given, then all drawings are discarded from the implied element.
662 .B A <element> <alignment>
663 moves implied element to <element> using <alignment> (see alignment in STYLE
664 AND ATTRIBUTES section, as <alignment> opts are similar).
666 .B < <text>
667 set element text using <text>.
669 .B <+ <text>
670 add additional text to element text using <text>.
672 .B > <var>
673 define a variable named <var> using element text to set its value.
675 .B g
676 enable/disable (toggle) moving the parent of the element by click-and-drag it.
677 Enabling this will automatically exclude x/y moving flags below.
679 .B X
680 enable/disable (toggle) moving an element inside its parent by click-and-drag on x axis
681 Enabling this will automatically exclude the flag to click-and-drag and move parent.
683 .B Y
684 enable/disable (toggle) moving an element inside its parent by click-and-drag on y axis
685 Enabling this will automatically exclude the flag to click-and-drag and move parent.
687 .SS Drawing operations
692 .B l [<color> <x1> <y1> <x2> <y2> [<...>]]
693 draws lines between given points using color <color> (beware this command consumes all the phrase).
694 If no arguments are given, then all element lines are discarded.
696 .B L [<color> <x1> <y1> <x2> <y2> [<...>]]
697 fills the polygon described by given points using color <color> (beware this command consumes all the phrase).
698 If no arguments are given, then all filled polygons are discarded.
700 .B a [<color> <x> <y> <w> <h> <alpha> <beta> [<...>]]
701 draws an arc using color <color> and whose "center" is at <x> <y>, major and minor axes are respectively
702 <w> and <h>, start and stop angles are <alpha> and <beta> (consumes all the phrase).
703 If no arguments are given, then all element arcs are discarded.
705 .B A [<color> <x> <y> <w> <h> <alpha> <beta> [<...>]]
706 fills an arc using color <color> and whose "center" is at <x> <y>, major and minor axes are respectively
707 <w> and <h>, start and stop angles are <alpha> and <beta> (consumes all the phrase).
708 If no arguments are given, then all element arcs are discarded.
710 .B p [<color> [<...>]]
711 draws given points using color <color> (beware this command consumes all the phrase).
712 If no arguments are given, then all points are discarded.
714 .B x [<color> [<...>]]
715 draws given pixels using color <color> (beware this command consumes all the phrase).
716 If no arguments are given, then all pixels are discarded.
718 .B n [<color> <name> <x> <y>]
719 draws given point using color <color> and putting the text <name> at that point.
720 If no arguments are given, then all points are discarded.
722 .SH NORMAL COMMANDS
726 .SS checkbox commands
728 .B C
729 check.
731 .B U
732 uncheck.
734 .SS input commands
736 .B S
737 show input data as normal while typing.
739 .B H
740 hide input data while typing.
742 .B P
743 use password mode, displaying just asterisks.
745 .B W
746 toggles "go to the next line" when hitting return (triggers return signal anyway).
748 .SS page commands
750 .B Q
751 make subelements equals (in size).
753 .B S <style>
754 style all subelements.
756 .B P
757 free all embedded elements.
759 .B << <element>
760 embeds element (or an external client).
762 .B <<< <element>
763 embeds element (or an external client), fitting the page to its content.
765 .B >> <element>
766 free element, reparenting it to root window.
768 .B >>> <element>
769 free element, reparenting it to root window and fitting the page to its content.
771 .B v
772 set vertical layout readjusting all subwidgets.
774 .B h
775 set horizontal layout readjusting all subwidgets.
777 .B Z <e1> <e2>
778 swaps sub-elements position.
780 .B N
781 inverts the order of sub-elements.
783 .SH SPECIAL SIGNALS
788 Special signals are independent from elements, and are tied to internal guish events.
791 .B q
792 triggered at program exit.
794 .B t
795 triggered when program receives a SIGINT or a SIGTERM.
797 .SH GENERIC SIGNALS
802 Generic signals are common to all elements.
805 .B x
806 triggered when element is closed.
808 .B c
809 triggered when element is clicked.
811 .B lc
812 triggered when element is left-clicked.
814 .B rc
815 triggered when element is right-clicked.
817 .B mc
818 triggered when element is middle-clicked.
820 .B cc
821 triggered when element is double clicked.
823 .B lcc
824 triggered when element is double left-clicked.
826 .B rcc
827 triggered when element is double right-clicked.
829 .B mcc
830 triggered when element is double middle-clicked.
832 .B p
833 triggered when element is pressed.
835 .B lp
836 triggered when element is left-pressed.
838 .B rp
839 triggered when element is right-pressed.
841 .B mp
842 triggered when element is middle-pressed.
844 .B r
845 triggered when element is released.
847 .B lr
848 triggered when element is left-released.
850 .B rr
851 triggered when element is right-released.
853 .B mr
854 triggered when element is middle-released.
856 .B m
857 triggered when element is moved.
859 .B s
860 triggered when element scrolled down.
862 .B S
863 triggered when element scrolled up.
865 .B z
866 triggered when element is resized.
868 .B e
869 triggered when mouse pointer "enters" the element.
871 .B l
872 triggered when mouse pointer "leaves" the element.
874 .B f
875 triggered when focusing the element.
877 .B u
878 triggered when un-focusing the element.
880 .SH NORMAL SIGNALS
885 Normal signals are per element.
888 .SS checkbox signals
890 .B U
891 triggered when checkbox is unchecked.
893 .B C
894 triggered when checkbox is checked.
896 .SS input signals
898 .B R
899 triggered when input has focus and "return" is hit.
901 .SH REDUNDANT TOKENS
904 These tokens are ignored: "\fB,\fR", "\fB->\fR".
906 .SH EVALUATION ORDER AND SUBSTITUTIONS
910 Every time a new phrase is evaluated, it goes through
911 a series of special substitutions/evaluations before it's commands
912 are interpreted.
914 The evaluation order is: hex substitution (at tokenizer level), evaluation of expressions
915 (where code evaluation/execution, substitutions and functions are computed),
916 evaluation of special commands and execution of generic/normal commands.
918 Moreover if after the execution phase (the last one) the phrase is not empty,
919 the evaluation cycle will restart from evaluation of expressions phase,
920 and it will continue until there are no more tokens in the phrase.
922 Every phrase is reduced to an empty phrase while evaluating:
925  a=234;{i1=|i|;<'input1'+}();{i2=|i|;<'input2'+}()|b|<btn+
928 This example is composed by 2 phrases, and
929 the code block in each phrase is executed before each assignment.
931 .SS Hex substitution
935 Non quoted tokens are subject to hex substitution: if a "\\x" plus 2 hexadecimal characters is found, it's substituted with corresponding ascii characters.
938  puts \\x68\\x6F\\x6D\\x65
941 Here, the string "home" is printed.
943 .SS Globbing
946 If a "\fB*\fR" is given, then all widgets wids are
947 substituted.
950  |b||b||b|+
951  puts *
954 .SS Variable substitution
957 With the \fB=\fR operator (actually, it's a special statement command), it's possible
958 to assign values to a variable, reusing it later by simply referencing it
959 using \fB@\fR operator when not inside quotes or by wrapping it
960 inside \fB@{}\fR when in double quotes, shell command substitution quotes \fB``\fR,
961 or external window id substitution \fB<( )\fR.
964  b = 123; puts @a
967 There are two methods to define/create empty variables: by explicitely assing
968 an empty string to a variable (ex. a = "") or by simply omit the
969 value (ex. a =).
971 In addition, if there is more than one value to assign, a block is automatically
972 created (embedding those values) and assigned to that variable:
975  a = 1              # this simply assigns '1' to the variable 'a'
976  b = 1, 2, 3, 4     # this instead assigns the block '{1, 2, 3, 4}' to the variable 'a'
977  c = {1, 2, 3, 4}   # same but explicit
980 Each block has it's own scope, and variable resolution works by searching from
981 the last scope to the first.
985  a = 1
986  puts(@a)
988      a=345
989      b=6534
990  }()
991  puts@a
992  puts"b:@{b}"
995 In the last example, a is set to 1 and printed, then it's
996 changed to 345 from another scope, in which another variable
997 (b) is set.
998 After code block, just "a" is updated, and "b" doesn't exist anymore.
1000 For example:
1003  gname = MY_GRIP_NAME
1004  |l|<@gname
1010  gname = MY_GRIP_NAME
1011  name = 'random name'
1012  puts "@{gname} is maybe @{name}"
1015 .SS Element expressions
1019 Anything inside \fB||\fR is an element expression; a widget of a given
1020 element is created and its X11 window id substituted.
1021 The synopsis is: |<element>[{<width>, <height>}]|
1025  |b|+
1028 If an integer is given, instead of one of available element types, then the program tries to find an existing program having that integer as window id.
1032  |12341234|-
1035 This creates a widget ("external") for the external program and hides it.
1037 .SS Shell command substitution
1041 Anything inside \fB``\fR is treated as a shell
1042 command, and it's output is substituted.
1045  d = `date`
1046  ols = `ls -l`
1049 .SS External window id substitution
1052 Everything inside \fB<( )\fR is recognized as an
1053 external command (X11 GUI), forked and executed, and its window id
1054 is substituted (using _NET_WM_PID).
1056 For example:
1059  a = <(xterm)
1062 xterm program is spawn, and can be driven (almost) like
1063 a normal element.
1065 .SH OPERATORS
1068 .SS Binary
1072 .B <s> \.\. <e>
1073 returns integers starting at <s> and ending at <e> (inclusive)
1074 as multiple tokens.
1076 .B <var> = [<val>, [<val1>, ...]]
1077 defines a variable (consumes all the phrase).
1078 If no value is given, an empty token is assigned to the variable.
1079 If a single value is given, that value is assigned to the variable.
1080 If multiple values are given, then all these values are wrapped
1081 inside a block, and this block is assigned to the variable.
1083 .B <attr> .= [<val>, [<val1>, ...]]
1084 defines an element using the implied subject attribute (consumes all the phrase).
1085 If no value is given, an empty token is assigned to the variable.
1086 If a single value is given, that value is assigned to the variable.
1087 If multiple values are given, then all these values are wrapped
1088 inside a block, and this block is assigned to the variable.
1090 .SS Unary
1094 .B @<varname|num>
1095 dereferences a variable name (or positional argument).
1097 .B @*
1098 returns all function parameters as tokens (usable with command line parameters too).
1100 .B [<eid>]\.<attr>
1101 dereferences an element attribute; if <eid> is given, uses
1102 that element, otherwise uses implied subject.
1106 .SH ELEMENT ATTRIBUTES
1110 Every element can have some default readonly attributes and a 
1111 variable number of custom attributes (which can be set by using assignment
1112 only, not by using \fBlet\fR function). To set an attribute, use
1113 the "\fB.=\fR" operator; to get it instead use the "\fB.\fR" operator.
1116  b = |b|; myattr .= 'here'; puts(@b.myattr)
1119 In the last example, a custom attribute, "myattr" is
1120 created and used.
1122 The following are default attributes (readonly):
1124 .B t
1125 widget's type.
1127 .B w
1128 widget's width.
1130 .B h
1131 widget's height.
1133 .B x
1134 widget's x coord.
1136 .B y
1137 widget's y coord.
1139 .B b
1140 widget's border width.
1142 .B g
1143 widget's margin width.
1145 .B d
1146 widget's text data.
1148 .B T
1149 widget's title.
1151 .B c
1152 widget's checked/unchecked status (only for checkbox).
1154 .B n
1155 widget's number of subwidgets (only for page).
1157 .B s
1158 widget's subwidgets ids (one token each, only for page).
1160 .B pid
1161 process ID associated with the widget.
1163 .B v
1164 widget is visible.
1166 .B e
1167 widget is enabled (freezed/unfreezed).
1169 .B f
1170 widget is focused.
1172 .SH BUILTIN FUNCTIONS
1175 Symbol "\fB...\fR" means a variable number of arguments.
1178 .B exists(<eid>)
1179 returns 1 if a widget with id <eid> exists, 0 otherwise.
1181 .B read([<file>])
1182 reads and returns a line (excluding newline) from standard input;
1183 if an existing file is given, reads and returns all its content.
1184 Beware that this function blocks the GUI events, and returns nothing
1185 when reading from stdin and source is non-blocking.
1187 .B write(<text>, <file>)
1188 writes text into file and returns the number of characters written.
1189 Creates the file if it doesn't exist yet.
1191 .B append(<text>, <file>)
1192 append text to the end of file and returns the number of characters written.
1193 Creates the file if it doesn't exist yet.
1195 .B eval(...)
1196 evaluates code by first stringifying all given arguments
1197 and then returns the result of evaluation if any.
1198 Beware that this function runs in the "current" scope,
1199 and can modify it.
1201 .B builtin(<func>, ...)
1202 gets the name of a builtin function and a variable number of arguments, then calls
1203 the builtin function with those arguments and returns the result (if any).
1204 It's useful when overriding builtin functions.
1206 .B each(<function>, ...)
1207 executes <function> for each additional argument given passing it as the
1208 first argument to the block. If return values are present, they
1209 will be accumulated and then returned.
1211 .B env(<var>)
1212 returns the value of the environment variable "var".
1214 .B cwd()
1215 returns the value of the current working directory.
1217 .B rev([<block>], ...)
1218 if a block is given as first argument, its element will be
1219 returned in reverse, otherwise \fBrev\fR will return all its arguments in reverse.
1220 This function is somewhat special, as when there are no arguments to get,
1221 it'll return nothing (statement behaviour).
1223 .B let([<var>, <val>], ...)
1224 sets variables, works exactly like assignment with special operator \fB=\fR,
1225 but in expressions. This function is somewhat special, it'll return nothing (statement behaviour).
1227 .B if(<cond>, [<v1>, [<v2>]])
1228 if <cond> is true and <v1> is given, returns <v1>, else if <cond> is false and <v2> is given,
1229 returns <v2>.
1231 .B unless(<cond>, [<v1>, [<v2>]])
1232 if <cond> is false and <v1> is given, returns <v1>, else if <cond> is true and <v2> is given,
1233 returns <v2>.
1235 .B and(...)
1236 returns the first true argument; if there are no true
1237 arguments, returns the last one which is false.
1238 The function evaluates any block given.
1240 .B or(...)
1241 returns the last true argument if all arguments are true, otherwise
1242 returns the first false argument.
1243 The function evaluates any block given.
1245 .B flat(...)
1246 returns all given arguments; if a block is found, then it is flatted.
1248 .B block(...)
1249 returns a code block, embedding the given arguments into \fB{\fR\fB}\fR.
1251 .B some(...)
1252 returns given arguments. If nothing is given, returns an empty token.
1254 .B puts(...)
1255 prints given arguments to stdout.
1256 This function is somewhat special, it'll return nothing (statement behaviour).
1258 .B push(...)
1259 pushes given arguments to current function arguments (works with command line parameters too).
1260 This function is somewhat special, it'll return nothing (statement behaviour).
1262 .B pushb(...)
1263 pushes given arguments to current function arguments from the beginning (works with command line parameters too).
1264 This function is somewhat special, it'll return nothing (statement behaviour).
1266 .B pop()
1267 pops the last argument from function arguments (works with command line parameters too).
1268 This function is somewhat special, as if there are no arguments to pop,
1269 it'll return nothing (statement behaviour).
1271 .B popb()
1272 pops the first argument from function arguments (works with command line parameters too).
1273 This function is somewhat special, as if there are no arguments to pop.
1275 .B times(<n>, <arg>)
1276 returns a sequence of tokens made by <n> times <arg>.
1277 This function is somewhat special, as when there are 0 tokens to replicate,
1278 it'll return nothing (statement behaviour).
1280 .B get(<name>)
1281 returns the value of the variable with name <name>, or an empty
1282 token if the variable does not exist.
1284 .B true(<arg>)
1285 returns 1 if <arg> is true, 0 otherwise.
1287 .B false(<arg>)
1288 returns 0 if <arg> is true, 1 otherwise.
1290 .B in(<n>, <heap>)
1291 returns 1 if <n> is found in <heap>, 0 otherwise;
1292 the arguments can be of any type (single tokens and blocks).
1294 .B join(...)
1295 joins blocks and/or tokens by applying the following rules to
1296 all arguments given, and accumulates the result as the first operand.
1297 If the operands are blocks, then a single new block is created by joining them;
1298 if the operands are tokens, then a single new token is created by joining them,
1299 and its type will be that of the "second" token; if the operands are mixed
1300 (eg. a block and a token), then the token will be embedded inside the block.
1302 .B isdef(<token>)
1303 returns 1 if <token> is a variable, 0 otherwise.
1305 .B isvar(<token>)
1306 returns 1 if <token> is a (type) variable, 0 otherwise.
1308 .B isfunc(<token>)
1309 returns 1 if <token> refers to a function, 0 otherwise.
1311 .B isblock(...)
1312 returns 1 if just one argument is given and is a block, 0 otherwise.
1314 .B isint(...)
1315 returns 1 if just one argument is given and is an integer, 0 otherwise.
1317 .B len(<arg>)
1318 if a block is given, returns the number of its element, otherwise returns
1319 the number of characters of the token.
1321 .B split(<token>, <sep>)
1322 splits "token" using separator "sep" and returns resulting tokens
1323 having their type equal to that of "token".
1325 .B csplit(<token>, <sep>)
1326 splits "token" using separator "sep" and returns resulting tokens
1327 as normal commands.
1329 .B seq(<t1>, <t2>, ...)
1330 returns 1 if all arguments are equal (string comparison), 0 otherwise.
1332 .B add(...)
1333 perform addition.
1335 .B sub(...)
1336 perform subtraction.
1338 .B mul(...)
1339 perform multiplication
1341 .B div(...)
1342 perform division.
1344 .B mod(...)
1345 perform modulus.
1347 .B rand()
1348 returns a random positive integer.
1350 .B sqrt(<n>)
1351 returns the square root of <n>.
1353 .B cbrt(<n>)
1354 returns the cube root of <n>.
1356 .B pow(<n>, <e>)
1357 returns the power of <n> raised to <e>.
1359 .B log(<n>)
1360 returns the base 10 logarithm of <n>.
1362 .B ln(<n>)
1363 returns the natural logarithm of <n>.
1365 .B sin(<n>)
1366 returns the sine of <n> (degrees).
1368 .B cos(<n>)
1369 returns the cosine of <n> (degrees).
1371 .B tan(<n>)
1372 returns the tangent of <n> (degrees).
1374 .B hex(<n>)
1375 returns <n> in its hexadecimal representation.
1377 .B int(<n>)
1378 returns integral part of given number <n>; rounds to nearest integer.
1380 .B xor(<n1>, <n2>, ...)
1381 perform bitwise XOR.
1383 .B band(<n1>, <n2>, ...)
1384 perform bitwise AND.
1386 .B bor(<n1>, <n2>, ...)
1387 perform bitwise OR.
1389 .B lsh(<n1>, <n2>, ...)
1390 perform bitwise left shift.
1392 .B rsh(<n1>, <n2>, ...)
1393 perform bitwise right shift.
1395 .B not(<n>)
1396 perform negation
1398 .B eq(<n1>, <n2>, ...)
1399 equal-to
1401 .B ne(<n1>, <n2>, ...)
1402 not-equal-to
1404 .B lt(<n1>, <n2>, ...)
1405 less-than
1407 .B gt(<n1>, <n2>, ...)
1408 greater-than
1410 .B le(<n1>, <n2>, ...)
1411 less-equal-than
1413 .B ge(<n1>, <n2>, ...)
1414 greater-equal-than
1416 .B abs(<n>)
1417 perform absolute value
1419 .B neg(<n>)
1420 unary minus.
1422 .SH STYLE AND ATTRIBUTES
1425 Each element has some properties/attributes which can be set by using style command. This command takes a string that has
1426 a format like CSS:
1429  |l| s 'bg: blue; fg: white'
1432 Here, we create a label with a blue background and white foreground.
1434 Each field must be separated by newlines, \fB;\fR or \fB|\fR.
1435 Colors can be specified by using a common shortname, such as "yellow", or by using RGB value, such as "#ff32ae".
1438 .B background | bg: <color|/<path to image>>
1439 set background color or a background image by specifying image path;
1440 if the string "null" is given as <path to image>, current image is
1441 removed. (Background image loading requires building guish with Imlib2 support.)
1443 .B color | foreground | fg: <color>
1444 set foreground color
1446 .B pressed-background | pbg: <color>
1447 background color when element is pressed
1449 .B pressed-color | pfg: <color>
1450 foreground color when element is pressed
1452 .B hovered-background | hbg: <color>
1453 background color when element is hovered
1455 .B hovered-color | hfg: <color>
1456 foreground color when element is hovered
1458 .B border-color | bc: <color>
1459 set border color
1461 .B width | w: <value in pixels>
1462 set width
1464 .B height | h: <value in pixels>
1465 set height
1467 .B border | b: <value in pixels>
1468 set border width
1470 .B line | l: <value in pixels>
1471 set line width (use with "/" command)
1473 .B margin | g: <value in pixels>
1474 set margin width
1476 .B mode | m: <expanding mode>
1477 set expanding mode type (See Expanding mode)
1479 .B align | a: <alignment>
1480 set alignment type (See Alignment)
1482 .B f | font: <font name>
1483 set font type using a X11 font name
1485 .SS Expanding mode
1489 .B fixed | f
1490 width and height are fixed (default for all elements)
1492 .B wfixed | w
1493 width is fixed, height can change
1495 .B hfixed | h
1496 height is fixed, width can change
1498 .B relaxed | r
1499 width and height can change
1501 .SS Alignment
1504 Any element that's not a page has a particular text alignment
1505 that can be changed.
1506 If an alignment is specified for a page element instead,
1507 (whose defaults alignments are top-center for horizontal
1508 layout, and middle-left for vertical one),
1509 then its sub-elements will be aligned accordingly, depending from page
1510 layout type too.
1513 .B l | left | middle-left
1514 show text at middle left
1516 .B r | right | middle-right
1517 show text at middle right
1519 .B c | center | middle-center
1520 show text at middle center
1522 .B tl | top-left
1523 show text at top left
1525 .B tr | top-right
1526 show text at top right
1528 .B t | top-center
1529 show text at top center
1531 .B bl | bottom-left
1532 show text at bottom left
1534 .B br | bottom-right
1535 show text at bottom right
1537 .B b | bottom-center
1538 show text at bottom center
1540 .SH AUTHOR
1543 Francesco Palumbo <phranz@subfc.net>
1545 .SH THANKS
1548 La vera Napoli, Carme, Pico, Titina, Molly, Leo, i miei amati nonni,
1549 mio padre, mia madre, e tutti coloro su cui ho potuto e posso contare.
1550 Grazie mille.
1552 .SH LICENSE
1555 .B GPL-3.0-or-later
1556 see COPYING