The new home of XED is <http://geology.usgs.gov/tools/xed/>
It is also possible to obtain the package through anonymous ftp: <ftp://geology.usgs.gov/pub/xed/xed-1.24.tar.gz>
The package is about 170k in size and contains only source code. Please contact me for assistance if it is difficult for you to compile on your system.
The Macintosh version prompts the user for a file to edit when the application is launched.
The MS-DOS version is built with the Watcom C/386 compiler and requires that the Rational Systems, Inc. DOS-Extender (DOS4GW.EXE) be located somewhere along the user's execution path, which is specified by the PATH environment variable. An 80386 CPU and extended memory are required for the MS-DOS version to work.
The backup resource, if specified, causes Xed to make a copy of the current on-disk version of the file, naming the copy filename.bak.
The keymap resource should specify a pathname for a file containing the key definitions, if other than the default key bindings are to be used. Additional instructions for changing the key bindings are given below.
The status_fg and status_bg resources, if specified, govern the foreground and background colors, respectively, of the status line and menus. These default to the background and foreground colors, respectively, of the main window, so that by default, the status line and menu colors will be the reverse of the main window's foreground and background colors.
Macintosh users can alter the default size and shape of the main window by editing the WIND resource of Xed using ResEdit.
L 10 C 12 IA4 +foo.datThis status line indicates that the cursor is on column 12 of line 10 of the file foo.dat, that the file has been modified i.e. that the copy in memory has changes that have not yet been saved to disk. Insert is active, as is autoindent. Tabs expand to 4 spaces. If you do not have write permission for the file, the plus sign will not appear; instead, the designation (Read Only) will precede the file name. If the file has been loaded as binary data, the designation (binary) will appear as well.
The X-windows and Macintosh versions pay attention to the pointer, i.e. the mouse. If you click the mouse anywhere in the window, the cursor moves to the character position nearest the point where the mouse button was pressed. The DOS version does not watch the mouse, since the DOS version of Xed operates in text mode, and mouse operations in DOS text modes are inherently clumsy.
Users should note that Xed considers tab width to be a variable. The default tab width is 4 spaces. Many documents created in the UNIX world assume that tabs are eight spaces, so you can alter the tab width by pressing Ctrl-Tab. Note also that tab characters are initially visible in Xed, and you cannot place the cursor onto any of the spaces that result from tab expansion. By pressing Ctrl-v, you can toggle the tab visibility through three states, an invisible state, a minimally visible state (the default), and a maximally visible state in which one can distinguish the tab fill characters (which fill the space between a tab and the following text) from true spaces.
The X Windows version has a rudimentary help facility associated with its menus. To find out what keystrokes can be used to produce the effect of a particular menu selection, highlight a menu item and press the question mark. Xed will print on the xterm from which it was launched brief descriptions of all keystrokes that produce this action. Note that these descriptions will refer to an "Alt" modifier key that may not be present on your system. This really refers to the Mod1 modifier key.
In the X Windows and MS-DOS versions, you can enter a directory specification at the "Edit file:" prompt. If Xed determines that the name you entered is a directory, it presents you with a list of files in that directory. Use the arrow keys to select a file from the list; if you choose another directory (identified with a trailing slash character), the corresponding list will appear.
When asked to read a file as binary data, Xed creates a hexadecimal display similar to that produced by the DOS utility DEBUG; each line has sixteen bytes displayed as hexadecimal numbers, followed by a tab, a pound sign (#), and the ASCII equivalents of those sixteen bytes. Non-printable characters are displayed in the ASCII section as periods.
You can edit this hexadecimal display as you like; no special binary editing mode exists. When asked to save the file, however, Xed will look through each line, converting pairs of hexadecimal digits back to binary bytes and writing them to the output file. When it encounters a character that is neither a hexadecimal digit nor a whitespace (blank or tab), it skips to the beginning of the next line and continues the conversion.
Since there aren't keys specifically made for many important functions, many keys have arbitrary assignments. These are intended to mimic other packages (e.g. Qedit and WordStar on MS-DOS systems) but do so in only a limited fashion.
To change what a particular key does, you'll need to modify a simple table in the source code and recompile the program.
A more dynamic configuration occurs under X Windows; if the X display name does not begin with a colon (i.e. if Xed is running on another machine), Xed looks for a file in the user's home directory named xed.hostname where hostname is the name of the host on which the window is to be displayed. This file, if it exists, is assumed to be the binary output of the configuration program xed_config (see below). Its contents replace the default keymap table.For those keys that are significant when modified using Shift, Ctrl or Alt, the modified action is either the same or is complementary to the action of the unmodified key. For example, the left arrow key moves the cursor left one space, while Ctrl-Left moves the cursor left one word. Similarly, the Home key moves the cursor to the beginning of the line, and Ctrl-Home moves it to the beginning of the file.
Items under the Print menu control the layout of the printed page.
If the block starts and ends on the same line, and the end follows the start, the intervening text is copied to the paste buffer, and can be inserted elsewhere by pressing Ctrl-p.
if (((c = getc(stdin)) != EOF) && ord[c] != 'a') {
abc d dc b a
Here matching letters appear on the line below matching parentheses.
KEY_FIND_MATCH operates either forward or backward, depending on
whether the character at the cursor position is a left-symbol (one
of (, [, {, or <) or the corresponding right-symbol (
respectively, ), ], }, or >).
Note that the text pasting operation respects the insert state. If Insert is off (no 'I' appears in the status line), the paste operation overwrites characters already in the line. This effect occurs both when KEY_PASTE is invoked directly (with Ctrl-p) and during replace operations.
to upper case Alt-1 (Command-1 on Macintosh) to lower case Alt-2 (Command-2 on Macintosh) switch case Alt-3 (Command-3 on Macintosh) to hexadecimal Ctrl-F2 from hexadecimal Ctrl-F4
Fn or Shift-Fn Ctrl-Fn Alt-Fn F1 SAVE_AND_EXIT CHANGE_NAME reserved F2 QUIT TO_HEX reserved F3 SAVE_FILE FIND_MATCH reserved F4 GO_TO_LINE FROM_HEX reserved F5 COPY_BLOCK WRITE_FILE reserved F6 MOVE_BLOCK DEL_BLOCK reserved F7 MARK_BLOCK_START READ_FILE reserved F8 MARK_BLOCK_END PS_PRINT reserved F9 DUP_LINE BREAK_LINE reserved F10 DUP_CHAR TOGGLE_BINARY reserved
key Ctrl-key KP_7 MOVE_TO_BEG_OF_LINE MOVE_TO_BEG_OF_FILE KP_8 MOVE_UP MOVE_TO_TOP_OF_SCREEN KP_9 PAGE_UP SCROLL_UP KP_4 MOVE_LEFT WORD_LEFT KP_5 IGNORE IGNORE KP_6 MOVE_RIGHT WORD_RIGHT KP_1 MOVE_TO_END_OF_LINE MOVE_TO_END_OF_FILE KP_2 MOVE_DOWN MOVE_TO_BOTTOM_OF_SCREEN KP_3 PAGE_DOWN SCROLL_DOWN KP_0 TOGGLE_INSERT TOGGLE_AUTOINDENT KP_Decimal DEL_RIGHT DEL_TO_EOL KP_Enter NEW_LINE not assigned
key or Shift-key Ctrl-key Insert TOGGLE_INSERT TOGGLE_AUTOINDENT Delete DEL_RIGHT DEL_TO_END_OF_LINE Home MOVE_TO_BEG_OF_LINE MOVE_TO_BEG_OF_FILE End MOVE_TO_END_OF_LINE MOVE_TO_END_OF_FILE Page Up PAGE_UP SCROLL_UP Page Down PAGE_DOWN SCROLL_DOWM Left MOVE_LEFT WORD_LEFT Right MOVE_RIGHT WORD_RIGHT Up MOVE_UP MOVE_TO_TOP_OF_SCREEN Down MOVE_DOWN MOVE_TO_BOTTOM_OF_SCREEN Backspace DEL_LEFT DEL_TO_BEG_OF_LINE Tab (tab) SET_TAB_WIDTH
Alt-b SET_RIGHT_MARGIN Alt-e ANOTHER_FILE on Macintosh use Command-O instead Alt-f SEARCH_BACKWARDS Alt-p SET_PASTE_TEXT Alt-q QUIT on Macintosh use Command-Q instead Alt-r REPLACE_ALL Alt-x SAVE_AND_EXIT on Macintosh use Command-W instead Alt-1 UPPER_CASE Alt-2 LOWER_CASE Alt-3 TOGGLE_CASE Alt-> NEXT_FILE Alt-< PREV_FILE
Ctrl-w SCROLL_DOWN Ctrl-e MOVE_UP Ctrl-r REPLACE_ONCE Ctrl-t DEL_SPACE_TO_RIGHT Ctrl-y DEL_LINE Ctrl-u UNDEL LINE Ctrl-i (tab) Ctrl-p PASTE Ctrl-s MOVE_LEFT Ctrl-d MOVE_RIGHT Ctrl-f SEARCH_FORWARD Ctrl-g DEL_RIGHT Ctrl-l FIND_NEXT Ctrl-z SCROLL_DOWM Ctrl-x MOVE_DOWN Ctrl-v TOGGLE_TAB_VISIBILITY Ctrl-b REFORMAT_PARAGRAPH
CHANGE_NAME CTRL-F1 ANOTHER_FILE Alt-E PS_PRINT CTRL-F8, Print PREV_FILE Alt-< NEXT_FILE Alt-> READ_FILE CTRL-F7 SAVE_FILE F3, SHFT-F3 SAVE_AND_EXIT ALT-x, F1, SHFT-F1 QUIT ALT-q, F2, SHFT-F2
MARK_BLOCK_START F7, SHFT-F7 MARK_BLOCK_END F8, SHFT-F8 COPY_BLOCK F5, SHFT-F5 MOVE_BLOCK F6, SHFT-F6 DEL_BLOCK CTRL-F6 WRITE_BLOCK CTRL-F5
MOVE_UP CTRL-SHFT-E, CTRL-e, KP_8, SHFT-Up, Up MOVE_DOWN CTRL-SHFT-X, CTRL-x, Down, KP_2, SHFT-Down MOVE_LEFT CTRL-SHFT-S, CTRL-s, KP_4, Left, SHFT-Left MOVE_RIGHT CTRL-SHFT-D, CTRL-d, KP_6, Right, SHFT-Right MOVE_TO_BEG_OF_LINE Home, KP_7, SHFT-Home MOVE_TO_END_OF_LINE End, KP_1, SHFT-End MOVE_TO_TOP_OF_SCREEN CTRL-KP_8, CTRL-Up MOVE_TO_BOTTOM_OF_SCREEN CTRL-Down, CTRL-KP_2 MOVE_TO_BEG_OF_FILE CTRL-Home, CTRL-KP_7 MOVE_TO_END_OF_FILE CTRL-End, CTRL-KP_1 PAGE_UP KP_9, Prior, SHFT-Prior PAGE_DOWN KP_3, Next, SHFT-Next WORD_LEFT CTRL-KP_4, CTRL-Left WORD_RIGHT CTRL-KP_6, CTRL-Right SCROLL_UP CTRL-KP_9, CTRL-Prior, CTRL-SHFT-W, CTRL-w SCROLL_DOWN CTRL-KP_3, CTRL-Next, CTRL-SHFT-Z, CTRL-z GO_TO_LINE F4, SHFT-F4
SEARCH_FORWARD CTRL-f SEARCH_BACKWARD ALT-f FIND_NEXT CTRL-SHFT-L, CTRL-l REPLACE_ONCE CTRL-r REPLACE_ALL ALT-r SET_PASTE_TEXT ALT-p PASTE CTRL-p FIND_MATCH CTRL-F3
NEW_LINE KP_Enter, Return, SHFT-KP_Enter, SHFT-Return DUP_CHAR F10, SHFT-F10 DUP_LINE F9, SHFT-F9 DEL_LEFT BackSpace, SHFT-BackSpace DEL_RIGHT CTRL-SHFT-G, CTRL-g, Delete, KP_Decimal, SHFT-Delete DEL_LINE CTRL-SHFT-Y, CTRL-y UNDEL_LINE CTRL-SHFT-U, CTRL-u DEL_SPACE_TO_RIGHT CTRL-SHFT-T, CTRL-t DEL_TO_BEG_OF_LINE CTRL-BackSpace DEL_TO_END_OF_LINE CTRL-Delete, CTRL-KP_Decimal LOWER_CASE ALT-2 UPPER_CASE ALT-1 TOGGLE_CASE ALT-3 BREAK_LINE CTRL-F9 REFORMAT_PARAGRAPH CTRL-b, CTRL-SHFT-B
SET_TAB_WIDTH CTRL-Tab TOGGLE_TAB_VISIBILITY CTRL-SHFT-V, CTRL-v TOGGLE_INSERT Insert, KP_0, SHFT-Insert TOGGLE_AUTOINDENT CTRL-Insert, CTRL-KP_0 SET_RIGHT_MARGIN ALT-b IGNORE CTRL-KP_5, KP_5
Open KEY_ANOTHER_FILE Merge KEY_READ_FILE Save KEY_SAVE_FILE Save As KEY_CHANGE_NAME Close KEY_SAVE_AND_EXIT Prev file KEY_PREV_FILE Next file KEY_NEXT_FILE Print KEY_PS_PRINT Add keys KEY_ADD_KEYS Quit KEY_QUIT
Toggle insert KEY_TOGGLE_INSERT Toggle autoindent KEY_TOGGLE_AUTOINDENT Toggle tab visibility KEY_TOGGLE_TAB_VISIBILITY Set tab width KEY_SET_TAB_WIDTH Set right margin KEY_SET_RIGHT_MARGIN Scroll up KEY_SCROLL_UP Scroll down KEY_SCROLL_DOWN
Word left KEY_WORD_LEFT Word right KEY_WORD_RIGHT Move to top of screen KEY_MOVE_TO_TOP_OF_SCREEN Move to bottom of screen KEY_MOVE_TO_BOTTOM_OF_SCREEN Move to beg of line KEY_MOVE_TO_BEG_OF_LINE Move to end of line KEY_MOVE_TO_END_OF_LINE Move to beg of file KEY_MOVE_TO_BEG_OF_FILE Move to end of file KEY_MOVE_TO_END_OF_FILE Page up KEY_PAGE_UP Page down KEY_PAGE_DOWN Find match KEY_FIND_MATCH Go to line KEY_GO_TO_LINE
Search forward KEY_SEARCH_FORWARD Search backward KEY_SEARCH_BACKWARD Find next KEY_FIND_NEXT Find nonprintable KEY_FIND_NEXT_NONPRINTABLE Set paste text KEY_SET_PASTE_TEXT Paste KEY_PASTE Replace once KEY_REPLACE_ONCE Replace all KEY_REPLACE_ALL
Mark start KEY_MARK_BLOCK_START Mark end KEY_MARK_BLOCK_END Copy KEY_COPY_BLOCK Move KEY_MOVE_BLOCK Save As KEY_WRITE_BLOCK Delete KEY_DEL_BLOCK Print KEY_PS_PRINT_BLOCK Hide KEY_HIDE_BLOCK
Del space to right KEY_DEL_SPACE_TO_RIGHT Del line KEY_DEL_LINE UnDelete line KEY_UNDEL_LINE Del to beg of line KEY_DEL_TO_BEG_OF_LINE Del to end of line KEY_DEL_TO_END_OF_LINE Dup char KEY_DUP_CHAR Dup line KEY_DUP_LINE New line KEY_NEW_LINE Break line KEY_BREAK_LINE Reformat paragraph KEY_REFORMAT_PARAGRAPH Toggle Binary File KEY_TOGGLE_BINARY
Upper case KEY_UPPER_CASE Lower case KEY_LOWER_CASE Toggle case KEY_TOGGLE_CASE To hex KEY_TO_HEX From hex KEY_FROM_HEX To binary KEY_TO_BINARY Hex to binary KEY_HEX_TO_BINARY
Type size KEY_PRINT_SIZE Top margin KEY_PRINT_TOP Bottom margin KEY_PRINT_BOTTOM Left margin KEY_PRINT_LEFT Line numbers KEY_PRINT_NUMBER Page orientation KEY_PRINT_ORIENTATION Page footers KEY_PRINT_FOOTER Set print command KEY_PRINT_COMMAND PS Print KEY_PS_PRINT
The MS-DOS version also has some code files to handle those user interface tasks that are handled by the system in UNIX and on the Macintosh. The X version has an icon bitmap file because this is difficult to change intelligently with a text editor. The Macintosh version has file I/O operations in a separate module, and has some utility routines in separate files. In addition, the Macintosh version requires appropriate resources, which are contained in a ResEdit 'rsrc' file.
No attempt was made to enable this code to be ported to 16-bit platforms. There are superb programmer's editors available for 16-bit DOS, and if they suit your needs you should use one of them. Qedit by SemWare is highly recommended. The only editor I have seen that runs in protected mode on MS-DOS systems is MicroEmacs and is distributed with the NDP compilers by MicroWay. Emacs fanatics might like it; I don't.
Xed was developed initially under UNIX on a Data General AViiON workstation running a MC88100 CPU. The GNU C compiler was used to build it, and it is compatible with X11R3, X11R4, and X11R5. It has been successfully built on an HP/UX system version 7.05 by installing the GNU C compiler version 2.1 and defining the symbol _SYS_FILE_INCLUDED to enable the definition of struct file in edit.h. It has also been built on a Sun SPARCstation IPX running OpenWindows, using the ANSI compiler acc.
The keystroke is described by the logical OR of the modifier keys (CTRL, SHFT, ALT) with the KeySym, the name X11 uses for the key. Neither the Mac nor MS-DOS has as convenient a way of describing keys as X11, so I have provided equivalent keysyms for both Mac and MS-DOS keys in a header file. The Mac keysyms are named MK_key, while the MS-DOS keysyms are named DK_key. A section of the X-windows keymap table is reproduced below.
{CTRL | 0 | 0 | XK_BackSpace, KEY_DEL_TO_BEG_OF_LINE, NULL},
{CTRL | 0 | 0 | XK_KP_Decimal, KEY_DEL_TO_END_OF_LINE, NULL},
{CTRL | 0 | 0 | XK_Delete, KEY_DEL_TO_END_OF_LINE, NULL},
{CTRL | 0 | 0 | XK_Escape, KEY_SHOW_VARIABLES, NULL},
{ 0 | 0 | ALT | XK_1, KEY_UPPER_CASE, NULL},
{ 0 | 0 | ALT | XK_2, KEY_LOWER_CASE, NULL},
{ 0 | 0 | ALT | XK_3, KEY_TOGGLE_CASE, NULL},
{ 0 | 0 | ALT | XK_b, KEY_SET_RIGHT_MARGIN, NULL},
{ 0 | 0 | ALT | XK_n, KEY_ANOTHER_FILE, NULL},
The symbols CTRL, SHFT, and ALT indicate the
activity of these modifier keys. A zero in one of those columns means
that the corresponding modifier is not activated. Caps Lock is treated
like Shift. The symbols beginning with XK_ are KeySyms, which
are defined in the header file /usr/include/X11/keysymdef.h on
UNIX, in DOSKEYS.H on MS-DOS, and in Mac_keysym.h on the
Macintosh.Macintosh and DOS keymaps look the same, except the keysyms begin with M or D, respectively, and the Mac has no ALT modifier column; instead the modifier CMD is used. The reason why Command is used instead of Alt is that the Alt key on the Mac is the Option key, and some Alt-keystrokes are not reported directly but instead modify the following key; these are intended to allow Mac users to put accents on letters.
Note that in X11, an upper case KeySym, like XK_D, must always be used with SHFT. Note also that the window manager may usurp some keys for its own use, not permitting the application to see these keys. On the DG AViiON, for example, Motif is usually configured to use Alt-F1 through Alt-F10, Alt-Tab, Alt-space, and Alt-Esc, so it will do no good to define key bindings for them. The window manager's key usage is controlled by its rc file (e.g. .mwmrc).
Use xed_config as follows:
xed_config keymap-text-file xed.hostname
The keymap text file is read and converted to binary format; the results are stored in file xed.hostname, which should be put in the user's home directory on the machine that runs the Xed client. For example, I sometimes run Xed on an HP 9000, but I control and display it from a (remote) DG AViiON 300, which has a very different keyboard. The HP's hostname is rprobe, and the DG's hostname is limulus. Therefore, I place in my home directory on rprobe a file called xed.limulus, which is used to define the keys when Xed is displayed on limulus.
The format of the file read by xed_config is governed by the following rules:
The output file generated by xed_config consists of a number of 12-byte binary entries, each consisting of (a) a four-byte modified X KeySym, (b) an xed action code, and (c) a four-byte NULL.
Macintosh users can alter the appearance of the menus through ResEdit, but altering their actions will require changes to the menu-handling code.
The Mac user interface has some rough spots that could be made quicker and smoother. For example, the routine refresh_window is called in more situations than is necessary, causing the display to flicker annoyingly occasionally. The Macintosh version does not properly process the "Open Documents" apple event. File I/O on the Mac is too slow, and the officially recommended method of saving files (by making a copy, deleting the original, and renaming the copy) is not followed.
Peter N. Schweitzer MS 918 National Center U.S. Geological Survey Reston, VA 20192 Tel: (703) 648-6533 FAX: (703) 648-6560 email: pschweitzer@usgs.gov