Category:Guish: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 161: Line 161:
There are single and double quoting: anything embedded inside single quotes '', is treated literally (no escaping takes place) and as a single token.
There are single and double quoting: anything embedded inside single quotes '', is treated literally (no escaping takes place) and as a single token.


Variable interpolation is used inside double quotes "", external command substitution quotes `` and external window id substitution <( ).
Variable and function interpolations (respectively via "'''@{...}'''" and "'''@(...)'''") are used inside double quotes "", external command substitution quotes `` and external window id substitution '''<(...)'''.


Escaping ("\n\t\r\f\v\b") takes place only inside double quotes "".
Escaping ("\n\t\r\f\v\b") takes place only inside double quotes "".


<pre> a = 'my string'; puts &quot;this is: @{a}&quot;</pre>
<pre> a = 'my string'; puts &quot;this is: @{a}&quot;
puts &quot;sum of 1 + 5 is: @(return add(1, 5))&quot;</pre>
Anything embedded inside '''{}''' is treated as a code block and no variable substitution is done at definition time.
Anything embedded inside '''{}''' is treated as a code block and no variable substitution is done at definition time.


Line 327: Line 328:
: quit guish (exit status &lt;status&gt;).
: quit guish (exit status &lt;status&gt;).
; '''cd &lt;path&gt;'''
; '''cd &lt;path&gt;'''
: change curret working directory using &lt;path&gt;.
: change current working directory using &lt;path&gt;.
; '''run &lt;cmd&gt;'''
; '''run &lt;cmd&gt;'''
: execute shell command &lt;cmd&gt;.
: execute shell command &lt;cmd&gt;.
Line 351: Line 352:
: schedule &lt;block&gt; to run once after &lt;seconds&gt; seconds are elapsed.
: schedule &lt;block&gt; to run once after &lt;seconds&gt; seconds are elapsed.
; '''wait &lt;seconds&gt;'''
; '''wait &lt;seconds&gt;'''
: stop command execution and wait &lt;seconds&gt; seconds before resuming (accept decimal values too). XEvent handling, schedules actions and signal execution are unaffected by this option.
: stop command execution and wait &lt;seconds&gt; seconds before resuming (accepts decimal values too). XEvent handling, schedules actions and signal execution are unaffected by this option.
; '''if &lt;condition&gt; &lt;block&gt;'''
; '''if &lt;condition&gt; &lt;block&gt;'''
: executes &lt;block&gt; if condition evaluates to true (see Conditionals).
: executes &lt;block&gt; if condition evaluates to true (see Conditionals).
Line 465: Line 466:


; '''l [&lt;color&gt; &lt;x1&gt; &lt;y1&gt; &lt;x2&gt; &lt;y2&gt; [&lt;...&gt;]'''
; '''l [&lt;color&gt; &lt;x1&gt; &lt;y1&gt; &lt;x2&gt; &lt;y2&gt; [&lt;...&gt;]'''
: draws lines between given points using color &lt;color&gt; (beware this command get all the phrase). If no arguments are given, then all element lines are discarded.
: draws lines between given points using color &lt;color&gt; (beware this command consumes all the phrase). If no arguments are given, then all element lines are discarded.
; '''L [&lt;color&gt; &lt;x1&gt; &lt;y1&gt; &lt;x2&gt; &lt;y2&gt; [&lt;...&gt;]'''
; '''L [&lt;color&gt; &lt;x1&gt; &lt;y1&gt; &lt;x2&gt; &lt;y2&gt; [&lt;...&gt;]'''
: fills the polygon described by given points using color &lt;color&gt; (beware this command get all the phrase). If no arguments are given, then all filled polygons are discarded.
: fills the polygon described by given points using color &lt;color&gt; (beware this command consumes all the phrase). If no arguments are given, then all filled polygons are discarded.
; '''a [&lt;color&gt; &lt;x&gt; &lt;y&gt; &lt;w&gt; &lt;h&gt; &lt;alpha&gt; &lt;beta&gt;]'''
; '''a [&lt;color&gt; &lt;x&gt; &lt;y&gt; &lt;w&gt; &lt;h&gt; &lt;alpha&gt; &lt;beta&gt;]'''
: draws an arc using color &lt;color&gt; and whose &quot;center&quot; is at &lt;x&gt; &lt;y&gt;, major and minor axes are respectively &lt;w&gt; and &lt;h&gt;, start and stop angles are &lt;alpha&gt; and &lt;beta&gt;. If no arguments are given, then all element arcs are discarded.
: draws an arc using color &lt;color&gt; and whose &quot;center&quot; is at &lt;x&gt; &lt;y&gt;, major and minor axes are respectively &lt;w&gt; and &lt;h&gt;, start and stop angles are &lt;alpha&gt; and &lt;beta&gt;. If no arguments are given, then all element arcs are discarded.
Line 742: Line 743:




Every element can have some default readonly attributes and a variable number of custom attributes (which can be set by using assignment only, not by using '''let''' function). To get/set an attribute, use the special &quot;'''.fR&quot; operator.'''
Every element can have some default readonly attributes and a variable number of custom attributes (which can be set by using assignment only, not by using '''let''' function). To set an attribute, use the &quot;'''.='''&quot; operator; to get it instead use the &quot;'''.'''&quot; operator.


<pre> b = |b|; myattr .= 'here'; puts(@b.myattr)</pre>
<pre> b = |b|; myattr .= 'here'; puts(@b.myattr)</pre>
Line 791: Line 792:
: returns 1 if a widget with id &lt;eid&gt; exists, 0 otherwise.
: returns 1 if a widget with id &lt;eid&gt; exists, 0 otherwise.
; '''read([&lt;file&gt;])'''
; '''read([&lt;file&gt;])'''
: reads and returns a line (excluding 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.
: reads and returns a line (excluding 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(&lt;text&gt;, &lt;file&gt;)'''
; '''write(&lt;text&gt;, &lt;file&gt;)'''
: writes text into file and returns the number of characters written. Creates the file if it doesn't exist yet.
: writes text into file and returns the number of characters written. Creates the file if it doesn't exist yet.