|
NAMEacmeevent, acme.rc - shell script support for acme clientsSYNOPSIS9p read acme/acme/$winid/event | acmeevent. /lib/acme.rc newwindow winread file winwrite file winctl cmd windump [ dumpdir | - ] [ dumpcmd | - ] winname name windel [ sure ] winwriteevent c1 c2 q0 q1 [ eq0 eq1 flag textlen text chordarg chordaddr ] wineventloop DESCRIPTIONAcmeevent and acme.rc make it easy to write simple client programs as shell scripts.Acme clients read the event files (see for the windows they control, reacting to the events. The events are presented in a format that is easy to read with C programs but hard to read with shell scripts. Acmeevent reads an event stream from standard input, printing a shell-friendly version of the events, one per line, on standard output. Each output line from acmeevent has the form:
The fields are:
To experiment with acmeevent, create an empty window in acme (using New),type
inside it, and execute it. Actions performed on the window will be printed as events in the +Errors window. Acme.rc is a library of shell functions useful for writing acme clients. Newwindow creates a new acme window and sets $winid to the new window's id. The other commands all use $winid to determine which window to operate on. Winread prints the current window's file to standard output. It is equivalent to cat /mnt/acme/acme/$winid/file on Plan 9. Similarly, winwrite writes standard input to the current window's file. Winread and winwrite are useful mainly in building more complex functions. Winctl writes cmd to the window's ctl file. The most commonly-used command is clean, which marks the window as clean. See for a full list of commands. Windump sets the window's dump directory and dump command (see If either argument is omitted or is -, that argument is not set. Winname sets the name displayed in the window's tag. Windel simulates the Del command. If the argument sure is given, it simulates the Delete command. Winwriteevent writes an event to the window's event file. The event is in the format produced by acmeevent. Only the first four arguments are necessary: the rest are ignored. Event handlers should call winwriteevent to pass unhandled button 2 or button 3 events back to acme for processing. Wineventloop executes the current window's event file, as output by acmeevent. It returns when the window has been deleted. Before running wineventloop , clients must define a shell function named event, which will be run for each incoming event, as rc executes the output of acmeevent. A typical event function need only worry about button 2 and button 3 events. Those events not handled should be sent back to acme with winwriteevent. EXAMPLEAdict, a dictionary browser, is implemented using acmeevent and acme.rc. The event handler is:
Note that the button 3 handler starts a subshell in which to run dictwin. That subshell will create a new window, set its name, possibly fill the window with a dictionary list or dictionary entry, mark the window as clean, and run the event loop:
The script starts with an initial window:
Button 3 clicking on a dictionary name in the initial window will create a new empty window for that dictionary. Typing and button 3 clicking on a word in that window will create a new window with the dictionary's entry for that word. See /bin/adict for the full implementation. SOURCE/src/cmd/acmeevent.c/lib/acme.rc SEE ALSOBUGSThere is more that could be done to ease the writing of complicated clients. Visit the GSP FreeBSD Man Page Interface. |