Path: seismo!harvard!husc6!talcott!panda!sources-request From: sources-request@panda.UUCP Newsgroups: mod.sources Subject: MicroEMACS 3.6 (Part 2 of 8) Message-ID: <1815@panda.UUCP> Date: 6 May 86 22:28:08 GMT Sender: jpn@panda.UUCP Lines: 883 Approved: jpn@panda.UUCP Mod.sources: Volume 4, Issue 99 Submitted by: genrad!decvax!ihnp4!itivax!duncan!lawrence echo x - emacs.tut sed 's/^X//' >emacs.tut <<'*-*-END-of-emacs.tut-*-*' XYou are looking at the MICRO-EMACS tutorial. Comments on this document Xmay be refered to Dana Hoggatt or Dan Lawrance. X XEMACS commands generally involve the CONTROL key (sometimes labelled CTRL or XCTL) or the META key (generally labelled ESCAPE). Rather than write out META Xor CONTROL each time we want you to prefix a character, we'll use the following Xabbreviations: X X ^ means hold the CONTROL key while typing the character X Thus, ^F would be: hold the CONTROL key and type F. X X ESC- means type the ESCAPE key and release it, then type the X character . The can be upper or lower case X and it will have the same meaning. X XImportant note: if you must exit at some point, type ^X ^C. X XThis tutorial attempts to help you "learn by doing". The characters ">>" Xat the left margin of your screen indicate directions for you to try using Xa command. For instance: X X>> Now type ^V (View next screen) to move to the next screen. X (go ahead, do it by depressing the control key and V together). X XFrom now on, you'll be expected to type ^V whenever you finish reading the Xcurrent screen. X XNote that there is an overlap when going from screen to screen; this Xprovides some continuity when moving through the file. X XThe first thing that you need to know is how to move around from place to Xplace in the file. You already know how to move forward a screen, with ^V. XTo move backwards a screen, type ^Z. (depress the CTRL key and type Z). X X>> Try typing ^Z and then ^V to move back and forth a few times. X X XSUMMARY X------- X XThe following commands are useful for viewing screenfuls: X X ^V Move forward one screenful X ^Z Move backward one screenful X ^L Clear screen and redisplay everything X putting the text near the cursor at the center. X X>> find the cursor and remember what text is near it. X Then type a ^L. X Find the cursor again and see what text is near it now. X X XBASIC CURSOR CONTROL X-------------------- X XGetting from screenful to screenful is useful, but how do you reposition Xyourself within a given screen to a specific place? There are several ways Xyou can do this. One way (not the best, but the most basic) is to use the Xcommands previous, backward, forward and next. As you can imagine these Xcommands (which are given to EMACS as ^P, ^B, ^F, and ^N respectively) move Xthe cursor from where it currently is to a new place in the given direction. XHere, in a more graphical form are the commands: X X Previous line, ^P X : X : X Backward, ^B .... Current cursor position .... Forward, ^F X : X : X Next line, ^N X XYou'll probably find it easy to think of these by letter. P for Xprevious, N for next, B for backward and F for forward. These are Xthe basic cursor positioning commands and you'll be using them ALL Xthe time so it would be of great benefit if you learn them now. X X>> Do a few ^N's to bring the cursor down to this line. X X>> Move into the line with ^F's and then up with several ^P's. X See what ^P does when the cursor is in the middle of the line. X XLines are separated by a single Linefeed character, which is what XUnix calls a Newline. X X>> Try to ^B at the beginning of a line. Do a few more ^B's. X Then do ^F's back to the end of the line and beyond. X XWhen you go off the top or bottom of the screen, the text beyond Xthe edge is shifted onto the screen so that your instructions can Xbe carried out while keeping the cursor on the screen. X X>> Try to move the cursor off the bottom of the screen with ^N and X see what happens. X XIf moving by characters is too slow, you can move by words. ESC-F X(Meta-F) moves forward a word and ESC-B moves back a word. X X>> Type a few ESC-F's and ESC-B's. Intersperse them with ^F's and ^B's. X XNotice the parallel between ^F and ^B on the one hand, and ESC-F and ESC-B on Xthe other hand. Very often Meta characters are used for operations related Xto English text whereas Control characters operate on the basic textual units Xthat are independent of what you are editing (characters, lines, etc). There Xis a similar parallel between lines and sentences: ^A and ^E move to the Xbeginning or end of a line. and ESC-A and ESC-E move to the beginning or end Xof a sentence. X X### Note: ESC-A and ESC-E are not implimented yet (DLH - 1/22/86) ### X X>> Try a couple of ^A's, and then a couple of ^E's. X Try a couple of ESC-A's, and then a couple of ESC-E's. X XSee how repeated ^A's do nothing, but repeated ESC-A's Xkeep moving farther. Do you think that this is right? X XTwo other simple cursor motion commands are ESC-< (Meta Less-than), Xwhich moves to the beginning of the file, and ESC-> (Meta Greater-than), Xwhich moves to the end of the file. You probably don't need to try Xthem, since finding this spot again will be boring. If you need the Xshift key to type a "<", then you must also use the shift key to type XESC-<. Otherwise, you would be typing ESC-, . X XThe location of the cursor within the text is also called "point". To Xparaphrase, the cursor shows on the screen where point is located in the text. X XHere is a summary of simple moving operations including Xthe word and sentence moving commands: X X ^F Move forward a character X ^B Move backward a character X X ESC-F Move forward a word X ESC-B Move backward a word X X ^N Move to next line X ^P Move to previous line X X ESC-N Move to next paragraph X ESC-P Move to previous paragraph X X ^A Move to beginning of line X ^E Move to end of line X X ESC-A Move back to beginning of sentence (not functional) X ESC-E Move forward to end of sentence (not functional) X X ESC-< Go to beginning of file X ESC-> Go to end of file X X>> Try all of these commands now a few times for practice. X Since the last two will take you away from this screen, X you can come back here with ^Z's and ^V's. These are X the most often used commands. X XLike all other commands in EMACS, these commands can be given Xarguments which cause them to be executed repeatedly. The way you Xgive a command a repeat count is by typing META and then the digits Xbefore you type the command. (Remember META is ususally called ESCAPE) X XFor instance, META 8 ^F moves forward eight characters. X X>> Try giving a suitable argument to ^N or ^P to come as close X as you can to this line in one jump. X XThis also applies to the screen moving commands, ^V and ^Z. When Xgiven an argument, they scroll the screen up or down by that many Xscreenfuls. As a special case, typing just ^U is equivalent to ESC-4. X X>> Try typing ESC-3 ^V now. X XIf you would like to scroll it down, you can give an argument to ^Z. X X XQUITTING FROM COMMANDS X---------------------- X XThe character in EMACS used to quit out of all commands which request Xinput is ^G. For example, you can use ^G to discard a numeric argument Xor the beginning of a command that you don't want to finish. X X>> Type ESC-100 to make a numeric arg of 100, then type ^G. X Now type ^F. How many characters does it move? X If you have typed an by mistake, you can get rid of it X with a ^G. X X XIBM CURSOR KEYS X--------------- X XOn the IBM-PC version, the cursor keypad has been bound to some of the Xmore useful screen movement commands. The mappings are as follows: X X Cursor-Right ^F Move forward a character X Cursor-Left ^B Move backward a character X X ^Cursor-Right ESC-F Move forward a word X ^Cursor-Left ESC-B Move backward a word X X Cursor-Down ^N Move to next line X Cursor-UP ^P Move to previous line X X Pg-Dn ^V Move to next screen X Pg-Up ^Z Move to previous screen X X Home ESC-< Go to beginning of file X End ESC-> Go to end of file X X Insert ^O Open up a new line X Delete ^K Kill to end of line X XUsage of the ^O and ^K commands is described later in the tutorial. A Xmap of the key layout looks something like this: X X ------------------------------------------------- X | 7 | 8 | 9 | X | Home | ^ | Pg Up | X | | | | | X | ESC-< | ^P | ^Z | X ------------------------------------------------- X | 4 | 5 | 6 | X | <-- | | --> | X | | | | X | ^B | | ^F | X ------------------------------------------------- X | 1 | 2 | 3 | X | End | | | Pg Dn | X | | v | | X | ESC-> | ^N | ^V | X ------------------------------------------------------------- X | 0 | . | X | Insert | Delete | X | | | X | ^O | ^K | X ------------------------------------------------------------- X X>> if you have an IBM-PC, practice using the cursor keypad. X X X XERRORS X------ X XSometimes you may do something which EMACS doesn't allow. If it is Xsomething simple, such as typing a control key sequence which is not Xassociated with any command, EMACS will just beep at you. Otherwise, XEMACS will also display an informative error message at the bottom of Xthe screen. X XSome versions of EMACS do not have all the features described in this Xtutorial implemented yet. If you come across such an unimplemented Xfeature, you may get an error message when you try to use it. Just Xtype a space and proceed on to the next section of the tutorial. X X XINSERTING AND DELETING X---------------------- X XIf you want to type text, just do it. Characters which you can see, such Xas A, 7, *, etc. are taken by EMACS as text and are immediately inserted. XType (the carriage-return key) to insert a line separator. X XYou can delete the last character you typed by typing either or ^H. XOn some keyboards, there is a dedicated key for creating a ^H. If so, it is Xusually labeled as either "Backspace" or "<--". is a key on the Xkeyboard, which may be labeled "Rubout" instead of "Delete" on some terminals. XMore generally, deletes the character immediately before the current Xcursor position. X X>> Do this now, type a few characters and then delete them by typing X a few times. Don't worry about this file being changed; X you won't affect the master tutorial. This is just a copy of it. X X>> Now start typing text until you reach the right margin, and keep X typing. When a line of text gets too big for one line on the X screen, the line of text is "continued" off the edge of the screen X The dollar sign at the right margin indicates a line which has X been continued. EMACS scrolls the line over so you can see what you X are editing. The '$' at the left or right edge of the screen indicates X that the current line extends off in that direction. X X>> The following line actually goes off the edge. Trying typing enough ^F's X so that you move off the right hand end of this line. This is a long line of text. Note the "$"s at each edge. Keep typing ^F's and watch where EMACS decides to scroll the line. Now, type ^B's until EMACS decides to scroll the line again. X XThis is one of those gizmos which is easier to understand by playing with it Xthan by reading about it. X X>> Use ^D's or s to delete the text until the text line fits on X one screen line again. The continuation "$" will go away. X X>> Move the cursor to the beginning of a line and type . This X deletes the line separator before the line and merges the line onto X the previous line. The resulting line may be too long to fit, in X which case it has a continuation indication. X X>> Type to insert the separator again. X XInternally, EMACS will allow you to have lines of nearly any length, limited Xonly by the amount of memory available. Externally, however, EMACS can only Xread or write lines, to or from a file, which are less than or equal to 255 Xcharacters. X XRemember that most EMACS commands can be given a repeat count; Note Xthat this includes characters which insert themselves. X X>> Try that now -- type META 8 * and see what happens. X XIf you want to create a blank line in between two lines, move to the Xsecond of the two lines and type ^O. X X>> Try moving to a line and typing ^O now. X XYou've now learned the most basic way of typing something in XEMACS and correcting errors. You can delete by words or lines Xas well. Here is a summary of the delete operations: X X delete the character just before the cursor X ^H delete the character just before the cursor X ^D delete the next character after the cursor X X ESC- kill the word immediately before the cursor X ESC-^H kill the word immediately before the cursor X ESC-D kill the next word after the cursor X X ^K kill from the cursor position to end of line X XNotice that and ^D vs ESC- and ESC-D extend the parallel Xstarted by ^F and ESC-F (well, isn't really a control Xcharacter, but let's not worry about that). X XNow suppose you kill something, and then you decide that you want to get Xit back? Well, whenever you kill something bigger than a character, EMACS Xsaves it for you. To yank it back, use ^Y. Note that you don't have to Xbe in the same place to do ^Y; This is a good way to move text around. XAlso note that the difference between "Killing" and "Deleting" something Xis that "Killed" things can be yanked back, and "Deleted" things cannot. XGenerally, the commands that can destroy a lot of text save it, while the Xones that attack only one character, or nothing but blank lines and spaces, Xdo not save. X XFor instance, type ^N a couple times to postion the cursor Xat some line on this screen. X X>> Do this now, move the cursor and kill that line with ^K. X XNote that a single ^K kills the contents of the line, and a second X^K kills the line itself, and make all the other lines move up. If Xyou give ^K a repeat count, it kills that many lines AND their contents. X XThe text that has just disappeared is saved so that you can Xretrieve it. To retrieve the last killed text and put it where Xthe cursor currently is, type ^Y. X X>> Try it; type ^Y to yank the text back. X XThink of ^Y as if you were yanking something back that someone took away Xfrom you. Notice that if you do several ^K's in a row the text that is Xkilled is all saved together so that one ^Y will yank all of the lines. X X>> Do this now, type ^K several times. X XNow to retrieve that killed text: X X>> Type ^Y. Then move the cursor down a few lines and type ^Y X again. You now see how to copy some text. X XWhat do you do if you have some text you want to yank back, and then Xyou kill something else? ^Y would yank the more recent kill. X X>> Kill a line, move around, kill another line. X Then do ^Y to get back the second killed line. X X XFILES X----- X XIn order to make the text you edit permanent, you must put it in a file. XOtherwise, it will go away when you leave EMACS. While you are editing a Xfile in EMACS, your changes are actually being made to a private X"scratch" copy of the file. However, the changes still don't become Xpermanent until you "save" the file. This is so you can have control to Xavoid leaving a half-changed file around when you don't want to. X XIf you look near the botton of the screen you will see a line that Xlooks like this: X X =* MicroEMACS 3.1 (NORMAL) == emacs.tut == File: emacs.tut ========== X --------------- X XNote that EMACS indicates the name of the file you are currently editing. XThis is the name of your own temporary copy of the text of the EMACS Xtutorial; the file you are now editing. Whatever file you edit, that Xfile's name will appear in that precise spot. X XThe commands for finding and saving files are unlike the other commands you Xhave learned in that they consist of two characters. They both start with the Xcharacter Control-X. There is a whole series of commands that start with XControl-X; many of them have to do with files, buffers, and related things, Xand all of them consist of Control-X followed by some other character. As Xwith ESC, the character is interpreted the same regardless of case. X XAnother thing about the command for finding a file is that you have to say Xwhat file name you want. We say the command "reads an argument from the Xterminal" (in this case, the argument is the name of the file). After you Xtype the command X X ^X ^F Find a file X XEMACS will ask you for the file name. You should end the name with Xthe Return key. After this command, you will see the contents of the Xfile in your EMACS. You can edit the contents. When you wish to make Xthe changes permanent, issue the command X X ^X ^S Save the file X XA new version of the file will be created. When the operation is Xfinished, EMACS prints the name and number of lines saved. X XIf you forget to save and edit a different file and then decide to quit, XEMACS will remind you that you made changes that have not been save and Xthen ask you whether you really want to quit. (If you don't save them, Xthey will be thrown away. That might be what you want!) You should Xanswer with a "N" to save them or a "Y" to throw the changes away. X XTo make a new file, just edit it "as if" it already existed. Then start Xtyping in the text. When you ask to "save" the file, EMACS will really Xcreate the file with the text that you have inserted. From then on, you Xcan consider yourself to be editing an already existing file. X XIt is not easy for you to try out editing a file and continue with the Xtutorial. But you can always come back into the tutorial by starting it Xover and skipping forward. So, when you feel ready, you should try editing Xa file named "FOO", putting some text in it, and saving it; then exit from XEMACS and look at the file to be sure that it worked. X X XEXTENDING THE COMMAND SET X------------------------- X X### The mechanisms for extending the command set and setting ### X### the key bindings has not been installed yet. Skip forward ### X### to the next section (TEXT REPLACEMENT). DLH (1/22/86) ### X XThere are many, many more EMACS commands than could possibly be put Xon all the control and meta characters. EMACS gets around this with Xthe X (eXtend) command. This comes in two flavors: X X ^X Character eXtend. Followed by one character. X ESC-X Named command eXtend. Followed by a long name. X XThese are commands that are generally useful but used less than the commands Xyou have already learned about. You have already seen two of them: the file Xcommands ^X ^F to Find and ^X ^S to Save. Another example is the command to Xtell EMACS that you'd like to stop editing. The command to do this is ^X ^C. X XThere are many ^X commands. The ones you need immediately are: X X ^X ^F Find file. X ^X ^S Save file. X ^X ^C Quit EMACS. This does not save your files auto- X matically, though if your files have been modi- X fied, EMACS asks if you really want to quit. The X standard way to save and exit is ^X ^S ^X ^C. X XNamed eXtended commands are commands which are used even less Xfrequently, or commands which are used only in certain modes. These Xcommands are usually called "functions". An example is the function X"apropos", which prompts for a keyword and then gives the names of all Xthe functions that apropos for that keyword. When you type ESC-X, EMACS Xprompts you at the bottom of the screen with ":" and you should type the Xname of the function you wish to call; in this case, "apropos". Just Xtype "apr" and EMACS will complete the name. EMACS will ask you Xfor a keyword or phrase and you type the string that you want ask about. X X>> Try typing ESC-X, followed by "apropos" or "apr" and then Return. X Then try typing "file" followed by a Return. X X XTEXT REPLACEMENT X---- ----------- X X>> Move the cursor to the blank line two lines below this one. X Then type ESC-r changedaltered. X X Notice how this line has changed: you've replaced X the word c-h-a-n-g-e-d with "altered" wherever it occurs X after the cursor. X XThe more customary command for replacing strings is the interactive Xcommand query-replace-search, which has several options. In essence, it Xshows each occurance of the first string and asks you if you want to Xreplace it or not. You can also choose to edit around the string, or go Xon and replace all occurances without asking further. It is described in Xdetail in the EMACS manual. Also, typing a '?' when it asks you if you Xwish to replace will list out the various options. X X XMODE LINE X--------- X XThe bottom line of the screen is known as the communications line. This Xis where EMACS interactively communicates with you. You have already Xseen how emacs prompts you for information (like when searching). EMACS Xcan also report things to you as well. X X>> Type ^X = and see what you get in the communications line. X XThe line immediately above the communications line is called the MODE XLINE. The mode line says something like X X =* MicroEMACS 3.1 (NORMAL) == emacs.tut == File: emacs.tut ========== X XThis is a very useful "information" line. X XThe star means that you have made changes to the text. Right after Xyou visit or save a file, there is no star. X XThe buffername is the name EMACS gave to the buffer, and it is usually Xrelated to the filename. You already know what the filename means -- it Xis the file you have edited. X XThe part of the mode line inside the parentheses is to tell you what Xmodes you are in. The default mode is NORMAL which is what you are in Xnow. It is an example of a "major mode". There are several major modes Xin EMACS for editing different languages and text, such as C mode, Text Xmode, etc. At any time one and only one major mode is active, and its Xname can always be found in the mode line just where "NORMAL" is now. X XEach major mode makes a few commands behave differently. For example, Xthere are commands for creating comments in a program, and since each Xprogramming language has a different idea of what a should look like, Xeach major mode has to insert comments differently. Each major mode is Xcontrolled by a EMACS variable which can be manipulated and queried with Xthe "set" and "print" extended commands. X XMajor modes are called major because there are also minor modes. They Xare called minor because they aren't alternatives to the major modes, Xjust minor modifications of them. Each minor mode can be turned on or Xoff by itself, regardless of what major mode you are in, and regardless Xof the other minor modes. So you can use no minor modes, or one minor Xmode, or any combination of several minor modes. X XOne minor mode which is very useful, especially for editing English Xtext, is WRAP mode. When this mode is on, EMACS breaks the line in Xbetween words automatically whenever the line gets too long. You can Xturn this mode on by doing ^X M wrap . When the mode is on, you Xcan turn it off by doing ^X ^M wrap . X X>> Type "^X ^M wrap " now. Then insert a line of "asdf " over X again until you see it divide into two lines. You must put in spaces X between them because Auto Fill breaks lines only at spaces. Note that X "WRAP" appears in the mode line, indicating that you are in WRAP mode. X XThe margin is usually set at 72 characters, but it can be shanged. XSimply type ESC nn ^X F, where "nn" is the column number for the right Xhand margin. X X XSEARCHING X--------- X XEMACS can do searches for strings (these are groups of contiguous Xcharacters or words) either forward through the file or backward Xthrough it. X X>> Now type ^S to start a search. Type the word 'cursor', then ESCAPE. X X>> Type ^S ESCAPE to find the next occurrence of "cursor". X XThe ^S starts a search that looks for any occurrence of the search Xstring AFTER the current cursor position. But what if you want to Xsearch for something earlier in the text? To do this one should Xtype ^R for Reverse search. Everything that applies to ^S applies Xto ^R except that the direction of the search is reversed. X X XGETTING MORE HELP X----------------- X XIn this tutorial we have tried to supply just enough information to Xget you started using EMACS. There is so much available in EMACS that Xit would be impossible to explain it all here. However, you may want Xto learn more about EMACS since it has numerous desirable features Xthat you don't know about yet. X X### The on-line help features have not been implimented yet. DLH ### X XThe most basic HELP feature is the describe-key function which is Xavailable by typing ^X ? and then a command character. EMACS prints one Xline line on the bottom of the screen tell what function is bound to Xthat key. X XThe describe-command function ESC-? will prompt for the name of a function Xand print out the section from the manual about that command. When you Xare finished reading it, type a Space or a ^G (quit) to bring your text Xback on the screen. X X>> Type ^X ? Control-P. The message at the bottom of the screen should X be something like "^P is bound to previous-line". X XMulti-character commands such as ^X ^Z and V are also allowed Xafter ^X ?. X XNow lets get more information about the previous-line command. X X>> Type ESC-? previous-line. When you are finished reading the X output, type a Space. X XThe "name of the function" is important for people who are customizing XEMACS. It is what appears in the EMACS CHART as the documentation for Xthe command character. X X XCONCLUSION X---------- X XRemember, to exit use ^X ^C. X XThis tutorial is meant to be understandable to all new users, so if Xyou found something unclear, don't sit and blame yourself - complain! X XYou'll probably find that if you use EMACS for a few days you won't Xbe able to give it up. Initially it may give you trouble. But remember Xthat this is the case with any editor, especially one that can do many, Xmany things. And EMACS can do practically everything. X X XAcknowledgements X---------------- X XThis is a modified version of the "JOVE Tutorial" by Jonathan Payne X(19 January 86). That document was in turn a modified version of the Xtutorial "Teach-Emacs" from MIT as modified by Steve Zimmerman at XCCA-UNIX (31 October 85). X XThis document was last updated on 2-7-86 by Dana Hoggatt. X *-*-END-of-emacs.tut-*-* echo x - estruct.h sed 's/^X//' >estruct.h <<'*-*-END-of-estruct.h-*-*' X/* ESTRUCT: Structure and preprocesser defined for X MicroEMACS 3.6 X X written by Dave G. Conroy X modified by Steve Wilhite, George Jones X greatly modified by Daniel Lawrence X*/ X X#undef LATTICE /* don't use their definitions...use ours */ X#undef MSDOS X#undef CPM X X/* Machine/OS definitions */ X X#define AMIGA 0 /* AmigaDOS */ X#define ST520 0 /* ST520, TOS */ X#define MSDOS 0 /* MS-DOS */ X#define V7 1 /* V7 UN*X or Coherent or BSD4.2*/ X#define BSD 0 /* also needed for BSD 4.2 */ X#define VMS 0 /* VAX/VMS */ X#define CPM 0 /* CP/M-86 */ X X/* Compiler definitions */ X#define MWC86 0 /* marc williams compiler */ X#define LATTICE 0 /* either lattice compiler */ X#define LAT2 0 /* Lattice 2.15 */ X#define LAT3 0 /* Lattice 3.0 */ X#define AZTEC 0 /* Aztec C 3.20e */ X X/* Terminal Output definitions */ X X#define ANSI 0 /* ansi escape sequences */ X#define HP150 0 /* HP150 screen driver */ X#define VMSVT 0 /* various VMS terminal entries */ X#define VT52 0 /* VT52 terminal (Zenith). */ X#define VT100 0 /* Handle VT100 style keypad. */ X#define LK201 0 /* Handle LK201 style keypad. */ X#define RAINBOW 0 /* Use Rainbow fast video. */ X#define TERMCAP 1 /* Use TERMCAP */ X X/* Configuration options */ X X#define CVMVAS 1 /* arguments to page forward/back in pages */ X#define NFWORD 1 /* forward word jumps to begining of word */ X#define CLRMSG 0 /* space clears the message line with no insert */ X#define TYPEAH 1 /* type ahead causes update to be skipped */ X#define FILOCK 0 /* file locking under unix BSD 4.2 */ X#define REVSTA 1 /* Status line appears in reverse video */ X X/* System dependant library redefinitions */ X X#if MSDOS & AZTEC X#undef fputc X#undef fgetc X#define fputc aputc X#define fgetc agetc X#endif X X/* internal constants */ X X#define NBINDS 200 /* max # of bound keys */ X#define NFILEN 80 /* # of bytes, file name */ X#define NBUFN 16 /* # of bytes, buffer name */ X#define NLINE 256 /* # of bytes, line */ X#define NSTRING 256 /* # of bytes, string buffers */ X#define NKBDM 256 /* # of strokes, keyboard macro */ X#define NPAT 80 /* # of bytes, pattern */ X#define HUGE 1000 /* Huge number */ X#define NLOCKS 100 /* max # of file locks active */ X X#define AGRAVE 0x60 /* M- prefix, Grave (LK201) */ X#define METACH 0x1B /* M- prefix, Control-[, ESC */ X#define CTMECH 0x1C /* C-M- prefix, Control-\ */ X#define EXITCH 0x1D /* Exit level, Control-] */ X#define CTRLCH 0x1E /* C- prefix, Control-^ */ X#define HELPCH 0x1F /* Help key, Control-_ */ X X#define CTRL 0x0100 /* Control flag, or'ed in */ X#define META 0x0200 /* Meta flag, or'ed in */ X#define CTLX 0x0400 /* ^X flag, or'ed in */ X#define SPEC 0x0800 /* special key (function keys) */ X X#define FALSE 0 /* False, no, bad, etc. */ X#define TRUE 1 /* True, yes, good, etc. */ X#define ABORT 2 /* Death, ^G, abort, etc. */ X X#define FIOSUC 0 /* File I/O, success. */ X#define FIOFNF 1 /* File I/O, file not found. */ X#define FIOEOF 2 /* File I/O, end of file. */ X#define FIOERR 3 /* File I/O, error. */ X#define FIOLNG 4 /*line longer than allowed len */ X X#define CFCPCN 0x0001 /* Last command was C-P, C-N */ X#define CFKILL 0x0002 /* Last command was a kill */ X X#define BELL 0x07 /* a bell character */ X#define TAB 0x09 /* a tab character */ X X/* X * There is a window structure allocated for every active display window. The X * windows are kept in a big list, in top to bottom screen order, with the X * listhead at "wheadp". Each window contains its own values of dot and mark. X * The flag field contains some bits that are set by commands to guide X * redisplay; although this is a bit of a compromise in terms of decoupling, X * the full blown redisplay is just too expensive to run for every input X * character. X */ Xtypedef struct WINDOW { X struct WINDOW *w_wndp; /* Next window */ X struct BUFFER *w_bufp; /* Buffer displayed in window */ X struct LINE *w_linep; /* Top line in the window */ X struct LINE *w_dotp; /* Line containing "." */ X short w_doto; /* Byte offset for "." */ X struct LINE *w_markp; /* Line containing "mark" */ X short w_marko; /* Byte offset for "mark" */ X char w_toprow; /* Origin 0 top row of window */ X char w_ntrows; /* # of rows of text in window */ X char w_force; /* If NZ, forcing row. */ X char w_flag; /* Flags. */ X} WINDOW; X X#define WFFORCE 0x01 /* Window needs forced reframe */ X#define WFMOVE 0x02 /* Movement from line to line */ X#define WFEDIT 0x04 /* Editing within a line */ X#define WFHARD 0x08 /* Better to a full display */ X#define WFMODE 0x10 /* Update mode line. */ X X/* X * Text is kept in buffers. A buffer header, described below, exists for every X * buffer in the system. The buffers are kept in a big list, so that commands X * that search for a buffer by name can find the buffer header. There is a X * safe store for the dot and mark in the header, but this is only valid if X * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for X * the buffer is kept in a circularly linked list of lines, with a pointer to X * the header line in "b_linep". X * Buffers may be "Inactive" which means the files accosiated with them X * have not been read in yet. These get read in at "use buffer" time. X */ Xtypedef struct BUFFER { X struct BUFFER *b_bufp; /* Link to next BUFFER */ X struct LINE *b_dotp; /* Link to "." LINE structure */ X short b_doto; /* Offset of "." in above LINE */ X struct LINE *b_markp; /* The same as the above two, */ X short b_marko; /* but for the "mark" */ X struct LINE *b_linep; /* Link to the header LINE */ X char b_active; /* window activated flag */ X char b_nwnd; /* Count of windows on buffer */ X char b_flag; /* Flags */ X char b_mode; /* editor mode of this buffer */ X char b_fname[NFILEN]; /* File name */ X char b_bname[NBUFN]; /* Buffer name */ X} BUFFER; X X#define BFTEMP 0x01 /* Internal temporary buffer */ X#define BFCHG 0x02 /* Changed since last write */ X X/* mode flags */ X#define NUMMODES 6 /* # of defined modes */ X X#define MDWRAP 0x0001 /* word wrap */ X#define MDCMOD 0x0002 /* C indentation and fence match*/ X#define MDSPELL 0x0004 /* spell error parcing */ X#define MDEXACT 0x0008 /* Exact matching for searches */ X#define MDVIEW 0x0010 /* read-only buffer */ X#define MDOVER 0x0020 /* overwrite mode */ X X/* X * The starting position of a region, and the size of the region in X * characters, is kept in a region structure. Used by the region commands. X */ Xtypedef struct { X struct LINE *r_linep; /* Origin LINE address. */ X short r_offset; /* Origin LINE offset. */ X short r_size; /* Length in characters. */ X} REGION; X X/* X * All text is kept in circularly linked lists of "LINE" structures. These X * begin at the header line (which is the blank line beyond the end of the X * buffer). This line is pointed to by the "BUFFER". Each line contains a the X * number of bytes in the line (the "used" size), the size of the text array, X * and the text. The end of line is not stored as a byte; it's implied. Future X * additions will include update hints, and a list of marks into the line. X */ Xtypedef struct LINE { X struct LINE *l_fp; /* Link to the next line */ X struct LINE *l_bp; /* Link to the previous line */ X short l_size; /* Allocated size */ X short l_used; /* Used size */ X char l_text[1]; /* A bunch of characters. */ X} LINE; X X#define lforw(lp) ((lp)->l_fp) X#define lback(lp) ((lp)->l_bp) X#define lgetc(lp, n) ((lp)->l_text[(n)]&0xFF) X#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) X#define llength(lp) ((lp)->l_used) X X/* X * The editor communicates with the display using a high level interface. A X * "TERM" structure holds useful variables, and indirect pointers to routines X * that do useful operations. The low level get and put routines are here too. X * This lets a terminal, in addition to having non standard commands, have X * funny get and put character code too. The calls might get changed to X * "termp->t_field" style in the future, to make it possible to run more than X * one terminal type. X */ Xtypedef struct { X short t_nrow; /* Number of rows. */ X short t_ncol; /* Number of columns. */ X short t_margin; /* min margin for extended lines*/ X short t_scrsiz; /* size of scroll region " */ X int (*t_open)(); /* Open terminal at the start. */ X int (*t_close)(); /* Close terminal at end. */ X int (*t_getchar)(); /* Get character from keyboard. */ X int (*t_putchar)(); /* Put character to display. */ X int (*t_flush)(); /* Flush output buffers. */ X int (*t_move)(); /* Move the cursor, origin 0. */ X int (*t_eeol)(); /* Erase to end of line. */ X int (*t_eeop)(); /* Erase to end of page. */ X int (*t_beep)(); /* Beep. */ X int (*t_rev)(); /* set reverse video state */ X} TERM; X X/* structure for the table of initial key bindings */ X Xtypedef struct { X short k_code; /* Key code */ X int (*k_fp)(); /* Routine to handle it */ X} KEYTAB; X X/* structure for the name binding table */ X Xtypedef struct { X char *n_name; /* name of function key */ X int (*n_func)(); /* function name is bound to */ X} NBIND; *-*-END-of-estruct.h-*-* exit