home *** CD-ROM | disk | FTP | other *** search
- /*
- * This file supplies the help facilities.
- * By Moshe braner, 8606--.
- * changes by John Stanley, 87-Feb-06
- */
-
- #include <stdio.h>
- #include "ed.h"
-
- #if HELP
-
- #if AtST
- /* overlay "me2" dal: not available in Alcyon C */
- #endif
-
- #if AtST
-
- static char *help_menu[] =
- {
- "--{ Main Help Menu }-- ",
- " ",
- " D. Disk Files S. Searching",
- " B. Buffers C. Cursor Control",
- " W. Window Control I. Insert and Delete",
- " M. Mouse Control P. Paste Buffer",
- " O. Other Stuff F. Function Keys",
- " ",
- " T. Transposition / Capital & Control Characters",
- " Q. Quitting microEMACS / Text Formatting",
- " A. Alternate character set",
- ""
- };
-
- static char *disk_cmds[] =
- {
- "-- [D] --<{ Disk Files }>--",
- " For the Visit and Read commands, if the typed filename contains wildcard",
- " characters ('?' or '*') EMACS will display a list of matching files.",
- " ",
- "[Alt-V] Visit a file. (also [Alt-F3]) Reads a file into new buffer.",
- " Flags buffer as view-only (press [Alt-E] to edit).",
- "[F4] Read file into current buffer, optionaly erasing previous contents.",
- " No new buffer will be created. Flags current buffer as editable.",
- "[Alt-S] Save current buffer to disk. Overwrites previous version of file.",
- "[Alt-W] Write current buffer to disk. Type a filename or Return for default.",
- "[^X][^F] Set a new default filename for the current buffer",
- ""
- };
-
- static char *buf_cmds[] =
- {
- "-- [B] --<{ Buffers }>--",
- "A BUFFER is a named area containing a document being edited. Many buffers may",
- "be active at once. Each buffer has a name, which is typically the lowercased",
- "disk filename of the document it contains.",
- " ",
- " [Shift-Help] Display a list of all current buffers",
- " [^X][^B] Enter a new name for current buffer",
- " [Alt-J] Jump to next buffer in buffer list",
- " [Alt-B] Switch to another buffer by name (default: previous one)",
- " [Alt-K] Kill a buffer (buffer can't be showing in any window)",
- " (At the Switch or Kill prompt use [+] or [-] to step thru the buffer list.)",
- ""
- };
-
- static char *wind_cmds[] =
- {
- "-- [ W ] --<{ Window control }>--",
- "Many windows may be active at once on the screen.",
- "Windows can show different buffers, or different parts of the same buffer.",
- " ",
- " [Alt-2] Split current window in two [Alt-N] Cursor to next window",
- " [Alt-1] Remove all but current window [Alt-P] Cursor to previous window",
- #if EXTRA
- " [Alt-^] Enlarge current window",
- #endif
- " ",
- #if EXTRA
- " [Shift-Up] Scroll window up one line [Alt-F9] Page other window up",
- " [Shift-Down] Scroll window down one line [Alt-F10] Page other window down",
- #else
- " [Alt-F9] Page other window up",
- " [Alt-F10] Page other window down",
- #endif
- " [Home] Scroll current line to top (or <argument> window position)",
- ""
- };
-
- static char *mouse1[] =
- {
- "-- [ M1 ] --<{ Mouse Control }>--",
- " ",
- "The mouse can be used in place of the cursor keys for cursor motion.",
- " [ESC]##[ESC][X] Set horizontal scale for mouse motion to ##",
- " [ESC]##[ESC][Y] Set vertical scale for mouse motion to ##",
- " ",
- " [ESC][M] Toggle mouse-button mode (mark-del-paste / do-bound-functions)",
- " (see the next two screens for more on this)",
- " ",
- "<<Press [+] for more>>",
- ""
- };
-
- static char *mouse2[] =
- {
- "-- [ M2 ] --<{ More Mouse Info }>--",
- " ",
- "The mouse buttons have two very(!) distinctly different",
- "command sets depending on the mouse-button mode:",
- " ",
- "MARK-DELETE-PASTE MODE: For rapid moving/editing of text. (default mode)",
- " [Left-Button] Set Mark",
- " [RightButton] (after setting a Mark) Delete region (copy if non-editable)",
- " (after delete-region) Paste (until another mark is set)",
- " ",
- "<<Press [+] for more>>",
- ""
- };
-
- static char *mouse3[] =
- {
- "-- [ M3 ] --<{ Last Mouse Info }>--",
- " ",
- "BOUND-FUNCTION MODE: Only single commands can be bound to the mouse buttons,",
- " but you can bind [F1] to a button and then record/replay a series of keys",
- " using the macro functions. See [O] or [F] for info on macros.",
- " ",
- " [SHIFT-Left-Button]<command> Bind <command> to left mouse button",
- " [SHIFT-RightButton]<command> Bind <command> to right mouse button",
- " [Left-Button] Execute left button command",
- " [RightButton] Execute right button command",
- ""
- };
-
- char *other_cmds[] =
- {
- "-- [ O ] --<{ Other Stuff }>--",
- " [Undo] Cancel current command and returns to top level of processing.",
- " (Also will undo a kill, cut or paste.)",
- " [Esc]<##> Argument (numerical) prefix. Some commands take a number as an",
- " argument. Most commands will repeat next command <##> times.",
- " [Alt-F1] Begin/End a macro definition: stores keystrokes (also [Alt-M])",
- " [F1] Execute the macro (keystrokes stored using Alt-F1)",
- " [Alt-=] Position report -- displays line number, column, ASCII code",
- " [Alt-E] Toggle between edit & view-only modes",
- " [Alt-I] Toggle between insert & overstrike modes",
- " [Alt-Q] Toggle visibility of tabs, spaces & newlines",
- ""
- };
-
- char *search_cmds[] =
- {
- "-- [ S ] --<{ Searching }>--",
- " ",
- " [F8] or [^S] Search forward. Type in a string to be searched for.",
- " End search string with [Esc] (or with [^C] to ignore case).",
- " [?] matches any one character.",
- " [^W] matches any amount of white space (including none).",
- " [F7] or [^R] Reverse search. Like above, but backwards from cursor.",
- " ",
- " [Alt-F8] or [Alt-)] Search forward for matching brace",
- " [Alt-F7] or [Alt-(] Same - backwards ('brace' == (), [], or {})",
- ""
- };
-
- char *curs_ctrl[] =
- {
- "-- [ C ] --<{ Cursor Control Functions }>--",
- " ",
- "____________|_[Left]_or_[Right]_|__[Up]_or_[Down]___|_______[Home]_____________",
- "Normal | Move one char | Move one Line | Place line at window top",
- #if EXTRA
- "[Shift] | Move by words | Scroll window | ...does nothing...",
- "[Control] | Start/End of line | Page up/down | Jump to end of file",
- "After [ESC] | Start/End of line | paragraph up/down | Jump to start of file",
- #else
- "[Shift] | Move by words | ..does nothing.. | ...does nothing...",
- "[Control] | Start/End of line | Page up/down | Jump to end of file",
- "After [ESC] | Start/End of line | ..does nothing.. | Jump to start of file",
- #endif
- " ",
- "Other: [Home] Shift current line to top line of window",
- " [Esc]##[Home] Shift current line to window line ##",
- " [Esc]##[Alt-G] Goto line number ## of file",
- ""
- };
-
- static char *insdel[] =
- {
- "-- [ I ] --<{ Insert and Delete }>--",
- " ",
- "_______________|_____[Backspace]______|_______[Delete]______|_____[Insert]_____",
- "Normal | Delete previous char | Delete current char | Insert blank line",
- #if EXTRA
- "[Shift]or[Ctrl]| Del.to start of line | Del. to end of line | Kill blank lines",
- "After [ESC] | Delete previous word | Delete next word | ..does nothing..",
- #else
- "[Shift]or[Ctrl]| Del.to start of line | Del. to end of line | ..does nothing..",
- "After [ESC] | Delete previous word | ..does nothing.. | ..does nothing..",
- #endif
- " (Note: The above delete functions place the deleted text in the paste",
- " buffer. See the next help-screen [P] for more paste buffer commands.)",
- " ",
- " [Return] Insert a newline. [Control-Return] Newline+Indent.",
- " [Tab] Insert a tab character (with numeric argument: sets tab size).",
- ""
- };
-
- static char *paste_cmds[] =
- {
- "-- [ P ] --<{ Paste Buffer }>-- (See alternative/additional paste buffer",
- " keys in the [F] and [I] helpscreens.)",
- " ",
- " [^K] Kill (delete) to end of line (saves in paste Buffer)",
- " [^X][ ] Mark start of region (other end is cursor)",
- " [^X][^X] Swaps mark and cursor",
- " [^W] Delete region (places region in paste buffer)",
- " [Esc][W] Copy region (puts copy of region in paste buffer)",
- " [^Y] Paste ('yank') contents of Kill Buffer back, at cursor",
- " [Undo] Undo the Delete (or Paste) just done",
- " [Alt-Undo] Flush paste buffer into a buffer called '[]'",
- ""
- };
-
- static char *funckeys[] =
- {
- "-- [ F ] --<{ Function Keys }>-- |_____with_[Shift],_[Control],_or_[Alt]_____",
- " [F1] | Execute macro......... | Start/End macro definiton",
- " [F2] | Set mark.............. | Swap cursor and mark",
- " [F3] | Switch buffer......... | Visit a file",
- " [F4] | Read a file........... | Write buffer to a file",
- " [F5] | Delete to end of line. | Delete ('wipe') region",
- " [F6] | Paste ('yank')........ | Copy region",
- " [F7] | Search backward....... | Find matching left (, [, or {",
- " [F8] | Search forward........ | Find matching right ), ], or }",
- " [F9] | Page Up............... | Page Up in other window",
- " [F10] | Page Down............. | Page Down in other window",
- ""
- };
-
- static char *transp_cap[] =
- {
- "-- [ T ] --<{ Transposition / Capital & control characters }>--",
- " ",
- " [^T] Transpose characters [Alt-T] Transpose lines",
- #ifdef EXTRA
- " ",
- " [Esc][U] Uppercase word ^X^U Convert region to uppercase",
- " [Esc][L] Lowercase word ^X^L Convert region to lowercase",
- " [Esc][C] Capitalize word (Use [F2] to mark start of region)",
- #endif
- " ",
- " [Esc][Q] or [^Q] Quote. Enter next char as-is (to insert ctrl chars)",
- " [Alt-A] Enter next char with high-bit set (graphics chars)",
- ""
- };
-
- char *fmt_prog[] =
- {
- "-- [ Q ] --<{ Quitting microEMACS and Text Formatting }>--",
- " [^Z] Save this buffer if changed, then Exit MicroEMACS",
- " [^C] Abort without saving any changes",
- " [Alt-D] Execute a single non-GEM program or internal shell command",
- " [Alt-C] Enter internal command shell",
- " [Esc][^C] \"Clone\" MicroEMACS with current configuration",
- " ",
- " [Esc]##[Tab] Sets tab spacing to <##> columns between tabs",
- " [Esc]##[Alt-R] Sets right margin to column <##>",
- " [Esc]##[Alt-L] Sets left margin to column <##>",
- " [Alt-F] Format text to fit margins (with argument = double spaced)",
- ""
- };
-
- char *alt_chars[] =
- {
- "\t ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_",
- "\t üéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥ßƒ <-- [Alt-A][Control-...]",
- " ",
- "\t !\"#$%&'()*+,-./0123456789:;<=>?",
- "\táíóúñѪº¿⌐¬½¼¡«»ãõØøœŒÀÃÕ¨´†¶©®™ <-- [Alt-A][...]",
- " ",
- "\t@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_",
- "\tijIJאבגדהוזחטיכלמנסעפצקרשתןךםףץ§∧∞",
- " ",
- "\t`abcdefghijklmnopqrstuvwxyz{|}~",
- "\tαβΓπΣσµτΦΘΩδ∮ϕ∈∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²³",
- ""
- };
-
- #else
-
- /* if not AtST: */
-
- char *help_menu[] =
- {
- "--{ Main Help Menu }-- ",
- " ",
- " D. Disk Files S. Searching",
- " B. Buffers C. Cursor Control",
- " W. Window Control I. Insert and Delete",
- " O. Other Stuff M. Move Text",
- " ",
- " T. Transposition / Capital & Control Characters",
- " Q. Quitting microEMACS / Text Formatting",
- ""
- };
-
- char *curs_ctrl[] =
- {
- " ",
- "^F Forward character E-F Forward word Keypad arrows",
- "^B Backward character E-B Backward word are active!",
- "^A Front of line ^E End of line",
- "^N Next line ^P Previous line",
- #if EXTRA
- "E-N Next paragraph E-P Previous paragraph",
- #endif
- "^V Scroll down E-V Scroll up",
- "E-< Begining of file E-> End of file",
- "E-. Set MARK at current cursor position",
- "^X^X eXchange mark and cursor",
- ""
- };
-
- char *insdel[] =
- {
- " ",
- "^H (BS) Delete previous character ^D (DEL) Delete current character",
- #if EXTRA
- "E-^H Delete previous word E-^D Delete next word",
- #endif
- "^O Open (insert) line",
- #if EXTRA
- "^X^O Kill blank lines around cursor",
- #endif
- "^K Kill (delete) to end of line (if at end: kill linebreak)",
- "^W Kill (Wipe) region between mark (set using E-.) and cursor",
- "^J Insert a newline and indent",
- "^I or <TAB> Insert a tab character (with argument: set tab size)",
- ""
- };
-
- char *search_cmds[] =
- {
- " ",
- "E-S Search forward. Type in a string to be searched for, end it with",
- " ESC (or with ^C to ignore case differences). '?' matches any one",
- " character, ^W matches any amount of white space (including none).",
- "E-R As above, but Reverse search from cursor position back.",
- " ",
- "E-G Goto line by number (precede with argument: E-#-E-G)",
- "E-) (or E-}) Search forward for complementing brace",
- "E-( (or E-{) Same - backwards",
- ""
- };
-
- char *transp_cap[] =
- {
- " ",
- "^T Transpose characters ^X T Transpose lines",
- #if EXTRA
- " ",
- "E-U UPPERCASE word E-L lowercase word",
- "E-C Capitalize word",
- "^X^U Convert region into Uppercase",
- "^X^L Convert region into Lowercase",
- #endif
- " ",
- "E-Q Quote next char (to enter ctrl chars into text)",
- ""
- };
-
- char *move_cmds[] =
- {
- " ",
- "E-W Copy region to KILL buffer",
- "^Y Yank contents of KILL buffer back, at cursor",
- "^X^Y Undo the Yank just done",
- "E-Y Flush kill buffer into a buffer called '[]'",
- " ",
- "Generally, the procedure for copying or moving text is:",
- " 1) Mark a REGION using E-. at beginning and cursor at end.",
- " 2) Delete it (with ^W) or copy it (with E-W) into KILL buffer.",
- " 3) Move cursor to desired location and yank it back (with ^Y).",
- ""
- };
-
- char *wind_cmds[] =
- {
- " ",
- "Many WINDOWS may be active at once on the screen. Windows may show",
- "different parts of one buffer, or different buffers.",
- " ",
- "^X 2 Split current window in two ^X 1 Remove all but current window",
- "^X N Cursor to next window ^X P Cursor to previous window",
- #if EXTRA
- "^X ^ Enlarge current window",
- "^X^N Scroll window one line down ^X^P Scroll one line up",
- #endif
- "^X V Scroll down, other window ^X Z Scroll up, other window",
- "E-! Scroll current line to top (or <argument> window position)",
- ""
- };
-
- char *buf_cmds[] =
- {
- " ",
- "A BUFFER is a named area containing a document being edited. Many buffers",
- "may be activated at once. Each buffer has a name, which is typically the",
- "lowercased disk filename of the document it contains.",
- "^X B Switch to another buffer, by name (default: previous one)",
- "^X ? List current buffers",
- "^X K Kill a non-displayed buffer.",
- "^X^B Enter a new name for buffer",
- "^X^F Enter a new default File name for buffer",
- ""
- };
-
- char *disk_cmds[] =
- {
- " ",
- "^X^R Read file into current buffer, erasing its previous contents.",
- " No new buffer will be created. Flag as editable.",
- "^X^V Visit file: read into a new buffer created from filename.",
- " Flag as view-only.",
- "^X S Save current buffer to disk, using the buffer's filename",
- " as the name of the disk file. Any disk file of that name",
- " will be overwritten.",
- "^X^W Write current buffer to disk. Type in a new filename at the",
- " prompt to write to; it will become the current buffer's filename.",
- ""
- };
-
- char *fmt_prog[] =
- {
- " ",
- "^X R Set right margin (fill column)",
- "^X L Set left margin",
- "^X F (Re)Format paragraph so that text lies between margins",
- " (with argument: double spaced)",
- "E#-<tab> Set tab spacing to n characters between tabs stops",
- "^X! Send one command to the operating system and return",
- "^X^C Start a new command processer, suspending MicroEMACS",
- "^C Exit MicroEMACS",
- "^Z Write out this buffer if changed, then Exit MicroEMACS",
- ""
- };
-
- char *other_cmds[] =
- {
- "^G Cancel command/macro in progress or undo kill/yank.",
- "Esc # (or ^U #, with default of 4) - Enter numerical argument.",
- " ('-' = -1) (Repeats the next command that many times.)",
- "^X M Begin or end a macro definition",
- "^X E Execute the defined macro",
- "^X = Position report -- displays line number, column, ASCII code",
- "^X^E Toggle between edit & view-only modes",
- "E-I Toggle between insert & overstrike modes",
- "^X Q Toggle visibility of tabs, spaces & newlines",
- "^L Redraw screen",
- ""
- };
-
- #endif AtST
-
- typedef struct
- {
- int matchch; /* character to match */
- char **hlpscn; /* screen to display */
- }
- SCRNS;
-
- static SCRNS scrns[] =
- {
- {'Y', help_menu},
- {'D', disk_cmds},
- {'B', buf_cmds},
- {'W', wind_cmds},
- #ifdef AtST
- {'M', mouse1},
- {'2', mouse2},
- {'3', mouse3},
- #endif
- {'O', other_cmds},
-
- {'S', search_cmds},
- {'C', curs_ctrl},
- {'I', insdel},
- #ifdef AtST
- {'P', paste_cmds},
- {'F', funckeys},
- #else
- {'M', move_cmds},
- #endif
-
- {'T', transp_cap},
- {'Q', fmt_prog},
-
- #if AtST
- {'A', alt_chars},
- #endif
- {0x0, NULL}
- }; /* end of scrns */
-
- /*
- * This routine builds a help screen's text
- * in the special secret buffer. It is called
- * by help() via make_popup(). Returns TRUE if
- * everything works. Returns FALSE if there is
- * an error (if there is no memory).
- */
- make_help(buffer, data)
- BUFFER *buffer;
- char *data[]; /* array of strings */
- {
- register char **dp;
- register int s;
-
- bbclear(buffer); /* Blow old text away */
- for(dp=data; **dp != '\0'; ++dp)
- {
- if (addline(*dp, buffer) == FALSE)
- return (FALSE);
- }
- return (TRUE); /* All done */
- }
-
- /*
- * Show help menu and then requested screens.
- * Bound to "E-?". By mb:
- */
- help(f, n)
- {
- register int c = 'Y';
- register int indx = 0, maxindx;
- register char **helpscrn;
-
- maxindx = 0;
- while (scrns[maxindx].matchch != 0)
- ++maxindx;
-
- while (c != 'N')
- {
- switch (c)
- {
- #if AtST
- case FUNC|0x4d: /* right */
- case FUNC|0x50: /* down */
- #endif
- case '+':
- if (++indx == maxindx)
- indx = 0;
- break;
-
- #if AtST
- case FUNC|0x4b: /* left */
- case FUNC|0x48: /* up */
- #endif
- case '-':
- if (indx == 0)
- indx = maxindx;
- --indx;
- break;
-
- default:
- for (indx=0; (scrns[indx].matchch != c); ++indx)
- if (indx == maxindx)
- break;
- }
-
- helpscrn = scrns[indx].hlpscn;
- if (helpscrn == NULL)
- break;
-
- if (make_popup(bhelpp, make_help, helpscrn)==TRUE)
- {
- update();
- mlwrite((c == 'Y')
- ? ("Enter first letter of choice: ")
- : ("More help? [y/n/+/-] ") );
- c = (*term.t_getchar)();
- if (c>='a' && c<='z')
- c -= 0x20;
- }
- else
- return (FALSE);
-
- } /* end of while() */
-
- if (helpscrn == NULL)
- {
- mlwrite("[aborted]");
- return (onlywind(f,n));
- }
- #if AtST
- mlwrite("[Alt-1 returns to one window]");
- #else
- mlwrite("[^X 1 returns to one window]");
- #endif
- return (TRUE);
- }
-
- #endif HELP
-