acme.html 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. <html>
  2. <title>
  3. data
  4. </title>
  5. <body BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#330088" ALINK="#FF0044">
  6. <H1>Acme: A User Interface for Programmers
  7. </H1>
  8. <DL><DD><I><I>Rob Pike</I>
  9. <I>rob@plan9.bell-labs.com</I>
  10. </I></DL>
  11. <DL><DD><H4>ABSTRACT</H4>
  12. <DL>
  13. <DT><DT>&#32;<DD>
  14. NOTE:<I> <HR>
  15. <br>
  16. Originally appeared in
  17. Proc. of the Winter 1994 USENIX Conf.,
  18. pp. 223-234,
  19. San Francisco, CA
  20. </I><DT>&#32;<DD></dl>
  21. <br>
  22. A hybrid of window system, shell, and editor, Acme gives text-oriented
  23. applications a clean, expressive, and consistent style of interaction.
  24. Traditional window systems support interactive client programs and offer libraries of
  25. pre-defined operations such as pop-up menus
  26. and buttons to promote a consistent
  27. user interface among the clients.
  28. Acme instead provides its clients with a fixed user interface and
  29. simple conventions to encourage its uniform use.
  30. Clients access the facilities of Acme through a file system interface;
  31. Acme is in part a file server that exports device-like files that may be
  32. manipulated to access and control the contents of its windows.
  33. Written in a concurrent programming language,
  34. Acme is structured as a set of communicating processes that neatly subdivide
  35. the various aspects of its tasks: display management, input, file server, and so on.
  36. <P>
  37. Acme attaches distinct functions to the three mouse buttons:
  38. the left selects text;
  39. the middle executes textual commands;
  40. and the right combines context search and file opening
  41. functions to integrate the various applications and files in
  42. the system.
  43. </P>
  44. <P>
  45. Acme works well enough to have developed
  46. a community that uses it exclusively.
  47. Although Acme discourages the traditional style of interaction
  48. based on typescript windows&#173;teletypes&#173;its
  49. users find Acme's other services render
  50. typescripts obsolete.
  51. </DL>
  52. </P>
  53. <H4>History and motivation
  54. </H4>
  55. <P>
  56. The usual typescript style of interaction with
  57. Unix and its relatives is an old one.
  58. The typescript&#173;an intermingling of textual commands and their
  59. output&#173;originates with the scrolls of paper on teletypes.
  60. The advent of windowed terminals has given each user what
  61. amounts to an array of teletypes, a limited and unimaginative
  62. use of the powers of bitmap displays and mice.
  63. Systems like the Macintosh
  64. that do involve the mouse as an integral part of the interaction
  65. are geared towards general users, not experts, and certainly
  66. not programmers.
  67. Software developers, at least on time-sharing systems, have been left behind.
  68. <br><img src="acme.fig1.14050.gif"><br>
  69. <br>&#32;<br>
  70. Figure 1. A small Acme screen&#173;normally it runs on a larger display&#173;demonstrating
  71. some of the details discussed in the text.
  72. The right column contains some guide files,
  73. a mailbox presented by Acme's mail program,
  74. the columnated display of files in Acme's own source directory,
  75. a couple of windows from the OED browser,
  76. a debugger window,
  77. and an error window showing diagnostics from a compilation.
  78. The left column holds a couple of source files
  79. (<TT>dat.h</TT>
  80. and
  81. <TT>acme.l</TT>),
  82. another debugger window displaying a stack trace,
  83. and a third source file
  84. (<TT>time.l</TT>).
  85. <TT>Time.l</TT>
  86. was opened from the debugger by clicking the right mouse button
  87. on a line in the stack window;
  88. the mouse cursor landed on the offending line of
  89. <TT>acme.l</TT>
  90. after a click on the compiler message.
  91. <br>
  92. <HR>
  93. </P>
  94. <P>
  95. Some programs have mouse-based editing of
  96. text files and typescripts;
  97. ones I have built include
  98. the window systems
  99. <TT>mux</TT>
  100. [Pike88]
  101. and
  102. <TT>8&#189;</TT>
  103. [Pike91]
  104. and the text editor
  105. Sam [Pike87].
  106. These have put the programmer's mouse to some productive work,
  107. but not wholeheartedly. Even experienced users of these programs
  108. often retype text that could be grabbed with the mouse,
  109. partly because the menu-driven interface is imperfect
  110. and partly because the various pieces are not well enough integrated.
  111. </P>
  112. <P>
  113. Other programs&#173;EMACS [Stal93] is the prime example&#173;offer a high
  114. degree of integration but with a user interface built around the
  115. ideas of cursor-addressed terminals that date from the 1970's.
  116. They are still keyboard-intensive and
  117. dauntingly complex.
  118. </P>
  119. <P>
  120. The most ambitious attempt to face these issues was the Cedar
  121. system, developed at Xerox [Swei86].
  122. It combined a new programming language, compilers,
  123. window system, even microcode&#173;a complete system&#173;to
  124. construct a productive, highly
  125. integrated and interactive environment
  126. for experienced users of compiled languages.
  127. Although successful internally, the system was so large
  128. and so tied to specific hardware that it never fledged.
  129. </P>
  130. <P>
  131. Cedar was, however, the major inspiration for Oberon [Wirt89],
  132. a system of similar scope but much smaller scale.
  133. Through careful selection of Cedar's ideas, Oberon shows
  134. that its lessons can be applied to a small, coherent system
  135. that can run efficiently on modest hardware.
  136. In fact, Oberon probably
  137. errs too far towards simplicity: a single-process system
  138. with weak networking, it seems an architectural throwback.
  139. </P>
  140. <P>
  141. Acme is a new program,
  142. a combined window system, editor, and shell,
  143. that applies
  144. some of the ideas distilled by Oberon.
  145. Where Oberon uses objects and modules within a programming language (also called Oberon),
  146. Acme uses files and commands within an existing operating system (Plan 9).
  147. Unlike Oberon, Acme does not yet have support for graphical output, just text.
  148. At least for now, the work on Acme has concentrated on
  149. producing the smoothest user interface possible for a programmer
  150. at work.
  151. </P>
  152. <P>
  153. The rest of this paper describes Acme's interface,
  154. explains how programs can access it,
  155. compares it to existing systems,
  156. and finally presents some unusual aspects of its implementation.
  157. </P>
  158. <H4>User interface
  159. </H4>
  160. <P>
  161. <br><img src="acme.fig2.14051.gif"><br>
  162. <br>&#32;<br>
  163. Figure 2. An Acme window showing a section of code.
  164. The upper line of text is the tag containing the file name,
  165. relevant commands, and a scratch area (right of the vertical bar);
  166. the lower portion of the window is the
  167. body, or contents, of the file.
  168. Here the scratch area contains a command for the middle button
  169. (<TT>mk</TT>)
  170. and a word to search for with the right button
  171. (<TT>cxfidalloc</TT>).
  172. The user has just
  173. clicked the right button on
  174. <TT>cxfidalloc</TT>
  175. and Acme has searched for the word, highlighted it,
  176. and moved the mouse cursor there. The file has been modified:
  177. the center of the layout box is black and the command
  178. <TT>Put</TT>
  179. appears in the tag.
  180. <br>
  181. <HR>
  182. Acme windows are arrayed in columns (Figure 1) and are used more
  183. dynamically than in an environment like X Windows or
  184. <TT>8&#189;</TT>
  185. [Sche86, Pike91].
  186. The system frequently creates them automatically and the user
  187. can order a new one with a single mouse button click.
  188. The initial placement of a new window is determined
  189. automatically, but the user may move an existing window anywhere
  190. by clicking or dragging a
  191. <I>layout box</I>
  192. in the upper left corner of
  193. the window.
  194. </P>
  195. <P>
  196. Acme windows have two parts: a
  197. <I>tag</I>
  198. holding a single line of text,
  199. above a
  200. <I>body</I>
  201. holding zero or more lines (Figure 2).
  202. The body typically contains an image of a file being edited
  203. or the editable output of a
  204. program, analogous to an
  205. EMACS shell
  206. window. The tag contains
  207. the name of the window
  208. (usually the name of the associated
  209. file or directory), some built-in commands, and a scratch area to hold arbitrary text.
  210. If a window represents a directory, the name in the tag ends with
  211. a slash and the body contains a list of the names of the files
  212. in the directory.
  213. Finally, each non-empty body holds a scroll bar at the left of the text.
  214. </P>
  215. <P>
  216. Each column of windows also has a layout box and a tag.
  217. The tag has no special meaning, although Acme pre-loads it with a few
  218. built-in commands.
  219. There is also a tag across the whole display, also loaded with
  220. helpful commands and a list of active processes started
  221. by Acme.
  222. </P>
  223. <P>
  224. Typing with the keyboard and selecting with the left button are as in
  225. many other systems, including the Macintosh,
  226. <TT>8&#189;</TT>,
  227. and Sam.
  228. The middle and right buttons are used, somewhat like the left button,
  229. to `sweep' text, but the indicated text is treated in a way
  230. that depends on the text's location&#173;<I>context</I>&#173;as well as its content.
  231. This context, based on the directory of the file containing the text,
  232. is a central component of Acme's style of interaction.
  233. </P>
  234. <P>
  235. Acme has no single notion of `current directory'.
  236. Instead, every command, file name,
  237. action, and so on is interpreted or executed in the directory named by the
  238. tag of the window containing the command. For example, the string
  239. <TT>mammals</TT>
  240. in a window labeled
  241. <TT>/lib/</TT>
  242. or
  243. <TT>/lib/insects</TT>
  244. will be interpreted as the file name
  245. <TT>/lib/mammals</TT>
  246. if such a file exists.
  247. </P>
  248. <P>
  249. Throughout Acme, the middle mouse button is used to execute commands
  250. and the right mouse button is used to locate and select files and text.
  251. Even when there are no true files on which to operate&#173;for example
  252. when editing mail messages&#173;Acme and its applications use
  253. consistent extensions of these basic functions.
  254. This idea is as vital to Acme as icons are to the Macintosh.
  255. </P>
  256. <P>
  257. The middle button executes commands: text swept with the button
  258. pressed is underlined; when the button is released, the underline is
  259. removed and the indicated text is executed.
  260. A modest number of commands are recognized as built-ins: words like
  261. <TT>Cut</TT>,
  262. <TT>Paste</TT>,
  263. and
  264. <TT>New</TT>
  265. name
  266. functions performed directly by Acme.
  267. These words often appear in tags to make them always available,
  268. but the tags are not menus: any text anywhere in Acme may be a command.
  269. For example, in the tag or body of any window one may type
  270. <TT>Cut</TT>,
  271. select it with the left button, use the middle button to execute it,
  272. and watch it disappear again.
  273. </P>
  274. <P>
  275. If the middle button indicates a command that is not recognized as a built-in,
  276. it is executed in the directory
  277. named by the tag of the window holding the text.
  278. Also, the file to be executed is searched for first in that directory.
  279. Standard input is connected to
  280. <TT>/dev/null</TT>,
  281. but standard and error outputs are connected to an Acme window,
  282. created if needed, called
  283. <I>dir</I><TT>/+Errors</TT> where
  284. <I>dir</I>
  285. is the directory of the window.
  286. (Programs that need interactive input use a different interface, described below.)
  287. A typical use of this is to type
  288. <TT>mk</TT>
  289. (Plan 9's
  290. <TT>make</TT>)
  291. in the scratch area in the tag of a C source window, say
  292. <TT>/sys/src/cmd/sam/regexp.c</TT>,
  293. and execute it.
  294. Output, including compiler errors, appears in the window labeled
  295. <TT>/sys/src/cmd/sam/+Errors</TT>,
  296. so file names in the output are associated with the windows and directory
  297. holding the source.
  298. The
  299. <TT>mk</TT>
  300. command remains in the tag, serving as a sort of menu item for the associated
  301. window.
  302. </P>
  303. <P>
  304. Like the middle button, the right button is used to indicate text by sweeping it out.
  305. The indicated text is not a command, however, but the argument of a generalized
  306. search operator.
  307. If the text, perhaps after appending it to the directory of the window containing it,
  308. is the name of an existing file, Acme creates a new window to hold the file
  309. and reads it in. It then moves the mouse cursor to that window. If the file is
  310. already loaded into Acme, the mouse motion happens but no new window is made.
  311. For example, indicating the string
  312. <TT>sam.h</TT>
  313. in
  314. <DL><DT><DD><TT><PRE>
  315. #include "sam.h"
  316. </PRE></TT></DL>
  317. in a window on the file
  318. <TT>/sys/src/cmd/sam/regexp.c</TT>
  319. will open the file
  320. <TT>/sys/src/cmd/sam/sam.h</TT>.
  321. </P>
  322. <P>
  323. If the file name is followed immediately by a colon and a legal address in
  324. Sam notation (for example a line number or a regular expression delimited in
  325. slashes or a comma-separated compound of such addresses), Acme highlights
  326. the target of that address in the file and places the mouse there. One may jump to
  327. line 27 of
  328. <TT>dat.h</TT>
  329. by indicating with the right button the text
  330. <TT>dat.h:27</TT>.
  331. If the file is not already open, Acme loads it.
  332. If the file name is null, for example if the indicated string is
  333. <TT>:/^main/</TT>,
  334. the file is assumed to be that of the window containing the string.
  335. Such strings, when typed and evaluated in the tag of a window, amount to
  336. context searches.
  337. </P>
  338. <P>
  339. If the indicated text is not the name of an existing file, it is taken to be literal
  340. text and is searched for in the body of the window containing the text, highlighting
  341. the result as if it were the result of a context search.
  342. </P>
  343. <P>
  344. For the rare occasion when a file name
  345. <I>is</I>
  346. just text to search for, it can be selected with the left button and used as the
  347. argument to a built-in
  348. <TT>Look</TT>
  349. command that always searches for literal text.
  350. </P>
  351. <H4>Nuances and heuristics
  352. </H4>
  353. <P>
  354. A user interface should not only provide the necessary functions, it should also
  355. <I>feel</I>
  356. right.
  357. In fact, it should almost not be felt at all; when one notices a
  358. user interface, one is distracted from the job at hand [Pike88].
  359. To approach this invisibility, some of Acme's properties and features
  360. are there just to make the others easy to use.
  361. Many are based on a fundamental principle of good design:
  362. let the machine do the work.
  363. </P>
  364. <P>
  365. Acme tries to avoid needless clicking and typing.
  366. There is no `click-to-type', eliminating a button click.
  367. There are no pop-up or pull-down menus, eliminating the mouse action needed to
  368. make a menu appear.
  369. The overall design is intended to make text on the screen useful without
  370. copying or retyping; the ways in which this happens involve
  371. the combination of many aspects of the interface.
  372. </P>
  373. <P>
  374. Acme tiles its windows and places them automatically
  375. to avoid asking the user to place and arrange them.
  376. For this policy to succeed, the automatic placement must behave well enough
  377. that the user is usually content with the location of a new window.
  378. The system will never get it right all the time, but in practice most
  379. windows are used at least for a while where Acme first places them.
  380. There have been several complete rewrites of the
  381. heuristics for placing a new window,
  382. and with each rewrite the system became
  383. noticeably more comfortable. The rules are as follows, although
  384. they are still subject to improvement.
  385. The window appears in the `active' column, that most recently used for typing or
  386. selecting.
  387. Executing and searching do not affect the choice of active column,
  388. so windows of commands and such do not draw new windows towards them,
  389. but rather let them form near the targets of their actions.
  390. Output (error) windows always appear towards the right, away from
  391. edited text, which is typically kept towards the left.
  392. Within the column, several competing desires are balanced to decide where
  393. and how large the window should be:
  394. large blank spaces should be consumed;
  395. existing text should remain visible;
  396. existing large windows should be divided before small ones;
  397. and the window should appear near the one containing the action that caused
  398. its creation.
  399. </P>
  400. <P>
  401. Acme binds some actions to chords of mouse buttons.
  402. These include
  403. <TT>Cut</TT>
  404. and
  405. <TT>Paste</TT>
  406. so these common operations can be done without
  407. moving the mouse.
  408. Another is a way to apply a command in one window to text (often a file name)
  409. in another, avoiding the actions needed to assemble the command textually.
  410. </P>
  411. <P>
  412. Another way Acme avoids the need to move the mouse is instead to move the cursor
  413. to where it is likely to be used next. When a new window is made, Acme
  414. moves the cursor to the new window; in fact, to the selected text in that window.
  415. When the user deletes a newly made window, the cursor is
  416. returned to the point it was before the window was made,
  417. reducing the irritation of windows that pop up to report annoying errors.
  418. </P>
  419. <P>
  420. When a window is moved, Acme moves the cursor to the layout box in
  421. its new place, to permit further adjustment without moving the mouse.
  422. For example, when a click of the left mouse button on the layout box grows
  423. the window, the cursor moves to the new location of the box so repeated clicks,
  424. without moving the mouse, continue to grow it.
  425. </P>
  426. <P>
  427. Another form of assistance the system can offer is to supply precision in
  428. pointing the mouse. The best-known form of this is `double-clicking' to
  429. select a word rather than carefully sweeping out the entire word.
  430. Acme provides this feature, using context to decide whether to select
  431. a word, line, quoted string, parenthesized expression, and so on.
  432. But Acme takes the idea much further by applying it to execution
  433. and searching.
  434. A
  435. <I>single</I>
  436. click, that is, a null selection, with either the middle or right buttons,
  437. is expanded automatically to indicate the appropriate text containing
  438. the click. What is appropriate depends on the context.
  439. </P>
  440. <P>
  441. For example, to execute a single-word command
  442. such as
  443. <TT>Cut</TT>,
  444. it is not necessary to sweep the entire word; just clicking the button once with
  445. the mouse pointing at the word is sufficient. `Word'
  446. means the largest string of likely file name characters surrounding the location
  447. of the click: click on a file name, run that program.
  448. On the right button, the rules are more complicated because
  449. the target of the click might be a file name, file name with address,
  450. or just plain text. Acme examines the text near the click to find
  451. a likely file name;
  452. if it finds one, it checks that it names an existing file (in the directory named in the tag, if the name is relative)
  453. and if so, takes that as the result, after extending it with any address
  454. that may be present. If there is no file with that name, Acme
  455. just takes the largest alphanumeric string under the click.
  456. The effect is a natural overloading of the button to refer to plain text as
  457. well as file names.
  458. </P>
  459. <P>
  460. First, though, if the click occurs over the left-button-selected text in the window,
  461. that text is taken to be what is selected.
  462. This makes it easy to skip through the occurrences of a string in a file: just click
  463. the right button
  464. on some occurrence of the text in the window (perhaps after typing it in the tag)
  465. and click once for each subsequent occurrence. It isn't even necessary to move
  466. the mouse between clicks; Acme does that.
  467. To turn a complicated command into a sort of menu item, select it:
  468. thereafter, clicking the middle button on it will execute the full command.
  469. </P>
  470. <P>
  471. As an extra feature, Acme recognizes file names in angle brackets
  472. <TT><></TT>
  473. as names of files in standard directories of include files,
  474. making it possible for instance to look at
  475. <TT><stdio.h></TT>
  476. with a single click.
  477. </P>
  478. <P>
  479. Here's an example to demonstrate how the actions and defaults work together.
  480. Assume
  481. <TT>/sys/src/cmd/sam/regexp.c</TT>
  482. is
  483. open and has been edited. We write it (execute
  484. <TT>Put</TT>
  485. in the tag; once the file is written, Acme removes the word from the tag)
  486. and type
  487. <TT>mk</TT>
  488. in the tag. We execute
  489. <TT>mk</TT>
  490. and get some errors, which appear in a new window labeled
  491. <TT>/sys/src/cmd/sam/+Errors</TT>.
  492. The cursor moves automatically to that window.
  493. Say the error is
  494. <DL><DT><DD><TT><PRE>
  495. main.c:112: incompatible types on assignment to `pattern'
  496. </PRE></TT></DL>
  497. We move the mouse slightly and click the right button
  498. at the left of the error message; Acme
  499. makes a new window, reads
  500. <TT>/sys/src/cmd/main.c</TT>
  501. into it, selects line 112
  502. and places the mouse there, right on the offending line.
  503. </P>
  504. <H4>Coupling to existing programs
  505. </H4>
  506. <P>
  507. Acme's syntax for file names and addresses makes it easy for other programs
  508. to connect automatically to Acme's capabilities. For example, the output of
  509. <DL><DT><DD><TT><PRE>
  510. grep -n variable *.[ch]
  511. </PRE></TT></DL>
  512. can be used to help Acme step through the occurrences of a variable in a program;
  513. every line of output is potentially a command to open a file.
  514. The file names need not be absolute, either: the output
  515. appears in a window labeled with the directory in which
  516. <TT>grep</TT>
  517. was run, from which Acme can derive the full path names.
  518. </P>
  519. <P>
  520. When necessary, we have changed the output of some programs,
  521. such as compiler error messages, to match
  522. Acme's syntax.
  523. Some might argue that it shouldn't be necessary to change old programs,
  524. but sometimes programs need to be updated when systems change,
  525. and consistent output benefits people as well as programs.
  526. A historical example is the retrofitting of standard error output to the
  527. early Unix programs when pipes were invented.
  528. </P>
  529. <P>
  530. Another change was to record full path names in
  531. the symbol table of executables, so line numbers reported by the debugger
  532. are absolute names that may be used directly by Acme; it's not necessary
  533. to run the debugger in the source directory. (This aids debugging
  534. even without Acme.)
  535. </P>
  536. <P>
  537. A related change was to add lines of the form
  538. <DL><DT><DD><TT><PRE>
  539. #pragma src "/sys/src/libregexp"
  540. </PRE></TT></DL>
  541. to header files; coupled with Acme's ability to locate a header file,
  542. this provides a fast, keyboardless way to get the source associated with a library.
  543. </P>
  544. <P>
  545. Finally, Acme directs the standard output of programs it runs to
  546. windows labeled by the directory in which the program is run.
  547. Acme's splitting of the
  548. output into directory-labeled windows is a small feature that has a major effect:
  549. local file names printed by programs can be interpreted directly by Acme.
  550. By indirectly coupling the output of programs to the input,
  551. it also simplifies the management of software that occupies multiple
  552. directories.
  553. </P>
  554. <H4>Coupling to new programs
  555. </H4>
  556. <P>
  557. Like many Plan 9 programs,
  558. Acme offers a programmable interface to
  559. other programs by acting as a file server.
  560. The best example of such a file server is the window system
  561. <TT>8&#189;</TT>
  562. [Pike91],
  563. which exports files with names such as
  564. <TT>screen</TT>,
  565. <TT>cons</TT>,
  566. and
  567. <TT>mouse</TT>
  568. through which applications may access the I/O capabilities of the windows.
  569. <TT>8&#189;</TT>
  570. provides a
  571. <I>distinct</I>
  572. set of files for each window and builds a private file name space
  573. for the clients running `in' each window;
  574. clients in separate windows see distinct files with the same names
  575. (for example
  576. <TT>/dev/mouse</TT>).
  577. Acme, like the process file system [PPTTW93], instead associates each
  578. window with a directory of files; the files of each window are visible
  579. to any application.
  580. This difference reflects a difference in how the systems are used:
  581. <TT>8&#189;</TT>
  582. tells a client what keyboard and mouse activity has happened in its window;
  583. Acme tells a client what changes that activity wrought on any window it asks about.
  584. Putting it another way,
  585. <TT>8&#189;</TT>
  586. enables the construction of interactive applications;
  587. Acme provides the interaction for applications.
  588. </P>
  589. <P>
  590. The root of
  591. Acme's file system is mounted using Plan 9 operations on the directory
  592. <TT>/mnt/acme</TT>.
  593. In
  594. that root directory appears a directory for each window, numbered with the window's identifier,
  595. analogous to a process identifier, for example
  596. <TT>/mnt/acme/27</TT>.
  597. The window's directory
  598. contains 6 files:
  599. <TT>/mnt/acme/27/addr</TT>,
  600. <TT>body</TT>,
  601. <TT>ctl</TT>,
  602. <TT>data</TT>,
  603. <TT>event</TT>,
  604. and
  605. <TT>tag</TT>.
  606. The
  607. <TT>body</TT>
  608. and
  609. <TT>tag</TT>
  610. files contain the text of the respective parts of the window; they may be
  611. read to recover the contents. Data written to these files is appended to the text;
  612. <TT>seeks</TT>
  613. are ignored.
  614. The
  615. <TT>addr</TT>
  616. and
  617. <TT>data</TT>
  618. files provide random access to the contents of the body.
  619. The
  620. <TT>addr</TT>
  621. file is written to set a character position within the body; the
  622. <TT>data</TT>
  623. file may then be read to recover the contents at that position,
  624. or written to change them.
  625. (The tag is assumed
  626. small and special-purpose enough not to need special treatment.
  627. Also,
  628. <TT>addr</TT>
  629. indexes by character position, which is not the same as byte offset
  630. in Plan 9's multi-byte character set [Pike93]).
  631. The format accepted by the
  632. <TT>addr</TT>
  633. file is exactly the syntax of addresses within the user interface,
  634. permitting regular expressions, line numbers, and compound addresses
  635. to be specified. For example, to replace the contents of lines 3 through 7,
  636. write the text
  637. <DL><DT><DD><TT><PRE>
  638. 3,7
  639. </PRE></TT></DL>
  640. to the
  641. <TT>addr</TT>
  642. file, then write the replacement text to the
  643. <TT>data</TT>
  644. file. A zero-length write deletes the addressed text; further writes extend the replacement.
  645. </P>
  646. <P>
  647. The control file,
  648. <TT>ctl</TT>,
  649. may be written with commands to effect actions on the window; for example
  650. the command
  651. <DL><DT><DD><TT><PRE>
  652. name /adm/users
  653. </PRE></TT></DL>
  654. sets the name in the tag of the window to
  655. <TT>/adm/users</TT>.
  656. Other commands allow deleting the window, writing it to a file, and so on.
  657. Reading the
  658. <TT>ctl</TT>
  659. file recovers a fixed-format string containing 5 textual numbers&#173;the window
  660. identifier, the number of characters in the tag, the number in the body,
  661. and some status information&#173;followed by the text of the tag, up to a newline.
  662. </P>
  663. <P>
  664. The last file,
  665. <TT>event</TT>,
  666. is the most unusual.
  667. A program reading a window's
  668. <TT>event</TT>
  669. file is notified of all changes to the text of the window, and
  670. is asked to interpret all middle- and right-button actions.
  671. The data passed to the program is fixed-format and reports
  672. the source of the action (keyboard, mouse, external program, etc.),
  673. its location (what was pointed at or modified), and its nature (change,
  674. search, execution, etc.).
  675. This message, for example,
  676. <DL><DT><DD><TT><PRE>
  677. MI15 19 0 4 time
  678. </PRE></TT></DL>
  679. reports that actions of the mouse
  680. (<TT>M</TT>)
  681. inserted in the body (capital
  682. <TT>I</TT>)
  683. the 4 characters of
  684. <TT>time</TT>
  685. at character positions 15 through 19; the zero is a flag word.
  686. Programs may apply their own interpretations of searching and
  687. execution, or may simply reflect the events back to Acme,
  688. by writing them back to the
  689. <TT>event</TT>
  690. file, to have the default interpretation applied.
  691. Some examples of these ideas in action are presented below.
  692. </P>
  693. <P>
  694. Notice that changes to the window are reported
  695. after the fact; the program is told about them but is not required to act
  696. on them. Compare this to a more traditional interface in which a program
  697. is told, for example, that a character has been typed on the keyboard and
  698. must then display and interpret it.
  699. Acme's style stems from the basic model of the system, in which any
  700. number of agents&#173;the keyboard, mouse, external programs
  701. writing to
  702. <TT>data</TT>
  703. or
  704. <TT>body</TT>,
  705. and so on&#173;may
  706. change the contents of a window.
  707. The style is efficient: many programs are content
  708. to have Acme do most of the work and act only when the editing is completed.
  709. An example is the Acme mail program, which can ignore the changes
  710. made to a message being composed
  711. and just read its body when asked to send it.
  712. A disadvantage is that some traditional ways of working are impossible.
  713. For example, there is no way `to turn off echo': characters appear on the
  714. screen and are read from there; no agent or buffer stands between
  715. the keyboard and the display.
  716. </P>
  717. <P>
  718. There are a couple of other files made available by Acme in its root directory
  719. rather than in the directory of each window.
  720. The text file
  721. <TT>/mnt/acme/index</TT>
  722. holds a list of all window names and numerical identifiers,
  723. somewhat analogous to the output of the
  724. <TT>ps</TT>
  725. command for processes.
  726. The most important, though, is
  727. <TT>/mnt/acme/new</TT>,
  728. a directory that makes new windows, similar to the
  729. <TT>clone</TT>
  730. directory in the Plan 9 network devices [Pres93].
  731. The act of opening any file in
  732. <TT>new</TT>
  733. creates a new Acme window; thus the shell command
  734. <DL><DT><DD><TT><PRE>
  735. grep -n var *.c &#62; /mnt/acme/new/body
  736. </PRE></TT></DL>
  737. places its output in the body of a fresh window.
  738. More sophisticated applications may open
  739. <TT>new/ctl</TT>,
  740. read it to discover the new window's identifier, and then
  741. open the window's other files in the numbered directory.
  742. </P>
  743. <H4>Acme-specific programs
  744. </H4>
  745. <P>
  746. Although Acme is in part an attempt to move beyond typescripts,
  747. they will probably always have utility.
  748. The first program written for Acme was therefore one
  749. to run a shell or other traditional interactive application
  750. in a window, the Acme analog of
  751. <TT>xterm</TT>.
  752. This program,
  753. <TT>win</TT>,
  754. has a simple structure:
  755. it acts as a two-way intermediary between Acme and the shell,
  756. cross-connecting the standard input and output of the shell to the
  757. text of the window.
  758. The style of interaction is modeled after
  759. <TT>mux</TT>
  760. [Pike88]: standard output is added to the window at the
  761. <I>output point;</I>
  762. text typed after the output point
  763. is made available on standard input when a newline is typed.
  764. After either of these actions, the output point is advanced.
  765. This is different from the working of a regular terminal,
  766. permitting cut-and-paste editing of an input line until the newline is typed.
  767. Arbitrary editing may be done to any text in the window.
  768. The implementation of
  769. <TT>win</TT>,
  770. using the
  771. <TT>event</TT>,
  772. <TT>addr</TT>,
  773. and
  774. <TT>data</TT>
  775. files, is straightforward.
  776. <TT>Win</TT>
  777. needs no code for handling the keyboard and mouse; it just monitors the
  778. contents of the window. Nonetheless, it allows Acme's full editing to be
  779. applied to shell commands.
  780. The division of labor between
  781. <TT>win</TT>
  782. and
  783. <TT>Acme</TT>
  784. contrasted with
  785. <TT>xterm</TT>
  786. and the X server demonstrates how much work Acme handles automatically.
  787. <TT>Win</TT>
  788. is implemented by a single source file 560 lines long and has no graphics code.
  789. </P>
  790. <P>
  791. <TT>Win</TT>
  792. uses the middle and right buttons to connect itself in a consistent way
  793. with the rest of Acme.
  794. The middle button still executes commands, but in a style more suited
  795. to typescripts. Text selected with the middle button is treated as if
  796. it had been typed after the output point, much as a similar feature in
  797. <TT>xterm</TT>
  798. or
  799. <TT>8&#189;</TT>,
  800. and therefore causes it to be `executed' by the application running in the window.
  801. Right button actions are reflected back to Acme but refer to the appropriate
  802. files because
  803. <TT>win</TT>
  804. places the name of the current directory in the tag of the window.
  805. If the shell is running, a simple shell function replacing the
  806. <TT>cd</TT>
  807. command can maintain the tag as the shell navigates the file system.
  808. This means, for example, that a right button click on a file mentioned in an
  809. <TT>ls</TT>
  810. listing opens the file within Acme.
  811. </P>
  812. <P>
  813. Another Acme-specific program is a mail reader that begins by presenting,
  814. in a window, a listing of the messages in the user's mailbox, one per line.
  815. Here the middle and right button actions are modified to refer to
  816. mail commands
  817. and messages, but the change feels natural.
  818. Clicking the right button on a line creates a new window and displays the
  819. message there, or, if it's already displayed, moves the mouse to that window.
  820. The metaphor is that the mailbox is a directory whose constituent files are messages.
  821. The mail program also places some relevant commands in the tag lines of
  822. the windows; for example, executing the word
  823. <TT>Reply</TT>
  824. in a message's tag creates a new window
  825. in which to compose a message to the sender of the original;
  826. <TT>Post</TT>
  827. then dispatches it.
  828. In such windows, the addressee is just a list of names
  829. on the first line of the body, which may be edited to add or change recipients.
  830. The program also monitors the mailbox, updating the `directory' as new messages
  831. arrive.
  832. </P>
  833. <P>
  834. The mail program is as simple as it sounds; all the work of interaction,
  835. editing, and management of the display is done by Acme.
  836. The only
  837. difficult sections of the 1200
  838. lines of code concern honoring the external protocols for managing
  839. the mailbox and connecting to
  840. <TT>sendmail</TT>.
  841. </P>
  842. <P>
  843. One of the things Acme does not provide directly is a facility like
  844. Sam's command language to enable actions such as global substitution;
  845. within Acme, all editing is done manually.
  846. It is easy, though, to write external programs for such tasks.
  847. In this, Acme comes closer to the original intent of Oberon:
  848. a directory,
  849. <TT>/acme/edit</TT>,
  850. contains a set of tools for repetitive editing and a template
  851. or `guide' file that gives examples
  852. of its use.
  853. Acme's editing guide,
  854. <TT>/acme/edit/guide</TT>,
  855. looks like this:
  856. <DL><DT><DD><TT><PRE>
  857. e file | x '/regexp/' | c 'replacement'
  858. e file:'0,$' | x '/.*word.*\n/' | p -n
  859. e file | pipe command args ...
  860. </PRE></TT></DL>
  861. The syntax is reminiscent of Sam's command language, but here the individual
  862. one-letter commands are all stand-alone programs connected by pipes.
  863. Passed along the pipes are addresses, analogous to structural expressions
  864. in Sam terminology.
  865. The
  866. <TT>e</TT>
  867. command, unlike that of Sam, starts the process by generating the address
  868. (default dot, the highlighted selection) in the named files.
  869. The other commands are as in Sam:
  870. <TT>p</TT>
  871. prints the addressed text on standard output (the
  872. <TT>-n</TT>
  873. option is analogous to that of
  874. <TT>grep</TT>,
  875. useful in combination with the right mouse button);
  876. <TT>x</TT>
  877. matches a regular expression to the addressed (incoming) text,
  878. subdividing the text;
  879. <TT>c</TT>
  880. replaces the text; and so on. Thus, global substitution throughout a file,
  881. which would be expressed in Sam as
  882. <DL><DT><DD><TT><PRE>
  883. 0,$ x/regexp/ c/replacement/
  884. </PRE></TT></DL>
  885. in Acme's editor becomes
  886. <DL><DT><DD><TT><PRE>
  887. e 'file:0,$' | x '/regexp/' | c 'replacement'
  888. </PRE></TT></DL>
  889. </P>
  890. <P>
  891. To use the Acme editing commands, open
  892. <TT>/acme/edit/guide</TT>,
  893. use the mouse and keyboard to edit one of the commands to the right form,
  894. and execute it with the middle button.
  895. Acme's context rules find the appropriate binaries in
  896. <TT>/acme/edit</TT>
  897. rather than
  898. <TT>/bin</TT>;
  899. the effect is to turn
  900. <TT>/acme/edit</TT>
  901. into a toolbox containing tools and instructions (the guide file) for their use.
  902. In fact, the source for these tools is also there, in the directory
  903. <TT>/acme/edit/src</TT>.
  904. This setup allows some control of the file name space for binary programs;
  905. not only does it group related programs, it permits the use of common
  906. names for uncommon jobs. For example, the single-letter names would
  907. be unwise in a directory in everyone's search path; here they are only
  908. visible when running editing commands.
  909. </P>
  910. <P>
  911. In Oberon,
  912. such a collection would be called a
  913. <I>tool</I>
  914. and would consist
  915. of a set of entry points in a module and a menu-like piece of text containing
  916. representative commands that may be edited to suit and executed.
  917. There is, in fact, a tool called
  918. <TT>Edit</TT>
  919. in Oberon.
  920. To provide related functionality,
  921. Acme exploits the directory and file structure of the underlying
  922. system, rather than the module structure of the language;
  923. this fits well with Plan 9's
  924. file-oriented philosophy.
  925. Such tools are central to the working of Oberon but they are
  926. less used in Acme, at least so far.
  927. The main reason is probably that Acme's program interface permits
  928. an external program to remain executing in the background, providing
  929. its own commands as needed (for example, the
  930. <TT>Reply</TT>
  931. command in the mail program); Oberon uses tools to
  932. implement such services because its must invoke
  933. a fresh program for each command.
  934. Also,
  935. Acme's better integration allows more
  936. basic functions to be handled internally; the right mouse button
  937. covers a lot of the basic utility of the editing tools in Oberon.
  938. Nonetheless, as more applications are written for Acme,
  939. many are sure to take this Oberon tool-like form.
  940. </P>
  941. <H4>Comparison with other systems
  942. </H4>
  943. <P>
  944. Acme's immediate ancestor is Help [Pike92], an experimental system written
  945. a few years ago as a first try at exploring some of Oberon's ideas
  946. in an existing operating system.
  947. Besides much better engineering, Acme's advances over Help
  948. include the actions of the right button (Help had nothing comparable),
  949. the ability to connect long-running programs to the user interface
  950. (Help had no analog of the
  951. <TT>event</TT>
  952. file),
  953. and the small but important change to split command output into
  954. windows labeled with the directory in which the commands run.
  955. </P>
  956. <P>
  957. Most of Acme's style, however, derives from the user interface and window
  958. system of Oberon [Wirt89, Reis91].
  959. Oberon includes a programming language and operating system,
  960. which Acme instead borrows from an existing system, Plan 9.
  961. When I first saw Oberon, in 1988, I was struck by the
  962. simplicity of its user interface, particularly its lack of menus
  963. and its elegant use of multiple mouse buttons.
  964. The system seemed restrictive, though&#173;single process,
  965. single language, no networking, event-driven programming&#173;and
  966. failed to follow through on some of its own ideas.
  967. For example, the middle mouse button had to be pointed accurately and
  968. the right button was essentially unused.
  969. Acme does follow through:
  970. to the basic idea planted by Oberon, it adds
  971. the ability to run on different operating systems and hardware,
  972. connection to existing applications including
  973. interactive ones such as shells and debuggers,
  974. support for multiple processes,
  975. the right mouse button's features,
  976. the default actions and context-dependent properties
  977. of execution and searching,
  978. and a host of little touches such as moving the mouse cursor that make the system
  979. more pleasant.
  980. At the moment, though, Oberon does have one distinct advantage: it incorporates
  981. graphical programs well into its model, an issue Acme has not yet faced.
  982. </P>
  983. <P>
  984. Acme shares with the Macintosh a desire to use the mouse well and it is
  985. worth comparing the results.
  986. The mouse on the Macintosh has a single button, so menus are essential
  987. and the mouse must frequently move a long way
  988. to reach the appropriate function.
  989. An indication that this style has trouble is that applications provide
  990. keyboard sequences to invoke menu selections and users often prefer them.
  991. A deeper comparison is that the Macintosh uses pictures where Acme uses text.
  992. In contrast to pictures, text can be edited quickly, created on demand,
  993. and fine-tuned to the job at hand; consider adding an option to a command.
  994. It is also self-referential; Acme doesn't need menus because any text can be
  995. in effect a menu item.
  996. The result is that, although a Macintosh screen is certainly prettier and probably
  997. more attractive, especially to beginners, an Acme screen is more dynamic
  998. and expressive, at least for programmers and experienced users.
  999. </P>
  1000. <P>
  1001. For its role in the overall system,
  1002. Acme most resembles EMACS [Stal93].
  1003. It is tricky to compare Acme to EMACS, though, because there are
  1004. many versions of EMACS and, since it is fully programmable, EMACS
  1005. can in principle do anything Acme does.
  1006. Also, Acme is much younger and therefore has not
  1007. had the time to acquire as many features.
  1008. The issue therefore is less what the systems can be programmed to do than
  1009. how they are used.
  1010. The EMACS versions that come closest to Acme's style are those that
  1011. have been extended to provide a programming environment, usually
  1012. for a language such as LISP [Alle92, Lucid92].
  1013. For richness of the existing interface, these EMACS versions are certainly superior to Acme.
  1014. On the other hand, Acme's interface works equally well already for a variety
  1015. of languages; for example, one of its most enthusiastic users works almost
  1016. exclusively in Standard ML, a language nothing like C.
  1017. </P>
  1018. <P>
  1019. Where Acme excels is in the smoothness of its interface.
  1020. Until recently, EMACS did not support the mouse especially well,
  1021. and even with the latest version providing features such as `extents'
  1022. that can be programmed to behave much like Acme commands,
  1023. many users don't bother to upgrade.
  1024. Moreover, in the versions that provide extents,
  1025. most EMACS packages don't take advantage of them.
  1026. </P>
  1027. <P>
  1028. The most important distinction is just that
  1029. EMACS is fundamentally keyboard-based, while
  1030. Acme is mouse-based.
  1031. </P>
  1032. <P>
  1033. People who try Acme find it hard to go back to their previous environment.
  1034. Acme automates so much that to return to a traditional interface
  1035. is to draw attention to the extra work it requires.
  1036. </P>
  1037. <H4>Concurrency in the implementation
  1038. </H4>
  1039. <P>
  1040. Acme is about 8,000 lines of code in Alef, a concurrent object-oriented language syntactically similar to C [Alef].
  1041. Acme's structure is a set of communicating
  1042. processes in a single address space.
  1043. One subset of the processes drives the display and user interface,
  1044. maintaining the windows; other processes forward mouse and keyboard
  1045. activity and implement the file server interface for external programs.
  1046. The language and design worked out well;
  1047. as explained elsewhere [Pike89, Gans93, Reppy93],
  1048. user interfaces built with concurrent systems
  1049. can avoid the clumsy
  1050. top-level event loop typical of traditional interactive systems.
  1051. </P>
  1052. <P>
  1053. An example of the benefits of the multi-process style
  1054. is the management of the state of open
  1055. files held by clients of the file system interface.
  1056. The problem is that some I/O requests,
  1057. such as reading the
  1058. <TT>event</TT>
  1059. file, may block if no data is available, and the server must
  1060. maintain the state of (possibly many) requests until data appears.
  1061. For example,
  1062. in
  1063. <TT>8&#189;</TT>,
  1064. a single-process window system written in C, pending requests were queued in
  1065. a data structure associated with each window.
  1066. After activity in the window that might complete pending I/O,
  1067. the data structure was scanned for requests that could now finish.
  1068. This structure did not fit well with the rest of the program and, worse,
  1069. required meticulous effort
  1070. to guarantee correct behavior under all conditions
  1071. (consider raw mode, reads of partial lines, deleting a window,
  1072. multibyte characters, etc.).
  1073. </P>
  1074. <P>
  1075. Acme instead creates a new dedicated process
  1076. for each I/O request.
  1077. This process coordinates with the rest of the system
  1078. using Alef's synchronous communication;
  1079. its state implicitly encodes the state of
  1080. the I/O request and obviates the need for queuing.
  1081. The passage of the request through Acme proceeds as follows.
  1082. </P>
  1083. <P>
  1084. Acme contains a file server process, F, that executes a
  1085. <TT>read</TT>
  1086. system call to receive a Plan 9 file protocol (9P) message from the client [AT&amp;T92].
  1087. The client blocks until Acme answers the request.
  1088. F communicates with an allocation process, M,
  1089. to acquire an object of type
  1090. <TT>Xfid</TT>
  1091. (`executing fid'; fid is a 9P term)
  1092. to hold the request.
  1093. M sits in a loop (reproduced in Figure 2) waiting for either a request for
  1094. a new
  1095. <TT>Xfid</TT>
  1096. or notification that an existing one has finished its task.
  1097. When an
  1098. <TT>Xfid</TT>
  1099. is created, an associated process, X,
  1100. is also made.
  1101. M queues idle
  1102. <TT>Xfids</TT>,
  1103. allocating new ones only when the list is empty.
  1104. Thus, there is always a pool of
  1105. <TT>Xfids</TT>,
  1106. some executing, some idle.
  1107. </P>
  1108. <P>
  1109. The
  1110. <TT>Xfid</TT>
  1111. object contains a channel,
  1112. <TT>Xfid.c</TT>,
  1113. for communication with its process;
  1114. the unpacked message; and some associated functions,
  1115. mostly corresponding to 9P messages such as
  1116. <TT>Xfid.write</TT>
  1117. to handle a 9P write request.
  1118. </P>
  1119. <P>
  1120. The file server process F parses the message to see its nature&#173;open,
  1121. close, read, write, etc. Many messages, such as directory
  1122. lookups, can be handled immediately; these are responded to directly
  1123. and efficiently
  1124. by F without invoking the
  1125. <TT>Xfid</TT>,
  1126. which is therefore maintained until the next message.
  1127. When a message, such as a write to the display, requires the attention
  1128. of the main display process and interlocked access to its data structures,
  1129. F enables X
  1130. by sending a function pointer on
  1131. <TT>Xfid.c</TT>.
  1132. For example, if the message is a write, F executes
  1133. <DL><DT><DD><TT><PRE>
  1134. x-&#62;c &#60;-= Xfid.write;
  1135. </PRE></TT></DL>
  1136. which sends
  1137. the address of
  1138. <TT>Xfid.write</TT>
  1139. on
  1140. <TT>Xfid.c</TT>,
  1141. waking up X.
  1142. </P>
  1143. <P>
  1144. The
  1145. <TT>Xfid</TT>
  1146. process, X, executes a simple loop:
  1147. <DL><DT><DD><TT><PRE>
  1148. void
  1149. Xfid.ctl(Xfid *x)
  1150. {
  1151. for(;;){
  1152. (*&#60;-x-&#62;c)(x); /* receive and execute message */
  1153. bflush(); /* synchronize bitmap display */
  1154. cxfidfree &#60;-= x; /* return to free list */
  1155. }
  1156. }
  1157. </PRE></TT></DL>
  1158. Thus X
  1159. will wake up with the address of a function to call (here
  1160. <TT>Xfid.write</TT>)
  1161. and execute it; once that completes, it returns itself to the pool of
  1162. free processes by sending its address back to the allocator.
  1163. </P>
  1164. <P>
  1165. Although this sequence may seem complicated, it is just a few lines
  1166. of code and is in fact far simpler
  1167. than the management of the I/O queues in
  1168. <TT>8&#189;</TT>.
  1169. The hard work of synchronization is done by the Alef run time system.
  1170. Moreover, the code worked the first time, which cannot be said for the code in
  1171. <TT>8&#189;</TT>.
  1172. </P>
  1173. <H4>Undo
  1174. </H4>
  1175. <P>
  1176. Acme provides a general undo facility like that of Sam, permitting
  1177. textual changes to be unwound arbitrarily.
  1178. The implementation is superior to Sam's, though,
  1179. with much higher performance and the ability to `redo' changes.
  1180. </P>
  1181. <P>
  1182. Sam uses
  1183. a multi-pass algorithm that builds
  1184. a transcript of changes to be made simultaneously
  1185. and then executes them atomically.
  1186. This was thought necessary because the elements of a repetitive
  1187. command such as a global substitution should all be applied to the same
  1188. initial file and implemented simultaneously; forming the complete
  1189. transcript before executing any of the changes avoids the
  1190. cumbersome management of addresses in a changing file.
  1191. Acme, however, doesn't have this problem; global substitution
  1192. is controlled externally and may be made incrementally by exploiting
  1193. an observation: if the changes are sorted in address order and
  1194. executed in reverse, changes will not invalidate the addresses of
  1195. pending changes.
  1196. </P>
  1197. <P>
  1198. Acme therefore avoids the initial transcript. Instead, changes are applied
  1199. directly to the file, with an undo transcript recorded in a separate list.
  1200. For example, when text is added to a window, it is added directly and a record
  1201. of what to delete to restore the state is appended to the undo list.
  1202. Each undo action and the file are marked with a sequence number;
  1203. actions with the same sequence number are considered a unit
  1204. to be undone together.
  1205. The invariant state of the structure
  1206. is that the last action in the undo list applies to the current state of the file,
  1207. even if that action is one of a related set from, for example, a global substitute.
  1208. (In Sam, a related set of actions needed to be undone simultaneously.)
  1209. To undo an action, pop the last item on the undo list, apply it to the file,
  1210. revert it, and append it to a second, redo list.
  1211. To redo an action, do the identical operation with the lists interchanged.
  1212. The expensive operations occur
  1213. only when actually undoing; in normal editing the overhead is minor.
  1214. For example, Acme reads files about seven times faster than Sam, partly
  1215. because of this improvement and partly because of a cleaner implementation.
  1216. </P>
  1217. <P>
  1218. Acme uses a temporary file to hold the text, keeping in memory only the
  1219. visible portion, and therefore can edit large files comfortably
  1220. even on small-memory machines such as laptops.
  1221. </P>
  1222. <H4>Future
  1223. </H4>
  1224. <P>
  1225. Acme is still under development.
  1226. Some things are simply missing.
  1227. For example, Acme should support non-textual graphics, but this is being
  1228. deferred until it can be done using a new graphics model being developed
  1229. for Plan 9. Also, it is undecided how Acme's style of interaction should best be
  1230. extended to graphical applications.
  1231. On a smaller scale, although the system feels smooth and comfortable,
  1232. work continues to tune the heuristics and
  1233. try new ideas for the user interface.
  1234. </P>
  1235. <P>
  1236. There need to be more programs that use Acme. Browsers for
  1237. Usenet and AP News articles, the Oxford English Dictionary, and other
  1238. such text sources exist, but more imaginative applications will
  1239. be necessary to prove that Acme's approach is viable.
  1240. One that has recently been started is an interface to the debugger Acid [Wint94],
  1241. although it is still
  1242. unclear what form it will ultimately take.
  1243. </P>
  1244. <P>
  1245. Acme shows that it is possible to make a user interface a stand-alone component
  1246. of an interactive environment. By absorbing more of the interactive
  1247. functionality than a simple window system, Acme off-loads much of the
  1248. computation from its applications, which helps keep them small and
  1249. consistent in their interface. Acme can afford to dedicate
  1250. considerable effort to making that interface as good as possible; the result
  1251. will benefit the entire system.
  1252. </P>
  1253. <P>
  1254. Acme is complete and useful enough to attract users.
  1255. Its comfortable user interface,
  1256. the ease with which it handles multiple tasks and
  1257. programs in multiple directories,
  1258. and its high level of integration
  1259. make it addictive.
  1260. Perhaps most telling,
  1261. Acme shows that typescripts may not be the most
  1262. productive interface to a time-sharing system.
  1263. </P>
  1264. <H4>Acknowledgements
  1265. </H4>
  1266. <P>
  1267. Howard Trickey, Acme's first user, suffered buggy versions gracefully and made
  1268. many helpful suggestions. Chris Fraser provided the necessary insight for the Acme editing
  1269. commands.
  1270. </P>
  1271. <H4>References
  1272. </H4>
  1273. <br>&#32;<br>
  1274. [Alef] P. Winterbottom,
  1275. ``Alef Language Reference Manual'',
  1276. Plan 9 Programmer's Manual,
  1277. AT&amp;T Bell Laboratories,
  1278. Murray Hill, NJ,
  1279. 1992;
  1280. revised in this volume.
  1281. <br>
  1282. [Alle92]
  1283. Allegro Common Lisp user Guide, Vol 2,
  1284. Chapter 14, "The Emacs-Lisp Interface".
  1285. March 1992.
  1286. <br>
  1287. [AT&amp;T92] Plan 9 Programmer's manual, Murray Hill, New Jersey, 1992.
  1288. <br>
  1289. [Far89] Far too many people, XTERM(1), Massachusetts Institute of Technology, 1989.
  1290. <br>
  1291. [Gans93] Emden R. Gansner and John H. Reppy, ``A Multi-threaded Higher-order User Interface Toolkit'', in
  1292. Software Trends, Volume 1,
  1293. User Interface Software,
  1294. Bass and Dewan (Eds.),
  1295. John Wiley &amp; Sons 1993,
  1296. pp. 61-80.
  1297. <br>
  1298. [Lucid92] Richard Stallman and Lucid, Inc.,
  1299. Lucid GNU EMACS Manual,
  1300. March 1992.
  1301. <br>
  1302. [Pike87] Rob Pike, ``The Text Editor <TT>sam</TT>'', Softw. - Pract. and Exp., Nov 1987, Vol 17 #11, pp. 813-845; reprinted in this volume.
  1303. <br>
  1304. [Pike88] Rob Pike, ``Window Systems Should Be Transparent'', Comp. Sys., Summer 1988, Vol 1 #3, pp. 279-296.
  1305. <br>
  1306. [Pike89] Rob Pike, ``A Concurrent Window System'', Comp. Sys., Spring 1989, Vol 2 #2, pp. 133-153.
  1307. <br>
  1308. [PPTTW93] Rob Pike, Dave Presotto, Ken Thompson, Howard Trickey, and Phil Winterbottom, ``The Use of Name Spaces in Plan 9'',
  1309. Op. Sys. Rev., Vol. 27, No. 2, April 1993, pp. 72-76,
  1310. reprinted in this volume.
  1311. <br>
  1312. [Pike91] Rob Pike, ``8&#189;, the Plan 9 Window System'', USENIX Summer Conf. Proc., Nashville, June, 1991, pp. 257-265,
  1313. reprinted in this volume.
  1314. <br>
  1315. [Pike92] Rob Pike, ``A Minimalist Global User Interface'', Graphics Interface '92 Proc., Vancouver, 1992, pp. 282-293. An earlier version appeared under the same title in USENIX Summer Conf. Proc., Nashville, June, 1991, pp. 267-279.
  1316. <br>
  1317. [Pike93] Rob Pike and Ken Thompson, ``Hello World or &#191;ALPHA&#191;&#191;MU&#191;&#191;ALPHA &#191;&#191;&#191;MUEPSILON or
  1318. &#191;&#191;&#191;&#191;&#191; &#191;&#191;'', USENIX Winter Conf. Proc., San Diego, 1993, pp. 43-50,
  1319. reprinted in this volume.
  1320. <br>
  1321. [Pres93] Dave Presotto and Phil Winterbottom, ``The Organization of Networks in Plan 9'', Proc. Usenix Winter 1993, pp. 271-287, San Diego, CA,
  1322. reprinted in this volume.
  1323. <br>
  1324. [Reis91] Martin Reiser, <I>The Oberon System,</I> Addison Wesley, New York, 1991.
  1325. <br>
  1326. [Reppy93] John H. Reppy,
  1327. ``CML: A higher-order concurrent language'', Proc. SIGPLAN'91 Conf. on Programming, Lang. Design and Impl., June, 1991, pp. 293-305.
  1328. <br>
  1329. [Sche86] Robert W. Scheifler and Jim Gettys,
  1330. ``The X Window System'',
  1331. ACM Trans. on Graph., Vol 5 #2, pp. 79-109.
  1332. <br>
  1333. [Stal93] Richard Stallman,
  1334. Gnu Emacs Manual, 9th edition, Emacs version 19.19,
  1335. MIT.
  1336. <br>
  1337. [Swei86] Daniel Sweinhart, Polle Zellweger, Richard Beach, and Robert Hagmann,
  1338. ``A Structural View of the Cedar Programming Environment'',
  1339. ACM Trans. Prog. Lang. and Sys., Vol. 8, No. 4, pp. 419-490, Oct. 1986.
  1340. <br>
  1341. [Wint94], Philip Winterbottom, ``Acid: A Debugger based on a Language'', USENIX Winter Conf. Proc., San Francisco, CA, 1993,
  1342. reprinted in this volume.
  1343. <br>
  1344. [Wirt89] N. Wirth and J. Gutknecht, ``The Oberon System'', Softw. - Prac. and Exp., Sep 1989, Vol 19 #9, pp 857-894.
  1345. <br>&#32;<br>
  1346. <A href=http://www.lucent.com/copyright.html>
  1347. Copyright</A> &#169; 2000 Lucent Technologies Inc. All rights reserved.
  1348. </body></html>