3 guish - A language to make and modify GUIs
8 \<code\>\]\[**-s**\]\[**-q**\]\[**-k**\]\[**-t**\]\[**-f**\]\[**-v**\]\[**-b**\]\[**-h**\]\[\<file\>\]\[\<arguments\>\]
12 **guish** is a language to create and modify GUIs; it can be used to tie
13 different programs together by embedding, or to make simple GUIs.
15 This is version 2.x, which depends just on Xlib as all toolkits have
16 been removed (there are some optional dependencies).
22 : read and execute commands from command line.
26 : display elements when created.
30 : quit when closing last element/window.
34 : terminate all external programs when quitting.
38 : fallback on tty after reading data from other inputs.
42 : show available X11 fonts.
50 : show build (compiled in) options.
58 guish reads commands from multiple source sequentially; these source
59 are: command line (with **-c** option), file, standard input, and if
60 **-t** option is given, controlling terminal. After reading commands
61 from a source, it tries to switch to another one, and when there are no
62 more sources, it simply stays idle.
64 After executing from file or command line or standard input, then
65 finally it switchs to controlling terminal (if **-t** option is given)
66 and executes from there.
68 If the file given is a named pipe, then it will be opened in
69 non-blocking mode, allowing to issue commands from the other end of the
74 Being a command interpreter, guish has a little set of syntax rules.
75 They comprises expressions, commands, quotes and special operators.
76 Generic commands and signals are common to all elements, while there are
77 ones which are specific to each element. A phrase is the execution unit,
78 and ends if the program encounters a newline-like character, or a
83 Single line comments begin with a **\#**, and end at newline like
86 a = 4 # this is a comment
88 Multiline comments instead are embedded inside **#\[** and **\]#** (or
89 end at the end of source):
92 is a multiline comment,
93 ending here. ]# puts "a: @{a}"
95 ## Elements and element expressions
97 Elements are basically widgets and have some commands and signals
98 associated with them; they can be created using element expressions,
99 enclosing element name within **\|\|**:
103 In this example, \"\|b\|\" is an expression which creates an element of
104 type button, and returns its X11 window id (ex, \"65011718\").
106 The **+** command will then show the button (all elements are hidden by
107 default unless **-s** option is given).
109 ## Subject and implied subject
111 To refer to the last created/modified element, you can use it without
112 naming it explicitly, for example:
116 The \"+\" command will by applied to element created by \"\|i\|\"
117 expression automatically.
119 ## Variables and variable substitution
121 We can refer to elements by using variable substitution, instead of
122 using their window ids:
132 Commands instead can be of three distinct types: special, generic and
135 Special commands are meant to change guish behaviour, generic ones are
136 meant to modify an element of any type and normal ones are for a
137 specific element type (every element can have specialized commands).
141 Signals make it possible to run actions on UI changes (or, more
142 generally, on some events).
146 Here, the user creates a button that when clicked will make guish
147 execute a system command (free in this case) (see **run** in SPECIAL
150 |b|<generator =>c{|b|<clone}
152 A button which is a factory of buttons (run this with **-s** option).
154 Here the evaluation of the code block is done when the click signal is
157 ## Scopes and closures
159 All variables (functions too, as blocks can be assigned to variables)
160 have a specific scope:
166 Here the variable \"a\" is defined in the global scope, while \"b\" is
167 defined in a temporarily block scope; hence just \"a\" is printed to
170 When accessing reading/defining a variable in a local scope, if the
171 variable is already defined in the enclosing scope then that variable is
172 picked to be read/modified:
181 Here \"a\" is defined in the global scope, then modified from block
182 scope and printed from there, and its value doesn\'t change.
184 If a variable is defined inside a block, then all embedded blocks that
185 reference that variable will get its value at definition time (a
195 ## Quotes, blocks and functions
197 There are single and double quoting: anything embedded inside single
198 quotes \'\', is treated literally (no escaping takes place) and as a
201 Variable and function interpolations (respectively via \"**\@{\...}**\"
202 and \"**@(\...)**\") are used inside double quotes \"\", external
203 command substitution quotes \`\` and external window id substitution
206 Escaping (\"\\n\\t\\r\\f\\v\\b\") takes place only inside double quotes
209 a = 'my string'; puts "this is: @{a}"
210 puts "sum of 1 + 5 is: @(add(1, 5))"
212 Anything embedded inside **{}** is treated as a code block and no
213 variable substitution is done at definition time.
215 To \"execute\" a block, simply use parens **()**. If arguments are
216 given, they can be referenced inside block by using **\@n**, where \"n\"
217 is a number which represents a specific argument by position, with
218 indexes starting at 1 (works with command line parameters too). To refer
219 to all arguments (at once) given to the block use **@\*** operator (when
220 in string interpolation, argument separator is a space).
223 a = {puts "here is @{v}"}
226 Here the variable \"v\" is not substituted when assigning the block to
227 \"a\"; it\'s substituted later, when function \"a\" is called.
230 puts join("string length is: ", len(@1))
233 Here instead, the block is defined and executed immediately, using
234 \"home\" as the first argument.
236 Being a block a piece of code, it can be used to define functions by
237 simply being assigned to a variable:
239 fn = {return add(@1, @2)}
240 puts join("my func res:", fn(2, 4))
242 In addition, when defining a new function, it\'s possible to
243 \"overwrite\" the builtin functions in the current scope.
245 When returning from a function, instead, it\'s possible to return
246 multiple arguments (the remaining phrase) to the caller:
253 Anything equal to 0, \"0\" or empty (like **\'\'**, **\"\"**, **{}**) is
254 false, true otherwise. This is useful with **if** and **else** commands:
256 if 1 { |b|<text } else { |b|<neverhere }
260 if ge(@a,4) { |l|<4 }
262 ## Loops and iteration
264 Here an example of a **while** loop:
273 And here another one using **each** function:
275 each({puts @1}, 1, 2, 3, 4, 5})
277 And another one of a **for** loop:
279 for x in 1 2 3 4: { puts @x }
281 ## Tail recursion optimization (TCO)
283 Since **2.2.1** version, guish supports tail recursion optimization too,
284 effectively turning a tail recursive function into a loop:
291 return upto(add(@1, 1), @2)
295 To use TCO, the last phrase of a function must use **return** command
296 directly (not inside another block like if-else).
298 ## External window id substitution
300 Everything inside **\<( )** is recognized as an external command (X11
301 GUI), forked and executed, and its window id is substituted (using
304 Note that this method will not work with programs that fork.
310 xterm program is spawn, and can be driven (almost) like a normal
313 ## External command substitution
315 Everything inside **\`\`** is recognized as an external command and
316 executed. Then the command output (STDOUT) is substituted inside source
317 code and interpreted after that.
325 Anything inside **\[\]** is trated as a slice expression. The usage is
326 **\[\<n\>\[,\<x\>\]\]**, when \<n\> is an index, and \<x\> is an
327 optional end index (always inclusive); if the preceding argument is a
328 regular token, then the expression will return its characters as
329 specified by index(es), otherwise if it\'s a block, the expression will
332 puts {1, 2, 3, 4, {a, b}, cat}[4][1]
334 The output of this example is \'b\'.
336 If the index(es) given are out of range, an empty token is returned.
342 : primary screen width, in pixels.
346 : primary screen height, in pixels.
350 : pointer\'s x coord.
354 : pointer\'s y coord.
358 : variable holding the window id when in signal code.
362 : refers to the block in which there are positional arguments and
363 function arguments (alternative syntax).
367 : variable holding the path of current source file.
371 : variable holding current line number at \"that\" point in source
374 # ENVIRONMENT VARIABLES
378 : the maximum number of seconds to wait when applying external window
379 id substitution (defaults to 3 seconds)
383 Available elements are:
399 : A page (container of other elements; show and hide are applied to
408 : A label with a totally transparent background (requires a
413 Special commands are not tied to elements, they are like statements.
415 **=\> \<signal\> \<subcmd\>**
417 : register a sub-command \<subcmd\> to run when \<signal\> triggers.
418 For normal signals (eg. signals tied to elements), there must exist
423 : unregister a sub-command \<subcmd\> previously registered on signal
428 : quit guish (exit status 0).
432 : quit guish (exit status \<status\>).
436 : change current working directory using \<path\>.
440 : execute shell command \<cmd\>.
442 **puts \[\<\...\>\]**
444 : prints remaining phrase to stdout with a newline added.
448 : prints remaining phrase to stdout.
452 : prints remaining phrase to stderr.
454 **unset \<name\|num\|wid\> \[\<attr\>\]**
456 : unsets a variable (\<name\>) or timed scheduled procedure registered
457 with \<num\>, see **every** command. If, instead of \<name\|num\>,
458 an element id \<wid\> is given and a name attribute \<attr\> is
459 given, deletes that element attribute.
463 : execute commands from file.
467 : shows all variables present in the current scope or, if \<wid\>
468 element id is given, shows all element attributes (uses stderr).
472 : display all existing widgets (stderr).
476 : delete a widget with id \<wid\>.
478 **every \<seconds\> \<block\>**
480 : schedule \<code\> to run after \<seconds\> seconds are elapsed.
482 **after \<seconds\> \<block\>**
484 : schedule \<block\> to run once after \<seconds\> seconds are
489 : stop command execution and wait \<seconds\> seconds before resuming
490 (accepts decimal values too). XEvent handling, schedules actions and
491 signal execution are unaffected by this option.
493 **if \<condition\> \<block\>**
495 : executes \<block\> if condition evaluates to true (see
498 **unless \<condition\> \<block\>**
500 : executes \<block\> if condition evaluates to false (see
505 : executes \<block\> if last conditional command was successful (see
508 **return \<phrase\>**
510 : when used inside a function, returns all its arguments (the
511 remaining phrase) to the caller.
513 **while \<condition\> \<block\>**
515 : executes \<block\> until \<condition\> evaluates to true (see
518 **until \<condition\> \<block\>**
520 : executes \<block\> until \<condition\> evaluates to true (see
523 **for \[\<var1\>, \<var2\>, \...\] in \[\<val1\>, \<val2\>, \...\] : \<block\>**
525 : executes the block \<block\> for each group of variables.
529 : exit from current loop.
531 **rel \<element1\> \<element2\> \<alignment\>**
533 : relates \<element1\> to \<element2\>, moving \<element1\> near
534 \<element2\> using \<alignment\> (see alignment in STYLE AND
535 ATTRIBUTES section, as \<alignment\> opts are similar) every time
536 \<element2\> is moved. If \"0\" is specified as alignment, the
539 **pass \[\<args\>\]**
541 : do nothing, consuming remaining arguments.
543 **send \<wid\> \<keysequence\>**
545 : send a keysequence to an element whose id si \<wid\> (must be
546 enabled at compilation time).
548 **ctrl \<wid\> \<keysequence\>**
550 : send control key sequence to an element whose id si \<wid\> (must be
551 enabled at compilation time).
555 Generic commands are applicable to any element, regardless of its type
556 (there are exceptions though).
560 : element is undetectable in taskbar.
564 : resize the element to fit the entire screen.
568 : restore element\'s default window attributes.
572 : bypass window manager.
576 : follow window manager as default.
580 : center element in its parent.
600 : make element stay at top.
604 : make element stay at bottom.
608 : hide element, or quit guish if quit-on-last-close is on and the
609 element is the last closed one.
621 : maximize the element.
625 : disable the element.
629 : enable the element.
633 : fits element\'s size to its content.
637 : resize an element in right-bottom directions to fit its parent,
638 respecting limits of other elements.
642 : resize an element in right-bottom directions to fit its parent.
646 : resize an element in right direction to fit its parent, respecting
647 limits of other elements.
651 : resize an element in right direction to fit its parent.
655 : resize an element in bottom direction to fit its parent, respecting
656 limits of other elements.
660 : resize an element in bottom direction to fit its parent.
664 : clear element\'s data.
672 : set element style (see STYLE AND ATTRIBUTES section).
676 : resize element by width and height.
680 : move element to coords \<x\> \<y\>.
682 **/ \[\<l\|L\|a\|A\|p\|x\|n\> \[\<\...\>\]\]**
684 : draws/fills lines, points and arcs depending on operation (See
685 Drawing operations subsection). Origin coordinates correspond to the
686 bottom-left corner as default Cartesian axes (instead of upper-left
687 one used for windows/elements). If no operation is given, then all
688 drawings are discarded from the implied element.
690 **A \<element\> \<alignment\>**
692 : moves implied element to \<element\> using \<alignment\> (see
693 alignment in STYLE AND ATTRIBUTES section, as \<alignment\> opts are
698 : set element text using \<text\>.
702 : add additional text to element text using \<text\>.
706 : define a variable named \<var\> using element text to set its value.
710 : enable/disable (toggle) moving the parent of the element by
711 click-and-drag it. Enabling this will automatically exclude x/y
716 : enable/disable (toggle) moving an element inside its parent by
717 click-and-drag on x axis Enabling this will automatically exclude
718 the flag to click-and-drag and move parent.
722 : enable/disable (toggle) moving an element inside its parent by
723 click-and-drag on y axis Enabling this will automatically exclude
724 the flag to click-and-drag and move parent.
726 ## Drawing operations
728 **l \[\<color\> \<x1\> \<y1\> \<x2\> \<y2\> \[\<\...\>\]\]**
730 : draws lines between given points using color \<color\> (beware this
731 command consumes all the phrase). If no arguments are given, then
732 all element lines are discarded.
734 **L \[\<color\> \<x1\> \<y1\> \<x2\> \<y2\> \[\<\...\>\]\]**
736 : fills the polygon described by given points using color \<color\>
737 (beware this command consumes all the phrase). If no arguments are
738 given, then all filled polygons are discarded.
740 **a \[\<color\> \<x\> \<y\> \<w\> \<h\> \<alpha\> \<beta\> \[\<\...\>\]\]**
742 : draws an arc using color \<color\> and whose \"center\" is at \<x\>
743 \<y\>, major and minor axes are respectively \<w\> and \<h\>, start
744 and stop angles are \<alpha\> and \<beta\> (consumes all the
745 phrase). If no arguments are given, then all element arcs are
748 **A \[\<color\> \<x\> \<y\> \<w\> \<h\> \<alpha\> \<beta\> \[\<\...\>\]\]**
750 : fills an arc using color \<color\> and whose \"center\" is at \<x\>
751 \<y\>, major and minor axes are respectively \<w\> and \<h\>, start
752 and stop angles are \<alpha\> and \<beta\> (consumes all the
753 phrase). If no arguments are given, then all element arcs are
756 **p \[\<color\> \[\<\...\>\]\]**
758 : draws given points using color \<color\> (beware this command
759 consumes all the phrase). If no arguments are given, then all points
762 **x \[\<color\> \[\<\...\>\]\]**
764 : draws given pixels using color \<color\> (beware this command
765 consumes all the phrase). If no arguments are given, then all pixels
768 **n \[\<color\> \<name\> \<x\> \<y\>\]**
770 : draws given point using color \<color\> and putting the text
771 \<name\> at that point. If no arguments are given, then all points
790 : show input data as normal while typing.
794 : hide input data while typing.
798 : use password mode, displaying just asterisks.
802 : toggles \"go to the next line\" when hitting return (triggers return
809 : make subelements equals (in size).
813 : style all subelements.
817 : free all embedded elements.
821 : embeds element (or an external client).
823 **\<\<\< \<element\>**
825 : embeds element (or an external client), fitting the page to its
830 : free element, reparenting it to root window.
832 **\>\>\> \<element\>**
834 : free element, reparenting it to root window and fitting the page to
839 : set vertical layout readjusting all subwidgets.
843 : set horizontal layout readjusting all subwidgets.
847 : swaps sub-elements position.
851 : inverts the order of sub-elements.
855 Special signals are independent from elements, and are tied to internal guish events.
861 : triggered at program exit.
865 : triggered when program receives a SIGINT or a SIGTERM.
869 Generic signals are common to all elements.
875 : triggered when element is closed.
879 : triggered when element is clicked.
883 : triggered when element is left-clicked.
887 : triggered when element is right-clicked.
891 : triggered when element is middle-clicked.
895 : triggered when element is double clicked.
899 : triggered when element is double left-clicked.
903 : triggered when element is double right-clicked.
907 : triggered when element is double middle-clicked.
911 : triggered when element is pressed.
915 : triggered when element is left-pressed.
919 : triggered when element is right-pressed.
923 : triggered when element is middle-pressed.
927 : triggered when element is released.
931 : triggered when element is left-released.
935 : triggered when element is right-released.
939 : triggered when element is middle-released.
943 : triggered when element is moved.
947 : triggered when element scrolled down.
951 : triggered when element scrolled up.
955 : triggered when element is resized.
959 : triggered when mouse pointer \"enters\" the element.
963 : triggered when mouse pointer \"leaves\" the element.
967 : triggered when focusing the element.
971 : triggered when un-focusing the element.
975 Normal signals are per element.
983 : triggered when checkbox is unchecked.
987 : triggered when checkbox is checked.
993 : triggered when input has focus and \"return\" is hit.
997 These tokens are ignored: \"**,**\", \"**-\>**\".
999 # EVALUATION ORDER AND SUBSTITUTIONS
1001 Every time a new phrase is evaluated, it goes through a series of
1002 special substitutions/evaluations before it\'s commands are interpreted.
1004 The evaluation order is: hex substitution (at tokenizer level),
1005 evaluation of expressions (where code evaluation/execution,
1006 substitutions and functions are computed), evaluation of special
1007 commands and execution of generic/normal commands.
1009 Moreover if after the execution phase (the last one) the phrase is not
1010 empty, the evaluation cycle will restart from evaluation of expressions
1011 phase, and it will continue until there are no more tokens in the
1014 Every phrase is reduced to an empty phrase while evaluating:
1016 a=234;{i1=|i|;<'input1'+}();{i2=|i|;<'input2'+}()|b|<btn+
1018 This example is composed by 2 phrases, and the code block in each phrase
1019 is executed before each assignment.
1023 Non quoted tokens are subject to hex substitution: if a \"\\x\" plus 2
1024 hexadecimal characters is found, it\'s substituted with corresponding
1027 puts \x68\x6F\x6D\x65
1029 Here, the string \"home\" is printed.
1033 If a \"**\***\" is given, then all widgets wids are substituted.
1038 ## Variable substitution
1040 With the **=** operator (actually, it\'s a special statement command),
1041 it\'s possible to assign values to a variable, reusing it later by
1042 simply referencing it using **@** operator when not inside quotes or by
1043 wrapping it inside **\@{}** when in double quotes, shell command
1044 substitution quotes **\`\`**, or external window id substitution **\<(
1049 There are two methods to define/create empty variables: by explicitely
1050 assing an empty string to a variable (ex. a = \"\") or by simply omit
1051 the value (ex. a =).
1053 In addition, if there is more than one value to assign, a block is
1054 automatically created (embedding those values) and assigned to that
1057 a = 1 # this simply assigns '1' to the variable 'a'
1058 b = 1, 2, 3, 4 # this instead assigns the block '{1, 2, 3, 4}' to the variable 'a'
1059 c = {1, 2, 3, 4} # same but explicit
1061 Each block has it\'s own scope, and variable resolution works by
1062 searching from the last scope to the first. Ex:
1073 In the last example, a is set to 1 and printed, then it\'s changed to
1074 345 from another scope, in which another variable (b) is set. After code
1075 block, just \"a\" is updated, and \"b\" doesn\'t exist anymore.
1079 gname = MY_GRIP_NAME
1084 gname = MY_GRIP_NAME
1085 name = 'random name'
1086 puts "@{gname} is maybe @{name}"
1088 ## Element expressions
1090 Anything inside **\|\|** is an element expression; a widget of a given
1091 element is created and its X11 window id substituted. The synopsis is:
1092 \|\<element\>\[{\<width\>, \<height\>}\]\| Ex.
1096 If an integer is given, instead of one of available element types, then
1097 the program tries to find an existing program having that integer as
1102 This creates a widget (\"external\") for the external program and hides
1105 ## Shell command substitution
1107 Anything inside **\`\`** is treated as a shell command, and it\'s output
1113 ## External window id substitution
1115 Everything inside **\<( )** is recognized as an external command (X11
1116 GUI), forked and executed, and its window id is substituted (using
1123 xterm program is spawn, and can be driven (almost) like a normal
1132 : returns integers starting at \<s\> and ending at \<e\> (inclusive)
1135 **\<var\> = \[\<val\>, \[\<val1\>, \...\]\]**
1137 : defines a variable (consumes all the phrase). If no value is given,
1138 an empty token is assigned to the variable. If a single value is
1139 given, that value is assigned to the variable. If multiple values
1140 are given, then all these values are wrapped inside a block, and
1141 this block is assigned to the variable.
1143 **\<attr\> .= \[\<val\>, \[\<val1\>, \...\]\]**
1145 : defines an element using the implied subject attribute (consumes all
1146 the phrase). If no value is given, an empty token is assigned to the
1147 variable. If a single value is given, that value is assigned to the
1148 variable. If multiple values are given, then all these values are
1149 wrapped inside a block, and this block is assigned to the variable.
1153 **@\<varname\|num\>**
1155 : dereferences a variable name (or positional argument).
1159 : returns all function parameters as tokens (usable with command line
1162 **\[\<eid\>\].\<attr\>**
1164 : dereferences an element attribute; if \<eid\> is given, uses that
1165 element, otherwise uses implied subject.
1167 # ELEMENT ATTRIBUTES
1169 Every element can have some default readonly attributes and a variable
1170 number of custom attributes (which can be set by using assignment only,
1171 not by using **let** function). To set an attribute, use the \"**.=**\"
1172 operator; to get it instead use the \"**.**\" operator.
1174 b = |b|; myattr .= 'here'; puts(@b.myattr)
1176 In the last example, a custom attribute, \"myattr\" is created and used.
1178 The following are default attributes (readonly):
1194 : widget\'s x coord.
1198 : widget\'s y coord.
1202 : widget\'s border width.
1206 : widget\'s margin width.
1210 : widget\'s text data.
1218 : widget\'s checked/unchecked status (only for checkbox).
1222 : widget\'s number of subwidgets (only for page).
1226 : widget\'s subwidgets ids (one token each, only for page).
1230 : process ID associated with the widget.
1234 : widget is visible.
1238 : widget is enabled (freezed/unfreezed).
1242 : widget is focused.
1246 Symbol \"**\...**\" means a variable number of arguments.
1250 : returns 1 if a widget with id \<eid\> exists, 0 otherwise.
1252 **read(\[\<file\>\])**
1254 : reads and returns a line (excluding newline) from standard input; if
1255 an existing file is given, reads and returns all its content. Beware
1256 that this function blocks the GUI events, and returns nothing when
1257 reading from stdin and source is non-blocking.
1259 **write(\<text\>, \<file\>)**
1261 : writes text into file and returns the number of characters written.
1262 Creates the file if it doesn\'t exist yet.
1264 **append(\<text\>, \<file\>)**
1266 : append text to the end of file and returns the number of characters
1267 written. Creates the file if it doesn\'t exist yet.
1271 : evaluates code by first stringifying all given arguments and then
1272 returns the result of evaluation if any. Beware that this function
1273 runs in the \"current\" scope, and can modify it.
1275 **builtin(\<func\>, \...)**
1277 : gets the name of a builtin function and a variable number of
1278 arguments, then calls the builtin function with those arguments and
1279 returns the result (if any). It\'s useful when overriding builtin
1282 **each(\<function\>, \...)**
1284 : executes \<function\> for each additional argument given passing it
1285 as the first argument to the block. If return values are present,
1286 they will be accumulated and then returned.
1290 : returns the value of the environment variable \"var\".
1294 : returns the value of the current working directory.
1296 **rev(\[\<block\>\], \...)**
1298 : if a block is given as first argument, its element will be returned
1299 in reverse, otherwise **rev** will return all its arguments in
1300 reverse. This function is somewhat special, as when there are no
1301 arguments to get, it\'ll return nothing (statement behaviour).
1303 **let(\[\<var\>, \<val\>\], \...)**
1305 : sets variables, works exactly like assignment with special operator
1306 **=**, but in expressions. This function is somewhat special, it\'ll
1307 return nothing (statement behaviour).
1309 **if(\<cond\>, \[\<v1\>, \[\<v2\>\]\])**
1311 : if \<cond\> is true and \<v1\> is given, returns \<v1\>, else if
1312 \<cond\> is false and \<v2\> is given, returns \<v2\>.
1314 **unless(\<cond\>, \[\<v1\>, \[\<v2\>\]\])**
1316 : if \<cond\> is false and \<v1\> is given, returns \<v1\>, else if
1317 \<cond\> is true and \<v2\> is given, returns \<v2\>.
1321 : returns the first true argument; if there are no true arguments,
1322 returns the last one which is false. The function evaluates any
1327 : returns the last true argument if all arguments are true, otherwise
1328 returns the first false argument. The function evaluates any block
1333 : returns all given arguments; if a block is found, then it is
1338 : returns a code block, embedding the given arguments into **{}**.
1342 : returns given arguments. If nothing is given, returns an empty
1347 : prints given arguments to stdout. This function is somewhat special,
1348 it\'ll return nothing (statement behaviour).
1352 : pushes given arguments to current function arguments (works with
1353 command line parameters too). This function is somewhat special,
1354 it\'ll return nothing (statement behaviour).
1358 : pushes given arguments to current function arguments from the
1359 beginning (works with command line parameters too). This function is
1360 somewhat special, it\'ll return nothing (statement behaviour).
1364 : pops the last argument from function arguments (works with command
1365 line parameters too). This function is somewhat special, as if there
1366 are no arguments to pop, it\'ll return nothing (statement
1371 : pops the first argument from function arguments (works with command
1372 line parameters too). This function is somewhat special, as if there
1373 are no arguments to pop.
1375 **times(\<n\>, \<arg\>)**
1377 : returns a sequence of tokens made by \<n\> times \<arg\>. This
1378 function is somewhat special, as when there are 0 tokens to
1379 replicate, it\'ll return nothing (statement behaviour).
1383 : returns the value of the variable with name \<name\>, or an empty
1384 token if the variable does not exist.
1388 : returns 1 if \<arg\> is true, 0 otherwise.
1392 : returns 0 if \<arg\> is true, 1 otherwise.
1394 **in(\<n\>, \<heap\>)**
1396 : returns 1 if \<n\> is found in \<heap\>, 0 otherwise; the arguments
1397 can be of any type (single tokens and blocks).
1401 : joins blocks and/or tokens by applying the following rules to all
1402 arguments given, and accumulates the result as the first operand. If
1403 the operands are blocks, then a single new block is created by
1404 joining them; if the operands are tokens, then a single new token is
1405 created by joining them, and its type will be that of the \"second\"
1406 token; if the operands are mixed (eg. a block and a token), then the
1407 token will be embedded inside the block.
1409 **isdef(\<token\>)**
1411 : returns 1 if \<token\> is a variable, 0 otherwise.
1413 **isvar(\<token\>)**
1415 : returns 1 if \<token\> is a (type) variable, 0 otherwise.
1417 **isfunc(\<token\>)**
1419 : returns 1 if \<token\> refers to a function, 0 otherwise.
1423 : returns 1 if just one argument is given and is a block, 0 otherwise.
1427 : returns 1 if just one argument is given and is an integer, 0
1432 : if a block is given, returns the number of its element, otherwise
1433 returns the number of characters of the token.
1435 **split(\<token\>, \<sep\>)**
1437 : splits \"token\" using separator \"sep\" and returns resulting
1438 tokens having their type equal to that of \"token\".
1440 **csplit(\<token\>, \<sep\>)**
1442 : splits \"token\" using separator \"sep\" and returns resulting
1443 tokens as normal commands.
1445 **seq(\<t1\>, \<t2\>, \...)**
1447 : returns 1 if all arguments are equal (string comparison), 0
1456 : perform subtraction.
1460 : perform multiplication
1472 : returns a random positive integer.
1476 : returns the square root of \<n\>.
1480 : returns the cube root of \<n\>.
1482 **pow(\<n\>, \<e\>)**
1484 : returns the power of \<n\> raised to \<e\>.
1488 : returns the base 10 logarithm of \<n\>.
1492 : returns the natural logarithm of \<n\>.
1496 : returns the sine of \<n\> (degrees).
1500 : returns the cosine of \<n\> (degrees).
1504 : returns the tangent of \<n\> (degrees).
1508 : returns \<n\> in its hexadecimal representation.
1512 : returns integral part of given number \<n\>; rounds to nearest
1515 **xor(\<n1\>, \<n2\>, \...)**
1517 : perform bitwise XOR.
1519 **band(\<n1\>, \<n2\>, \...)**
1521 : perform bitwise AND.
1523 **bor(\<n1\>, \<n2\>, \...)**
1525 : perform bitwise OR.
1527 **lsh(\<n1\>, \<n2\>, \...)**
1529 : perform bitwise left shift.
1531 **rsh(\<n1\>, \<n2\>, \...)**
1533 : perform bitwise right shift.
1539 **eq(\<n1\>, \<n2\>, \...)**
1543 **ne(\<n1\>, \<n2\>, \...)**
1547 **lt(\<n1\>, \<n2\>, \...)**
1551 **gt(\<n1\>, \<n2\>, \...)**
1555 **le(\<n1\>, \<n2\>, \...)**
1559 **ge(\<n1\>, \<n2\>, \...)**
1561 : greater-equal-than
1565 : perform absolute value
1571 # STYLE AND ATTRIBUTES
1573 Each element has some properties/attributes which can be set by using
1574 style command. This command takes a string that has a format like CSS:
1576 |l| s 'bg: blue; fg: white'
1578 Here, we create a label with a blue background and white foreground.
1580 Each field must be separated by newlines, **;** or **\|**. Colors can be
1581 specified by using a common shortname, such as \"yellow\", or by using
1582 RGB value, such as \"#ff32ae\".
1584 **background \| bg: \<color\|/\<path to image\>\>**
1586 : set background color or a background image by specifying image path;
1587 if the string \"null\" is given as \<path to image\>, current image
1588 is removed. (Background image loading requires building guish with
1591 **color \| foreground \| fg: \<color\>**
1593 : set foreground color
1595 **pressed-background \| pbg: \<color\>**
1597 : background color when element is pressed
1599 **pressed-color \| pfg: \<color\>**
1601 : foreground color when element is pressed
1603 **hovered-background \| hbg: \<color\>**
1605 : background color when element is hovered
1607 **hovered-color \| hfg: \<color\>**
1609 : foreground color when element is hovered
1611 **border-color \| bc: \<color\>**
1615 **width \| w: \<value in pixels\>**
1619 **height \| h: \<value in pixels\>**
1623 **border \| b: \<value in pixels\>**
1627 **line \| l: \<value in pixels\>**
1629 : set line width (use with \"/\" command)
1631 **margin \| g: \<value in pixels\>**
1635 **mode \| m: \<expanding mode\>**
1637 : set expanding mode type (See Expanding mode)
1639 **align \| a: \<alignment\>**
1641 : set alignment type (See Alignment)
1643 **f \| font: \<font name\>**
1645 : set font type using a X11 font name
1651 : width and height are fixed (default for all elements)
1655 : width is fixed, height can change
1659 : height is fixed, width can change
1663 : width and height can change
1667 Any element that\'s not a page has a particular text alignment that can
1668 be changed. If an alignment is specified for a page element instead,
1669 (whose defaults alignments are top-center for horizontal layout, and
1670 middle-left for vertical one), then its sub-elements will be aligned
1671 accordingly, depending from page layout type too.
1673 **l \| left \| middle-left**
1675 : show text at middle left
1677 **r \| right \| middle-right**
1679 : show text at middle right
1681 **c \| center \| middle-center**
1683 : show text at middle center
1687 : show text at top left
1691 : show text at top right
1695 : show text at top center
1697 **bl \| bottom-left**
1699 : show text at bottom left
1701 **br \| bottom-right**
1703 : show text at bottom right
1705 **b \| bottom-center**
1707 : show text at bottom center
1711 Francesco Palumbo \<phranz.dev@gmail.com\>
1715 La vera Napoli, Carme, Pico, Titina, Molly, Leo, i miei amati nonni, mio
1716 padre, mia madre, e tutti coloro su cui ho potuto e posso contare.
1721 **GPL-3.0-or-later** see COPYING