Category:Guish: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 129:
<pre> guish -zc &quot;|b|&lt;generator =&gt;c{|b|&lt;clone}&quot;</pre>
A button which is a factory of buttons.
 
In addition, being a the last argument a code block, it's possible to pass arguments to it (like functions):
 
<pre> guish -zc '|b|&lt;generator =&gt;c{|b|&lt;&quot;clone: @{1}&quot;}(&quot;myname&quot;)'</pre>
Here the evaluation of the code block is done when the click signal is triggered.
 
== Scopes ==
Line 155 ⟶ 160:
Anything embedded inside '''{}''' is treated as a code block and no variable substitution is done at definition time.
 
If a block is the first argument in a phrase (and while evaluating a phrase), then it's executed, and parameters can be specified inside parens '''()''', and referenced inside block by using '''@n''', where 'n' is a number between 1 and 7 (inclusive) which represents a specific argument by position.
 
<pre> v = myvar; a = {puts &quot;here is @{v}&quot;}; a()</pre>
Line 333 ⟶ 338:
; '''rel &lt;element1&gt; &lt;element2&gt; &lt;alignment&gt;'''
: relates &lt;element1&gt; to &lt;element2&gt;, moving &lt;element1&gt; near &lt;element2&gt; using &lt;alignment&gt; (see alignment in STYLE AND ATTRIBUTES section, as &lt;alignment&gt; opts are similar) every time &lt;element2&gt; is moved. If &quot;0&quot; is specified as alignment, the relation is deleted.
; '''pass [&lt;args&gt;]'''
: do nothing, consuming remaining arguments.
; '''send &lt;keysequence&gt;'''
: send a keysequence to an element (must be enabled at compilation time)
Line 627 ⟶ 632:
name = 'random name'
puts &quot;@{gname} is maybe @{name}&quot;</pre>
It's also possible to assign &quot;lists&quot; to a variable by putting the tokens inside '''[]''':
 
<pre> a = [a, b]; for x @a { puts @x }</pre>
Beware that this works just for assignment, '''[]''' cannot be used in expressions.
 
== Element substitution ==
 
Line 710 ⟶ 720:
: gets an element id and returns 1 if the element exists, else 0.
; '''read([file])'''
: reads and returns a line (expluding newline) from standard input; if an existing [file] is given, reads and returns all its content. Beware that this function blocks the GUI events, and returns nothing when reading from stdin and source is non-blocking.
; '''write(text, file)'''
: writes text into file and returns the number of characters written. Creates the file if it doesn't exist yet.
Line 717 ⟶ 727:
; '''call(name, ...)'''
: gets a variable name and a variable number of arguments, then calls the function whose name is 'name' with those arguments and returns the result.
;; '''fixedtake(i, | f...)'''
: returns the token at index 'i'.
; '''slice(si, ei, token)'''
: returns the portion of a token starting at index 'si' and ending at 'ei' (inclusive).
Line 725 ⟶ 737:
; '''join(sep, ...)'''
: returns a single token from a variable number of tokens, joining them using 'sep'.
; '''range(start, end)'''
: returns numbers starting at 'start' and ending at 'end' (inclusive) as multiple tokens.
;; '''wfixed | wnargs()'''
: returns the number of arguments passed to a block.
; '''defined(name)'''
: returns 1 if 'name' is a variable, otherwise 0.
Line 800 ⟶ 816:
: set margin width
; '''mode | m'''
: set expanding mode type (See Expanding mode)
;; '''fixed | f'''
;: width and height are fixed (default for all elements)
;; '''wfixed | w'''
;: width is fixed, height can change
;; '''hfixed | h'''
;: height is fixed, width can change
;; '''relaxed | r'''
;: width and height can change
; '''align | a'''
: set text alignment type (See Alignment)
;; '''l | left | middle-left'''
;: show text at middle left
;; '''r | right | middle-right'''
;: show text at middle right
;; '''c | center | middle-center'''
;: show text at middle center
;; '''tl | top-left'''
;: show text at top left
;; '''tr | top-right'''
;: show text at top right
;; '''t | top-center'''
;: show text at top center
;; '''bl | bottom-left'''
;: show text at bottom left
;; '''br | bottom-right'''
;: show text at bottom right
;; '''b | bottom-center'''
;: show text at bottom center
; '''f | font'''
: set font type using a X11 font name
 
== Expanding mode ==
 
 
 
; '''fixed | f'''
;: width and height are fixed (default for all elements)
; '''wfixed | w'''
;: width is fixed, height can change
;; '''hfixed | h'''
;: height is fixed, width can change
;; '''relaxed | r'''
;: width and height can change
 
== Alignment ==
 
 
 
;; '''l | left | middle-left'''
;: show text at middle left
;; '''r | right | middle-right'''
;: show text at middle right
;; '''c | center | middle-center'''
;: show text at middle center
;; '''tl | top-left'''
;: show text at top left
;; '''tr | top-right'''
;: show text at top right
;; '''t | top-center'''
;: show text at top center
;; '''bl | bottom-left'''
;: show text at bottom left
;; '''br | bottom-right'''
;: show text at bottom right
;; '''b | bottom-center'''
;: show text at bottom center
 
= AUTHOR =
39

edits