1 Xedit is a simple text editor for X.
2
3 Please check xedit(1) for information about resources and configurable
4 options.
5
6 The authors file should list the original authors of all files, but
7 unfortunately most collaborators and people that changed portions of the
8 code is not listed.
9
10
11 List of default keyboard commands.
12 Uppercase letters means both, uppercase and lowercase.
13 Lowercase letter usually means Shift key is not pressed.
14 C- Means Control key.
15 M- Means Meta key.
16 Usually Alt key has the same effect.
17 S- Means Shift key.
18
19 C-A Move cursor to beginning of line.
20 C-B or Left
21 Move cursor backwards one character.
22 C-C Insert CUT_BUFFER0 selection at cursor position.
23 C-D Delete next character.
24 C-E Move cursor to end of line.
25 C-F or Right
26 Move cursor forwards one character.
27 C-G Keyboard reset.
28 Use it to switch direction in the Undo stack, i.e. switch between
29 Undo and Redo.
30 It can also be used to stop the lisp interpreter if it is executing
31 code.
32 C-H Deletes character before cursor.
33 C-J Adds a newline and indent.
34 If the current buffer is the *scratch* buffer, it will work
35 like C-X,C-E, but print the lisp output directly to the scratch
36 buffer. Examples:
37 (list 1 2 3) C-J will print (1 2 3) and move the cursor to
38 the next line.
39 C-K Deletes text from cursor position to end of line.
40 C-L Redraw text window.
41 C-M Adds a newline.
42 C-N or Down
43 Move cursor to next line.
44 C-O Adds one newline at cursor position without moving cursor.
45 C-P or Up
46 Move cursor to previous line.
47 C-R Opens search dialog, searching backwards.
48 C-S Opens search dialog, searching forwards.
49 C-T Transpose characters.
50 C-U Starts multiply mode.
51 Multiply mode means that most keyboard commands will be repeated
52 by its parameter. After pressing C-U type a number, that can be
53 negative. Examples:
54 C-U 10 C-F will move the cursor 10 characters forwards
55 C-U -10 C-F will move the cursor 10 characters backwards
56 If no number is specified, or if the number zero is specified,
57 the default value is 4.
58 C-V or PageDown
59 Move cursor to next page.
60 C-W Kills current selection.
61 C-W is also useful when there is no active selection, to return to
62 the previous position the left mouse was clicked in the text window.
63 C-Y Inserts SECONDARY selection.
64 This usually means text delete with commands other than by just
65 pressing Backspace or Delete (that can be multiplied)
66 C-Z Scroll one line up.
67 M-B or C-Left
68 Move cursor backwards one word.
69 C-Left only moves over alphabetic or numeric characters
70 M-C Capitalize word under cursor position, or next word.
71 M-F or C-Right
72 Move cursor forwards one word.
73 C-Right only moves over alphabetic or numeric characters.
74 M-I Opens a dialog prompting for a file name to be inserted at the
75 cursor position.
76 (This isn't very user friendly, this is a cavemen interface, you will
77 love it, you will never use it).
78 M-K Kills text from cursor position to end of paragraph.
79 M-L Downcase word at cursor position or next word.
80 M-Q Format paragraph.
81 Xedit interfaces Xaw code that allows several types of text
82 formatting. To use it, you need to Select "Auto Fill" in the
83 "Edit Menu" and select values for "Break Columns". After that,
84 Select "Edit Menu"->"Justification" for the available options.
85 Text typed will usually be automatically corrected, but if you
86 need to change text in the middle of a previous line, use M-Q
87 to reformat, and C-_ to undo if required.
88 Examples of text:
89
90 This text with align
91 left and break
92 columns at 20 and
93 40.
94
95 This text with align
96 right and break
97 columns at 25 and
98 45. Remember that
99 Auto Fill must be
100 selected. And it may
101 be required to press
102 M-Q when going back
103 to edit previous
104 lines.
105
106 This text with align center
107 and break columns at 40 and
108 70. A good tip is to make sure
109 there are empty lines before
110 and after the aligned text, so
111 that M-Q will not format more
112 text than it should.
113
114 This text with full align,
115 note that it will spread the
116 words to fully fill the
117 configured break columns, in
118 this case 15 and 45. Also note
119 that it doesn't remove any
120 extra indentation from the
121 first line. This may be
122 considered a bug or feature,
123 but it doesn't respect 2
124 spaces after an '.' dot. And
125 it doesn't align the last line
126 of text.
127
128 This text with Auto Fill disabled. When Auto Fill is disabled, tabs are
129usually preserved, like this, and this. But it
130will basically format the text to not be larger than the text widget screen
131width and. But it the screen is scrolled horizontally, it will not work as
132expected, the advantage over the above interface is that is considers font
133characters width, while the other interface assumes fixed width characters.
134
135 Notice that "auto formatting" with Auto Fill mode is done when
136 pressing enter, but information isn't saved per paragraph, so
137 if values of align or break columns are changed, trying to edit
138 a text block with different configuration will not give the expected
139 results.
140 Also notice that lines starting with non printable characters aren't
141 automatically formatted. This is helpful for some editing modes
142 where symbols can be used before lines in a paragraph. If you don't
143 need this feature, usually pressing Space or Tab is enough to put the
144 cursor at the proper position.
145 M-U Upcase word at cursor position or next word.
146 M-V or PageUp
147 Move cursor to previous page.
148 M-Y Kill ring yank feature. Basically it will circulate over all
149 text that has been cut in the current session. Keep pressing it
150 until happy :-)
151 M-Z Scrolls one line down.
152 M-D Kill word at cursor position or next word.
153 S-M-D Delete word at cursor position or next word.
154 Does not go to the kill ring.
155 M-H or M-Delete or M-Backspace.
156 Kill word at cursor position or previous word.
157 S-M-H or S-M-Delete or S-M-Backspace
158 Delete word at cursor position or previous word.
159 Does not go to the kill ring.
160 M-. Find definition/declaration of symbol string of selected text, and/or
161 finds next tag when more than one definition exists for the symbol.
162 M-< or Home
163 Move cursor to beginning of file.
164 M-> or End
165 Move cursor to end of file.
166 M-] or C-Down
167 Move cursor to next paragraph.
168 M-[ or C-Up
169 Move cursor to previous paragraph.
170 C-_ or C-X,U
171 Undo.
172 If enabled in the given textwidget. Not enabled by default in the
173 message window and filename window, or any of the other text widgets
174 in the several available dialogs.
175 C-\ or C-Kanji
176 Reconnect Input Method.
177 In international mode (probably broken interface).
178 S-Insert
179 Insert PRIMARY selection from CUT_BUFFER0.
180 C-Q
181 Followed by any character, will insert the next typed character
182 useful to insert control characters. For example C-Q,C-L will
183 insert ^L at the cursor position.
184 LeftMouseButton
185 When pressed marks the start of a PRIMARY selection at CUTBUFFER0
186 When moved while pressed extends the selection.
187 MiddleMouseButton
188 When pressed, inserts the PRIMARY selection at CUTBUFFER0 at
189 the cursor position.
190 RightMouseButton
191 Can be used to adjust a selection done with LeftMouseButton.
192 C-A,Tab
193 If the loaded file has a indentation rules file, C or Lisp, xedit
194 will reindent the line. Also, entering a fresh character on a
195 newline should be enough to move the cursor to the proper position.
196 To override it, you may need to use the C-U to multiply the action,
197 as it will only indent if only one character was added.
198 C-X,C-C or (Pressing the Quit button)
199 Exits xedit.
200 If there are unsaved files, a message will be printed asking to
201 "exit" again, or save the files.
202 C-X,C-E
203 Execute lisp expression before the cursor position.
204 C-X,C-F
205 Changes keyboard input focus to the filename text input window.
206 In this mode, pressing Tab will try to complete the filename
207 being typed.
208 When more than one match exists, pressing Tab again will display
209 the directory navigation window.
210 The initial search path usually is the basename of the file loaded
211 in the current textwindow, or currently directory from where
212 xedit was started if the *scratch* is the current "buffer".
213 The character ~ can be used as a shortcut for the home directory
214 and ~username will be replaced by the home directory of "username"
215 if it exists.
216 C-X,C-S or (Pressing the Save button)
217 Saves the file in the current text window.
218 C-X,Tab
219 Indents the current paragraph.
220 Use the C-U modifier to specify the number of spaces to insert
221 or remove if the C-U parameter is negative.
222 C-X,0
223 Deletes the current window.
224 The file being edited is not unloaded.
225 C-X,1
226 Deletes the other window.
227 The file being edited is not unloaded.
228 C-X,2
229 Splits vertically the current window.
230 C-X,3
231 Splits vertically the current window.
232 C-X,b
233 Switch the contents of the current window to the next file in
234 the list of loaded files.
235 C-X,d
236 Displays the directory listing window.
237 In this window, it is possible to navigate in the file system
238 to choose a file to edit.
239 Usually, this is the same as pressing C-X,C-F,Tab
240 See C-X,C-F for more information.
241 C-X,k
242 Unloads the file being edited.
243 If the file has not been saved, a message will be displayed,
244 asking to either press C-X,k again, or save the file
245 The *scratch* buffer cannot be killed and will always
246 prints a warning when exiting xedit. This is the expected behavior.
247 C-X,o
248 Switch input focus to the other window, making it the current one
249 If the editor doesn't have splited windows, this command is ignored.
250 Insert
251 Switches between insert and overwrite mode.
252 In overwrite mode text is typed over existing file contents,
253 only extending the file contents when typing at the end of
254 a line (or file).
255 Escape
256 Enters the line edit mode.
257 In this mode it is possible to use regex expressions to search and
258 replace the contents of the file loaded in the current text window.
259 Refer to the xedit(1) manpage for more information of the regex
260 expression format.
261 Note that the regex used by xedit isn't IEEE Std 1003.2 compliant,
262 and not compliant with most regex implementations in that it doesn't
263 support some complex search patterns, usually involving patterns
264 like ((.*)+)? that may require too much restarts or have several
265 correct interpretations for multiple matches. Also, it always does
266 minimal matching, and it is not configurable like in pcre, example:
267 searching "a1a1a1" with the pattern "(.*)\d" will find "a1" and
268 not "a1a1a1" as could be expected.
269 Please refer to lisp/re/README for more information on the supported
270 regex expressions.
271 C-LeftMouseButton
272 Displays the "File Menu" from where it is possible to select a
273 new file to be edited in the current window.
274 C-MiddleMouseButton
275 Displays the "Edit Menu" that usually has the following options:
276 +------------------+-------------+
277 | Wrapping -> | Never |
278 | | Line |
279 | | Word |
280 | Auto Fill +-------------+
281 | +-------------+
282 | Justification -> | Left |
283 | | Right |
284 | | Center |
285 | | Full |
286 | +-------------+
287 | Break Columns... |
288 | +-------------+
289 | Scrollbars -> | Vertical |
290 | | Horizontal |
291 | +-------------+
292 | +-------------+
293 | Edit Mode -> | Plain/None |
294 | | C/C++ |
295 | | Lisp/Scheme |
296 | | X imake |
297 | | Makefile |
298 | | Unix shell |
299 | | SGML |
300 | | HTML |
301 | | Man page |
302 | | X resource |
303 | | XF86Config |
304 | | RPM spec |
305 | | XFree86 log |
306 | | Patch file |
307 +------------------+-------------+
308 "Wrapping" is disabled if "Auto Fill" is enabled.
309 "Justification" and "Break Columns..." are enabled if "Auto Fill"
310 is also enabled.
311 "Edit Mode" lists the available syntax highlight and indentation
312 rules defined.
313 Note that most of these options don't work in "international" mode.
314 Several xedit interfaces works only with 8 bits encodings, and
315 doesn't properly handle UTF-8.
316 C-RightMouseButton
317 Displays the "Option Menu".
318 Currently the only option is an Ispell frontend.
319 FourthMouseButton (usually also moving up the mouse wheel)
320 Scroll one line down
321 FifthMouseButton (usually also moving down the mouse wheel)
322 Scroll one line up
323
324
325
326 There is also some documentation in lisp/README, lisp/TODO,
327 lisp/re/README, lisp/re/tests.txt, and comments/justifications/wishlists for
328 the cases the interpreter fail to give the proper result for a given test.
329
330 The lisp interpreter implements most of a standard COMMON LISP
331 environment, but the compiler generates only byte code and not everything
332 can be compiled, in those cases the interpreter does the work. Examples are
333 constructs involving UNWIND-PROTECT or any kind of jump outside of the
334 current function body.
335
336 For more information please consult any COMMON LISP documentation or
337 tutorial.
338
339
340
341 Simple tutorial on writing a "foolang" syntax highlight mode for xedit.
342
343 Create a file called foolang.lsp
344 Add:
345 --
346 (require "syntax")
347 (require "indent")
348 (in-package "XEDIT")
349 --
350 to foolang.lsp
351 Check the available files if you want a custom property, or to know about
352 the available ones. One example is:
353 --
354 (defsynprop *prop-foolang*
355 "foolang"
356 :font "fixed"
357 :foreground "rgb:a/b/c"
358 :background "rgb:1/2/3"
359 :underline t
360 :overstrike t)
361 --
362 Check lisp/modules/xedit.lsp for the other options, like subscript,
363 superscript and/or combining XLFD properties.
364 Create a syntax definition for foolang. Check the definition of defsyntax in
365 lisp/modules/syntax.lsp for more details. One example for foolang is:
366 --
367 (defsyntax *foolang-mode* :foolang nil nil nil
368 ;; use the sample property created for foolang whenever the string
369 ;; foolang is found at the toplevel
370 (syntoken "\\<foolang\\>" :property *prop-foolang*)
371
372 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
373 ;; process C style comments
374 (syntoken "/*" :nospec t :begin :comment :contained t)
375 ;; contained is an option to not "export" this definition to child
376 ;; tables
377
378 (syntable :comment *prop-comment* #'default-indent
379 ;; #'default-indent means a very simple indent that follows indentation
380 ;; of previous line. Use nil for no indentation
381
382 ;; Don't start a new table, instead flag as an error if nested
383 (syntoken "/*" :nospec t :property *prop-error*)
384 ;; :nospec t sets the RE_NOSPEC flag for the regex, i.e. searches
385 ;; a literal string, and * will not be a special character
386
387 (syntoken "XXX|TODO|FIXME" :property *prop-annotation*)
388 ;; just to make it easier to flag some important comment
389
390 (syntoken "*/" :nospec t :switch -1)
391 ;; The :switch argument is the number of tables to "pop", in
392 ;; this case, we are at table :comment, and :switch -1 returns
393 ;; to table :foolang, that is the "root" table
394 )
395
396 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
397 ;; Process lisp comments that can nest
398 (syntable :lisp-comment *prop-comment* nil
399
400 ;; Start a comment, possibly nested
401 (syntoken "#|" :nospec t :begin :lisp-comment)
402
403 ;; Returns to previous comment in stack or to main :foolang table
404 (syntoken "|#" :nospec t :switch -1)
405
406 ;; For easier flagging important comments
407 (syntoken "XXX|FIXME|TODO" :property *prop-annotation*)
408 )
409
410 ;; This is usually in the end of the list, but can be anywhere,
411 ;; just that if it isn't at the end, conflicting rules are resolved
412 ;; by declaration order
413 (synaugment :lisp-comment)
414 ;; Adds the :lisp-comment table to :foolang table
415
416 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
417 ;; Lisp like strings that don't need a \ at the end of the line
418 (syntable :lisp-string *prop-string* nil
419 ;; ignore a escaped " in the middle of the string
420 (syntoken "\\\\.")
421 ;; Note that no options are used, just keep using the current
422 ;; property. Unfortunately, backslashes must be escaped twice.
423 ;; Once for the lisp reader and once for the regex compiler.
424
425 (syntoken "\"" :nospec: t :switch -1)
426 ;; :nospec is used just to create a faster regex. switch -1
427 ;; returns to the previous syntax table. It isn't an error to
428 ;; try to go down the "root" table, but if that happens, it
429 ;; probably means either wrong syntax definition of malformed input.
430 )
431
432 (synaugment :lisp-string)
433 ;; Adds the :lisp-string table to :foolang table
434 ;; Note that since there isn't a rule to start a string in the
435 ;; :lisp-string table, it cannot nest, maybe because the ending
436 ;; character is the starting character ? :-))
437
438 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
439 ;; C style string rules
440 (syntable :string *prop-string* nil
441 ;; Ignore escaped characters
442 (syntoken "\\\\.")
443
444 ;; Match, most, printf arguments.
445 (syntoken "%%|%([+-]?\\d+)?(l?[deEfgiouxX]|[cdeEfgiopsuxX])"
446 :property *prop-format*)
447 ;; Just for fun. This makes easier to see printf formats in strings
448 ;; *prop-format* is *prop-string* with the :underline option
449
450 (syntoken "\\\\$")
451 ;; a backslash extends the string to the next line
452
453 ;; A nonscaped " inside a string finishes it, since this table doesn't
454 ;; have sub tables, and cannot nest, should return to :foolang table
455 ;; from here
456 (syntoken "\"" :nospec t :switch -1)
457
458 ;; This token rule starts a new table called :error because end of line
459 ;; has been matched. Note that it is defined last, so that a line
460 ;; ending with " or \ will be processed first.
461 (syntoken ".?$" :begin :error)
462
463 (synaugment :string)
464 ;; Adds the :string table to :foolang table
465
466 ;; This table is used by :string, but could be shared for other patterns
467 ;; like characters constants, etc.
468 ;; It uses :switch -2 because it is started inside the :string table,
469 ;; but it is also a table, so, pops two tables from the table stack
470 (syntable :error *prop-error* nil
471 (syntoken "^.*$" :switch -2)
472 )
473 )
474 --
475
476 Indentation rules are significantly more complex. I suggest looking at
477 lisp/modules/indent.lsp for the macros and function definitions;
478 and lisp/modules/progmodes/lisp.lsp and lisp/modules/progmodes/c.lsp for two
479 sample implementations of indentation for Lisp/Scheme and C/C++
480 respectively.
481
482 Note also that indentation is parsed backwards, what can cause some
483 confusion, and make "visualization" of order or precedence of evaluation for
484 rules harder to understand.
485
486 A simple indentation rules definition for foolang could be:
487
488 --
489 (defindent *foolang-mode-indent* :foolang
490 ;; This must be the first token and usually the only token matching
491 ;; BOL (Beginning of Line)
492 (indtoken "^\\s*" :indent
493 :code (or *offset* (setq *offset* (+ *ind-offset* *ind-length*))))
494 ;; the keyword :indent is a pattern put on a list when there is
495 ;; a match, so that later patterns can be "reduced" by some other
496 ;; rule, i.e.: (:indent :indent) could be reduced to (:indent)
497
498 (indtoken "//.*$" nil)
499 ;; C++ style comment. Returning nil instead of a token basically
500 ;; ignores the token, as it should not enter the reduction pattern
501 ;; list
502
503 ;; Sample C comment pattern
504 (indtoken "*/" :ccomment :nospec t :begin :comment)
505 ;; Note that the indaugment macro doesn't need to be used, and actually
506 ;; would be an error. In this example, the indentation compiler checks
507 ;; the :begin :comment and handles it internally, as it already needs
508 ;; to check for things like typos, unreachable labels, detectable
509 ;; non resolving rules, etc. There is runtime check also, so it should
510 ;; never enter an infinite loop when trying to resolve reduction rules.
511 ;; Check lisp/modules/indent.lsp:(compile-indent-table) for the
512 ;; implementation and more comments.
513
514 ;; Indentation rules also have stacked tables
515 (indtable :comment
516 (indtoken "/*" :ocomment :nospec t :switch -1))
517 ;; Note that the name is :ocomment (open comment), but that the
518 ;; the table is finished when matching the open comment pattern
519
520 ;; A simple initialization of a variable used by the indentation rules
521 (indinit (parens 0))
522 ;; This variable can be declared anywhere in the body of defindent,
523 ;; It will be properly moved to a "variables declaration section"
524 ;; when expanding and compiling the table.
525
526 (indtoken "(" :oparen :nospec t :code (incf parens))
527 (indtoken ")" :cparen :nospec t :code (decf parens))
528 ;; These two tokes add the patterns :oparen and :cparen to the
529 ;; "pattern list", and also have code to remember the balancing
530 ;; of parenthesis.
531
532
533 ;; One of the simplest reduction rules :-)
534 (indreduce nil
535 t
536 ((:comment)))
537 ;; Once the boundings of a comment are found, just ignore it, like
538 ;; what was done with the // pattern, but in that case, the boundings
539 ;; were readily available.
540 ;; The t (True) parameter means that this rule is always evaluated,
541 ;; but conditional code may be used, and implicit code may be added
542 ;; to the end of the indreduce macro.
543 ;; Since it is a macro, code can be compiled to optimized bytecode
544 ;; after the macro is expanded.
545
546 (indinit (indent 0))
547 ;; Note that there is a special *indent* variable that should hold the
548 ;; proper indentation value, but it may be required to "overwrite"
549 ;; without forgetting that value, for things like:
550 ;;
551 ;; foo(bar(baz(blah
552 ;; ^ ^
553 ;; | |
554 ;; indent |
555 ;; effective indentation to be used
556 ;;
557 ;; where it is desirable to align the code in the next line with the
558 ;; last open parenthesis.
559
560
561 Since the interface is, unfortunately, complex enough to not expect
562 casual users to have something like a $HOME/.xedit file, if you want to add
563 new modes, please check lisp/modules/xedit.lsp:*auto-modes*
564
565 There is some documentation about the variable. It should be possible to
566 change/update the variable from the lisp interface in the *scratch* buffer,
567 but for safety, it is suggested that if you add new rules, you should
568 restart xedit after it. Also note that there is compiled code in
569 lisp/xedit.c that expects that variable to follow an specific format.
570
571 You may notice that several .lsp files aren't "properly indented"; this
572 is because the lisp indentation rules file was made long after most of the
573 other files were done, and it was considered a bad practice to gratuitously
574 reindent all files.
575
576
577
578 At the time of this writing, the ispell interface should be again
579 functional, but it may be required to use some old ispell program to handle
580 non utf8 text. But it should work properly for the english language, and in
581 international mode, should work with any language. But there are problems in
582 international mode not fixed.
583
584 I (Paulo Cesar) considered several times to extend the normal
585 textwidget to handle utf8, but this is probably a lot of work/time badly
586 spent and I prefer to work on other personal projects, but still xedit is
587 the editor I use for programming. The XPRINT support unfortunately is broken
588 due to it. Note that xedit, like pretty much any other Xaw application can
589 be linked against Xaw with XPRINT support. In the case of xedit, a flag
590 could be used, like the "international" variable to, at runtime, disable all
591 the related code, if required.
592
593 Also at the time of this writing, the tags interface was added, as well
594 as several other bug fixes. The tags interface is documented in the manpage,
595 but the action shortcut may not be clear. The default shortcut is M-. .
596 There is no support for more than one tags file, or changing the tags file
597 at runtime. But the code should be easy to adapt for this case, as all
598 related functions receive pointers to the appropriate structures. One option
599 could be to descend from the directory of the loaded file searching for a
600 tags file, and then associate the file with the tags definition, if it isn't
601 already loaded. Shouldn't be hard to implement. For "inter project" files,
602 it should be better to have one xedit window per "project", i.e. searching
603 the definition of something like a libc symbol should probably be done in
604 another xedit window.
605