acme 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. .TH ACME 4
  2. .SH NAME
  3. acme \- control files for text windows
  4. .SH SYNOPSIS
  5. .B acme
  6. [
  7. .B -ab
  8. ]
  9. [
  10. .B -c
  11. .I ncol
  12. ]
  13. [
  14. .B -f
  15. .I varfont
  16. ]
  17. [
  18. .B -F
  19. .I fixfont
  20. ]
  21. [
  22. .B -l
  23. .I file
  24. |
  25. .I file
  26. \&... ]
  27. .SH DESCRIPTION
  28. The text window system
  29. .IR acme (1)
  30. serves a variety of files for reading, writing, and controlling
  31. windows.
  32. Some of them are virtual versions of system files for dealing
  33. with the virtual console; others control operations
  34. of
  35. .I acme
  36. itself.
  37. When a command is run under
  38. .IR acme ,
  39. a directory holding these files is mounted on
  40. .B /mnt/acme
  41. (also bound to
  42. .BR /mnt/wsys )
  43. and also
  44. .BR /dev ;
  45. the files mentioned here
  46. appear in both those directories.
  47. .PP
  48. Some of these files supply virtual versions of services available from the underlying
  49. environment, in particular the character terminal files
  50. .IR cons (3).
  51. (Unlike in
  52. .IR rio (1),
  53. each command under
  54. .I acme
  55. sees the same set of files; there is not a distinct
  56. .B /dev/cons
  57. for each window.)
  58. Other files are unique to
  59. .IR acme .
  60. .TP
  61. .B acme
  62. is a subdirectory used by
  63. .B win
  64. (see
  65. .IR acme (1))
  66. as a mount point for the
  67. .I acme
  68. files associated with the window in which
  69. .B win
  70. is running.
  71. It has no specific function under
  72. .I acme
  73. itself.
  74. .TP
  75. .B cons
  76. is the standard and diagnostic output file for all commands
  77. run under
  78. .IR acme .
  79. (Input for commands is redirected to
  80. .BR /dev/null .)
  81. Text written to
  82. .B cons
  83. appears in a window labeled
  84. .IB dir /+Errors\f1,
  85. where
  86. .I dir
  87. is the directory in which the command
  88. was run.
  89. The window is created if necessary, but not until text is actually written.
  90. .TP
  91. .B consctl
  92. is an empty unwritable file present only for compatibility; there is no way
  93. to turn off `echo', for example, under
  94. .IR acme .
  95. .TP
  96. .B index
  97. holds a sequence of lines of text, one per window. Each line has 5 decimal numbers,
  98. each formatted in 11 characters plus a blank\(emthe window ID;
  99. number of characters (runes) in the tag;
  100. number of characters in the body;
  101. a 1 if the window is a directory, 0 otherwise;
  102. and a 1 if the window is modified, 0
  103. otherwise\(emfollowed by the tag up to a newline if present.
  104. Thus at character position 5×12 starts the name of the window.
  105. If a file has multiple zeroxed windows open,
  106. only the most recently used will appear in the
  107. .B index
  108. file.
  109. .TP
  110. .B label
  111. is an empty file, writable without effect, present only for compatibility with
  112. .BR rio .
  113. .TP
  114. .B log
  115. reports a log of window operations since the opening of the
  116. .B log
  117. file.
  118. Each line describes a single operation using three fields separated by single spaces:
  119. the decimal window ID, the operation, and the window name.
  120. Reading from
  121. .B log
  122. blocks until there is an operation to report, so reading the file
  123. can be used to monitor editor activity and react to changes.
  124. The reported operations are
  125. .L new
  126. (window creation),
  127. .L zerox
  128. (window creation via zerox),
  129. .LR get ,
  130. .LR put ,
  131. .LR focus ,
  132. and
  133. .LR del
  134. (window deletion).
  135. The window name can be the empty string; in particular it is empty in
  136. .L new
  137. log entries corresponding to windows created by external programs.
  138. .TP
  139. .B new
  140. is a directory analogous to the numbered directories
  141. .RI ( q.v. ).
  142. Accessing any
  143. file in
  144. .B new
  145. creates a new window. Thus to cause text to appear in a new window,
  146. write it to
  147. .BR /dev/new/body .
  148. For more control, open
  149. .BR /dev/new/ctl
  150. and use the interface described below.
  151. .LP
  152. .PP
  153. Each
  154. .I acme
  155. window has associated a directory numbered by its ID.
  156. Window IDs are chosen sequentially and may be discovered by the
  157. .B ID
  158. command, by
  159. reading the
  160. .B ctl
  161. file, or
  162. indirectly through the
  163. .B index
  164. file. The files in the numbered directories are as follows.
  165. .TP
  166. .B addr
  167. may be written with any textual address (line number, regular expression, etc.),
  168. in the format understood by button 3 but without the initial colon, including compound addresses,
  169. to set the address for text accessed through the
  170. .B data
  171. file.
  172. When read, it returns the value of the address that would next be read
  173. or written through the
  174. .B data
  175. file, formatted as 2 decimal numbers
  176. .I m
  177. and
  178. .IR n ,
  179. each formatted in 11 characters plus a blank.
  180. .I M
  181. and
  182. .I n
  183. are the character (not byte) offsets of the
  184. beginning and end of the address,
  185. which would be expressed in
  186. .I acme 's
  187. input language as
  188. .BI # m ,# n \fR.
  189. Thus a regular expression may be evaluated by writing it to
  190. .B addr
  191. and reading it back.
  192. The
  193. .B addr
  194. address has no effect on the user's selection of text.
  195. .TP
  196. .B body
  197. holds contents of the window body. It may be read at any byte offset.
  198. Text written to
  199. .B body
  200. is always appended; the file offset is ignored.
  201. .TP
  202. .B ctl
  203. may be read to recover the five numbers as held in the
  204. .B index
  205. file, described above, plus three more fields: the width of the
  206. window in pixels, the name of the font used in the window,
  207. and the width of a tab character in pixels.
  208. Text messages may be written to
  209. .B ctl
  210. to affect the window.
  211. Each message is terminated by a newline and multiple
  212. messages may be sent in a single write.
  213. .RS .5i
  214. .TF limit=addr
  215. .TP
  216. .B addr=dot
  217. Set the
  218. .B addr
  219. address to that of the user's selected text in the window.
  220. .TP
  221. .B clean
  222. Mark the window clean as though it has just been written.
  223. .TP
  224. .B dirty
  225. Mark the window dirty, the opposite of clean.
  226. .TP
  227. .B cleartag
  228. Remove all text in the tag after the vertical bar.
  229. .TP
  230. .B del
  231. Equivalent to the
  232. .B Del
  233. interactive command.
  234. .TP
  235. .B delete
  236. Equivalent to the
  237. .B Delete
  238. interactive command.
  239. .TP
  240. .B dot=addr
  241. Set the user's selected text in the window to the text addressed by the
  242. .B addr
  243. address.
  244. .TP
  245. .BI dump " command
  246. Set the command string to recreate the window from a dump file.
  247. .TP
  248. .BI dumpdir " directory
  249. Set the directory in which to run the command to recreate the window from a dump file.
  250. .TP
  251. .B get
  252. Equivalent to the
  253. .B Get
  254. interactive command with no arguments; accepts no arguments.
  255. .TP
  256. .B limit=addr
  257. When the
  258. .B ctl
  259. file is first opened, regular expression context searches in
  260. .B addr
  261. addresses examine the whole file; this message restricts subsequent
  262. searches to the current
  263. .B addr
  264. address.
  265. .TP
  266. .B mark
  267. Cancel
  268. .BR nomark ,
  269. returning the window to the usual state wherein each modification to the
  270. body must be undone individually.
  271. .TP
  272. .B menu
  273. Maintain
  274. .BR Undo ,
  275. .BR Redo ,
  276. and
  277. .B Put
  278. in the left half of the tag.
  279. (This is the default for file windows.)
  280. .TP
  281. .BI name " name
  282. Set the name of the window to
  283. .IR name .
  284. .TP
  285. .B nomark
  286. Turn off automatic `marking' of changes, so a set of related changes
  287. may be undone in a single
  288. .B Undo
  289. interactive command.
  290. .TP
  291. .B nomenu
  292. Do not maintain
  293. .BR Undo ,
  294. .BR Redo ,
  295. and
  296. .B Put
  297. in the left half of the tag.
  298. (This is the default for directory and error windows.)
  299. .TP
  300. .B noscroll
  301. Turn off automatic `scrolling' of the window to show text written to the body.
  302. .TP
  303. .B put
  304. Equivalent to the
  305. .B Put
  306. interactive command with no arguments; accepts no arguments.
  307. .TP
  308. .B scroll
  309. Cancel a
  310. .B noscroll
  311. message, returning the window to the default state wherein each write
  312. to the
  313. .B body
  314. file causes the window to `scroll' to display the new text.
  315. .TP
  316. .B show
  317. Guarantee at least some of the selected text is visible on the display.
  318. .RE
  319. .PD
  320. .TP
  321. .B data
  322. is used in conjunction with
  323. .B addr
  324. for random access to the contents of the body.
  325. The file offset is ignored when writing the
  326. .B data
  327. file; instead the location of the data to be read or written is determined by the state of the
  328. .B addr
  329. file.
  330. Text, which must contain only whole characters (no `partial runes'),
  331. written to
  332. .B data
  333. replaces the characters addressed by the
  334. .B addr
  335. file and sets the address to the null string at the end of the written text.
  336. A read from
  337. .B data
  338. returns as many whole characters as the read count will permit starting
  339. at the beginning of the
  340. .B addr
  341. address (the end of the address has no effect)
  342. and sets the address to the null string at the end of the returned
  343. characters.
  344. .TP
  345. .B errors
  346. Writing to the
  347. .B errors
  348. file appends to the body of the
  349. .IB dir /+Errors
  350. window, where
  351. .I dir
  352. is the directory currently named in the tag.
  353. The window is created if necessary,
  354. but not until text is actually written.
  355. .TP
  356. .B event
  357. When a window's
  358. .B event
  359. file is open, changes to the window occur as always but the
  360. actions are also reported as
  361. messages to the reader of the file. Also, user actions with buttons 2 and 3
  362. (other than chorded
  363. .B Cut
  364. and
  365. .BR Paste ,
  366. which behave normally) have no immediate effect on the window;
  367. it is expected that the program reading the
  368. .B event
  369. file will interpret them.
  370. The messages have a fixed format:
  371. a character indicating the origin or cause of the action,
  372. a character indicating the type of the action,
  373. four free-format blank-terminated decimal numbers,
  374. optional text, and a newline.
  375. The first and second numbers are the character addresses of the action,
  376. the third is a flag,
  377. and the final is a count of the characters in the optional text, which
  378. may itself contain newlines.
  379. The origin characters are
  380. .B E
  381. for writes to the
  382. .B body
  383. or
  384. .B tag
  385. file,
  386. .B F
  387. for actions through the window's other files,
  388. .B K
  389. for the keyboard, and
  390. .B M
  391. for the mouse.
  392. The type characters are
  393. .B D
  394. for text deleted from the body,
  395. .B d
  396. for text deleted from the tag,
  397. .B I
  398. for text inserted to the body,
  399. .B i
  400. for text inserted to the tag,
  401. .B L
  402. for a button 3 action in the body,
  403. .B l
  404. for a button 3 action in the tag,
  405. .B X
  406. for a button 2 action in the body, and
  407. .B x
  408. for a button 2 action in the tag.
  409. .IP
  410. If the relevant text has less than 256 characters, it is included in the message;
  411. otherwise it is elided, the fourth number is 0, and the program must read
  412. it from the
  413. .B data
  414. file if needed. No text is sent on a
  415. .B D
  416. or
  417. .B d
  418. message.
  419. .IP
  420. For
  421. .BR D ,
  422. .BR d ,
  423. .BR I ,
  424. and
  425. .BR i
  426. the flag is always zero.
  427. For
  428. .BR X
  429. and
  430. .BR x ,
  431. the flag is a bitwise OR (reported decimally) of the following:
  432. 1 if the text indicated is recognized as an
  433. .I acme
  434. built-in command;
  435. 2 if the text indicated is a null string that has a non-null expansion;
  436. if so, another complete message will follow describing the expansion
  437. exactly as if it had been indicated explicitly (its flag will always be 0);
  438. 8 if the command has an extra (chorded) argument; if so,
  439. two more complete messages will follow reporting the argument (with
  440. all numbers 0 except the character count) and where it originated, in the form of
  441. a fully-qualified button 3 style address.
  442. .IP
  443. For
  444. .B L
  445. and
  446. .BR l ,
  447. the flag is the bitwise OR of the following:
  448. 1 if
  449. .I acme
  450. can interpret the action without loading a new file;
  451. 2 if a second (post-expansion) message follows, analogous to that with
  452. .B X
  453. messages;
  454. 4 if the text is a file or window name (perhaps with address) rather than
  455. plain literal text.
  456. .IP
  457. For messages with the 1 bit on in the flag,
  458. writing the message back to the
  459. .B event
  460. file, but with the flag, count, and text omitted,
  461. will cause the action to be applied to the file exactly as it would
  462. have been if the
  463. .B event
  464. file had not been open.
  465. .TP
  466. .B tag
  467. holds contents of the window tag. It may be read at any byte offset.
  468. Text written to
  469. .B tag
  470. is always appended; the file offset is ignored.
  471. .TP
  472. .B xdata
  473. The
  474. .B xdata
  475. file like
  476. .B data
  477. except that reads stop at the end address.
  478. .SH SOURCE
  479. .B /sys/src/cmd/acme
  480. .SH SEE ALSO
  481. .IR rio (1),
  482. .IR acme (1),
  483. .IR cons (3).