Category:Guish: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 129:
<pre> guish -zc "|b|<generator =>c{|b|<clone}"</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|<generator =>c{|b|<"clone: @{1}"}("myname")'</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
<pre> v = myvar; a = {puts "here is @{v}"}; a()</pre>
Line 333 ⟶ 338:
; '''rel <element1> <element2> <alignment>'''
: relates <element1> to <element2>, moving <element1> near <element2> using <alignment> (see alignment in STYLE AND ATTRIBUTES section, as <alignment> opts are similar) every time <element2> is moved. If "0" is specified as alignment, the relation is deleted.
; '''pass [<args>]'''
: do nothing, consuming remaining arguments.
; '''send <keysequence>'''
: send a keysequence to an element (must be enabled at compilation time)
Line 627 ⟶ 632:
name = 'random name'
puts "@{gname} is maybe @{name}"</pre>
It's also possible to assign "lists" 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.
: 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.
: 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'''
; '''wfixed | w'''
== Alignment ==
= AUTHOR =
|