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 |
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 "this is: @{a}" |
<pre> a = 'my string'; puts "this is: @{a}" |
||
puts "sum of 1 + 5 is: @(return add(1, 5))"</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 <status>). |
: quit guish (exit status <status>). |
||
; '''cd <path>''' |
; '''cd <path>''' |
||
: change |
: change current working directory using <path>. |
||
; '''run <cmd>''' |
; '''run <cmd>''' |
||
: execute shell command <cmd>. |
: execute shell command <cmd>. |
||
Line 351: | Line 352: | ||
: schedule <block> to run once after <seconds> seconds are elapsed. |
: schedule <block> to run once after <seconds> seconds are elapsed. |
||
; '''wait <seconds>''' |
; '''wait <seconds>''' |
||
: stop command execution and wait <seconds> seconds before resuming ( |
: stop command execution and wait <seconds> seconds before resuming (accepts decimal values too). XEvent handling, schedules actions and signal execution are unaffected by this option. |
||
; '''if <condition> <block>''' |
; '''if <condition> <block>''' |
||
: executes <block> if condition evaluates to true (see Conditionals). |
: executes <block> if condition evaluates to true (see Conditionals). |
||
Line 465: | Line 466: | ||
; '''l [<color> <x1> <y1> <x2> <y2> [<...>]''' |
; '''l [<color> <x1> <y1> <x2> <y2> [<...>]''' |
||
: draws lines between given points using color <color> (beware this command |
: draws lines between given points using color <color> (beware this command consumes all the phrase). If no arguments are given, then all element lines are discarded. |
||
; '''L [<color> <x1> <y1> <x2> <y2> [<...>]''' |
; '''L [<color> <x1> <y1> <x2> <y2> [<...>]''' |
||
: fills the polygon described by given points using color <color> (beware this command |
: fills the polygon described by given points using color <color> (beware this command consumes all the phrase). If no arguments are given, then all filled polygons are discarded. |
||
; '''a [<color> <x> <y> <w> <h> <alpha> <beta>]''' |
; '''a [<color> <x> <y> <w> <h> <alpha> <beta>]''' |
||
: draws an arc using color <color> and whose "center" is at <x> <y>, major and minor axes are respectively <w> and <h>, start and stop angles are <alpha> and <beta>. If no arguments are given, then all element arcs are discarded. |
: draws an arc using color <color> and whose "center" is at <x> <y>, major and minor axes are respectively <w> and <h>, start and stop angles are <alpha> and <beta>. 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 |
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 "'''.='''" operator; to get it instead use the "'''.'''" 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 <eid> exists, 0 otherwise. |
: returns 1 if a widget with id <eid> exists, 0 otherwise. |
||
; '''read([<file>])''' |
; '''read([<file>])''' |
||
: reads and returns a line (excluding newline) from standard input; if an existing |
: 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(<text>, <file>)''' |
; '''write(<text>, <file>)''' |
||
: 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. |