Category:Guish: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
(26 intermediate revisions by the same user not shown) | |||
Line 13:
'''guish''' ['''-c''' <code>]['''-s''']['''-q''']['''-k''']['''-t''']['''-f''']['''-v''']['''-b''']['''-h'''][<file>][<arguments>]
= DESCRIPTION =
Line 29 ⟶ 27:
; '''-
: read and execute commands from command line.
; '''-
: display elements when created.
; '''-q'''
: quit when closing last element/window.
; '''-k'''
: terminate all external programs when quitting.
; '''-
: fallback on tty after reading data from other inputs.
; '''-
: show available X11 fonts.
; '''-
: show version.
; '''-
: show build (compiled in) options.
; '''-
: guess.
= INPUTS AND SOURCES =
Line 58 ⟶ 50:
guish reads commands from multiple source sequentially; these source are: command line (with '''-c''' option), file, standard input, and if '''-
If
= SYNTAX OVERVIEW =
Line 68 ⟶ 60:
Being a command interpreter, guish has a little set of syntax rules. They comprises expressions, commands, quotes and special operators. Generic commands and signals are common to all elements, while there are ones which are specific to each element. A phrase is the execution unit, and ends if the program encounters a newline-like character, or a semicolon (
== Comments ==
Line 88 ⟶ 80:
Elements are basically widgets and have some commands and signals associated with them; they can be created using element expressions, enclosing element name within '''||''':
<pre>
In this example, "|b|" is an expression which creates an element of type button, and returns its X11 window id (ex, "65011718
The '''+''' command will then show the button (all elements are hidden by default unless '''-
== Subject and implied subject ==
Line 100 ⟶ 92:
<pre> |i|;+</pre>
The "+" command will by applied to element created by "|i|" expression automatically.
== Variables and variable substitution ==
Line 106 ⟶ 100:
We can refer to elements by using variable substitution, instead of using their window ids:
<pre>
and then:
Line 124 ⟶ 118:
Signals make it possible to run actions on UI changes (or, more generally, on some events).
<pre>
Here, the user creates a button that when clicked will make guish execute a system command (free in this case) (see '''run''' in SPECIAL COMMANDS).
<pre>
A button which is a factory of buttons (run this with '''-s''' option).
Here the evaluation of the code block is done when the click signal is triggered.
== Scopes and closures ==
Line 136 ⟶ 132:
All variables (functions too, as blocks can be assigned to variables) have a specific scope:
<pre> a = 1
{b = 2}()
puts "@{a}:@{b}"</pre>
Here the variable "a" is defined in the global scope, while "b" is defined in a temporarily block scope; hence just "a" is printed to stdout.
When accessing reading/defining a variable in a local scope, if the variable is already defined in the enclosing scope then that variable is picked to be read/modified:
<pre> a = 1
{
a = 5
puts@a
}()
puts@a</pre>
Here "a" is defined in the global scope, then modified from block scope and printed from there, and its value doesn't change.
If a variable is defined inside a block, then all embedded blocks that reference that variable will get its value at definition time (a closure):
<pre> {
a = 1
return {
puts @a
}
}()()</pre>
== Quotes, blocks and functions ==
There are single and double quoting
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 "".
<pre> a = 'my string'; puts "this is: @{a}"
puts "sum of 1 + 5 is: @(add(1, 5))"</pre>
Anything embedded inside '''{}''' is treated as a code block and no variable substitution is done at definition time.
<pre> v = myvar
a = {puts "here is @{v}"}
a()</pre>
Here the variable "v" is not substituted when assigning the block to "a"; it's substituted later, when function "a" is called.
<pre> {
puts join("string length is: ", len(@1))
}("home")</pre>
Here instead, the block is defined and executed immediately, using "home" as the first argument.
Line 166 ⟶ 184:
<pre> fn = {return add(@1, @2)}
puts join(
In addition, when defining a new function, it's possible to "overwrite" the builtin functions in the current scope.
When returning from a function, instead, it's possible to return multiple arguments (the remaining phrase) to the caller:
<pre> fn = {return 1 2 3}
puts join(fn())</pre>
== Conditionals ==
Anything equal to 0
<pre> if 1 { |b|<text } else { |b|<neverhere }</pre>
Line 184 ⟶ 201:
<pre> if ge(@a,4) { |l|<4 }</pre>
== Loops and iteration ==
Line 195 ⟶ 207:
Here an example of a '''while''' loop:
<pre> a = 1
after 4 {a = 0}
while {eq(@a, 1)} {
wait 1 puts 'true'
}
puts 'end'</pre>
And here another one using '''each''' function:
<pre> each({puts @1}, 1, 2, 3, 4, 5})</pre>
And another one of a '''for''' loop:
<pre> for x in 1 2 3 4: { puts @x }</pre>
== Tail recursion optimization (TCO) ==
Since '''2.2.1''' version, guish supports tail recursion optimization too, effectively turning a tail recursive function into a loop:
<pre> upto = {
if gt(@1, @2) {
return
}
puts @1
return upto(add(@1, 1), @2)
}
upto(1, 7)</pre>
To use TCO, the last phrase of a function must use '''return''' command directly (not inside another block like if-else).
== External window id substitution ==
Line 221 ⟶ 257:
<pre> |b|<`echo clickme`</pre>
==
Anything inside '''[]''' is trated as a slice expression. The usage is '''[<n>[,<x>]]''', when <n> is an index, and <x> is an optional end index (always inclusive); if the preceding argument is a regular token, then the expression will return its characters as specified by index(es), otherwise if it's a block, the expression will return its tokens:
<pre> puts {1, 2, 3, 4, {a, b}, cat}[4][1]</pre>
The output of this example is 'b'.
If the index(es) given are out of range, an empty token is returned.
= SPECIAL VARIABLES =
Line 242 ⟶ 282:
; '''self'''
: variable holding the window id when in signal code.
; '''args'''
: refers to the block in which there are positional arguments and function arguments (alternative syntax).
; '''FILE'''
: variable holding the path of current source file.
; '''LINE'''
: variable holding current line number at "that" point in source code.
= ENVIRONMENT VARIABLES =
Line 259 ⟶ 303:
; '''b'''
: A button.
; '''i'''
: An input box.
; '''l'''
: A label.
; '''p'''
: A page (container of other elements; show and hide are applied to all subelements).
; '''c'''
: A checkbox.
; '''t'''
: A label with a totally transparent background (requires a compositor).
Line 280 ⟶ 322:
; '''=> <signal> <subcmd>'''
: register a sub-command <subcmd> to run when <signal> triggers. For normal signals (eg. signals tied to elements), there must exist an implied subject.
; '''!> <signal>'''
: unregister a sub-command <subcmd> previously registered on signal <signal>.
; '''q'''
: quit guish (exit status 0).
; '''exit <status>'''
: quit guish (exit status <status>).
; '''cd <path>'''
: change current working directory using <path>.
; '''run <cmd>'''
: execute shell command <cmd>.
; '''
:
; '''
:
; '''
: prints remaining phrase to stderr.
; '''
: unsets a variable (<name>) or timed scheduled procedure registered with <num>, see '''every''' command. If, instead of <name|num>, an element id <wid> is given and a name attribute <attr> is given, deletes that element attribute.
; '''source <file>'''
: execute commands from file.
; '''vars [<wid>]'''
: shows all variables present in the current scope or, if <wid> element id is given, shows all element attributes (uses stderr).
; '''ls'''
: display all existing widgets
; '''del <wid>'''
: delete a widget with id <wid>.
; '''every <seconds> <block>'''
: schedule <code> to run after <seconds> seconds are elapsed.
; '''after <seconds> <block>'''
: schedule <block> to run once after <seconds> seconds are elapsed.
; '''wait <seconds>'''
: stop command execution and wait <seconds> seconds before resuming
; '''if <condition> <block>'''
: executes <block> if condition evaluates to true (see Conditionals).
Line 321 ⟶ 363:
; '''return <phrase>'''
: when used inside a function, returns all its arguments (the remaining phrase) to the caller.
; '''while <condition> <block>'''
: executes <block> until <condition> evaluates to true (see Conditionals).
; '''until <condition> <block>'''
: executes <block> until <condition> evaluates to true (see Conditionals).
; '''for [<
: executes the block <
; '''break'''
: exit from current loop.
; '''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 <wid> <keysequence>'''
: send a keysequence to an element whose id si <wid> (must be enabled at compilation time).
; '''ctrl <wid> <keysequence>'''
: send control key sequence to an element whose id si <wid> (must be enabled at compilation time).
Line 347 ⟶ 387:
; '''G'''
: element is undetectable in taskbar.
; '''F'''
: resize the element to fit the entire screen.
; '''d'''
: restore element's default window attributes.
; '''!'''
: bypass window manager.
; '''!!'''
: follow window manager as default.
; '''n'''
: center element in its parent.
; '''-'''
: hide element.
; '''+'''
: show element.
; '''c'''
: click element.
; '''f'''
: focus element.
; '''t'''
: make element stay at top.
; '''b'''
: make element stay at bottom.
; '''x'''
: hide element, or quit guish if quit-on-last-close is on and the element is the last closed one.
; '''l'''
: lower the element.
; '''r'''
: raise the element.
; '''M'''
: maximize the element.
; '''D'''
: disable the element.
; '''E'''
: enable the element.
; '''o'''
: fits element's size to its content.
; '''w'''
: resize an element in right-bottom directions to fit its parent, respecting limits of other elements.
; '''nfill'''
: resize an element in right-bottom directions to fit its parent.
; '''rfill'''
: resize an element in right direction to fit its parent, respecting limits of other elements.
; '''nrfill'''
: resize an element in right direction to fit its parent.
; '''bfill'''
: resize an element in bottom direction to fit its parent, respecting limits of other elements.
; '''nbfill'''
: resize an element in bottom direction to fit its parent.
; '''L'''
: clear element's data.
; ''': <title>'''
: set element title.
; '''s <text>'''
: set element style (see STYLE AND ATTRIBUTES section).
; '''z <w> <h>'''
: resize element by width and height.
; '''m <x> <y>'''
: move element to coords <x> <y>.
; '''
: draws/fills lines, points and arcs depending on operation (See Drawing operations subsection). Origin coordinates correspond to the bottom-left corner as default Cartesian axes (instead of upper-left one used for windows/elements). If no operation is given, then all drawings are discarded from the implied element.
; '''A <element> <alignment>'''
: moves implied element to <element> using <alignment> (see alignment in STYLE AND ATTRIBUTES section, as <alignment> opts are similar).
; '''< <text>'''
: set element text using <text>.
; '''<+ <text>'''
: add additional text to element text using <text>.
; '''> <var>'''
: define a variable named <var> using element text to set its value.
; '''g'''
: enable/disable (toggle) moving the parent of the element by click-and-drag it. Enabling this will automatically exclude x/y moving flags below.
Line 431 ⟶ 463:
: enable/disable (toggle) moving an element inside its parent by click-and-drag on y axis Enabling this will automatically exclude the flag to click-and-drag and move parent.
==
; '''l [<color> <x1> <y1> <x2> <y2> [<...>]]'''
: 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> [<...>]]'''
: 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> [<...>]]'''
: 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> (consumes all the phrase). If no arguments are given, then all element arcs are discarded.
; '''A [<color> <x> <y> <w> <h> <alpha> <beta> [<...>]]'''
: fills 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> (consumes all the phrase). If no arguments are given, then all element arcs are discarded.
; '''p [<color> [<...>]]'''
: draws given points using color <color> (beware this command consumes all the phrase). If no arguments are given, then all points are discarded.
; '''x [<color> [<...>]]'''
: draws given pixels using color <color> (beware this command consumes all the phrase). If no arguments are given, then all pixels are discarded.
; '''n [<color> <name> <x> <y>]'''
: draws given point using color <color> and putting the text <name> at that point. If no arguments are given, then all points are discarded.
= NORMAL COMMANDS =
== checkbox commands ==
; '''C'''
: check.
; '''U'''
: uncheck.
; '''S'''
: show input data as normal while typing.
; '''H'''
: hide input data while typing.
; '''P'''
: use password mode, displaying just asterisks.
; '''W'''
: toggles "go to the next line" when hitting return (triggers return signal anyway).
; '''Q'''
: make subelements equals (in size).
; '''S <style>'''
: style all subelements.
; '''P'''
: free all embedded elements.
; '''<< <element>'''
: embeds element (or an external client).
; '''<<< <element>'''
: embeds element (or an external client), fitting the page to its content.
; '''>> <element>'''
: free element, reparenting it to root window.
; '''>>> <element>'''
: free element, reparenting it to root window and fitting the page to its content.
; '''v'''
: set vertical layout readjusting all subwidgets.
; '''h'''
: set horizontal layout readjusting all subwidgets.
; '''Z <e1> <e2>'''
: swaps sub-elements position.
; '''N'''
: inverts the order of sub-elements.
= SPECIAL SIGNALS =
; Special signals are independent from elements, and are tied to internal guish events.
:
; '''q'''
: triggered at program exit.
; '''t'''
: triggered when program
= GENERIC SIGNALS =
; Generic signals are common to all elements.
:
; '''x'''
: triggered when element is closed.
; '''c'''
: triggered when element is clicked.
; '''lc'''
: triggered when element is left-clicked.
; '''rc'''
: triggered when element is right-clicked.
; '''mc'''
: triggered when element is middle-clicked.
; '''cc'''
: triggered when element is double clicked.
; '''lcc'''
: triggered when element is double left-clicked.
; '''rcc'''
: triggered when element is double right-clicked.
; '''mcc'''
: triggered when element is double middle-clicked.
; '''p'''
: triggered when element is pressed.
; '''lp'''
: triggered when element is left-pressed.
; '''rp'''
: triggered when element is right-pressed.
; '''mp'''
: triggered when element is middle-pressed.
; '''r'''
: triggered when element is released.
; '''lr'''
: triggered when element is left-released.
; '''rr'''
: triggered when element is right-released.
; '''mr'''
: triggered when element is middle-released.
; '''m'''
: triggered when element is moved.
; '''s'''
: triggered when element scrolled down.
; '''S'''
: triggered when element scrolled up.
; '''z'''
: triggered when element is resized.
; '''e'''
: triggered when mouse pointer "enters" the element.
; '''l'''
: triggered when mouse pointer "leaves" the element.
; '''f'''
: triggered when focusing the element.
; '''u'''
: triggered when un-focusing the element.
; Normal signals are per element.
:
; '''U'''
: triggered when checkbox is unchecked.
; '''C'''
: triggered when checkbox is checked.
; '''R'''
: triggered when input has focus and
= REDUNDANT TOKENS =
Line 570 ⟶ 620:
These tokens are ignored:
= EVALUATION ORDER AND SUBSTITUTIONS =
Line 576 ⟶ 626:
Every time a new phrase is evaluated, it goes through a series of special substitutions/evaluations before it's commands are interpreted
The evaluation order is: hex substitution (at tokenizer level), evaluation of expressions (where code evaluation/execution, substitutions and functions are computed), evaluation of special commands and execution of generic/normal commands.
Moreover if after the execution phase (the last one) the phrase is not empty, the evaluation cycle will restart from evaluation of expressions phase, and it will continue until there are no more tokens in the phrase.
Every phrase is reduced to an empty phrase while evaluating:
<pre> a=234;{i1=|i|;<'input1'+}();{i2=|i|;<'input2'+}()|b|<btn+</pre>
This example is composed by 2 phrases, and the code block in each phrase is executed before each assignment.
== Hex substitution ==
Line 593 ⟶ 641:
Non quoted tokens are subject to hex substitution: if a
<pre> puts \x68\x6F\x6D\x65</pre>
Here, the string
== Globbing ==
Line 602 ⟶ 650:
If a
<pre> |b||b||b|+
puts *</pre>
== Variable substitution ==
With the '''=''' operator (actually, it's a special statement command), it's possible to assign
<pre> b = 123; puts @a</pre>
There are two methods to define/create empty variables: by explicitely assing an empty string to a variable (ex. a = "") or by simply omit the value (ex. a =).
In addition, if there is more than one value to assign, a block is automatically created (embedding those values) and assigned to that variable:
<pre> a = 1 # this simply assigns '1' to the variable 'a'
b = 1, 2, 3, 4 # this instead assigns the block '{1, 2, 3, 4}' to the variable 'a'
c = {1, 2, 3, 4} # same but explicit</pre>
Each block has it's own scope, and variable resolution works by searching from the last scope to the first. Ex:
<pre> a = 1
puts(@a)
{
a=345
b=6534
}()
puts@a
puts"b:@{b}"</pre>
In the last example, a is set to 1 and printed, then it's changed to 345 from another scope, in which another variable (b) is set. After code block, just "a" is updated, and "b" doesn't exist anymore.
For example:
Line 627 ⟶ 689:
name = 'random name'
puts "@{gname} is maybe @{name}"</pre>
== Element
Anything inside '''||''' is an element expression; a widget of a given element is created and its X11 window id substituted. The synopsis is: |<element>[{<width>, <height>}]| Ex.
<pre> |b|+</pre>
Line 658 ⟶ 720:
xterm program is spawn, and can be driven (almost) like a normal element.
= OPERATORS =
== Binary ==
; '''<s> .. <e>'''
: returns integers starting at <s> and ending at <e> (inclusive) as multiple tokens.
; '''<var> = [<val>, [<val1>, ...]]'''
: defines a variable (consumes all the phrase). If no value is given, an empty token is assigned to the variable. If a single value is given, that value is assigned to the variable. If multiple values are given, then all these values are wrapped inside a block, and this block is assigned to the variable.
; '''<attr> .= [<val>, [<val1>, ...]]'''
: defines an element using the implied subject attribute (consumes all the phrase). If no value is given, an empty token is assigned to the variable. If a single value is given, that value is assigned to the variable. If multiple values are given, then all these values are wrapped inside a block, and this block is assigned to the variable.
== Unary ==
; '''@<varname|num>'''
: dereferences a variable name (or positional argument).
; '''@*'''
: returns all function parameters as tokens (usable with command line parameters too).
; '''[<eid>].<attr>'''
: dereferences an element attribute; if <eid> is given, uses that element, otherwise uses implied subject.
= ELEMENT ATTRIBUTES =
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>
In the last example, a custom attribute, "myattr" is created and used.
The following are default attributes (readonly):
; '''t'''
: widget's type.
; '''w'''
: widget's width.
; '''h'''
: widget's height.
; '''x'''
: widget's x coord.
; '''y'''
: widget's y coord.
; '''b'''
: widget's border width.
; '''g'''
: widget's margin width.
; '''d'''
: widget's text data.
; '''T'''
: widget's title.
; '''c'''
: widget's checked/unchecked status (only for checkbox).
; '''n'''
: widget's number of subwidgets (only for page).
; '''s'''
: widget's subwidgets ids (one token each, only for page).
; '''pid'''
: process ID associated with the widget.
; '''v'''
: widget is visible.
; '''e'''
: widget is enabled (freezed/unfreezed).
; '''f'''
: widget is focused.
Symbol
; '''exists(<eid>)'''
:
; '''read([<file>])'''
: reads and returns a line (
; '''write(<text>, <file>)'''
: writes text into file and returns the number of characters written. Creates the file if it doesn't exist yet.
; '''append(<text>, <file>)'''
: append text to the end of file and returns the number of characters written. Creates the file if it doesn't exist yet.
; '''
: evaluates code by first stringifying all given arguments and then returns the result of evaluation if any. Beware that this function runs in the "current" scope, and can modify it.
; '''
: gets the name of a builtin function and a variable number of arguments, then calls the builtin function with those arguments and returns the result (if any). It's useful when overriding builtin functions.
; '''
: executes <function> for each additional argument given passing it as the first argument to the block. If return values are present, they will be accumulated and then returned.
; '''
: returns
; '''
: returns the value of the current working directory.
; '''
: if a block is given as first argument, its element will be returned in reverse, otherwise '''rev''' will return all its arguments in reverse. This function is somewhat special, as when there are no arguments to get, it'll return nothing (statement behaviour).
; '''
: sets variables, works exactly like assignment with special operator '''=''', but in expressions. This function is somewhat special, it'll return nothing (statement behaviour).
; '''
: if <cond> is true and <v1> is given, returns <v1>, else if <cond> is false and <v2> is given, returns <v2>.
; '''
: if <cond> is false and <v1> is given, returns <v1>, else if <cond> is true and <v2> is given, returns <v2>.
; '''
: returns the first true argument; if there are no true arguments, returns the last one which is false. The function evaluates any block given.
; '''or(...)'''
: returns the last true argument if all arguments are true, otherwise returns the first false argument. The function evaluates any block given.
; '''flat(...)'''
: returns all given arguments; if a block is found, then it is flatted.
; '''block(...)'''
: returns a code block, embedding the given arguments into '''{}'''.
; '''some(...)'''
: returns given arguments. If nothing is given, returns an empty token.
; '''puts(...)'''
: prints given arguments to stdout. This function is somewhat special, it'll return nothing (statement behaviour).
; '''push(...)'''
: pushes given arguments to current function arguments (works with command line parameters too). This function is somewhat special, it'll return nothing (statement behaviour).
; '''pushb(...)'''
: pushes given arguments to current function arguments from the beginning (works with command line parameters too). This function is somewhat special, it'll return nothing (statement behaviour).
; '''pop()'''
: pops the last argument from function arguments (works with command line parameters too). This function is somewhat special, as if there are no arguments to pop, it'll return nothing (statement behaviour).
; '''popb()'''
: pops the first argument from function arguments (works with command line parameters too). This function is somewhat special, as if there are no arguments to pop.
; '''times(<n>, <arg>)'''
: returns a sequence of tokens made by <n> times <arg>. This function is somewhat special, as when there are 0 tokens to replicate, it'll return nothing (statement behaviour).
; '''get(<name>)'''
: returns the value of the variable with name <name>, or an empty token if the variable does not exist.
; '''true(<arg>)'''
: returns 1 if <arg> is true, 0 otherwise.
; '''false(<arg>)'''
: returns 0 if <arg> is true, 1 otherwise.
; '''in(<n>, <heap>)'''
: returns 1 if <n> is found in <heap>, 0 otherwise; the arguments can be of any type (single tokens and blocks).
; '''join(...)'''
: joins blocks and/or tokens by applying the following rules to all arguments given, and accumulates the result as the first operand. If the operands are blocks, then a single new block is created by joining them; if the operands are tokens, then a single new token is created by joining them, and its type will be that of the "second" token; if the operands are mixed (eg. a block and a token), then the token will be embedded inside the block.
; '''isdef(<token>)'''
: returns 1 if <token> is a variable, 0 otherwise.
; '''isvar(<token>)'''
: returns 1 if <token> is a (type) variable, 0 otherwise.
; '''isfunc(<token>)'''
: returns 1 if <token> refers to a function, 0 otherwise.
; '''isblock(...)'''
: returns 1 if just one argument is given and is a block, 0 otherwise.
; '''isint(...)'''
: returns 1 if just one argument is given and is an integer, 0 otherwise.
; '''len(<arg>)'''
: if a block is given, returns the number of its element, otherwise returns the number of characters of the token.
; '''split(<token>, <sep>)'''
: splits "token" using separator "sep" and returns resulting tokens having their type equal to that of "token".
; '''csplit(<token>, <sep>)'''
: splits "token" using separator "sep" and returns resulting tokens as normal commands.
; '''seq(<t1>, <t2>, ...)'''
: returns 1 if all arguments are equal (string comparison), 0 otherwise.
; '''add(...)'''
Line 745 ⟶ 882:
; '''mod(...)'''
: perform modulus.
; '''
: returns a random positive integer.
; '''sqrt(<n>)'''
: returns the square root of <n>.
; '''cbrt(<n>)'''
: returns the cube root of <n>.
; '''pow(<n>, <e>)'''
: returns the power of <n> raised to <e>.
; '''log(<n>)'''
: returns the base 10 logarithm of <n>.
; '''ln(<n>)'''
: returns the natural logarithm of <n>.
; '''sin(<n>)'''
: returns the sine of <n> (degrees).
; '''cos(<n>)'''
: returns the cosine of <n> (degrees).
; '''tan(<n>)'''
: returns the tangent of <n> (degrees).
; '''hex(<n>)'''
: returns <n> in its hexadecimal representation.
; '''int(<n>)'''
: returns integral part of given number <n>; rounds to nearest integer.
; '''xor(<n1>, <n2>, ...)'''
: perform bitwise XOR.
; '''band(<n1>, <n2>, ...)'''
: perform bitwise AND.
; '''bor(<n1>, <n2>, ...)'''
: perform bitwise OR.
; '''lsh(<n1>, <n2>, ...)'''
: perform bitwise left shift.
; '''rsh(<n1>, <n2>, ...)'''
: perform bitwise right shift.
; '''not(<n>)'''
: perform negation
; '''eq(<n1>, <n2>, ...)'''
: equal-to
; '''ne(<n1>, <n2>, ...)'''
: not-equal-to
; '''lt(<n1>, <n2>, ...)'''
: less-than
; '''gt(<n1>, <n2>, ...)'''
: greater-than
; '''le(<n1>, <n2>, ...)'''
: less-equal-than
; '''ge(<n1>, <n2>, ...)'''
: greater-equal-than
; '''abs(<n>)'''
: perform absolute value
; '''neg(<n>)'''
: unary minus.
Line 773 ⟶ 942:
Here, we create a label with a blue background and white foreground.
Each field must be separated by newlines, ''';''' or '''|'''. Colors can be specified by using a common shortname, such as
; '''background | bg: <color|/<path to image>>'''
: set background color or a background image by specifying image path; if the string "null" is given as <path to image>, current image is removed. (Background image loading requires building guish with Imlib2 support.)
; '''color | foreground | fg: <color>'''
: set foreground color
; '''pressed-background | pbg: <color>'''
: background color when element is pressed
; '''pressed-color | pfg: <color>'''
: foreground color when element is pressed
; '''hovered-background | hbg: <color>'''
: background color when element is hovered
; '''hovered-color | hfg: <color>'''
: foreground color when element is hovered
; '''border-color | bc: <color>'''
: set border color
; '''
: set width
; '''height | h: <value in pixels>'''
: set height
; '''border | b: <value in pixels>'''
: set border width
; '''
: set line width (use with "/" command)
; '''margin | g: <value in pixels>'''
: set margin width
; '''mode | m: <expanding mode>'''
: set expanding mode type (See Expanding mode)
: set alignment type (See Alignment)
: 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 ==
Any element that's not a page has a particular text alignment that can be changed. If an alignment is specified for a page element instead, (whose defaults alignments are top-center for horizontal layout, and middle-left for vertical one), then its sub-elements will be aligned accordingly, depending from page layout type too.
; '''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 =
Line 837 ⟶ 1,018:
Francesco Palumbo <phranz@subfc.net>
= THANKS =
La vera Napoli, Carme, Pico, Titina, Molly, Leo, i miei amati nonni, mio padre, mia madre, e tutti coloro su cui ho potuto e posso contare. Grazie mille.
= LICENSE =
|