|
1902 | 1902 | The ''Help'' menu contains commands to show various pieces of information including an inventory of resources available in the executable file. This information is supplied by functions defined in the '''"""INIT-CMD"""''' resource, which may be customised as required.
|
1903 | 1903 | </pre>
|
1904 | 1904 | </div>
|
1905 |
| -<div title="Introduction" creator="John Hind" modifier="John Hind" created="201005272040" modified="201402211438" tags="startup" changecount="10"> |
| 1905 | +<div title="Introduction" creator="John Hind" modifier="John Hind" created="201005272040" modified="201403240925" tags="startup" changecount="11"> |
1906 | 1906 | <pre>Winsh.lua is an advanced runtime for the [[Lua]] language on Windows. With the supplied libraries it is ideal for writing small, self-contained utilities with simple command line or graphical interfaces such as backup automation scripts, installers and portable application menus.
|
1907 | 1907 |
|
1908 | 1908 | Winsh.lua is compatible with all versions of Windows starting with Windows XP. However a few library features are only supported in later Windows versions. These are noted in this documentation and are designed to degrade as gracefully as possible.
|
|
1921 | 1921 | The [[Interactive Console]] and [[Lua]] topics are good starting points for new users.
|
1922 | 1922 |
|
1923 | 1923 | ----
|
1924 |
| -This help file was created using the superb and innovative """TiddlyWiKi""": http://classic.tiddlywiki.com/.</pre> |
| 1924 | +This document was created using the superb and innovative """TiddlyWiKi""": http://classic.tiddlywiki.com/.</pre> |
1925 | 1925 | </div>
|
1926 | 1926 | <div title="JHBackstagePlugin" creator="John Hind" modifier="John Hind" created="201102041649" modified="201102152102" tags="systemConfig excludeLists excludePublished excludeSearch excludeMissing" changecount="9">
|
1927 | 1927 | <pre>/***
|
|
3000 | 3000 | };
|
3001 | 3001 | //}}}</pre>
|
3002 | 3002 | </div>
|
3003 |
| -<div title="Menu Class" creator="John Hind" modifier="John Hind" created="201311231135" modified="201402211711" changecount="24"> |
| 3003 | +<div title="Menu Class" creator="John Hind" modifier="John Hind" created="201311231135" modified="201403241042" changecount="29"> |
3004 | 3004 | <pre>!menu = winsh.Menu([title] [, onshow] [, gutter])
|
3005 |
| -The Menu Class generates objects which represent menus of actions. Menu inherits from [[List Class]] and all List methods may be used to create and modify the menu list. The optional parameters initialise the pre-defined fields (see below). A string parameter initialises '''title''', a callable parameter initialises '''onshow''' and a boolean parameter '''gutter'''. |
| 3005 | +The Menu Class generates objects which represent menus of actions. Menu inherits the methods of [[List Class]] and all List methods may be used to create and modify the menu list. However [[list:insert]] inserts Menu class objects as objects rather than as lists allowing sub-menus to be created. The optional parameters initialise some of the pre-defined fields (see below). A string parameter initialises '''title''', a callable parameter initialises '''onshow''' and a boolean parameter '''gutter'''. |
3006 | 3006 |
|
3007 | 3007 | Each list item must have a value comprising one of the following:
|
3008 | 3008 | * A [[Command Class]] object representing a command which may be executed from the menu.
|
3009 | 3009 | * A [[Menu Class]] object representing a sub-menu which may be opened from the menu.
|
3010 | 3010 | * A string "-" which causes a horizontal separator line to be drawn.
|
3011 | 3011 | * A string "|" which specifies a column split dividing the menu into two columns.
|
3012 | 3012 | * A string (not one of the above) which becomes a non-selectable menu item (heading) unless it exists in a column on its own, in which case it becomes a vertical side-bar label.
|
3013 |
| -The pre-defined (read-only) fields are as follows: |
| 3013 | +The pre-defined fields are as follows: |
3014 | 3014 | ;'''title'''
|
3015 | 3015 | :This string value is the menu text shown for a sub-menu. If a menu object is used to define a sub-menu and this field is missing the default text "sub menu" is used.
|
3016 | 3016 | ;'''onshow'''
|
3017 | 3017 | :This is an optional field and if present the value can be any callable Lua object (usually a function) which is called immediately prior to showing the menu and passed a single parameter, the Menu object. It can be used to modify the Menu or Command objects to vary the appearance and function of the menu that is shown to the user.
|
3018 | 3018 | ;'''gutter'''
|
3019 | 3019 | :If present this overrides the default handling which shows a gutter if any Command objects in the menu or any sub-menus have '''icon''' or boolean '''value''' fields and not otherwise. Set to boolean {{{true}}} to show the gutter always, or boolean {{{false}}} to hide it always (in which case icons will be ignored and boolean '''value''' will be rendered using text colour rather than checkmarks). The setting applies globally to the menu and all of its sub-menus, and the '''gutter''' key should be applied in the main Menu table (however '''gutter''' {{{true}}} in a sub-menu will have effect as long as there is no '''gutter''' {{{false}}} in a parent menu or a subsequent sub-menu).
|
| 3020 | +;'''disabled''' |
| 3021 | +:This field is initialised {{{false}}}. It may be changed (usually in an '''onshow''' function). It only has effect for a menu used as a submenu within another menu. If it is true when the menu is shown, the title entry for the sub-menu is shown disabled and the menu itself is not shown. |
3020 | 3022 | </pre>
|
3021 | 3023 | </div>
|
3022 | 3024 | <div title="Nested Sliders" creator="John Hind" modifier="John Hind" created="201102061601" modified="201105211433" tags="excludeLists excludePublished excludeSearch excludeMissing">
|
|
3821 | 3823 | [[key:deletevalue]] - Delete a named value of the current key.
|
3822 | 3824 | </pre>
|
3823 | 3825 | </div>
|
3824 |
| -<div title="Release 2.0" creator="John Hind" modifier="John Hind" created="201102271549" modified="201402181749" tags="imprint excludeLists" changecount="16"> |
| 3826 | +<div title="Release 2.0" creator="John Hind" modifier="John Hind" created="201102271549" modified="201403251041" tags="imprint excludeLists" changecount="26"> |
3825 | 3827 | <pre>|Name|Winsh|
|
3826 | 3828 | |Author|[[John Hind]]|
|
3827 |
| -|Version|2.0| |
3828 |
| -|Copyright|&copy;2012 [[John Hind]]| |
3829 |
| -|Release Date|26th November 2012| |
| 3829 | +|Version|2.0.1| |
| 3830 | +|Copyright|&copy;2014 [[John Hind]]| |
| 3831 | +|Release Date|25th March 2014| |
3830 | 3832 | {{H3{Release Notes}}}
|
3831 |
| ->2.0 - Changed object model and added clipboard support. |
| 3833 | +>2.0.1 - Added {{{__whole}}} metafield for [[List Class]]. Used this to fix sub-menu insertion. Added {{{disabled}}} field to [[Menu Class]] (for sub-menus). |
| 3834 | +>2.0 - Changed object model and added clipboard support. Updated Lua core to 5.2.2. Changed name from Grunt to Winsh. |
3832 | 3835 | >1.2 - Updated the """Self-Iterating""" Objects Lua patch, changed [[winsh.taskicon]].
|
3833 | 3836 | >1.1 - Upgraded Lua core to 5.2.1.
|
3834 | 3837 | ''<<publish>>''</pre>
|
|
5166 | 5169 |
|
5167 | 5170 | %/<<tiddler {{'ShowPopup##'+('$1'=='$'+'1'?'info':'show')}} with: [[$1]] [[$2]] [[$3]] [[$4]] [[$5]] [[$6]]>></pre>
|
5168 | 5171 | </div>
|
5169 |
| -<div title="Side-by-side Execution" creator="John Hind" modifier="John Hind" created="201005292130" modified="201402211459" changecount="4"> |
| 5172 | +<div title="Side-by-side Execution" creator="John Hind" modifier="John Hind" created="201005292130" modified="201403061230" changecount="5"> |
5170 | 5173 | <pre>This is like [[Command-line Execution]] except that no command-line is required. Winsh will look for a folder or file with the same name as its own executable and in the same folder, but with the extension {{{.lua}}} rather than {{{.exe}}}. Note that the filename of the Winsh Executable may be changed to reflect the application, allowing more than one script system to exist in the same folder.
|
5171 | 5174 |
|
5172 | 5175 | For example, assuming the following directory layout ({{{myapp.exe}}} being one of the [[Winsh Executables]] renamed):
|
|
5177 | 5180 | Executing {{{myapp.exe}}} will load and run {{{myapp.lua}}}. Alternatively, with the following layout:
|
5178 | 5181 | {{{
|
5179 | 5182 | C:\test\myapp.exe
|
5180 |
| -C:\test\myapp\start.lua |
5181 |
| -C:\test\myapp\library1.lua |
5182 |
| -C:\test\myapp\lib\library2.dll |
| 5183 | +C:\test\myapp.lua\start.lua |
| 5184 | +C:\test\myapp.lua\library1.lua |
| 5185 | +C:\test\myapp.lua\lib\library2.dll |
5183 | 5186 | }}}
|
5184 |
| -Then executing {{{myapp.exe}}} will load and run {{{myapp\start.lua}}} and that script may contain the following Lua statements: |
| 5187 | +Then executing {{{myapp.exe}}} will load and run {{{myapp.lua\start.lua}}} and that script may contain the following Lua statements: |
5185 | 5188 | {{{
|
5186 | 5189 | lib1 = require("library1")
|
5187 | 5190 | lib2 = require("lib.library2")
|
|
7687 | 7690 | }}}
|
7688 | 7691 | </pre>
|
7689 | 7692 | </div>
|
7690 |
| -<div title="list:insert" creator="John Hind" modifier="John Hind" created="201005152140" modified="201312131731" changecount="6"> |
| 7693 | +<div title="list:insert" creator="John Hind" modifier="John Hind" created="201005152140" modified="201403241050" changecount="8"> |
7691 | 7694 | <pre>!list:insert(index, item)
|
7692 | 7695 |
|
7693 |
| -If ''item'' is a List object, the elements in this list are inserted into the list, otherwise, ''item'' is inserted as a single entry. The elements are inserted into the list starting at the given ''index''. Negative indexes are also supported with {{{-1}}} being the last item in the current List, and {{{0}}} meaning to add the new items at the end of the List. The original item at the specified ''index'', and all the subsequent items, are shifted after the inserted items. |
| 7696 | +If ''item'' is a List object, the elements in this list are inserted into the list, otherwise, ''item'' is inserted as a single entry. |
| 7697 | + |
| 7698 | +The elements are inserted into the list starting at the given ''index''. Negative indexes are also supported with {{{-1}}} being the last item in the current List, and {{{0}}} representing the index after the last item in the current List. The original item at the specified ''index'', and all the subsequent items, are shifted after the inserted items. |
| 7699 | + |
| 7700 | +Expansion of inserted lists may be overridden for derived classes by providing a {{{__whole}}} metafield. If the object being inserted has this metafield and it tests {{{true}}}, then it is inserted as a single entry, the value being the object itself. |
7694 | 7701 | {{{
|
7695 | 7702 | lst = List("one", "two", "three")
|
7696 | 7703 | lst:insert(-2, "one.one")
|
|
0 commit comments