IX(1): ink shell and command executor
USAGE
usage: ix [-DIn] [-l file] {file}
-D: debug
-I: debug ink
-l file: load the session from the given file
-n: dry run (don't ever save)
DESCRIPTION
Ix is a shell using the [net/ink(2)], web based, graphics interface. It lets the user browse the file system, execute commands, edit files, and open other ink interfaces (including web pages and interfaces from other tools in the system).The interface is reached on the ink port using a Web browser. Initially, a command window is created. Other command windows and further edits may be open using it. The words near the top are buttons:
more
: increases the number of columns in the page.less
: decreases the number of columns in the page.win
: opens a new command window.quit
: quits IX.
Each window is decorated with a status line. A click on the icons shown in the line may be used to close the window, save it (only shown if the window has unsaved changed), minimize all windows in the same column, make the window larger, make it smaller, and resize it to make its bottom the bottom of the column. A click on the rest of the status line shifts the windows in the column, moving the top window to the end of the column. Windows may be dragged and moved to another location using button-1 on the status line.
The status line shows a label written in black when the window is clean. The label is written in blue when the window is dirty (and should be saved). The status line background is shown in a lighter color when the window has the focus, and it is darkern when the window is not the focus.
A click with button-1 on a window sets it as the focus. However, the keyboard follows the mouse and writes at the window under the mouse pointer. You can type commands in a window and use another one as the focus for them.
The width of a window depends on the number of columns and cannot be adjusted by the user. The height of a window can be adjusted by dragging its bottom line with the mouse.
Button-1 sets the selection. It is empty for a single click, a word for a double click, and a long word for a tripple click. A long word accepts more runes as word characters. A double click on a rune that seems to delimit a range (like brackets, quotes, etc.) selects the enclosed text. A double click at the end of the line selects the entire line. To select more text than shown in a window, use the scroll wheel while holding down button-1.
While holding down button-1, a click with button-2 cuts the selected text, and a click with button-3 replaces the selected text with a paste of the clipboard. A chick with button-4 while holding down button-1 copies the selection into the clipboard. Keys Command-!x!, Command-!v!, and Command-!c!, achieve the same effect.
Commands are executed with the button-2, either with a single click or with a selection. New edits can be looked for with the button-3, either with a single click or with a selection. Text search happens when using button-4, which searches for the last text selected (perhaps at a different window) on the clicked window. Executing a directory in a commands window changes the dot to that directory. Executing it in a directory window replaces the directory shown with the one executed.
For buttons 2 and 3, a click at the end of a line refers to the whole line, a click on a word refers on the whole word, and a click on a selection refers to the text selected. A click on a final empty line selects the previous line.
The mouse wheel scrolls up and down the text shown in the window. When used outside a window it scrolls the whole page (or screen). Up and down array keys also scroll text in windows.
A thin blue line on the right of text windows depicts the location of the text shown within the full text. The size of the line is proportional to the percentage of text shown and its position indicates the location of the shown text. This line cannot be used to scroll.
The left and right arrow keys do not move the cursor, but perform undo and redo operations.
There is no command language (although there are some builtins). Commands executed are standard ql(1) commands, unless they are a builtin. IX serves a standard output ink channel to all commands executed in it. Commands with user interfaces rely on this to use the relevant IX instance. But note how
eco http://lsub.org >[out:ink]
and similar commands can be used to output URLs, or HTML in general, to the standard output ink and convince IX to display external interfaces or resources. When a command outputs a file address (or more), IX selects that address as a result, and button-3 clicks on such selection iterates through the address list.
Ink messages starting with exec:
are
understood as requests to execute commands and display its output in a
new window. Those starting with look:
are
understood as requests to look for text.
The variable $look
, or the file
$home/lib/look
, or
$home/.look
are used to learn rules to
execute commands when the user looks for text.
Command windows operate like a typescript. Upon command execution, the command output will get inserted on the line after the end of the command. Each window operates in its own Clive command context and may use a different name space, dot, etc.
The builtin commands are:
cd
: changes the directory to that of the focus (if no argument is given) or to that given.pwd
: print the current directory.cmds
: list the running commands.=
: print the dot (the selection of the focus).n file
: create a new edit for the named file.w [file]
: write the focus, if dirty, back to disk. If the file name is given, it is written to that file and the edit is updated to operate on the new name.e
: re-read the focus, discarding all edits, and start a new edit.d
: delete the focus.u
: undo the last edit.r
: redo the last undo.> cmds...
: run commands using the dot as input.< cmds...
: run commands inserting their output at the dot.|cmds...
: filter the dot with commands.x [expr] cmd
: run command for all selections of edits matching expr.X [expr] cmd
: run command for all edits matching expr.. cmd...
: run command on the dot., cmd...
: run command on the focus.dump [name]
: print the state of the session or dump it into the given file name, if any.load name
: load the session edits dumped at the given file name.win
: start a new commands window.rules
: reload the look rules.
Typing Esc twice at a window clears the window. For command windows, the text is cleared. For directory windows, the directory is re-read. For text edits, the edits are discarded and the on-disk text is re-read.
Text processing happens for keys supplied by the browser (which might or might not take into account your keyboard layout and locale settings). Nevertheless, the Alt key may be used to compose a key by typing Alt and then one or more keys. The valid sequences are those of Plan 9 from Bell Labs. See keyboard(3) for a description of valid key sequences.
EXAMPLES
Open all go files under the current dir:-
Type
.,~*.go
and right-click on it.
Find foo in the current edit: Type
, >gr -x foo
and middle-click on it. If you click (button-3) on one of the
addresses printed by gr
, the selection is
changed. If you click on one of those selections (button-3), the next
address located by gr
is looked for. If you
click on one of those selections (button-4), the next instance of
selected text is looked for.
Replace foo with bar in all edits: Type
X |trex foo bar
and middle click on it.
Save everything: Type
X w
and middle click on it.
Teach IX to show manual pages and to use the OS browser to open URLs, and teach it to open PostScript and PDF files by itself.
look='# rules for look(2), used by ix(1)
^([a-zA-Z.]+)\(([0-9]+)\)$
doc \2 \1|rf
^https://localhost
not
^(http|https)://.*$
open \0
^.*\.(ps|pdf)$
eco file://^<{path \0} '|' \0 >[out:ink]
'
ix &
SEE ALSO
- gr(1) has many useful examples for command lines that may be used as IX commands to perform common editing tasks.
- cmd.look(2) for a description of look rules.
- keyboard(3)
for composing keys.
SOURCE
/zx/sys/src/clive/cmd/ix