leif@erix.UUCP (Leif Samuelsson) (02/16/85)
# This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by erisun!leif on Sat Feb 9 18:11:59 MET 1985 # Contents: lib/ tmp/ lib/tut2 lib/helpmenu lib/changedfile lib/queryrep # lib/basic lib/instring lib/tut1 lib/summary lib/aproposlist lib/news echo mkdir - lib mkdir lib chmod u=rwx,g=rx,o=rx lib echo x - lib/tut2 sed 's/^@//' > "lib/tut2" <<'@//E*O*F lib/tut2//' *** SCAME *** (the SCreen-oriented Anti-Misery Editor) Welcome to part two of the SCAME tutorial. EXTENDING THE COMMAND SET ------------------------- There are many, many more SCAME commands than could possibly be put on all the control and meta characters. SCAME gets around this with the X (eXtend) command. This comes in two flavors: C-X Character eXtend. Followed by one character. M-X Named command eXtend. Followed by a long name. These are commands that are generally useful but used less than the commands you have already learned about. You have already seen two of them: the file commands C-X C-V to Visit and C-X C-S to Save. Another example is the command to tell SCAME that you'd like to stop editing. The command to do this is C-X C-Z. Think of it as Z for zapping yourself. There are many C-X commands. The ones you need immediately are: C-X C-V Visit file. C-X C-S Save file. C-X C-Z Quit SCAME. This does NOT save your file. The standard way to save and exit is C-X C-S C-X C-Z. Named eXtend commands are commands which are used even less frequently, or commands which are used only in certain modes. These commands are usually called "functions". An example the function Replace String which globally replaces one string with another. When you type M-X, SCAME prompts you at the bottom of the screen with M-X and you should type the name of the function you wish to call; in this case, "Replace String". Just type "Replace String<Return>". Then you type the string that you want to replace, a return, the string you want to replace it with, and a return. >> Move the cursor to the blank line two lines below this one. Then type M-X replace string<Return>changed<Return>altered<Return>. Notice how this line has changed: you've replaced the word c-h-a-n-g-e-d with "altered" wherever it occurs after the cursor. MODE LINE --------- If SCAME sees that you are typing commands slowly it shows them to you at the bottom of the screen in an area called the echo area. The echo area contains the bottom line of the screen. The line immediately above it is called the MODE LINE. The mode line says something like SCAME (Fundamental) Main: filename --nn%-- * This is a very useful "information" line. You already know what the filename means - it is the file you have visited. What the --nn%-- means is that nn percent of the file is above the top of the screen. If the top of the file is on the screen, it will say --TOP-- instead of --00%--. If the bottom of the file is on the screen, it will say --BOT--. If you are looking at a file so small it all fits on the screen, the --nn%-- will simply not be there. The star means that you have made changes to the text. Right after you visit or save a file, there is no star. The part of the mode line inside the parentheses is to tell you what modes you are in. The default mode is Fundamental which is what you are in now. It is an example of a "major mode". There are several major modes in SCAME for editing different languages and text, such as Pascal Mode, Swedish Mode, etc. At any time one and only one major mode is active, and its name can always be found in the mode line just where "Fundamental" is now. Each major mode makes a few commands behave differently. For example, there are commands for creating comments in a program, and since each programming language has a different idea of what a comment should look like, each major mode has to insert comments differently. Each major mode is the name of an extended command, which is how you get into the mode. For example, M-X Fundamental Mode is how to get into Fundamental mode. If you are going to be editing Swedish text, you should probably use Swedish Mode. >> Type M-X Swedish Mode<Return>. Don't worry, none of the commands you have learned changes in any great way. But you can now observe that the special swedish characters }{| and ][\ are now part of words when you do M-F or M-B! Major modes are usually like that: commands don't change into completely unrelated things, but they work a little bit differently. Major modes are called major because there are also minor modes. They are called minor because they aren't alternatives to the major modes, just minor modifications of them. Each minor mode can be turned on or off by itself, regardless of what major mode you are in, and regardless of the other minor modes. So you can use no minor modes, or one minor mode, or any combination of several minor modes. (At this moment there are no minor modes implemented in SCAME). SEARCHING --------- SCAME can do searches for strings (these are groups of contiguous characters or words) either forward through the file or backward through it. To search for the string means that you are trying to locate it somewhere in the file and have SCAME show you where the occurrences of the string exist. This type of search is somewhat different from what you may be familiar with. It is a search that is performed as you type in the thing to search for. The command to initiate a search is C-S for forward search, and C-R for reverse search. BUT WAIT! Don't do them now. When you type C-S you'll notice that the string "I-search" appears as a prompt in the echo area. This tells you that SCAME is in what is called an incremental search waiting for you to type the thing that you want to search for. A search is terminated by C-@ (Control-Space on some terminals). >> Now type C-S to start a search. SLOWLY, one letter at a time, type the word 'cursor', pausing after you type each character to notice what happens to the cursor. >> Type C-S to find the next occurrence of "cursor". >> Now type <Rubout> four times and see how the cursor moves. >> Type C-@ (or C-Space) to terminate the search. Did you see what happened? SCAME, in an incremental search, tries to go to the occurrence of the string that you've typed out so far. To go to the next occurrence of 'cursor' just type C-S again. If no such occurrence exists SCAME beeps and tells you that it is a failing search. C-G would also terminate the search. If you are in the middle of an incremental search and type <Rubout>, you'll notice that the last character in the search string is erased and the search backs up to the last place of the search. For instance, suppose you currently have typed 'cu' and you see that your cursor is at the first occurrence of 'cu'. If you now type <Rubout>, the 'u' on the search line is erased and you'll be repositioned in the text to the occurrence of 'c' where the search took you before you typed the 'u'. This provides a useful means for backing up while you are searching. If you are in the middle of a search and happen to type a control character (other than a C-S or C-R, which tell SCAME to search for the next occurrence of the string), the search is terminated. The C-S starts a search that looks for any occurrence of the search string AFTER the current cursor position. But what if you want to search for something earlier in the text? To do this one should type C-R for Reverse search. Everything that applies to C-S applies to C-R except that the direction of the search is reversed. GETTING MORE HELP ----------------- In this tutorial we have tried to supply just enough information to get you started using SCAME. There is so much available in SCAME that it would be impossible to explain it all here. However, you may want to learn more about SCAME since it has numerous desirable features that you don't know about yet. SCAME has a great deal of internal documentation. All of these commands can be accessed through the HELP character. If there is no key labelled "HELP" on your keyboard, you can type the <HELP> character as C-_ (Control-Underscore). Be warned: many terminals are faulty and do not allow you to type the character C-_ in the logical way (hold down Control and type an underscore). For example, on a VT-100 it works to hold down Control and type "/" or "?". To use the HELP features, type the <HELP> character, and then a character saying what kind of help you want. If you are REALLY lost, type <HELP> ? and SCAME will tell you what kinds of help it can give. If you have typed the <HELP> character and decide you don't want any help, just type C-G to abort. The most basic HELP feature is <HELP> B. Type <HELP>, a B, and SCAME prints a short summary of its most important commands. >> Type <HELP> B. When the summary has been printed, SCAME will wait for you to to type a space. When you have done that, the text in the text buffer (this text) will be restored on the screen. Another simple HELP feature is <HELP> S. Type <HELP>, an S, and SCAME will print a summary of all commands available. >> Type <HELP> S. It should print the command summary. When it says "--MORE--" at the bottom of the screen, type a Space to see the next screenful of the list. CONCLUSION ---------- This tutorial is meant to be understandable to all new users, so if you found something unclear, don't sit and blame yourself - complain! This tutorial was adapted from <EMACS>TEACH-EMACS.TUTORIAL, a tutorial file for EMACS, an advanced real-time screen editor of which SCAME is but a faint shadow. If you have access to a DEC-20 or MULTICS computer, you could benefit from all the wonders of EMACS, but otherwise you will have to be satisfied with this! He, who useth SCAME, or any other EMACS-inspired editor, should acknowledge the work of Richard M. Stallman of the M.I.T. Artificial Intelligence laboratory, who conceived and implemented EMACS. @//E*O*F lib/tut2// chmod u=rw,g=r,o=r lib/tut2 echo x - lib/helpmenu sed 's/^@//' > "lib/helpmenu" <<'@//E*O*F lib/helpmenu//' You are at top level. Type a HELP option to say which kind of help you want: A tells something Apropos a keyword. You supply the keyword. B lists the Basic commands you need to use SCAME. C says what a certain Command (character) does. You type the character. L tells you the Last 60 character you typed. N lists a file of SCAME News. S lists a Summary of all commands. 1 runs part 1 of the SCAME tutorial. 2 runs part 2. Q or RubOut Quit, you don't really want help. @//E*O*F lib/helpmenu// chmod u=rw,g=r,o=r lib/helpmenu echo x - lib/changedfile sed 's/^@//' > "lib/changedfile" <<'@//E*O*F lib/changedfile//' Since SCAME last visited or saved this file it has been changed on disk. @//E*O*F lib/changedfile// chmod u=rw,g=r,o=r lib/changedfile echo x - lib/queryrep sed 's/^@//' > "lib/queryrep" <<'@//E*O*F lib/queryrep//' Space => Replace this. RubOut => Don't replace this. ! => Go ahead with the rest. @. => Replace this and then stop. Escape => Quit. Now type a space to see text again @//E*O*F lib/queryrep// chmod u=rw,g=r,o=r lib/queryrep echo x - lib/basic sed 's/^@//' > "lib/basic" <<'@//E*O*F lib/basic//' +---------------------- SUMMARY OF BASIC COMMANDS --------------------------+ ! C-B means "Control-B", i.e. press CTRL while you type B ! ! M-X means "Meta-X", i.e. type ESC and then type X ! +---------------------------------------------------------------------------+ Editing: C-X C-V Visit file (choose a file to edit). C-X C-S Save file. C-X C-Z Zap (Leave SCAME). Moving around: C-B Backwards C-F Forward C-P Previous Line C-N Next Line M-V Previous Screen C-V Next Screen M-< Beginning of Buffer M-> End of Buffer Write and delete: Ordinary characters are self-inserting. <RUB OUT> Delete the character left of the cursor C-D Delete the character at the cursor C-K Kill rest of the line (or empty line) C-Y Insert text that was last killed Other useful commands: C-S Incremental Search C-L Redisplay screen >>>>> Press <SPACE> when finished reading this!! <<<<< @//E*O*F lib/basic// chmod u=rw,g=r,o=r lib/basic echo x - lib/instring sed 's/^@//' > "lib/instring" <<'@//E*O*F lib/instring//' You are typing the argument to a command. These commands are available here: Return Enter the line. Escape Fill in the default string, if any, as shown within parentheses. Only works at the beginning of the line. ^F Fill in the current filename. ^G Abort this. ^Q Insert the next character. (Quoting ^@ won't work). ^U Rub out the whole line back to the prompt. @//E*O*F lib/instring// chmod u=rw,g=r,o=r lib/instring echo x - lib/tut1 sed 's/^@//' > "lib/tut1" <<'@//E*O*F lib/tut1//' *** SCAME *** (the SCreen-oriented Anti-Misery Editor) You are looking at the SCAME tutorial. Comments on this document should be sent via "mail leif@erisun.UUCP". SCAME commands generally involve the <CONTROL> key (sometimes labelled <CTRL> or <CTL>) or the <ESCAPE> key (sometimes labelled <ESC> or <ALT>). Rather than write out <ESCAPE> or <CONTROL> each time we want you to prefix a character, we'll use the following abbreviations: C-<chr> means hold the <CONTROL> key while typing the character <chr>. Thus, C-F (pronounced Control-F) would be: hold the <CONTROL> key and type F. M-<chr> stands for META-<chr>. If you don't have a <META>-key, you must use the <ESCAPE> key. Thus, M-F (pronounced Meta-F) would be: Type <ESCAPE>, release it, then type the character F. The characters ">>" at the left margin indicate directions for you to try using a command. For instance: >> Now type C-V (View next screen) to move to the next screen. (go ahead, do it by depressing the control key and V together). From now on, you'll be expected to do this whenever you finish reading the screen. Note that there is an overlap when going from screen to screen; this provides some continuity when moving through the file. The first thing that you need to know is how to move around from place to place in the file. You already know how to move forward a screen, with C-V. To move backwards a screen, type M-V (i e type <ESCAPE>, release it, then type a V). >> Try typing M-V and then C-V to move back and forth a few times. Make sure you understand the difference between a Control-command and a Meta-command. SUMMARY ------- The following commands are useful for viewing screenfuls: C-V Move forward one screenful M-V Move backward one screenful C-L Clear screen and redisplay everything putting the text near the cursor at the center. >> Find the cursor and remember what text is near it. Then type a C-L. Find the cursor again and see what text is near it now. WATCH OUT --------- For the moment, some of the commands described here have not been implemented yet. If you try to use them, you will get the "NYI Function is Not Yet Implemented?" error message. Also, some commands do not yet function exactly as described here. When you encounter one of those cases, have forbearance. BASIC CURSOR CONTROL -------------------- Getting from screenful to screenful is useful, but how do you reposition yourself within a given screen to a specific place? There are several ways you can do this. One way (not the best, but the most basic) is to use the commands previous, backward, forward and next. As you can imagine these commands (which are given to SCAME as C-P, C-B, C-F, and C-N respectively) move the cursor from where it currently is to a new place in the given direction. Here, in a more graphical form are the commands: Previous line, C-P : : Backward, C-B .... Current cursor position .... Forward, C-F : : Next line, C-N You'll probably find it easy to think of these by letter. P for previous, N for next, B for backward and F for forward. These are the basic cursor positioning commands and you'll be using them ALL the time so it would be of great benefit if you learn them now. >> Do a few C-N's to bring the cursor down to this line. >> Move into the line with C-F's and then up with C-P's. See what C-P does when the cursor is in the middle of the line. Lines are separated by one character, called a Linefeed (or Newline). >> Try to C-B at the beginning of this line. Do a few more C-B's. Then do C-F's back to the end of the line and beyond. When you go off the top or bottom of the screen, the text beyond the edge is shifted onto the screen so that your instructions can be carried out while keeping the cursor on the screen. >> Try to move the cursor off the bottom of the screen with C-N and see what happens. If moving by characters is too slow, you can move by words. M-F (Meta-F) moves forward a word and M-B moves back a word. >> Type a few M-F's and M-B's. Intersperse them with C-F's and C-B's. Notice the parallel between C-F and C-B on the one hand, and M-F and M-B on the other hand. Very often Meta characters are used for operations related to English text whereas Control characters operate on the basic textual units that are independent of what you are editing (characters, lines, etc). There is a similar parallel between lines and sentences: C-A and C-E move to the beginning or end of a line, and M-A and M-E move to the beginning or end of a sentence. >> Try a couple of C-A's, and then a couple of C-E's. Try a couple of M-A's, and then a couple of M-E's. See how repeated C-A's do nothing, but repeated M-A's keep moving farther. Do you think that this is right? Two other simple cursor motion commands are M-< (Meta Less-than), which moves to the beginning of the file, and M-> (Meta Greater-than), which moves to the end of the file. You probably don't need to try them, since finding this spot again will be boring. The location of the cursor in the text is also called "point". To paraphrase, the cursor shows on the screen where point is located in the text. Here is a summary of simple moving operations including the word and sentence moving commands: C-F Move forward a character C-B Move backward a character M-F Move forward a word M-B Move backward a word C-N Move to next line C-P Move to previous line C-A Move to beginning of line C-E Move to end of line M-A Move back to beginning of sentence M-E Move forward to end of sentence M-< Go to beginning of file M-> Go to end of file >> Try all of these commands now a few times for practice. Since the last two will take you away from this screen, you can come back here with M-V's and C-V's. These are the most often used commands. Like all other commands in SCAME, these commands can be given arguments which cause them to be executed repeatedly. The way you give a command a repeat count is by typing C-U and then the digits before you type the command. For instance, C-U 8 C-F moves forward eight characters. >> Try giving a suitable argument to C-N or C-P to come as close as you can to this line in one jump. The only apparent exception to this is the screen moving commands, C-V and M-V. When given an argument, they scroll the screen up or down by that many lines, rather than screenfuls. This proves to be much more useful. >> Try typing C-U 8 C-V now. Did it scroll the screen up by 8 lines? If you would like to scroll it down you can give an argument to M-V. WHEN SCAME IS HUNG ------------------ If you want to interrupt SCAME when it is waiting for input, you can stop it safely by typing C-G. You can also use C-G to discard a numeric argument or the beginning of a command that you don't want to finish. >> Type C-U 100 to make a numeric arg of 100, then type C-G. Now type C-F. How many characters does it move? If you have typed an <ESCAPE> by mistake, you can get rid of it with a C-G. Note that you can only use C-G to interrupt SCAME when it is waiting for input. If SCAME is running, the only way to stop it is by logging in on another terminal and killing the SCAME process. Note that this is a dangerous procedure that may cause your text buffer to be lost! Don't use it unless you absolutely have to. INSERTING AND DELETING ---------------------- If you want to type text, just do it. Characters which you can see, such as A, 7, *, etc. are taken by SCAME as text and inserted immediately. Type <Return> (the carriage-return key) to insert a line separator. You can delete the last character you typed by typing <Rubout>. <Rubout> is a key on the keyboard, which may be labelled "Delete" instead of "Rubout" on some terminals. More generally, <Rubout> deletes the character immediately before the current cursor position. >> Do this now, type a few characters and then delete them by typing <Rubout> a few times. Don't worry about this file being changed; you won't affect the master tutorial. This is just a copy of it. >> Now start typing text until you reach the right margin, and keep typing. When a line of text gets too big for one line on the screen, the line of text is "continued" onto a second screen line. The exclamation mark at the right margin indicates a line which has been continued. >> Use <Rubout>s to delete the text until the line fits on one screen line again. The continuation line goes away. >> Move the cursor to the beginning of a line and type <Rubout>. This deletes the line separator before the line and merges the line onto the previous line. The resulting line may be too long to fit, in which case it has a continuation line. >> Type <Return> to insert the separator again. Remember that most SCAME commands can be given a repeat count; Note that this includes characters which insert themselves. >> Try that now -- type C-U 8 * and see what happens. You've now learned the most basic way of typing something in SCAME and correcting errors. You can delete by words or lines as well. Here is a summary of the delete operations: <Rubout> delete the character just before the cursor C-D delete the next character after the cursor M-<Rubout> kill the word immediately before the cursor M-D kill the next word after the cursor C-K kill from the cursor position to end of line M-K kill to the end of the current sentence Notice that <Rubout> and C-D vs M-<Rubout> and M-D extend the parallel started by C-F and M-F (well, <Rubout> isn't really a control character, but let's not worry about that). C-K and M-K are like C-E and M-E, sort of, in that lines are opposite sentences. Now suppose you kill something, and then you decide that you want to get it back? Well, whenever you kill something bigger than a character, SCAME saves it for you. To yank it back, use C-Y. Note that you don't have to be in the same place to do C-Y; This is a good way to move text around. Also note that the difference between "Killing" and "Deleting" something is that "Killed" things can be yanked back, and "Deleted" things cannot. Generally, the commands that can destroy a lot of text save it, while the ones that attack only one character, or nothing but blank lines and spaces, do not save. For instance, type C-N a couple times to postion the cursor at some line on this screen. >> Do this now, move the cursor and kill that line with C-K. Note that a single C-K kills the contents of the line, and a second C-K kills the line itself, and make all the other lines move up. If you give C-K a repeat count, it kills that many lines AND their contents. The text that has just disappeared is saved so that you can retrieve it. To retrieve the last killed text and put it where the cursor currently is, type C-Y. >> Try it; type C-Y to yank the text back. Think of C-Y as if you were yanking something back that someone took away from you. Notice that if you do several C-K's in a row the text that is killed is all saved together so that one C-Y will yank all of the lines. >> Do this now, type C-K several times. Now to retrieve that killed text: >> Type C-Y. Then move the cursor down a few lines and type C-Y again. You now see how to copy some text. FILES ----- In order to make the text you edit permanent, you must put it in a file. Otherwise, it will go away when your invocation of SCAME goes away. You put your editing in a file by "visiting" the file. What visiting means is that you see the contents of the file in your SCAME; and, loosely speaking, what you are editing is the file itself. However, the changes still don't become permanent until you "save" the file. This is so you can have control to avoid leaving a half-changed file around when you don't want to. Even then, SCAME really makes a new version of the file and saves the old version under a slightly different name (so that you can verify or throw away your changes later if you like). If you look near the botton of the screen you will see a line that starts with "SCAME (Fundamental) tut1:" and continues with the filename tut1, which is the name of the SCAME tutorial; the file you are now visiting. Whatever file you visit, that file's name will appear in that precise spot. The commands for visiting and saving files are unlike the other commands you have learned in that they consist of two characters. They both start with the character Control-X. There is a whole series of commands that start with Control-X; many of them have to do with files, buffers, and related things, and all of them consist of Control-X followed by some other character. Another thing about the command for visiting a file is that you have to say what file name you want. We say the command "reads an argument from the terminal" (in this case, the argument is the name of the file). After you type the command C-X C-V Visit a file SCAME will ask you for the file name. You should end the name with the Return key. After this command, you will see the contents of the file in your SCAME and you can start editing edit its contents. If you are editing a file in SCAME and type the command C-X C-V to visit another file, you will lose whatever changes you did to the first file. If you wish to make the changes permanent, you must issue the command C-X C-S Save the file A new version of the file will be created. When the operation is finished, SCAME prints the name of the file saved. You should save fairly often, so that you will not lose very much work if the system should crash. Note that there are two ways to visit a file in SCAME. Either you can start SCAME with the file's name as an argument to the shell, ($ scame foo.p), or you can use the C-X C-V command inside SCAME. To make a new file, just visit it "as if" it already existed. Then start typing in the text. When you ask to "save" the file, SCAME will really create the file with the text that you have inserted. @From then on, you can consider yourself to be editing an already existing file. >> Try it: Type C-X C-V and then the name of a file, "foo" for instance. Put some text in it, and save it; then exit from SCAME and look at the file to be sure that it worked. Then continue with part two of the tutorial. @//E*O*F lib/tut1// chmod u=rw,g=r,o=r lib/tut1 echo x - lib/summary sed 's/^@//' > "lib/summary" <<'@//E*O*F lib/summary//' SCAME Command Chart as of 27-Oct-1982 ===== To get a C-A (Control-A) hold down the 'Ctrl'-key and type an 'A'. If your terminal has a 'Meta'-key: To get a M-A (Meta-A) hold down the 'Meta'-key and type an 'A'. To get a C-M-A (Control-Meta-A) hold down both the 'Ctrl'-key and the 'Meta'-key and type an 'A'. If your terminal lacks 'Meta'-key: To get a M-A (Meta-A) first type an 'Esc' and then an 'A'. To get a C-M-A (Control-Meta-A) first type a C-Z and then an 'A'. C-@ Set/Pop Mark C-A Beginning Of Line C-B Backward Character C-C Exit To Shell C-D Delete Character C-E End Of Line C-F Forward Character C-G Cancel >>type SPACE to see more<< C-H (Backspace) Backward Character C-I (Tab) Indent According to Mode C-J (Linefeed) Indent New Line C-K Kill Line C-L Reposition Window C-N Down Line C-O Open Line C-P Up Line C-Q Insert Next Character C-R Reverse Incremental Search C-S Incremental Search C-T Transpose Characters C-U Universal Argument (Must be in the range 0..32767) C-V Next Screen C-W Kill Region C-X is a prefix character. See below C-Y Un-Kill C-Z Prefix Control-Meta C-[ (Escape) Prefix Meta C-\ Prefix Meta C-_ Help C-^ Prefix Control RubOut Backward Delete Character C-X C-B List Buffers C-X C-D Directory Display C-X C-F Find File C-X Tab Indent Region C-X C-L Lowercase Region C-X C-S Save File C-X C-U Uppercase Region C-X C-V Visit File C-X C-W Write File C-X C-X Exchange Point and Mark C-X C-Z Exit C-X ( Start Kbd Macro C-X ) End Kbd Macro C-X . Set Fill Prefix C-X 1 One Window C-X 2 Two Windows C-X ; Set Comment Column C-X = What Cursor Position C-X B Select Buffer C-X D Dired C-X E Execute Kbd Macro C-X H Mark Whole Buffer C-X L Count Lines Page C-X K Kill Buffer C-X M Send Mail C-X O Other Window C-X R Read Mail C-X ^ Grow Window M-Return Back to Indentation M-! Execute Shell Command M-% Query Replace M-( Make () M-+ Push to Shell M-0 .. M-9 Auto Argument M-; Indent for Comment M-< Goto Beginning M-= Count Lines Region M-> Goto End M-@ Mark Word M-A Backward Sentence M-B Backward Word M-C Capitalize Word M-D Kill Word M-E Forward Sentence M-F Forward Word M-G Fill Region M-K Kill Sentence M-L Lowercase Word M-U Uppercase Word M-V Previous Screen M-W Copy Region M-X Instant Extended Command (see below) M-\ Delete Horizontal Space M-^ Delete Indentation M-~ Buffer Not Modified M-RubOut Backward Kill Word C-M-% Query Replace C-M-M Back to Indentation C-M-T Display Date and Time C-M-Z Exit C-M-V Scroll Other Window C-M-W Append Next Kill Most printable characters are self-inserting. Extended commands: (T means toggle) ------------------ M-X Ada Mode A Major mode for editing ADA programs M-X Auto Fill Mode (T) A minor mode useful when writing in text M-X C Mode For editing C programs M-X Change Directory Change the working directory M-X Check Mail Tell if there is new mail M-X Delete Matching Lines Delete all lines containing a pattern. M-X Fundamental Mode When nothing else applies M-X Insert Character Given an argument, inserts the character with the corresponding ASCII code M-X Insert File Asks for a file to insert at point M-X Load Kbd Macro Read keyboard macro from a file. M-X Lisp Mode For editing LisP code M-X Overwrite Mode (T) A minor mode for overwrite instead of insert. M-X Pascal Mode For editing Pascal programs M-X Replace String Replace from point to end of buffer (not query) M-X Revert File Restore file from disk M-X Rot 13 Region Encrypt/decrypt offensive text. M-X Save Kbd Macro Write keyboard macro to a file. M-X Set Key Put a function on a key M-X Set Variable Given an argument, will change the value of a variable M-X Sort Buffer Sort all lines in alphabetical order. M-X Stop Stop SCAME temporarily. M-X Swedish Mode For editing swedish text M-X Tabify Convert spaces into tabs where possible, starting from point M-X Undo Try to undo the last command. Only some commands may be undone. M-X View File Show a file without creating a new buffer. M-X View Working Directory Type out the current working directory M-X View Variable Show the value of a named variable M-X Write Region Write out the region to a file. Does not change the current filename. Variables: (Default values in parentheses) ---------- Auto Fill Mode (0) Controls the Auto Fill Mode Auto Push Point Option (500) When to set mark after I-Search Bottom Display Margin (100) Maximum percentage of screen to keep above cursor Comment Column (33) Used by M-; to decide where to start a comment. Fill Column (72) Used by Fill Region and Auto Fill Mode to decide where to break lines. Hackmatic Will be nonzero if the terminal has a META-key. Mail Check Interval (100) How often to check for new mail. Overwrite Mode (0) Controls the Overwrite Mode System Output Holding (0) If nonzero, will make scame ignore ^X and ^Q, using C-] for C-S and C-^ for C-Q instead. Tab Self Insert (0) Controls the action of TAB when in Pascal or C Mode. Terminal types: --------------- You can specify what kind of terminal you are using by putting the following two lines in your file .profile (which is executed every time you log in): TERM=<terminal type> export TERM where <terminal type> is one of the names listed in the file /etc/termcap If you are using the C shell , i.e. the one with the % prompt, you should put "setenv TERM <terminal type>" in the file .login instead. Please report bugs via "mail leif_s" /Leif Samuelsson @//E*O*F lib/summary// chmod u=rw,g=r,o=r lib/summary echo x - lib/aproposlist sed 's/^@//' > "lib/aproposlist" <<'@//E*O*F lib/aproposlist//' C-@ Set/Pop Mark;set mark C-A Beginning Of Line C-B Backward Character C-C Exit To Shell C-D Delete Character C-E End Of Line C-F Forward Character C-G Cancel C-H (Backspace) Backward Character C-I (Tab) Indent According to Mode C-J (Linefeed) Indent New Line C-K Kill Line C-L Reposition Window C-N Down Line C-O Open Line C-P Up Line C-Q Insert Next Character C-R Reverse Incremental Search C-S Incremental Search C-T Transpose Characters C-U Universal Argument (Must be in the range 0..32767) C-V Next Screen C-W Kill Region C-X is a prefix character. See below C-Y Un-Kill C-Z Prefix Control-Meta C-[ (Escape) Prefix Meta C-\ Prefix Meta C-_ Help C-^ Prefix Control RubOut Backward Delete Character C-X C-B List Buffers C-X C-D Directory Display C-X C-F Find File C-X Tab Indent Region C-X C-L Lowercase Region C-X C-S Save File C-X C-U Uppercase Region C-X C-V Visit File C-X C-W Write File C-X C-X Exchange Point and Mark C-X C-Z Exit C-X ( Start Kbd Macro;keyboard macro;define C-X ) End Kbd Macro;keyboard macro C-X . Set Fill Prefix C-X 1 One Window C-X 2 Two Windows C-X \; Set Comment Column C-X = What Cursor Position C-X B Select Buffer C-X D Dired;edit directory C-X E Execute Kbd Macro;keyboard macro C-X H Mark Whole Buffer C-X L Count Lines Page C-X K Kill Buffer C-X M Send Mail C-X O Other Window C-X R Read Mail C-X ^ Grow Window M-Return Back to Indentation M-! Execute Shell Command M-% Query Replace;substitute M-( Make () M-+ Push to Shell M-0 .. M-9 Auto Argument M-\; Indent for Comment M-< Goto Beginning M-= Count Lines Region M-> Goto End M-@ Mark Word M-A Backward Sentence M-B Backward Word M-C Capitalize Word M-D Kill Word M-E Forward Sentence M-F Forward Word M-G Fill Region (with argument it becomes Justify Region) M-K Kill Sentence M-L Lowercase Word M-U Uppercase Word M-V Previous Screen M-W Copy Region M-X Instant Extended Command (see below) M-\ Delete Horizontal Space M-^ Delete Indentation M-~ Buffer Not Modified M-RubOut Backward Kill Word C-M-% Query Replace;substitute C-M-M Back to Indentation C-M-T Display Date and Time C-M-Z Exit C-M-V Scroll Other Window C-M-W Append Next Kill M-X Ada Mode A Major Mode for editing ADA programs M-X Auto Fill Mode A Minor Mode, useful when entering text M-X C Mode For editing C programs M-X Change Directory Change the working directory M-X Check Mail Tell if there is new mail M-X Delete Matching Lines Delete all lines containing a pattern;Flush lines M-X Fundamental Mode When nothing else applies M-X Insert Character Inserts the character with ASCII code arg M-X Insert File Asks for a file to insert at point M-X Load Kbd Macro Read keyboard macro from a file. M-X Lisp Mode For editing LisP code M-X Overwrite Mode Overwrite instead of insert typed characters.;replace mode M-X Pascal Mode For editing Pascal programs M-X Replace String Replace to end of buffer (not query);substitute M-X Revert File Restores file from disk M-X Rot 13 Region Encrypt/decrypt offensive text.;Rotate;rot13 M-X Save Kbd Macro Write keyboard macro to a file. M-X Set Key Put a function on a key;bind key M-X Set Variable Given an argument, changes a variable's value M-X Sort Buffer Sort all lines in alphabetical order. M-X Stop Stop SCAME temporarily;suspend job M-X Swedish Mode For editing swedish text M-X Tabify Convert spaces into tabs, starting from point M-X Undo Try to undo the last command. M-X View File Show a file without creating a new buffer. M-X View Working Directory Type out the current working directory;pwd M-X View Variable Shows the value of a named variable M-X Write Region Write out the region to a file. Auto Fill Mode (0) Controls the corresponding Minor Mode Auto Push Point Option (500) When to set mark after I-Search Comment Column (33) Used by M-\; to decide where to start a comment. Fill Column (72) Used by fill commands when breaking lines. Hackmatic Will be nonzero if the terminal has a META-key. Mail Check Interval (100) How often to check for new mail. Overwrite Mode (0) Controls the corresponding Minor Mode System Output Holding (0) If nonzero, will make scame ignore ^X and ^Q Tab Self Insert (0) Controls the action of TAB in some modes @//E*O*F lib/aproposlist// chmod u=rw,g=r,o=r lib/aproposlist echo x - lib/news sed 's/^@//' > "lib/news" <<'@//E*O*F lib/news//' SCAME News Bulletin =================== 1985-02-08 Truncated the newsfile /LS @... 1982-10-18 Introduced the newsfile. /LS End of file. @//E*O*F lib/news// chmod u=rw,g=r,o=r lib/news echo mkdir - tmp mkdir tmp chmod u=rwx,g=rwx,o=rwx tmp echo Inspecting for damage in transit... temp=/tmp/shar$$; dtemp=/tmp/.shar$$ trap "rm -f $temp $dtemp; exit" 0 1 2 3 15 cat > $temp <<\!!! 208 1714 9729 tut2 12 93 496 helpmenu 2 14 73 changedfile 7 34 178 queryrep 21 132 952 basic 10 65 364 instring 363 2622 14875 tut1 200 946 5604 summary 130 711 4300 aproposlist 11 18 145 news 964 6349 36716 total !!! wc lib/tut2 lib/helpmenu lib/changedfile lib/queryrep lib/basic lib/instring lib/tut1 lib/summary lib/aproposlist lib/news | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp if [ -s $dtemp ] then echo "Ouch [diff of wc output]:" ; cat $dtemp else echo "No problems found." fi exit 0
leif@erix.UUCP (Leif Samuelsson) (02/16/85)
# This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by erisun!leif on Sat Feb 9 18:13:17 MET 1985 # Contents: main.c screen.c scame0.c scame1.c echo x - main.c sed 's/^@//' > "main.c" <<'@//E*O*F main.c//' /* SCAME main.c */ /* Version 1.0.0 1985-01-30 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; #include "scame.h" #ifdef BSD42 # include <sys/file.h> #endif /* global variables */ struct bufstruct buftab[MAXBUFS], cb = { "Main", "gazonk", 0, 0, FUNDAMENTAL, FALSE, (time_t) 0, { 0L }, { -1, 72 } }; struct gvarstruct gvars = { 500, /* Auto Push Point Option */ 100, /* Bottom Display Margin */ 0, /* Cbreak Mode */ 33, /* Comment Column */ 0, /* Hackmatic */ MAILCHECKINTERVAL, /* Mail Check Interval */ 17, /* Quote Char (^Q) */ 18, /* Search Backward (^R) */ 27, /* Search Exit Char (^@) */ 19, /* Search Forward (^S) */ 0, /* System Output Holding */ 0, /* Tab Self Insert */ 0 /* Top Display Margin */ }; int cmdchar; int noofbufs = 1; int bufno = 0; int oldbuf = -1; int otherbuf; /* Buffer of other window */ char *buf; char currentdir[FILENAMESIZE]; char mailfile[FILENAMESIZE]; char *username; char tempfile[] = TMPFILE; char scamelib[] = SCAMELIB; char *modes[] = { "Ada", "C", "Fundamental", "Lisp", "Pascal", "Swedish" }; char more[]="--MORE--", killbuffile[FILENAMESIZE], kbdmacfile[FILENAMESIZE], screen[SCRDIMY][SCRDIMX+1], oldscreen[SCRDIMY][SCRDIMX+1], commandprompt[80]="", fillprefix[80]="", tmpmode_string[80]=""; char *dot, *z, *home, *oldhome, *away, *mark[16], *otherdot, *otherhome; char *gaps, *gape; int upcasearr[512], nupcasarr[512]; long bufsize; int cury, curx, linpos; int screenlen,screenwidth; int windows=1; /* Number of windows */ int wintop, winbot; /* Top and bottom of window */ int oldhpos; /* used for moving up or down */ Bool savehpos=FALSE; Bool killing, control_prefix = FALSE, meta_prefix = FALSE, echobusy = FALSE, updateflag = FALSE, typing = FALSE, savearg = FALSE; long arg; Bool xarg,xxarg; /* xarg => argument has been given */ /* xxarg => explicit arg has been given, */ /* not only C-U */ int pipeup[2], pipedown[2]; int uid; /* user id. */ int ppid; /* parent process id. */ char lastinput[LASTINPUTSIZE]; int lstindex = 0; Bool defining_kbd_mac = FALSE, quiet = FALSE; int kbdmfd, execfd = -1; long chkmailcnt; int recursive_level = 0; Bool pop_pending = FALSE; #ifdef SIGTSTP char lockfile[FILENAMESIZE]; #endif main(argc,argv) int argc; char **argv; { /* Bool updflg; */ initupcase(); ppid = getppid(); uid = getuid(); if (!isatty(0)) { printf("Sorry, but SCAME must communicate directly with a terminal\n"); exit(1); } if (getenv("TERM") == NIL) { printf("You haven't set the terminal type, please do\ \"man scame\"\n"); exit(1); } #ifdef SIGTSTP { int fd; sprintf(lockfile, tempfile, ppid, uid); strcat(lockfile, "S"); if ((fd=open(lockfile, 0)) >= 0 #ifdef BSD42 && flock(fd, LOCK_EX | LOCK_NB) != 0 #endif ) { printf("You have Scame already running somewhere\n"); exit(1); } creat(lockfile, 0600); #ifdef BSD42 flock(fd, LOCK_EX | LOCK_NB); #endif } #endif getwd(currentdir); free(malloc(0x80)); /* For getchar(). */ buf=sbrk(0); /* Obtain the startaddress of the buffer */ bufsize = 0; dot=home=z=otherdot=otherhome=gaps=gape=buf; away=NIL; oldhome= NIL; #ifdef PDP11 inittypeaheadcheck(); #endif gotobegin(); for (lstindex = LASTINPUTSIZE; lstindex > 0;) lastinput[--lstindex] = 0200; gettermtype(); setupterm(TRUE); wintop = 0; winbot = screenlen-3; sprintf(killbuffile, tempfile, ppid, uid); strcat(killbuffile, "k"); sprintf(kbdmacfile, tempfile, ppid, uid); strcat(kbdmacfile, "m"); username = getenv("USER"); sprintf(mailfile, "%s/%s", MAILDIR, username); checkmail(FALSE); if ((argc == 1 || argv[1][0] != '-') && restart()) { ttycbreak(); cls(); while (--argc > 0) { if (argv[argc][0] != '-') { buildfilename(cb.filename,argv[argc]); findfile(); fixbuftab(PUT); } } } else { int i; cls(); execfile(".scamerc"); i=1; while (argc > i && argv[i][0] == '-') i++; if (argc > i) buildfilename(cb.filename,argv[i]); findmode(); readfile(); cb.modified=FALSE; while (--argc > i) { if (argv[argc][0] != '-') { fixbuftab(PUT); buildfilename(cb.filename,argv[argc]); findfile(); } } } killing=FALSE; *mark=buf; editloop(); exitscame(0); } /* end of main */ exitscame(code) int code; { if (!code) { savescame(); if (CE != NIL) { cur(screenlen-2,0); cleol(FALSE); } cur(screenlen-1,0); setupterm(FALSE); pchar('\n'); } #ifdef SIGTSTP unlink(lockfile); #endif exit(code); } editloop() { int c; if (execfd < 0) recursive_level++; update(); if (!quiet) { modeline(); refresh(TRUE); } /* cur(cury,curx); */ oldhpos = curx; while (!pop_pending) { if (control_prefix || meta_prefix) { if (xarg) sprintf(commandprompt,"%ld ",arg); else *commandprompt = '\0'; if (control_prefix) strcat(commandprompt, "C-"); if (meta_prefix) strcat(commandprompt, "M-"); } else if (!savearg) { arg=1; xarg=xxarg=FALSE; *commandprompt = '\0'; } savearg = FALSE; c=inchar(TRUE); if (c == EOF) return; if (c & 0200) meta_prefix=TRUE; if ((c & 0177) == '\007') { if (!quiet) pchar(BELL); control_prefix = meta_prefix = FALSE; if (!quiet && echobusy) clearecho(); } else { if ((c & 0177) >= 0 && (c & 0177) < 32) c = (c + '@') | 0400; if (control_prefix) c = b_control(c); if (meta_prefix) c = b_meta(c); control_prefix = meta_prefix = FALSE; fflush(stdout); cmdchar = c; (*disptab[cmdchar])(); } if (typing) { int ch; typing = FALSE; *commandprompt = '\0'; ch = inchar(TRUE); if (ch == EOF) return; if (execfd < 0 && ch != ' ') unget(ch); } if (updateflag || dot<home || dot>away || home != oldhome) { update(); modeline(); } else findxy(); if (!(pop_pending || quiet)) refresh(TRUE); /* if (!typeahead() && (cury != vpos || curx != hpos)) cur(cury,curx); if (c!= '\007' && c!= '\016' && c != '\020' && c!= '\0207') */ if (!savehpos) oldhpos = curx; else savehpos = FALSE; if (!(quiet || echobusy || --chkmailcnt)) checkmail(TRUE); echobusy = FALSE; } if (execfd < 0) recursive_level--; pop_pending = FALSE; } recurse() { char tstr[SCRDIMX+1]; strcpy(tstr, tmpmode_string); *tmpmode_string = '\0'; editloop(); tmodlin(tstr); } @//E*O*F main.c// chmod u=rw,g=r,o= main.c echo x - screen.c sed 's/^@//' > "screen.c" <<'@//E*O*F screen.c//' /* SCAME screen.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; # include "scame.h" update() { register char *tdot; register int i, j, y, x; int sw = screenwidth-1; int wb; upd2(); if (typeahead()) return; for (j=(windows > 1 && bufno == otherbuf); j >= 0; j--) { y=wintop; x=0; /* upd2(); */ wb=winbot+1; tdot=home; if (away < z) { while (y<wb) { /* vvvvvvvvvvvvvvvv THIS CODE IS DOUBLED FOR SPEED */ if (*tdot == '\n') { screen[y++][x]='\0'; x = -1; } else { if (x==sw) { screen[y][x]='!'; screen[y++][++x]='\0'; x=0; } if (*tdot == '\t') { i = min(x+TABWID-(x&7), sw); while (x < i) screen[y][x++]=' '; x--; } else if (*tdot < ' ' || *tdot == DEL) { screen[y][x++]='^'; if (x==sw){ screen[y][x]='!'; screen[y++][++x]='\0'; x=0;} screen[y][x] = *tdot + 64; } else screen[y][x] = *tdot; } tdot++; x++; } } /* ^^^^^^^^^^^^^^^^ */ else { while (tdot<z) { /* vvvvvvvvvvvvvvvv */ if (*tdot == '\n') { screen[y++][x]='\0'; x = -1; } else { if (x==sw) { screen[y][x]='!'; screen[y++][++x]='\0'; x=0; } if (*tdot == '\t') { i = min(x+TABWID-(x&7), sw); while (x < i) screen[y][x++]=' '; x--; } else if (*tdot < ' ' || *tdot == DEL) { screen[y][x++]='^'; if (x==sw){ screen[y][x]='!'; screen[y++][++x]='\0'; x=0;} screen[y][x] = *tdot + 64; } else screen[y][x] = *tdot; } tdot++; x++; } /* ^^^^^^^^^^^^^^^^ */ if (y < wb) screen[y][x]='\0'; while (++y < wb) *screen[y]='\0'; } if (j) { otherwindow(); upd2(); } } if (windows > 1 && bufno == otherbuf) { otherwindow(); upd2(); } oldhome = home; updateflag = FALSE; } upd2() /* Updates the values of home, */ { /* curx, cury and away. */ register char *tdot; register int i; int y=wintop; register int x=0; int sw=screenwidth-1; if (gaps < home + GAPDIST) closegap(); if (dot < home) { home = dot; while (home > buf && *(home-1) != '\n') home--; center(); } tdot=home; while (y < winbot+1 && tdot < z) { if (tdot==dot) { curx=x; cury=y; } if (*tdot == '\n') { y++; x = -1; } else { if (x==sw) { y++; x=0; } if (*tdot == '\t') x = min(x + TABWID -(x & 7), sw)-1; else if (*tdot < ' ' || *tdot == DEL) { x++; if (x==sw) { y++; x=0; } } } tdot++; x++; } if (tdot==dot) { curx=x; cury=y; } if (*(tdot-1) == '\n' && tdot < z) away=tdot-1; else away=tdot; if (dot > away || cury > wintop + (winbot-wintop)*gvars.bottom_display_margin/100 || cury < wintop + (winbot-wintop)*gvars.top_display_margin/100) { home = dot; while (home > buf && *(home-1) != '\n') home--; center(); upd2(); } } refline(y,invflg) int y; Bool invflg; { register char *pt1,*pt2,*pt3,*pt4; int len, len1, len2, i; pt1 = screen[y]; pt2 = oldscreen[y]; pt1[screenwidth] = '\0'; /* In case line was too long */ len1 = strlen(pt1); len2 = strlen(pt2); while (*pt1 == *pt2 && *pt1 != '\0' && *pt2 != '\0') { pt1++; pt2++; } if (*pt2 != *pt1) { if (*pt2 == '\0') while (*pt1 == ' ') pt1++; cur(y, pt1 - screen[y]); if (len1 == len2) { pt3 = screen[y] + len1 - 1; pt4 = oldscreen[y] + len1 - 1; while (*pt3 == *pt4) { pt3--; pt4--; } pt3++; len = pt3 - pt1; } else len = len1 - (pt1 - screen[y]); if (invflg) invmod(TRUE); write(1,pt1,len); if (invflg) invmod(FALSE); hpos += len; if (len1 < len2) { if (CE != NIL) cleol(FALSE); else for(i=1; i<=len2-len1;i++,hpos++) pchar(' '); } strcpy(oldscreen[y],screen[y]); } } refresh(modeflg) int modeflg; { register int y; if (!typeahead()) refline(cury,FALSE); if (modeflg) refline(winbot+1,TRUE); if (typeahead()) return; if (modeflg) { if (winbot < screenlen-3) refline(screenlen-2,TRUE); else if (wintop > 0) refline(wintop-1,TRUE); } for (y=0; y < screenlen-2; y++) { if (typeahead()) return; if (y != cury) refline(y,FALSE); } if (!typeahead() && (cury != vpos || curx != hpos)) cur(cury,curx); } findxy() /* Updates the values of */ { /* linpos, curx and cury */ register char *t; register int i; int y=wintop; register int x=0; int sw=screenwidth-1; int tlinpos=0; if (gaps < home + GAPDIST) closegap(); if (dot < home) { home = dot; while (home > buf && *(home-1) != '\n') home--; center(); } t=home; while (y <= winbot && t < z) { if (t==dot) { curx=x; cury=y; linpos=tlinpos; return; } if (*t == '\n') { y++; x = -1; tlinpos = -1; } else { if (x==sw) { y++; x=0; } if (*t == '\t') { i = min(x + TABWID -(x & 7), sw)-1; tlinpos += i-x; x = i; } else if (*t < ' ' || *t == DEL) { x++; tlinpos++; if (x==sw) { y++; x=0; } } } t++; x++; tlinpos++; } if (t==dot) { curx=x; cury=y; linpos=tlinpos; return; } home = dot; while (home > buf && *(home-1) != '\n') home--; center(); findxy(); } int findcurx() { char *tdot; register int i,x,y; int sw = screenwidth-1; tdot = dot; while (tdot > buf && *(tdot-1) != '\n') tdot--; x = 0; y = wintop; while (tdot < dot) { if (x == sw) { x = 0; y++; } if (*tdot == '\t') x = min(x + TABWID -(x & 7), sw) - 1; else if (*tdot < ' ' || *tdot == DEL) { x++; if (x==sw) { x = 0; y++; } } tdot++; x++; } curx = x; return y; } @//E*O*F screen.c// chmod u=rw,g=r,o= screen.c echo x - scame0.c sed 's/^@//' > "scame0.c" <<'@//E*O*F scame0.c//' /* SCAME scame0.c */ /* Revision 1.0.0 1985-01-30 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; # include "scame.h" # include <ctype.h> Bool insertc(c,i) char c; long i; { register char *p1, *p2; killing=FALSE; if ((gaps > dot + GAPDIST || (long) (gape-gaps) < i) && !gapto(dot + GAPDIST, GAPSIZE + i)) { errmes(BF); return (FALSE); } blockmove(dot, dot+i, (long)(gaps-dot)); if (gape == z) gape += i; z += i; gaps += i; p1 = dot; dot = p2 = dot+i; while (p1 < p2) *p1++ = c; updateflag = TRUE; cb.modified = TRUE; return (TRUE); } insertstr(str,l) char *str; long l; { register char *tdot; register int midwindow; if (l == 0L) return; midwindow = (winbot-wintop)/3; tdot=dot; if (insertc('\0',l)) { while (tdot < dot) { *(tdot++) = *str++; if (*str == '\n' && (CS != NIL || DL != NIL) && cury >= winbot) { if (dot==z && cury==winbot+1) vtscroll(2*midwindow+1,wintop); else if (dot != z && cury == winbot) vtscroll(2*midwindow,wintop); cury = midwindow; } } cb.modified = TRUE; } } indent(i) long i; { char *tdot; if (!xarg) switch (cb.majormode) { case ADA: case C: case LISP: case PASCAL: tdot=dot; passline(-1L); backtoindent(); findxy(); i = curx+1; xarg = TRUE; dot = tdot; findxy(); } else i++; if (xarg) { if (i > 0) { delhorizspace(); findxy(); if (curx < i) { while (curx+1 < i && insertc('\t',1L)) findxy(); if (curx >= i) { *(dot-1) = ' '; findxy(); insertc(' ', i-curx-1); } } } else errmes(ILA); } else insertc('\t',1L); } indentregion(i) long i; { char *tdot, *ttdot; tdot = min(dot, *mark); adjustmark(); if (dot > *mark) exchgdotmark(); while (dot < *mark) { backtoindent(); findxy(); xarg = TRUE; ttdot = dot; indent(curx + i); *mark += dot-ttdot; passline(1L); } *mark = tdot; } scroll(lines) long lines; { register int x; register int y=0; char *tdot0; register char *tdot; closegap(); if (lines > 0){ while (lines-- > 0 && home<z) { x=0; while(home<z && *home++ != '\n' && x++< screenwidth-1); } } else if (lines < 0) { tdot = dot; lines = -lines; while (lines-- && home > buf) { dot=home; do { home--; x = 0; while (home > buf && *(home-1) != '\n' && x++ < screenwidth) home--; findxy(); } while (cury == wintop && home > buf); while (cury > wintop + 1) { home++; findxy(); } } dot = tdot; } } center(i) int i; /* move line with cursor to be near center of window */ { home=dot; findxy(); scroll((long)((wintop-winbot)*4/10)); } newwindow(i) long i; /* Refresh window and let current line be line i if arg given */ { int j, k; if (xxarg) { if (i < 0) i = winbot-wintop+1 + i; if (i >= 0 && i < winbot-wintop+1 && wintop + i != cury) { vtscroll((int)(cury - wintop-i),wintop); scroll(cury-wintop-i); upd2(); modeline(); } } else if (xarg) { for (j=0; j<screenwidth; j++) oldscreen[cury][j] = 128; } else { if (windows == 1) { cls(); for (j=wintop; j<=winbot+1; j++) *oldscreen[j]='\0'; } else for(j=wintop; j<=winbot+1; j++) for (k=0; k<screenwidth; k++) oldscreen[j][k]=128; center(); modeline(); } } forwchar(i) register long i; { if (dot + i > z) { errmes(NIB); i = z - dot; } if (dot + i >= gaps) gapto(dot+i+GAPDIST, GAPSIZE); dot += i; killing=FALSE; } long backchar(i) register long i; { if (dot - i < buf) { errmes(NIB); i = dot - buf; } dot -= i; killing=FALSE; return (i); } passline(i) register long i; { register char *tdot, *end; tdot = dot; if (i > 0) { closegap(); end = z; while (i-- > 0 && tdot < end) while (tdot < end && *tdot++ != '\n'); } else { end = buf; while (i++ < 0 && tdot > end) { while (tdot > end && *--tdot != '\n'); if (*(tdot) != '\n') while (tdot < z && *tdot != '\n') tdot++; } } dot = tdot; killing=FALSE; } downline(i) long i; { int y, wsize=(winbot-wintop); register int x; findxy(); y = cury; if (i==1 && y >= wintop + wsize * gvars.bottom_display_margin / 100 && dot < z) vtscroll((int)(wsize*(gvars.bottom_display_margin - 38)/100)+1, wintop); passline(i); findxy(); if (i==1 && cury==y && dot==z) insertc('\n',1L); else { x = curx-1; while (++x < oldhpos && dot < z && *dot != '\n') { if (*dot == '\t') x = min(x + TABWID - (x&7), screenwidth - 1)-1; else if (*dot < ' ' || *dot == DEL) x++; dot++; } } killing=FALSE; } upline(i) long i; { int y=cury; char *d=dot; register int x; passline(-i); if (d != dot) begofline(); findxy(); x = curx-1; while (++x < oldhpos && dot < z && *dot != '\n') { if (*dot == '\t') x = min(x + TABWID - (x&7), screenwidth-1) - 1; else if (*dot < ' ' || *dot == DEL) x++; dot++; } if (i==1 && home>buf && y <= wintop + (winbot-wintop)*gvars.top_display_margin/100) vtscroll((int)((wintop-winbot)*(40-gvars.top_display_margin)/100-1), wintop); killing=FALSE; } endofline() { closegap(); while (dot < z && *dot != '\n') dot++; killing=FALSE; } begofline() { while (dot > buf && *(dot-1) != '\n') dot--; killing=FALSE; } backtoindent() { closegap(); begofline(); while (dot < z && *dot != '\n' && isblank(*dot)) dot++; } delhorizspace() { char *tdot; closegap(); while (dot>buf && isblank(*(dot-1))) dot--; tdot = dot; while (tdot < z && isblank(*tdot)) tdot++; delchar((long)(tdot-dot)); } delindent() { if (xarg) passline(1L); begofline(); delchar(backchar(1L)); delhorizspace(); insertc(' ',1L); } killchar(i) long i; { Bool killflag=killing; if (dot + i >= gaps) closegap(); if (i < 0L) i = -backchar(-i); else i = min(i, (long) (z - dot)); killing=killflag; if (killing) { if (i > 0) filncat(killbuffile, dot, i); else filnprep(killbuffile,dot, -i); } else { filncpy(killbuffile,dot, abs(i), 0600); killing=TRUE; } delchar(abs(i)); } delchar(i) long i; { int lin1,lin2,lines; long j; if (i > 0L){ if (dot + i >= gaps) gapto(dot + i + GAPDIST, GAPSIZE); if (dot+i <= z) { upd2(); if ((CS != NIL || DL != NIL) && dot+i < away) { findxy(); lin1 = cury; for(j=0; j<i && *(dot+j)!='\n'; j++); if (j==i && curx+i >= screenwidth) lin1++; if (i==1 && *dot != '\n' && curx == screenwidth-1) lin1++; dot += i; findxy(); lin2 = cury; dot -= i; if (lin2 > lin1) { lines = lin2-lin1; if (*(dot-1)!='\n' || dot==buf || *(dot+i-1)!='\n' ) lin1++; vtscroll(lines,lin1); } } blockmove(dot+i, dot, (long)(gaps-dot-i)); if (gape == z) gape -= i; z -= i; gaps -= i; updateflag = TRUE; cb.modified = TRUE; } else errmes(NIB); } } nextscreen() { if (away < z) { dot=away+1; passline(-2L); begofline(); home=dot; upd2(); } } prevscreen() { if (home > buf) { passline((long)(-(winbot-wintop+1)+2-cury)); begofline(); home=dot; upd2(); } } readfile() { int f; register char *tdot; off_t fz; closegap(); if (*cb.filename == '\0') { errmes(NSF); return; } else if ((f = open(cb.filename,0)) > -1) { fz = filesize(cb.filename); if ((long)fz > bufsize && !incbuf((long)fz - bufsize)) errmes(FTB); else { z = buf + read(f, buf, (int) bufsize); for (tdot = buf; tdot<z; tdot++) *tdot &= 127; gotobegin(); cb.modified=FALSE; cb.mtime = filemodified(cb.filename); } close(f); } else { echo("(New File)"); z=buf; gotobegin(); cb.modified=FALSE; cb.mtime = (time_t) 0; } updateflag = TRUE; upd2(); modeline(); killing=FALSE; gape = gaps = z; } insertfile(infilename) char *infilename; { int f; register char *tdot; off_t fz; closegap(); if ((f = open(infilename,0)) > -1) { fz = filesize(infilename); if (fz == 0) echo("File is empty"); else if ((long)(z - buf + fz) <= bufsize || incbuf((long)(z - buf + fz - bufsize))) { pushpopmark(1L); insertc('\0', (long) fz); read(f,dot - fz, (int) fz); for (tdot = dot - fz ; tdot < dot; tdot++) *tdot &= 127; cb.modified=TRUE; } else errmes(FTB); close(f); } else if (*infilename != '\0') errmes(NSF); killing=FALSE; } writefile() { register int f; char bakfil[FILENAMESIZE], *cp, *tdot; struct stat fst; unsigned mode; closegap(); if (cb.majormode == PASCAL && *(z-1) == '.') { tdot = dot; gotoend(); insertc('\n',1L); dot = tdot; } if (*cb.filename != '\0') { echo("Written: "); /* strncpy(bakfil,(cp= rindex(cb.filename,'/')) == 0? cb.filename: &cp[1],10); bakfil[10]='\0'; strcat(bakfil,".BAK"); */ cp= rindex(cb.filename,'/'); if (cp == NIL) cp = cb.filename; else cp++; sprintf(bakfil, BACKUPNAME, cp); /* Now what if the file is a link??? (FIX THIS) */ unlink(bakfil); if (rename(cb.filename,bakfil) == 0) { stat(bakfil,&fst); mode = fst.st_mode; } else mode = 0666; if ((f=creat(cb.filename,(int) mode))>=0) { if (write(f,buf,z-buf) == z-buf) { strout(cb.filename); cb.modified = FALSE; modeline(); close(f); cb.mtime = filemodified(cb.filename); } else { pchar(BELL); echo("can't write file"); close(f); } } else { pchar(BELL); echo("can't create file!"); } } else { pchar(BELL); echo("No saved filename"); } killing=FALSE; } killline(i) long i; { Bool killflag=killing; Bool blankline=TRUE; pushpopmark(1L); if (xarg || *dot == '\n') passline(i); else { while (dot < z && *dot != '\n') { if (!isblank(*dot)) blankline = FALSE; dot++; } if (blankline) passline(1L); } exchgdotmark(); killing=killflag; killregion(); } killregion() { long int n; adjustmark(); n = *mark-dot; if (dot != *mark) killchar(n); *mark=dot; } copyregion() { long howmany; char *from= dot; adjustmark(); howmany= *mark - dot; if (howmany < 0) { howmany = -howmany; from = *mark; } if (dot != *mark) { closegap(); if (killing) filncat(killbuffile, from, howmany); else { filncpy(killbuffile, from, howmany, 0600); killing=TRUE; } } } gotobegin() { dot=home=buf; cury=curx=0; killing=FALSE; } gotoend() { closegap(); dot=z; killing=FALSE; } tmodlin(text) char *text; { if (text == NIL) *tmpmode_string = '\0'; else strcpy(tmpmode_string, text); modeline(); refresh(TRUE); } modeline() { register char *pt; char tstr[10]; register int i; pt = screen[winbot+1]; *pt = '\0'; for (i = recursive_level - 1; i > 0; i--) strcat(pt, "["); if (*tmpmode_string) strcat(pt, tmpmode_string); else { strcat(pt,"SCAME ("); strcat(pt,modes[(int)cb.majormode]); if (cb.minormodes.autofill) strcat(pt, " Fill"); if (cb.minormodes.overwrite) strcat(pt, " Ovwrt"); if (defining_kbd_mac) strcat(pt, " DEF"); strcat(pt,") "); strcat(pt,cb.name); /* FLAG CONTROL! */ strcat(pt,": "); if (strsub(cb.filename,currentdir,FALSE,FALSE) == 0) { int i = 0; while (*(cb.filename+i) == *(currentdir+i)) i++; strcat(pt,cb.filename+i+(i>1)); } else strcat(pt,cb.filename); /* FLAG CONTROL! */ } strcat(pt," "); /* truncate line if too long */ pt[screenwidth-9-recursive_level] = '\0'; if (home==buf) { if (away<z) strcat(pt,"--TOP--"); } else if (away==z) strcat(pt,"--BOT--"); else { sprintf(tstr,"--%ld%%--", (unsigned) (home-buf)*100L/(unsigned)(z-buf)); strcat(pt,tstr); } strcat(pt, " "); if (cb.modified) pt[strlen(pt)-1] = '*'; for (i = recursive_level - 1; i > 0; i--) strcat(pt, "]"); fflush(stdout); } transchar() { char c; if (*(dot-1) != '\n') { if (*dot == '\n' || dot == z) backchar(1L); c = *dot; *dot = *(dot-1); backchar(1L); *dot = c; forwchar(2L); updateflag = TRUE; cb.modified = TRUE; } else pchar(BELL); killing=FALSE; } yank() { int f; register char *tdot; off_t fz; fz = filesize(killbuffile); if (fz && (f = open(killbuffile,0)) > -1) { if ((long)(z - buf + fz) <= bufsize || incbuf((long)(z - buf + fz - bufsize))) { pushpopmark(1L); insertc('\0', (long) fz); read(f,dot - fz, (int) fz); for (tdot = dot - fz ; tdot < dot; tdot++) *tdot &= 127; cb.modified=TRUE; } else errmes(BF); close(f); } else pchar(BELL); killing=FALSE; } Bool getfilename(prompt, name) char *prompt, *name; { char tfilename[FILENAMESIZE]; int c; char tprompt[80]; basename(name,tfilename,FALSE); strcpy(tprompt,prompt); if (*tfilename != '\0') sprintf(&tprompt[strlen(tprompt)]," (%s)",tfilename); strcat(tprompt,": "); *tfilename= '\0'; do { c=instring(tprompt,tfilename,strlen(tfilename), " \023\t", "\r\007\033"); if (c == ESC) { if (*tfilename == '\0') { basename(name,tfilename,FALSE); } else pchar(BELL); } } while (c == ESC); if (c==13) { if (*tfilename == '\0') basename(name, tfilename, FALSE); if (strcmp(name,tfilename)!=0) buildfilename(name,tfilename); return TRUE; } else { echo(NIL); return FALSE; } } adjustmark() { *mark = min(*mark,z); } exchgdotmark() { char *tdot=dot; adjustmark(); if (dot < *mark) forwchar((long)(*mark - dot)); else backchar((long)(dot - *mark)); *mark = tdot; } markquant(q, i, movepoint) enum quantity_t q; long i; Bool movepoint; { char *tdot; tdot = dot; forwquant(q, i); pushpopmark(1L); dot = tdot; if (movepoint && !endofquantp(q, dot)) backquant(q, 1L); } killquant(q,i) enum quantity_t q; long i; { Bool killflag=killing; pushpopmark(1L); if (i>0) forwquant(q,i); else backquant(q,-i); exchgdotmark(); killing=killflag; killregion(); } forwquant(q,i) enum quantity_t q; register long i; { closegap(); while (i-- > 0) { switch (q) { case WORD: while (dot < z && endofquantp(q,dot)) dot++; while (dot < z && !endofquantp(q,dot)) dot++; break; case LINE: passline(i); break; case SENTENCE: if (dot < z-1) dot++; while (dot < z && *dot == '\n') dot++; while ((dot < z-1) && (index(".?!", *(dot-1)) == NIL || (*dot != ' ' || *(dot+1) != ' ')) && (index(".?!", *(dot-1)) == NIL || (*dot != '\n')) && (*dot != '\n' || *(dot+1) != '\n')) dot++; break; case REGION: case PARAGRAPH: errmes(ILQ); break; case BUFFER: gotoend(); break; } } killing=FALSE; } backquant(q,i) enum quantity_t q; register long i; { while (i-- > 0 && dot > buf) { switch (q) { case WORD: backchar(1L); while (endofquantp(q,dot) && backchar(1L)!=0L); while (!endofquantp(q,dot) && backchar(1L)!=0L); if (dot>buf && dot < z) dot++; break; case LINE: passline(-i); break; case SENTENCE: if (dot > buf) backchar(1L); while (dot > buf && (*dot == '\n' || isblank(*dot))) backchar(1L); while ((dot > buf) && (index(".?!", *(dot-1)) == NIL || (*dot != ' ' || *(dot+1) != ' ')) && (index(".?!", *(dot-1)) == NIL || (*dot != '\n')) && (*dot != '\n' || *(dot+1) != '\n')) backchar(1L); while(dot < z && (*dot == '\n' || isblank(*dot))) dot++; break; case REGION: case PARAGRAPH: errmes(ILQ); break; case BUFFER: gotobegin(); break; } } killing=FALSE; } upcaseword(i,flg) register long i; short flg; { register Bool swedish = (cb.majormode==SWEDISH); closegap(); while (i-- > 0) { while (dot < z && endofquantp(WORD,dot)) dot++; if (dot<z && flg == 2) { *dot=upcase(*dot,swedish); dot++; flg=FALSE; } if (flg) { while (dot < z && !endofquantp(WORD,dot)) { *dot=upcase(*dot,swedish); dot++; } } else { while (dot < z && !endofquantp(WORD,dot)) { *dot=lowcase(*dot,swedish); dot++; } } } updateflag = TRUE; cb.modified = TRUE; killing=FALSE; } upcaseregion(f) Bool f; { register char *d1,*d2; register Bool swedish=(cb.majormode==SWEDISH); adjustmark(); d1 = min(dot,*mark)-1; d2 = max(dot,*mark); if (f) { while (++d1 < d2) *d1=upcase(*d1,swedish); } else { while (++d1 < d2) *d1=lowcase(*d1,swedish); } updateflag = TRUE; cb.modified = TRUE; killing=FALSE; } rot13_region() { register char *d1,*d2; adjustmark(); d1 = min(dot,*mark)-1; d2 = max(dot,*mark); if (d1 < d2-1) { while (++d1 < d2) { if (isalpha(*d1)) { if ((*d1 & 31) <= 13) *d1 = *d1+13; else *d1 = *d1-13; } } updateflag = TRUE; cb.modified = TRUE; } killing=FALSE; } stop() { #ifdef SIGTSTP register int i; signal(SIGHUP, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); signal(SIGTSTP, SIG_DFL); setupterm(FALSE); echo(NIL); kill(getpid(), SIGTSTP); /* stop here until continued */ setupterm(TRUE); cls(); vpos=0; hpos=0; upd2(); modeline(); for (i=0; i<=screenlen-2; i++) *oldscreen[i]='\0'; signal(SIGTSTP, stop); #else errmes(NYI); #endif killing=FALSE; } findmode() { char *str; str=rindex(cb.filename,'.'); if (str != NIL) { if (!strcmp(str,".A")) setmode(ADA); else if (!strcmp(str,".c")) setmode(C); else if (!strcmp(str,".l") || !strcmp(str,".lsp") || !strcmp(str,".lisp")) setmode(LISP); else if (!strcmp(str,".p") || !strcmp(str,".pas")) setmode(PASCAL); else if (!strcmp(str,".swe")) setmode(SWEDISH); else setmode(FUNDAMENTAL); } else setmode(FUNDAMENTAL); } setmode(mode) enum majormode_t mode; { static int haspiped=FALSE; register int i; register swedish = (mode == SWEDISH); char initfile[FILENAMESIZE]; if (mode != cb.majormode) { switch (mode) { case LISP: cb.lvars.disp_matching_paren = 1L; break; default: cb.lvars.disp_matching_paren = -1L; } if (mode == SWEDISH) for (i=0; i < 512; i++) { nupcasarr[i] = ((i & 0177) >= 'a' && (i & 0177) <= '}') ? (i & 0337) : i; #ifdef COMMENT nlocasarr[i] = ((i & 0177) >= 'A' && (i & 0177) <= ']') ? (i | 0040) : i; #endif } strcpy(initfile,".scamerc_"); strcat(initfile,modes[(int)mode]); for (i=0; i < strlen(initfile); i++) initfile[i] = lowcase(initfile[i],FALSE); execfile(initfile); } cb.majormode = mode; modeline(); } setminormode(mode,arg) long *mode; long arg; { if (xarg) *mode = arg; else *mode = (long) !(*mode); modeline(); } whatcursorposition() { char s[SCRDIMX+1]; long l; l = (z != buf) ? (unsigned)(dot-buf)*100L/(unsigned)(z-buf) : 0L; sprintf(s, "X=%d Y=%d ",curx,cury); if (dot < z) sprintf(&s[strlen(s)], "CH=%o ",*dot); sprintf(&s[strlen(s)], ".=%u(%ld%% of %u) Allocated=%ld", dot-buf, l, z-buf, bufsize); echo(s); } comment() { closegap(); switch (cb.majormode) { case FUNDAMENTAL: case LISP: case SWEDISH: begofline(); while (dot < z && *dot != ';' && *dot != '\n') dot++; findxy(); while (curx > gvars.commcol+4 && isblank(*(dot-1))) { delchar(backchar(1L)); findxy(); } while (curx < gvars.commcol-1 && insertc('\t',1L)) findxy(); if (*(dot-1) != '\t') insertc('\t',1L); if (dot==z || *dot != ';') insertc(';',1L); else if (dot<z) dot++; break; case PASCAL: begofline(); while (((dot < z && *dot != '(') || (dot< z-1 && *(dot+1) != '*')) && *dot != '\n') dot++; findxy(); while (curx > gvars.commcol+4 && isblank(*(dot-1))) { delchar(backchar(1L)); findxy(); } while (curx < gvars.commcol-1 && insertc('\t',1L)) findxy(); if (*(dot-1) != '\t') insertc('\t',1L); if (dot==z || *dot != '(') { insertstr("(* *)",6L); backchar(3L); } else forwchar(3L); break; case ADA: begofline(); while (((dot < z && *dot != '-') || (dot< z-1 && *(dot+1) != '-')) && *dot != '\n') dot++; findxy(); while (curx > gvars.commcol+4 && isblank(*(dot-1))) { delchar(backchar(1L)); findxy(); } while (curx < gvars.commcol-1 && insertc('\t',1L)) findxy(); if (*(dot-1) != '\t') insertc('\t',1L); if (dot==z || *dot != '-') insertstr("-- ",3L); else forwchar(3L); break; case C: begofline(); while (((dot < z && *dot != '/') || (dot< z-1 && *(dot+1) != '*')) && *dot != '\n') dot++; findxy(); while (curx > gvars.commcol+4 && isblank(*(dot-1))) { delchar(backchar(1L)); findxy(); } while (curx < gvars.commcol-1 && insertc('\t',1L)) findxy(); if (*(dot-1) != '\t') insertc('\t',1L); if (dot==z || *dot != '/') { insertstr("/* */",6L); backchar(3L); } else forwchar(3L); break; } /* switch */ } pushpopmark(a) long a; { register int i; char *tdot; if (a == 1) { for (i=15; i > 0; i--) mark[i] = mark[i-1]; *mark=dot; } else { closegap(); tdot= min(*mark,z); for (i=0; i < 15 && mark[i+1] != NIL; i++) mark[i]= mark[i+1]; mark[i] = dot; dot = tdot; } } int tablk(table,str,index) struct tabstruct table[]; char *str; int index; /* Look through table for str. * If one match is found, return index of that. * If more than one, return -(no of matching entries). * If none, return -1 * * Also, fill in as much as is unique in str. * */ { register int i, count = 0; char mstr[80]; *mstr = '\0'; for (i = index; table[i].name != NIL; i++) if (strsub(table[i].name,str,TRUE,FALSE) == 0) { count++; index = i; if (*mstr == '\0') strcpy(mstr,table[i].name); else while(strsub(table[i].name,mstr,TRUE,FALSE) != 0) mstr[strlen(mstr)-1] = '\0'; if (count==1 && strneq(table[i].name,str,strlen(mstr),TRUE)) break; } if (count == 0) return(-1); else { if (*mstr != '\0') strcpy(str,mstr); if (count == 1) return(index); else return(-count); } } listmatching(table,str) struct tabstruct table[]; char *str; { register int i = -1; typing = FALSE; typeout("Here are the possible completions of what you have typed:"); while (table[++i].name != NIL) if (strsub(table[i].name,str,TRUE,FALSE) == 0 && !typeout(table[i].name)) break; } Bool incbuf(i) long i; { long j; char *p; if (i > 0) { p = sbrk((int) i); if ((int) p != -1) { j = sbrk(0) - p; bufsize += j; if (j >= i) return(TRUE); } } errmes(BF); return (FALSE); } setfillprefix() { char *tdot= dot; begofline(); strncpy(fillprefix,dot,tdot-dot); fillprefix[tdot-dot] = '\0'; dot = tdot; if (!quiet) { echo("Fill Prefix now \""); write(1, fillprefix, strlen(fillprefix)); pchar('"'); } } /* * Gap routines. gaps points to first position in gap. * gape points to first character after gap. If gaps=gape * then gap is empty */ Bool gapto(pos,size) char *pos; long size; { long stepsize; #ifdef PDP11 stepsize = 64; #else stepsize = 1024; #endif closegap(); pos = min(z, pos); if ((z + size <= buf + bufsize) || incbuf(size + stepsize - ((long)sbrk(0) + size) % stepsize)) { gaps = pos; gape = pos+size; blockmove(gaps, gape, (long)(z-gaps)); return (TRUE); } else return(FALSE); } closegap() { if (gaps < z) blockmove(gape, gaps,(long)(z-gaps)); gape = gaps = z; } char *func_name(fn, fname) /* Get the printname for a function, */ int (*fn)(); /* given a pointer to it. */ char *fname; { register int i = 0; while(x_comtab[i].name != NIL && x_comtab[i].funcp != fn) i++; if (x_comtab[i].funcp == fn) strcpy(fname, x_comtab[i].name); else *fname = '\0'; return(fname); } revertfile() { char *tdot,*thome; tdot=dot; thome = home; readfile(); dot = min(tdot,z); if (thome <= z) home = thome; } @//E*O*F scame0.c// chmod u=rw,g=,o= scame0.c echo x - scame1.c sed 's/^@//' > "scame1.c" <<'@//E*O*F scame1.c//' /* SCAME scame1.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; # include "scame.h" extern int k_ubk(); /* clearecho makes the echo line disappear after a while */ clearecho() { sleep(1); echo(NIL); } /* select buffer */ selectbuffer() { char c; char bufname[80]; char tprompt[80]; strcpy(tprompt,"Select Buffer"); if (oldbuf >=0) sprintf(&tprompt[strlen(tprompt)]," (%s)",buftab[oldbuf].name); strcat(tprompt,": "); c = instring(tprompt,bufname,0," \t\033","\007\r"); if (c == '\r' && (*bufname != '\0' || oldbuf >= 0)) { bufname[BUFNAMESIZE-1] = '\0'; fixbuftab(PUT); if (*bufname == '\0') getbuffer(buftab[oldbuf].name); else getbuffer(bufname); } killing = FALSE; } Bool getbuffer(name) char *name; { int i=0; while (i<noofbufs && !strneq(name,buftab[i].name,strlen(name)+1,TRUE)) i++; if (i != bufno && i < MAXBUFS) { if (wtmp(bufno)) { oldbuf = bufno; bufno = i; if (i < noofbufs && rtmp(bufno)) /* old buffer */ fixbuftab(GET); else { /* new buffer */ if (i == noofbufs) noofbufs++; strcpy(cb.name,name); gotobegin(); z = buf; cb.modified = FALSE; *cb.filename = '\0'; cb.mtime = (time_t) 0; setmode(FUNDAMENTAL); cb.minormodes.autofill = 0L; cb.minormodes.overwrite = 0L; updateflag = TRUE; } } } else if (i >= MAXBUFS) { errmes(BTF); return(FALSE); } return (TRUE); } /* kill buffer */ kbuffer() { char c; char bufname[80]; char tprompt[80]; if (noofbufs == 1) { echo("Must have at least one buffer!"); pchar(BELL); return; } sprintf(tprompt,"Kill Buffer (%s): ",cb.name); c = instring(tprompt,bufname,0," \t\033","\007\r"); if (c == '\r') { bufname[BUFNAMESIZE-1] = '\0'; fixbuftab(PUT); if (*bufname == '\0') removebuffer(cb.name); else removebuffer(bufname); } } removebuffer(name) char *name; { int tmplen, i=0; char tf1[FILENAMESIZE],tf2[FILENAMESIZE]; Bool select; select = FALSE; fixbuftab(PUT); wtmp(bufno); while (i<noofbufs && !strneq(name,buftab[i].name,strlen(name)+1,TRUE)) i++; if (i < noofbufs) { if (bufno == i) select = TRUE; else if (bufno > i) bufno--; if (windows == 2) { if (otherbuf == i) onewindow(); else if (otherbuf > i) otherbuf--; } if (oldbuf == i) oldbuf = -1; else if (oldbuf > i) oldbuf--; /* and kill it */ sprintf(tf1,tempfile,ppid,uid); sprintf(tf2,tempfile,ppid,uid); tmplen = strlen(tf1); while(i < noofbufs-1) { buftab[i] = buftab[i+1]; sprintf(&tf1[tmplen],"%d",i); sprintf(&tf2[tmplen],"%d",i+1); if (rename(tf2,tf1) != 0) printf("Cannot rename %s to %s\r\n",tf2,tf1); i++; } noofbufs--; if (select) { if (oldbuf == -1) oldbuf = 0; bufno = oldbuf; rtmp(bufno); fixbuftab(GET); selectbuffer(); } } else errmes(NSB); } /* List Buffers */ listbuffers() { int i,j; char s[150]; fixbuftab(PUT); typing = FALSE; typeout(" Buffer (mode) Filename"); typeout(NIL); for (i=0; i < noofbufs; i++) { s[0] = '\0'; if (buftab[i].modified) strcat(s,"* "); else strcat(s," "); if (i == bufno) strcat(s,"- "); else strcat(s," "); strcat(s,buftab[i].name); strcat(s,": ("); strcat(s,modes[(int)(buftab[i].majormode)]); strcat(s,")"); for (j = strlen(s); j < 35; j++) strcat(s," "); strcat(s,buftab[i].filename); s[79] = '\0'; /* trim if too long */ if (!typeout(s)) break; } } /* wtmp(), rtmp(), fixbuftab() support for temporary files */ Bool wtmp(i) int i; { int f; char s[FILENAMESIZE]; Bool flg; flg=FALSE; sprintf(s, tempfile, ppid, uid); sprintf(&s[strlen(s)], "%d", i); if ((f=creat(s, 0600)) >= 0) { closegap(); if (write(f,buf,z-buf) == z-buf) flg = TRUE; else echo("can't write tempfile"); close(f); } else echo("can't create tempfile!"); return(flg); } Bool rtmp(i) int i; { int f; char s[FILENAMESIZE]; sprintf(s, tempfile, ppid, uid); sprintf(&s[strlen(s)], "%d", i); if ((f = open(s,0)) > -1) { z = buf + read(f, buf, (int) bufsize); close(f); dot = min(dot, z); updateflag = TRUE; return(TRUE); } else { echo("can't read tempfile"); return (FALSE); } } fixbuftab(flg) int flg; { switch(flg) { case (PUT): buftab[bufno] = cb; buftab[bufno].dot = dot - buf; buftab[bufno].home = home - buf; break; case (GET): cb = buftab[bufno]; dot = buf + buftab[bufno].dot; home = buf + buftab[bufno].home; modeline(); } } /* exec() - does a nice system() */ exec(s) char *s; { int c,i; signal(SIGHUP, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); setupterm(FALSE); cur(screenlen-1, 0); write(1,"\n",1); system(s); write(1, more, strlen(more)); setupterm(TRUE); *commandprompt = '\0'; if ((c= inchar(TRUE)) != ' ') unget(c); cls(); for (i=0; i<=screenlen-2; i++) *oldscreen[i]= '\0'; echo(NIL); } /* Tabify - turn spaces into tabs if possible */ tabify() { register char *tdot; int q2,q3,q4; while (dot < z) { dot--; while (++dot < z && (*dot != ' ' || *(dot+1) != ' ' || *(dot+2)!=' ')); if (dot < z) { tdot=dot; while (++dot < z && *dot == ' '); findxy(); q3 = (curx) % TABWID; backchar((long)q3); q2 = dot - tdot; if (q2 > 1) { q4 = (TABWID - 1 + q2) / TABWID; delchar(backchar((long)(q2 - q4))); backchar((long)q4); while (q4--) *dot++ = '\t'; } while(q3--) dot++; } } } /* Saving and restarting SCAME */ Bool restart() { int f; char s[FILENAMESIZE]; long od; /* same as otherdot */ long tz; /* same as bufsize */ sprintf(s, tempfile, ppid, uid); strcat(s, "d"); if ((f = open(s,0)) > -1) { echo("(Continuing)"); read(f, (char *) &noofbufs, sizeof(noofbufs)); read(f, (char *) &bufno, sizeof(bufno)); read(f, (char *) &oldbuf, sizeof(oldbuf)); read(f, (char *) &tz, sizeof(tz)); if (tz) incbuf(tz); read(f, (char *) mark, 16 * sizeof(char *)); read(f, (char *) &od, sizeof(od)); otherdot=buf+od; read(f, (char *) &windows, sizeof(windows)); read(f, (char *) &otherbuf, sizeof(otherbuf)); read(f, (char *) &wintop, sizeof(wintop)); read(f, (char *) &winbot, sizeof(winbot)); if (wintop != 0) winbot = screenlen-3; read(f, (char *) &quiet, sizeof(quiet)); read(f, (char *) &execfd, sizeof(execfd)); read(f, oldsstr, 80); read(f, fillprefix, 80); read(f, tmpmode_string, 80); read(f, (char *) &gvars, sizeof(struct gvarstruct)); read(f, lastinput, LASTINPUTSIZE); read(f, (char *) &lstindex, sizeof(lstindex)); read(f, oldshellcommand, 80); read(f, oldmailname, 80); read(f, (char *) disptab, sizeof(disptab)); read(f, (char *) c_x_disptab, sizeof(c_x_disptab)); read(f, (char *) m_o_disptab, sizeof(m_o_disptab)); read(f, (char *) buftab, noofbufs * sizeof(struct bufstruct)); if (rtmp(bufno)) fixbuftab(GET); modeline(); close(f); clearecho(); return(TRUE); } else return(FALSE); } savescame() { int f; funcp fp; long od; char s[FILENAMESIZE]; Bool flg; *s='\0'; sprintf(s, tempfile,ppid, uid); strcat(s, "d"); if (wtmp(bufno)) { fixbuftab(PUT); flg = FALSE; if ((f=creat(s, 0600)) >= 0) { write(f, (char *) &noofbufs, sizeof(noofbufs)); write(f, (char *) &bufno, sizeof(bufno)); write(f, (char *) &oldbuf, sizeof(oldbuf)); write(f, (char *) &bufsize, sizeof(bufsize)); write(f, (char *) mark, 16 * sizeof(char *)); od = otherdot - buf; write(f, (char *) &od, sizeof(od)); write(f, (char *) &windows, sizeof(windows)); write(f, (char *) &otherbuf, sizeof(otherbuf)); write(f, (char *) &wintop, sizeof(wintop)); write(f, (char *) &winbot, sizeof(winbot)); write(f, (char *) &quiet, sizeof(quiet)); write(f, (char *) &execfd, sizeof(execfd)); write(f, oldsstr, 80); write(f, fillprefix, 80); write(f, tmpmode_string, 80); write(f, (char *) &gvars, sizeof(struct gvarstruct)); write(f, lastinput, LASTINPUTSIZE); write(f, (char *) &lstindex, sizeof(lstindex)); write(f, oldshellcommand, 80); write(f, oldmailname, 80); write(f, (char *) disptab, sizeof(disptab)); write(f, (char *) c_x_disptab, sizeof(c_x_disptab)); write(f, (char *) m_o_disptab, sizeof(m_o_disptab)); write(f, (char *) buftab, noofbufs * sizeof(struct bufstruct)); close(f); flg = TRUE; } else echo("can't create tempfile!"); return(flg); } return(FALSE); } vfile(dir,file, modflg,waitflg,grepstring) char *dir, *file; Bool modflg, waitflg; char *grepstring; { int f; char tline[81]; char mline[80]; char tfile[80]; char *cp; int c; int line; Bool eof; line = wintop; *tfile = '\0'; if (dir != NIL) sprintf(tfile,"%s/",dir); strcat(tfile,file); if ((f=open(tfile,0)) >= 0) { eof = FALSE; *commandprompt='\0'; *tline = '\0'; if (modflg) { sprintf(mline,"SCAME Viewing file: %s",tfile); tmodlin(mline); } while (!eof) { getline(f,tline,min(80,screenwidth),&eof); if (grepstring == NIL || strsub(tline,grepstring,FALSE,TRUE) >= 0) { strcpy(screen[line],tline); if (grepstring != NIL) { cp = screen[line]; while ((cp = index(cp,';')) != NIL) { if (cp > screen[line] && *(cp-1) == '\\') { *(cp-1) = ';'; *cp++ = ' '; } else *cp = '\0'; } } refline(line,FALSE); if (++line > winbot && !eof){ echo(more); if ((c= inchar(FALSE)) != ' '){ unget(c); write(1, " FLUSHED",8); clearecho(); goto flushed; } echo(NIL); line= wintop; } } } /* while */ if (grepstring != NIL) { strcpy(screen[line],"done"); refline(line,FALSE); if (++line <= winbot) { screen[line][0] = '\0'; refline(line,FALSE); } } if (waitflg && (c= inchar(FALSE)) != ' ') unget(c); flushed: close(f); updateflag = TRUE; } /* if open */ else echo("Can't find file"); if (modflg) tmodlin(NIL); modeline(); cur(cury,curx); typing = FALSE; killing = FALSE; } /* vfile */ /* Type Out (a bit like FT in TECO) */ Bool typeout(str) char *str; { static int line; char c; updateflag = TRUE; if (!typing) { if (str != NIL) strcpy(screen[wintop],str); else *screen[wintop] = '\0'; refline(wintop,FALSE); typing = TRUE; line = wintop+1; *screen[line] = '\0'; refline(line,FALSE); } else { if (line == winbot+1) { echo(more); *commandprompt='\0'; if ((c = inchar(TRUE))!= ' ') { unget(c); write(1," FLUSHED",8); clearecho(); return (FALSE); } echo(NIL); line = wintop; *screen[line] = '\0'; refline(line,FALSE); } if (str != NIL) strcpy(screen[line],str); else *screen[line] = '\0'; refline(line++,FALSE); if (line <= winbot) { *screen[line] = '\0'; refline(line,FALSE); } } return (TRUE); } /* Find File. * Search through buffers for a file. Create a new buffer * for it if it isn't found. */ findfile() { int i,c; Bool flg; char tstr[FILENAMESIZE], bufname[FILENAMESIZE]; char tprompt[80]; struct stat fst; basename(cb.filename,bufname,TRUE); ffloop: flg = FALSE; i = 0; while (i < noofbufs && strcmp(cb.filename,buftab[i].filename) != 0) { if (strneq(bufname,buftab[i].name,strlen(bufname)+1,TRUE)) flg = TRUE; i++; } if (i < noofbufs) { getbuffer(buftab[i].name); if (stat(cb.filename, &fst) == 0 && fst.st_mtime > cb.mtime) { vfile(scamelib,"changedfile",FALSE,FALSE,NIL); if (yesorno("Restore file from disk") == 1) revertfile(); typing = FALSE; } } else { if (flg) { sprintf(tprompt, "Name of buffer or RETURN to reuse %s: ", bufname); c = instring(tprompt, tstr,0," \t\033","\007\r"); if (c == '\007') { fixbuftab(GET); return; } else if (*tstr != '\0') { strcpy(bufname, tstr); goto ffloop; } } bufname[BUFNAMESIZE-1] = '\0'; strcpy(tstr,cb.filename); if (getbuffer(bufname)) { strcpy(cb.filename,tstr); readfile(); findmode(); } else fixbuftab(GET); } killing = FALSE; } hangup() { char tfile[FILENAMESIZE], hupfile[FILENAMESIZE]; char command[200]; char *cp; int i; sprintf(tfile,tempfile,ppid, uid); strcat(tfile,"0"); savescame(); for (i = 0; i < noofbufs; i++) { tfile[strlen(tfile)-1] = '0' + i; if (buftab[i].filename[0] != '\0') { strncpy(hupfile, (cp= rindex(buftab[i].filename, '/')) == NIL? buftab[i].filename: &cp[1],10); hupfile[10]='\0'; strcat(hupfile,".hup"); sprintf(command, "cp %s %s",tfile,hupfile); system(command); } } exitscame(1); } @//E*O*F scame1.c// chmod u=rw,g=r,o= scame1.c echo Inspecting for damage in transit... temp=/tmp/shar$$; dtemp=/tmp/.shar$$ trap "rm -f $temp $dtemp; exit" 0 1 2 3 15 cat > $temp <<\!!! 308 857 6343 main.c 253 895 5497 screen.c 1248 3265 23107 scame0.c 578 1569 12452 scame1.c 2387 6586 47399 total !!! wc main.c screen.c scame0.c scame1.c | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp if [ -s $dtemp ] then echo "Ouch [diff of wc output]:" ; cat $dtemp else echo "No problems found." fi exit 0
leif@erix.UUCP (Leif Samuelsson) (02/16/85)
# This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by erisun!leif on Sat Feb 9 18:14:11 MET 1985 # Contents: scame2.c strings.c io.c files.c macro.c k_funcs.c echo x - scame2.c sed 's/^@//' > "scame2.c" <<'@//E*O*F scame2.c//' /* SCAME scame2.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; # include "scame.h" /* Change Directory */ changedir() { char c; char dirname[80], homedir[80]; char tprompt[80]; strcpy(homedir,getenv("HOME")); sprintf(tprompt, "Change to Directory (%s): ", homedir); *dirname = '\0'; do { c = instring(tprompt, dirname, 0 ," \t", "\007\r\033"); if (c == ESC) { if (*dirname == '\0') strcpy(dirname,homedir); else pchar(BELL); } } while (c == ESC); if (c == '\r') { if (*dirname != '\0') buildfilename(homedir, dirname); if (chdir(homedir) < 0) { echo("Couldn't change directory"); pchar(BELL); } else { getwd(currentdir); modeline(); echo(NIL); } } else echo(NIL); } /* View Working Directory */ viewworkingdir() { echo("Working directory = "); strout(currentdir); } /* Delete Blank Lines */ # ifdef COMMENT delblanklines() { char *tdot1, *tdot2; Bool blankline; closegap(); tdot1 = dot; do { blankline = TRUE; tdot2 = tdot1; while (tdot1 < z && *tdot1 != '\n') { if (!isblank(*tdot1)) blankline = FALSE; tdot1++; } if (blankline && tdot1<z) tdot1++; } while (blankline && tdot1 < z); delchar((long)(tdot2 - dot)); killing=FALSE; } #endif /* Shell Command */ char oldshellcommand[80]=""; shellcommand() { char c, tstr[80], tprompt[80]; strcpy(tprompt,"Shell command"); if (*oldshellcommand != '\0') sprintf(&tprompt[strlen(tprompt)]," (\"%s\")",oldshellcommand); strcat(tprompt,": "); *tstr= '\0'; do { c=instring(tprompt,tstr,strlen(tstr),"","\r\007\033"); if (c == ESC) { if (*tstr == '\0') { strcpy(tstr,oldshellcommand); } else pchar(BELL); } } while (c == ESC); if (c == '\r') { if (*tstr != '\0') strcpy(oldshellcommand,tstr); exec(oldshellcommand); } else echo (NIL); } /* Send Mail */ char oldmailname[80]=""; mailbuffer() { #ifdef MAIL char c, tstr[80], tprompt[80]; strcpy(tprompt,"Mail Buffer to"); if (*oldmailname != '\0') sprintf(&tprompt[strlen(tprompt)]," (\"%s\")",oldmailname); strcat(tprompt,": "); *tstr= '\0'; do { c=instring(tprompt, tstr,strlen(tstr)," \t","\r\007\033"); pchar('\r'); if (c == ESC) { if (*tstr == '\0') { strcpy(tstr,oldmailname); } else pchar(BELL); } } while (c == ESC); if (c==13) { if (*tstr == '\0') strcpy(tstr,oldmailname); else strcpy(oldmailname,tstr); if (*tstr != '\0') pipe_to(MAIL, tstr, NIL, NIL, buf, z); else echo("Mail not sent - no addressee"); } else echo(NIL); #else errmes(NYI); #endif } checkmail(report) Bool report; { static time_t fm; time_t tfm; tfm = filemodified(mailfile); if (report && tfm > fm && filesize(mailfile) > 0) { echo("New mail for you, "); strout(username); pchar(BELL); } fm = tfm; chkmailcnt = gvars.mail_check_interval; } /* Multiple windows */ twowindows() { if (windows == 1) { windows = 2; otherdot = dot; otherhome = home; otherbuf = bufno; winbot = screenlen/2 - 2; modeline(); update(); wintop = screenlen/2; winbot = screenlen-3; upd2(); modeline(); } else errmes(A2W); killing = FALSE; } onewindow() { if (windows > 1) { windows = 1; wintop = 0; winbot = screenlen-3; upd2(); modeline(); updateflag = TRUE; } else errmes(O1W); } otherwindow() { int i; char *h; if (windows > 1) { if (wintop == 0) { wintop = winbot + 2; winbot = screenlen - 3; } else { winbot = wintop - 2; wintop = 0; } if (bufno == otherbuf) { if (otherdot + GAPDIST > gaps) closegap(); h = dot; dot = min(z,otherdot); otherdot = h; h = home; home = min(z,otherhome); otherhome = h; } else { closegap(); otherdot = dot; otherhome = home; i = bufno; fixbuftab(PUT); getbuffer(buftab[otherbuf].name); otherbuf = i; } } else errmes(O1W); } scrollotherwindow(i) long i; { if (windows > 1) { otherwindow(); upd2(); nextscreen(i); update(); modeline(); otherwindow(); } else errmes(O1W); } growwindow(i) long i; { char *tdot; if (windows > 1) { if (wintop == 0 && winbot < screenlen-5-i) { winbot += i; upd2(); modeline(); updateflag = TRUE; } else if (winbot == screenlen-3 && wintop > i + 2) { wintop -= i; otherwindow(); update(); modeline(); otherwindow(); if (home > buf) { tdot = dot; scroll(-i); dot = tdot; } updateflag = TRUE; } else echo("\007Windows need at least two lines."); } } pipe_to(prog, arg1, arg2, arg3, from, to) char *prog, *arg1, *arg2, *arg3, *from, *to; { int p[2], status; closegap(); pipe(p); if (fork() == 0) { close(p[1]); close(0); dup(p[0]); execl(prog, "", arg1, arg2, arg3, 0); write(2, "Can't find ", 10); write(2, prog, strlen(prog)); exit(1); } close(p[0]); write(p[1], from, to-from); close(p[1]); wait(&status); } pipe_through(prog, arg1, arg2, arg3, from, to) char *prog, *arg1, *arg2, *arg3, *from, *to; { int p[2], status; char tfile[FILENAMESIZE], *tdot; if (!fileexists(prog)) { echo("Can't find "); strout(prog); return; } sprintf(tfile,tempfile,ppid,uid); strcat(tfile,"t"); closegap(); pipe(p); if (fork() == 0) { close(p[1]); close(0); dup(p[0]); close(1); creat(tfile, 0600); execl(prog, "", arg1, arg2, arg3, 0); exit(1); } close(p[0]); write(p[1], from, to-from); close(p[1]); wait(&status); if (status) { echo("Can't run "); strout(prog); } else { tdot = dot; dot = from; delchar((long)(to-from)); insertfile(tfile); dot = min(tdot, z); cb.modified = TRUE; } } saveforundo(fn) int (*fn)(); { int f; Bool flg; char tfile[FILENAMESIZE]; closegap(); flg=FALSE; sprintf(tfile,tempfile,ppid,uid); strcat(tfile,"u"); if ((f=creat(tfile, 0600)) >= 0) { write(f,&fn,sizeof(fn)); write(f,&cb.modified,sizeof(cb.modified)); if (write(f,buf,z-buf) == z-buf) flg = TRUE; else echo("can't write tempfile"); close(f); } else echo("can't create tempfile!"); return(flg); } undo() { int f; char tfile[FILENAMESIZE], ufile[FILENAMESIZE]; char s[80], *p; int (*fn)(); sprintf(tfile,tempfile,ppid,uid); strcat(tfile,"t"); sprintf(ufile,tempfile,ppid,uid); strcat(ufile,"u"); strcpy(s,"Undo last "); p = &s[strlen(s)]; unlink(tfile); if ((f=open(ufile,0)) >= 0) { read(f, &fn, sizeof(fn)); func_name(fn, p); if (yesorno(s) == 1) { rename(ufile,tfile); saveforundo(undo); read(f,&cb.modified,sizeof(cb.modified)); z = buf + read(f,buf,(int) bufsize); dot = min(dot,z); updateflag = TRUE; } close(f); clearecho(); } else echo("Sorry, can't undo"); modeline(); } writeregion() { char tfile[FILENAMESIZE]; int c; long howmany; char *from= dot; c = instring("Write Region to file: ",tfile,0," \t\033","\r\007"); if (c==13 && *tfile != '\0') { adjustmark(); howmany= *mark - dot; if (howmany < 0) { howmany = -howmany; from = *mark; } if (max(dot,*mark) >= gaps) closegap(); if (filncpy(tfile, from, howmany, 0666)) clearecho(); killing=FALSE; } } /* Fill & Justify */ fillregion() { char *tdot, *tmpCS; adjustmark(); if (dot == *mark) return; if (dot > *mark) exchgdotmark(); gapto(*mark + 1, GAPSIZE); /* if (*(*mark - 1) == '\n') (*mark)--; */ tdot = dot; tmpCS = CS; CS = NIL; while (dot < *mark) { while (dot < *mark && isblank(*dot) || *dot == '\n') { delchar(1L); (*mark)--; } linpos = 0; while (linpos < cb.lvars.fillcolumn && dot < *mark) { while(dot<*mark && !isblank(*dot) && *dot != '\n') dot++; if (dot == *mark-1 && *dot == '\n') dot++; while (dot<*mark && (isblank(*dot) || *dot == '\n')){ delchar(1L); (*mark)--; } if (dot < *mark) { insertc(' ',1L); (*mark)++; findxy(); } } if (linpos > cb.lvars.fillcolumn) { while (dot>buf && isblank(*(dot-1))) dot--; while (dot>buf && !isblank(*(dot-1))) dot--; if (dot>buf) *(dot-1) = '\n'; } } *mark = tdot; CS = tmpCS; } justifyregion() { char *tdot; int blanks,n; tdot = min(dot, *mark); adjustmark(); if (dot > *mark) exchgdotmark(); while (dot < *mark - 1) { begofline(); blanks = 0; while (dot < *mark - 1 && isblank(*dot)) { delchar(1L); (*mark)--; } while (dot < *mark - 1 && *dot != '\n'){ while(dot<*mark - 1 && !isblank(*dot) && *dot != '\n') dot++; while (dot<*mark-1 && isblank(*dot)) { delchar(1L); (*mark)--; } if (dot < *mark-1 && *dot != '\n') { insertc(' ',1L); (*mark)++; blanks++; } } findxy(); n = cb.lvars.fillcolumn - linpos; while (n > 0 && blanks > 0) { begofline(); while (n > 0 && dot < *mark - 1 && *dot != '\n') { while(dot<*mark - 1 && !isblank(*dot) && *dot != '\n') dot++; while(dot<*mark - 1 && isblank(*dot) && *dot != '\n') dot++; if (dot < *mark-1 && *dot != '\n') { insertc(' ',1L); (*mark)++; n--; } } } passline(1L); } *mark = tdot; } breakline() { char *tdot, *tdot2; findxy(); if (linpos > cb.lvars.fillcolumn) { tdot = dot; begofline(); tdot2 = dot; linpos = 0; while (linpos <= cb.lvars.fillcolumn) { while(dot<tdot && isblank(*dot)) dot++; while(dot<tdot && !isblank(*dot)) dot++; findxy(); } while (dot>tdot2 && !isblank(*(dot-1))) dot--; while (dot>tdot2 && isblank(*(dot-1))) dot--; while (dot<tdot && isblank(*dot)) { delchar(1L); tdot--; } if (*(dot-1) != '\n') { insertc('\n', 1L); tdot++; } insertstr(fillprefix, (long) strlen(fillprefix)); dot = tdot + strlen(fillprefix); } } showrightparen() { char *tdot; register int level; static Bool echoed = FALSE; if (cb.lvars.disp_matching_paren != 0L) { upd2(); tdot = dot--; level = 1; if (cb.lvars.disp_matching_paren > 0L) { while (level > 0) { while (dot > buf && *(--dot) != '(' && *dot != ')'); if (*dot == '(') level--; else if (*dot == ')') level++; if (level > 0 && dot == buf) level = -1; } if (level == 0) { if (dot < home) { char *tdot2, *tdot3; tdot2 = dot; begofline(); tdot3 = dot; endofline(); echo(NIL); strnout(tdot3, (int) (tdot2-tdot3)); invmod(TRUE); outchar(*tdot2++, FALSE); invmod(FALSE); strnout(tdot2, (int) (dot-tdot2)); echoed = TRUE; } else { if (echoed) { echo(NIL); echoed = FALSE; } findxy(); cur(cury, curx); suspend(cb.lvars.disp_matching_paren * 1000, TRUE); } } else { pchar(BELL); if (echoed) { echo(NIL); echoed = FALSE; } } } else { while (level > 0) { while (dot > home && *(--dot) != '(' && *dot != ')'); if (*dot == '(') level--; else if (*dot == ')') level++; if (level > 0 && dot == home) level = -1; } if (level == 0) { findxy(); cur(cury, curx); suspend(abs(cb.lvars.disp_matching_paren) * 1000, TRUE); } dot = tdot; findxy(); } dot = tdot; } } @//E*O*F scame2.c// chmod u=rw,g=r,o= scame2.c echo x - strings.c sed 's/^@//' > "strings.c" <<'@//E*O*F strings.c//' /* SCAME strings.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; # include "scame.h" Bool strneq(s1,s2,i,swedish) /* Are s1 and s2 equal? */ register char *s1,*s2; register int i; Bool swedish; { while(i-- > 0 && upcase(*s1,swedish)==upcase(*s2,swedish)) { s1++; s2++; } return (i == -1); } int strsub(s1,s2,swedish,anywhere) /* Is s2 a substring of s1? */ char *s1,*s2; Bool swedish, anywhere; { register char *t1, *t2, *tt1, *tt2; tt1 = s1; tt2 = s2; do { t1=tt1; t2=tt2; while(upcase(*t1,swedish) == upcase(*t2,swedish)) { if (*t1 == '\0') return(tt1-s1); *t1++; *t2++; } if (*t2 == '\0') return(tt1-s1); } while (anywhere && *(++tt1) != '\0'); return (-1); } Bool isblank(c) char c; { return (c == ' ' || c == '\t'); } int strsize(str) char *str; { register int i=0; while (*str != '\0') { i = i + 1 + (*str < ' ' || *str > '~'); str++; } return (i); } Bool endofquantp(q,p) enum quantity_t q; char *p; /* Is *p outside of quantity? */ { char c; c = *p; switch (q) { case WORD: switch (cb.majormode) { case LISP: return((Bool) (c < '!' || c > '~' || index("()[]';", c))); case SWEDISH: return((Bool) (c < '0' || (c > '9' && c < 'A') || (c > ']' && c < 'a') || c > '}')); default: return((Bool) (c < '0' || (c > '9' && c < 'A') || (c > 'Z' && c < 'a') || c > 'z')); } break; case LINE: return((Bool) (p > buf && *(p-1) != '\n')); default: return(FALSE); } } basename(file,base,removext) char *file, *base; Bool removext; { char *cp; char tstr[FILENAMESIZE]; strcpy(tstr,(cp= rindex(file,'/')) == NIL? file: &cp[1]); if (removext && (cp = rindex(tstr,'.')) != NIL && cp != tstr) *cp = '\0'; strcpy(base,tstr); } #ifndef BSD42 char *index(str, c) char *str, c; { while(*str && *str != c) str++; if (*str) return(str); else return(NIL); } char *rindex(str, c) char *str, c; { register char *tp; if (*str) { tp = str + strlen(str) - 1; while (tp >= str && *tp != c) tp--; if (tp >= str) return(tp); else return(NIL); } else return(NIL); } #endif initupcase() { register int i; for (i=0; i < 512; i++) { upcasearr[i] = nupcasarr[i] = ((i & 0177) >= 'a' && (i & 0177) <= 'z') ? (i & 0737) : i; #ifdef COMMENT locasearr[i] = ((i & 0177) >= 'A' && (i & 0177) <= 'Z') ? (i | 0040) : i; #endif } } @//E*O*F strings.c// chmod u=rw,g=r,o=r strings.c echo x - io.c sed 's/^@//' > "io.c" <<'@//E*O*F io.c//' /* SCAME io.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; /* This file contains functions for input/ouput, * and other miscellaneous primitives. */ # include "scame.h" # include "k_funcs.h" #ifdef S5 # include <termio.h> #else # include <sgtty.h> #endif /* Variables for saving original terminal parameters */ #ifdef S5 struct termio templ, ttparms; #else struct sgttyb templ, ttparms; struct tchars oldtchars, tmptchars = { -1, 28, -1, -1, -1, -1 }; struct ltchars oldltchars, tmpltchars = { -1, -1, -1, -1, -1, -1 }; #endif /* Terminal attributes */ char tbuf[1024]; Bool BS; char *AL, *BC, *CD, *CL, *CE, *CM, *CR, *CS, *DL, *UP, *HO, *KE, *KS, *ND, *NL, *SE, *SO, *SR, *TI, *TE; short ospeed; pchar(c) char c; { /* int ii,jj; ii=0; for (jj=0; jj<=7;jj++) if (c & (1<<jj)) ii++; if (~ (ii & 1)) c += 128; */ c &= (char) 127; write(1, &c, 1); } putchar_x(c) char c; { putchar(c); } tputs_x(s) char *s; { tputs(s, 0, putchar_x); fflush(stdout); } pstring(s) char *s; { write(1, s, strlen(s)); } int hpos, vpos; ttyraw() { /* set tty raw mode */ #ifdef S5 /* stty -icrnl -onlcr -isig -icanon -echo eof */ ioctl(0, TCGETA, &templ); ttparms = templ; ttparms.c_iflag &= ~ICRNL; ttparms.c_oflag &= ~ONLCR; ttparms.c_lflag &= ~(ISIG | ICANON | ECHO); ttparms.c_cc[4] = 1; /* When ICANON is off, EOF char value means */ /* number of characters to buffer on input */ ioctl(0, TCSETA, &ttparms); #else gtty(0,&templ); ttparms = templ; ttparms.sg_flags |= RAW; ttparms.sg_flags &= ~(CRMOD | ECHO); stty(0,&ttparms); ioctl(0, TIOCGETC, &oldtchars); ioctl(0, TIOCGLTC, &oldltchars); #endif signal(SIGHUP, hangup); signal(SIGINT,SIG_IGN); #ifdef SIGTSTP signal(SIGTSTP, stop); #endif } push() { int status; register int i; char *shell; if (fork()==0) { signal(SIGHUP, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); setupterm(FALSE); echo("Return to SCAME with "); #ifdef TIOCGETC outchar(oldtchars.t_eofc, TRUE); #else #ifdef S5 outchar(templ.c_cc[4], TRUE); #else outchar('\004', TRUE); /* ^D */ #endif #endif pchar('\n'); shell = getenv("SHELL"); if (shell == NIL || *shell == '\0') shell = "/bin/sh"; execl(shell,"sh <from scame>",0); echo("no shell?"); exit(1); } wait(&status); setupterm(TRUE); cls(); vpos=0; hpos=0; upd2(); modeline(); for (i=0; i<=screenlen-2; i++) *oldscreen[i]='\0'; killing=FALSE; } ttycbreak() { /* set tty cbreak mode */ #ifdef S5 if (gvars.cbreak_mode) ttparms.c_lflag |= ISIG; else ttparms.c_lflag &= ~ISIG; #else #ifdef CBREAK if (gvars.cbreak_mode) ttparms.sg_flags = CBREAK | (ttparms.sg_flags & ~ RAW); else ttparms.sg_flags = RAW | (ttparms.sg_flags & ~ CBREAK); stty(0,&ttparms); ioctl(0, TIOCSETC, &tmptchars); ioctl(0, TIOCSLTC, &tmpltchars); #endif #endif } char *termtyp; gettermtype() { char tptr[1024]; char *tbufptr; termtyp=getenv("TERM"); switch(tgetent(tptr,termtyp)) { case -1: printf("Can't read termcap\n"); exitscame(1); case 0: printf("Can't find your terminal type (%s) in termcap\n", termtyp); exitscame(1); } tbufptr=tbuf; gvars.hackmatic = tgetflag("km", &tbufptr); /* terminal has META */ gvars.system_output_holding = tgetflag("xx", &tbufptr); /* no ^S/^Q */ AL = tgetstr("al", &tbufptr); BC = tgetstr("bc", &tbufptr); BS = tgetflag("bs",&tbufptr); CD = tgetstr("cd", &tbufptr); CL = tgetstr("cl", &tbufptr); CE = tgetstr("ce", &tbufptr); CM = tgetstr("cm", &tbufptr); CS = tgetstr("cs", &tbufptr); DL = tgetstr("dl", &tbufptr); HO = tgetstr("ho", &tbufptr); KE = tgetstr("ke", &tbufptr); KS = tgetstr("ks", &tbufptr); ND = tgetstr("nd", &tbufptr); NL = tgetstr("nl", &tbufptr); SO = tgetstr("so", &tbufptr); SE = tgetstr("se", &tbufptr); SR = tgetstr("sr", &tbufptr); TI = tgetstr("ti", &tbufptr); TE = tgetstr("te", &tbufptr); UP = tgetstr("up", &tbufptr); screenwidth = min(tgetnum("co"), SCRDIMX); screenlen = min(tgetnum("li"), SCRDIMY); if (screenwidth < 2 || screenlen < 4 || !CL || (!CM && !(HO && ND)) || !UP) { printf("Sorry, but your terminal appears to be too dumb.\n"); exitscame(1); } } setupterm(flg) /* If flg==TRUE, set line in raw mode and */ Bool flg; /* initialize the terminal,otherwise restore */ { if (flg) { ttyraw(); if (KS) tputs_x(KS); /* Keypad on */ if (TI) tputs_x(TI); /* start CM mode */ if (!gvars.hackmatic) { gvars.cbreak_mode = 1L; ttycbreak(); } } else { if (KE) tputs_x(KE); /* Restores Keypad */ if (TE) tputs_x(TE); /* exit CM mode */ #ifdef S5 /* stty icrnl icanon isig onlcr echo eof */ ioctl(0, TCSETA, &templ); #else stty(0,&templ); ioctl(0, TIOCSETC, &oldtchars); ioctl(0, TIOCSLTC, &oldltchars); #endif } } cls() /* Clear screen */ { tputs_x(CL); hpos = vpos = 0; } cleol(cd_ok) Bool cd_ok; { /* Clear to end of line */ if (CE != NIL) tputs_x(CE); else if (cd_ok && CD != NIL) tputs_x(CD); /* Clear to end of screen */ else { int i; /* A very poor simulation, should be avoided */ for (i=0; i<15; i++) pchar(' '); for (i=0; i<15; i++) pchar('\b'); } } do_CM(y,x) register int y,x; { int i; extern char *tgoto(); if (CM != NIL) tputs_x(tgoto(CM,x,y)); else { tputs_x(HO); for (i=0; i<y; i++) { if (NL) tputs_x(NL); else pchar('\n'); } for (i=0; i<x; i++) tputs_x(ND); } } cur(y,x) /* Move cursor to line y, column x */ register int y,x; /* where 0 < y < screenlen-1 */ { /* 0 < x < screenwidth-1 */ if (x != hpos || y != vpos) { if (x == 0 && y == 0 && HO) tputs_x(HO); else if (y == vpos) { if (x == 0 && CR) tputs_x(CR); else if (x == hpos-1 && (BC || BS)) { if (BC) tputs_x(BC); else pchar('\b'); } else if (x == hpos+1 && ND) tputs_x(ND); else do_CM(y,x); } else if (x == hpos) { if (y == vpos-1 && UP) tputs_x(UP); else if (y == vpos+1) { if (NL) tputs_x(NL); else pchar('\n'); } else do_CM(y,x); } else do_CM(y,x); hpos = x; vpos = y; } } vtscroll(i,lin1) /* Scroll region between lin1 and */ int i,lin1; /* winbot i lines upwards */ { register int j; char str[10]; extern char *tgoto(); if (CS != NIL) { tputs_x(tgoto(CS,winbot,lin1)); hpos = vpos = 0; if (i>0) { cur(winbot,0); for (j = 0; j < i; j++) tputs_x(NL); for (j = lin1; j <= winbot-i; j++) strcpy(oldscreen[j],oldscreen[j+i]); for (j = winbot+1-i; j <= winbot; j++) *oldscreen[j] = '\0'; } else if (i<0) { cur(lin1,0); for (j = 0; j > i; j--) tputs_x(SR); for (j = winbot; j >= lin1-i; j--) strcpy(oldscreen[j],oldscreen[j+i]); for (j = lin1; j < lin1-i; j++) *oldscreen[j] = '\0'; } tputs_x(tgoto(CS,screenlen-1,0)); hpos = vpos = 0; } else if (winbot == screenlen-3) { if (i > 0 && DL != NIL) { cur(lin1,0); for (j = 0; j < i; j++) tputs_x(DL); for (j = lin1; j <= screenlen-2-i; j++) strcpy(oldscreen[j],oldscreen[j+i]); for (j = screenlen-1-i; j <= screenlen-2; j++) *oldscreen[j] = '\0'; } else if (i < 0 && AL != NIL) { cur(lin1,0); for (j = 0; j > i; j--) tputs_x(AL); if (CD != NIL) { cur(screenlen-2,0); tputs_x(CD); } for (j = screenlen-3; j >= lin1-i; j--) strcpy(oldscreen[j],oldscreen[j+i]); *oldscreen[screenlen-2] = '\0'; for (j = lin1; j < lin1-i; j++) *oldscreen[j] = '\0'; } } } /* Check if there is typeahead */ #ifdef PDP11 int kmemfd; inittypeaheadcheck() { int c; if ((kmemfd = open("/dev/kmem",0))<0){ write(2,"Can't sense KBD\r\n", 16); return; } lseek(kmemfd, 0140544L, 0); read(kmemfd, &c, 2); /* tty */ lseek(kmemfd, (long) c + 2, 0); } #endif Bool typeahead() { int n; # ifdef FIONREAD ioctl(0, FIONREAD, &n); # else # ifdef PDP11 lseek(kmemfd, -2L, 1); read(kmemfd,&n,2); # else n = 0; # endif # endif return(n != 0 || stdin->_cnt || quiet); } outchar(c, verbose) char c; Bool verbose; { if (verbose) { if (c & 0400) { pstring("Control-"); c &= 0377; } if (c & 0200) { pstring("Meta-"); c &= 0177; } switch (c) { case '\010': pstring("Backspace"); break; case '\011': pstring("Tab"); break; case '\012': pstring("Linefeed"); break; case '\r' : pstring("Return"); break; case '\033': pstring("Escape"); break; case ' ' : pstring("Space"); break; case DEL : pstring("Rubout"); break; default : if (c < ' ' || c==DEL) { pchar('^'); hpos++; c = (c+64) & 0177; } pchar(c); hpos++; } } else { if ((c < ' ' && c != '\t') || c==DEL) { pchar('^'); hpos++; c = (c+64) & 0177; } pchar(c); hpos++; } } strnout(str,len) char *str; int len; { while(len--) outchar(*str++, FALSE); } strout(str) char *str; { while(*str) outchar(*str++, FALSE); } invmod(flg) Bool flg; { switch (flg) { case TRUE: if (SO != NIL) tputs_x(SO); break; case FALSE:if (SE != NIL) tputs_x(SE); break; } } vt100a(asciiflg) /* Change character set */ Bool asciiflg; { if (strneq(termtyp,"VT100",5,TRUE)) { if (asciiflg) pchar('\017'); else pstring("\033)1\016"); } } errmes(code) enum errcode_t code; { char *s; pchar(BELL); switch (code) { case A2W: s = "A2W Already 2 Windows"; break; case CCF: s = "CCF Can't Create File"; break; case BF: s = "BF Buffer Full"; break; case BTF: s = "BTF Buffer Table Full"; break; case FTB: s = "FTB File Too Big"; break; case FTF: s = "FTF File Table Full"; break; case ILA: s = "ILA Illegal Argument"; break; case ILQ: s = "ILQ Illegal Quantity"; break; case MTF: s = "MTF Macro Table Full"; break; case NIB: s = "NIB Character Not In Buffer"; break; case NKM: s = "NKM No Kbd Macro"; break; case NSB: s = "NSB No Such Buffer"; break; case NSF: s = "NSF No Such File"; break; case NYI: s = "NYI Function is Not Yet Implemented"; break; case O1W: s = "O1W Only One Window"; break; case RKM: s = "RKM Recursive Kbd Macro"; break; case SSF: s = "SSF String Space Full"; break; case UBK: s = "UBK Unbound Key"; break; } echo(s); pchar('?'); } echo(str) char *str; { alarm(0); cur(screenlen-1,0); cleol(TRUE); if (str != NIL) { strout(str); echobusy = TRUE; } else echobusy = FALSE; } short yesorno(str) char *str; { int c; *commandprompt = '\0'; yquery: if (!quiet) { echo(str); strout(" (Y or N)? "); } c = upcasearr[inchar(FALSE)]; if (!quiet) outchar(c, TRUE); if (c != 'Y' && c != 'N' && c != '\007') { pchar(BELL); goto yquery; } switch (c) { case 'N': return(0); case 'Y': return(1); default: return(2); } } int instring(prompt, strp, pos, notallowed, exitstr) char *prompt, *strp; int pos; char *notallowed,*exitstr; { int c; int i; Bool gotit; char tstr[80]; *commandprompt='\0'; gotit=FALSE; strcpy(tstr,strp); tstr[pos]= '\0'; if (!quiet) { echo(prompt); strnout(tstr,pos); } while (!gotit) { c=inchar(FALSE); if (c == EOF) return c; if (notallowed != NIL && index(notallowed,c) != 0) pchar(BELL); else if (exitstr != NIL && index(exitstr,c) != 0) { tstr[pos]='\0'; gotit = TRUE; if (c=='\007') { pchar(BELL); outchar(7, FALSE); } else if (c == '\r' && !quiet) { pchar(c); hpos = 0; } } else if (c == gvars.quote_char) { /* ^Q */ c=inchar(FALSE); if (pos < 80 - 1) { if (!quiet) outchar(c, FALSE); tstr[pos++]=c; } else pchar(BELL); } else switch (c) { case '\006': /* ^F */ if (pos < 80 - strlen(cb.filename)) { strcpy(&tstr[pos],cb.filename); if (!quiet) { strout(cb.filename); pos += strlen(cb.filename); } } else pchar(BELL); break; case '\037': /* ^_ */ vfile(scamelib,"instring", FALSE,FALSE,NIL); case '\014': /* ^L */ echo(prompt); strnout(tstr,pos); break; case '\025': /* ^U */ case DEL: /* RubOut */ i = (c == DEL) ? min(1, pos) : pos; while (i-- > 0) { if (!quiet) { pchar('\b'); pchar(' '); pchar('\b'); } pos--; hpos--; if (tstr[pos] < ' ' || tstr[pos] == '\0177') { if (!quiet) { pchar('\b'); pchar(' '); pchar('\b'); } hpos--; } } break; default: if (pos < 80 - 1) { if (!quiet) outchar(c, FALSE); tstr[pos++]=c; } else pchar(BELL); } } strcpy(strp,tstr); return c; } static Bool timedout; catchalarm() { echo(commandprompt); timedout = TRUE; } int inchar(metaallowed) Bool metaallowed; { char pipestr[1000]; char c, *p1, *p2; struct stat s; int ic,l; ignore: if (*commandprompt != '\0' && !quiet) { signal(SIGALRM, catchalarm); alarm(2); } if (execfd >= 0) { nextc: if (read(execfd,&c,1) == 0) return(EOF); if (c == '\\') { if (read(execfd,&c,1) == 0) return(EOF); if (c == '\n') goto nextc; } } else { timedout = FALSE; if ((ic=getchar()) == -1) c = (char) getchar(); else { c = (char) ic; alarm(0); } if (timedout) { if (commandprompt[strlen(commandprompt)-1] == '-') outchar(nupcasarr[c] & 0177, TRUE); else outchar(c & 0177, TRUE); } } if (gvars.system_output_holding && (c == '\023' || c == '\021')) goto ignore; if (!metaallowed || gvars.cbreak_mode || !gvars.hackmatic) c &= 0177; /* Strip parity */ lastinput[lstindex] = c; lstindex = (lstindex + 1) % LASTINPUTSIZE; if (defining_kbd_mac) write(kbdmfd,&c,1); return (c & 0377); } unget(c) char c; { ungetc(c,stdin); lstindex--; if (lstindex < 0) lstindex = LASTINPUTSIZE - 1; } getline(f, s, lim, eof) int f; char s[]; int lim; Bool *eof; { register int i, j, l; static char c='\0'; i=0; if (c != '\0' && lim--) { if (c == '\t') { lim++; j = i; while(i < j + 8 -(j & 7) && lim--) s[i++]=' '; } else s[i++]=c; } while((lim-- > 0) && ((l=read(f,&c,1))==1) && (c != '\n')) if (c == '\t') { lim++; j = i; while(i < j + 8 -(j & 7) && lim--) s[i++]=' '; } else s[i++]=c; *eof = (!l); c = s[i] = '\0'; if (lim == 0 && c != '\n') { read(f,&c,1); if (c == '\n') c='\0'; } return(i); } blockmove(src, dst, len) char *src; register char *dst; long len; { register char *p1, *p2; #ifdef VAX if (len < 65536L) { asm("movc3 12(ap),*4(ap),*8(ap)"); return; } #endif if (dst > src) { p1 = src + len - 1; p2 = dst + len - 1; while (p2 >= dst) *p2-- = *p1--; } else if (dst < src) { p1 = dst + len - 1; p2 = src; while (dst <= p1) *dst++ = *p2++; } } suspend(msecs, break_if_typeahead) long msecs; Bool break_if_typeahead; { long t; t = msecs + time(0) * 1000; while(time(0) * 1000 < t && !(break_if_typeahead && typeahead())); } int b_getkey(s) char *s; { int c; if(!quiet) { echo(s); strout(": "); } *commandprompt = '\0'; c = inchar(TRUE); if ((c & 0177) >= 0 && (c & 0177) < 32) c = (c + '@') | 0400; if (disptab[c] == k_c_prefix) { if (!quiet) strout("C-"); c = inchar(TRUE); if (!quiet) outchar(c, TRUE); c = b_control(c); } else if (disptab[c] == k_m_prefix) { if (!quiet) strout("M-"); c = inchar(TRUE); if (!quiet) outchar(c, TRUE); c = b_meta(c); } else if (disptab[c] == k_c_m_prefix) { if (!quiet) strout("C-M-"); c = inchar(TRUE); if (!quiet) outchar(c, TRUE); c = b_control(b_meta(c)); } return(c); } int b_control(c) /* Set bit nine. */ int c; { if ((c & 0177) >= 0 && (c & 0177) < 32) c += '@'; return(nupcasarr[c] | 0400); } int b_meta(c) /* Set bit eight. */ int c; { if ((c & 0177) >= 0 && (c & 0177) < 32) c = (c + '@') | 0400; return(nupcasarr[c] | 0200); } char *key_name(c, s, verbose) int c; char *s; Bool verbose; { *s = '\0'; if (c & 0400) { if (verbose) strcat(s, "Control-"); else strcat(s, "C-"); c = c & 0377; } if (c & 0200) { if (verbose) strcat(s, "Meta-"); else strcat(s, "M-"); c = c & 0177; } if (c == '\010') strcat(s,"Backspace"); else if (c == '\011') strcat(s,"Tab"); else if (c == '\012') strcat(s,"Linefeed"); else if (c == '\r' ) strcat(s,"Return"); else if (c == '\033') strcat(s,"Escape"); else if (c == ' ' ) strcat(s,"Space"); else if (c == DEL ) strcat(s,"Rubout"); else { if (c < ' ' || c==DEL) { strcat(s,"^"); c = (c+64) & 0177; } sprintf(&s[strlen(s)],"%c",c); } return(s); } funcp getfuncname(prompt) char *prompt; { char str[80], tstr[80], *p; int c, i; *str = '\0'; do { c=instring(prompt, str, strlen(str), "\t", "\007\022\033\r ?"); if (c == 7 || (c == 13 && *str=='\0')) return(0); switch (c) { case '\022': /* ^R */ strcat(str, "^R"); break; case '?': listmatching((struct tabstruct *)x_comtab,str); break; case ' ': strcpy(tstr,str); (void) tablk((struct tabstruct *)x_comtab,str,0); if (strlen(str) == strlen(tstr)) pchar(BELL); else if ((p=index(str+strlen(tstr), ' ')) != NIL) *(p+1) = '\0'; break; default: if ((i = tablk((struct tabstruct *)x_comtab,str,0)) <0) pchar(BELL); } } while (i<0 || index("\022\033 ?", c) != NIL); return(x_comtab[i].funcp); } @//E*O*F io.c// chmod u=rw,g=r,o= io.c echo x - files.c sed 's/^@//' > "files.c" <<'@//E*O*F files.c//' /* SCAME files.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; # include "scame.h" # include <sys/dir.h> # include <pwd.h> # include <ctype.h> #ifndef BSD42 /* * Get working (current) directory */ Bool getwd(path) char path[]; { int file; int off = 0; struct stat d, dd; struct direct dir; int rdev, rino; path[0] = '/'; stat("/", &d); rdev = d.st_dev; rino = d.st_ino; for (;;) { stat(".", &d); if (d.st_ino==rino && d.st_dev==rdev) break; if ((file = open("..",0)) < 0) return(FALSE); fstat(file, &dd); chdir(".."); if(d.st_dev == dd.st_dev) { if(d.st_ino == dd.st_ino) break; do { if (read(file, (char *)&dir, sizeof(dir)) < sizeof(dir)) return(FALSE); } while (dir.d_ino != d.st_ino); } else do { if(read(file, (char *)&dir, sizeof(dir)) < sizeof(dir)) return(FALSE); stat(dir.d_name, &dd); } while(dd.st_ino!= d.st_ino || dd.st_dev != d.st_dev); close(file); { register i, j; i = -1; while (dir.d_name[++i] != 0); if ((off+i+2) > 511) break; for(j=off+1; j>=1; --j) path[j+i+1] = path[j]; off += i+1; path[i+1] = '/'; for(--i; i>=0; --i) path[i+1] = dir.d_name[i]; } } if (off == 0) off = 1; path[off] = '\0'; close(file); chdir(path); return(TRUE); } #endif buildfilename (fout,fin) char *fin, *fout; { register char *p1, *p2, *p3; if (fin[0] == '~' && fin[1] == '/') sprintf(fout, "%s%s", getenv("HOME"), &fin[1]); else if (*fin != '/') sprintf(fout, "%s/%s", currentdir, fin); else strcpy(fout, fin); p2 = p1 = fout; while (*p1) { if ((*p2++ = *p1++) == '/' && p2 > fout + 1) { p3 = p2 - 2; if (*p3 == '/') --p2; /* // */ else if (*p3 == '.') { if (*--p3 == '/') p2 -= 2; /* /./ */ else if (*p3 == '.' && *--p3 == '/') { /* /../ */ while (p3 > fout && *--p3 != '/'); p2 = p3 + 1; } } } } if (*(p2 - 1) == '/') p2--; *p2 = '\0'; } Bool fileexists(fname) char *fname; { struct stat fst; return(stat(fname,&fst)==0); } time_t filemodified(fname) char *fname; { struct stat fst; if (stat(fname,&fst)==0) return(fst.st_mtime); else return((time_t) 0); } off_t filesize(fname) char *fname; { struct stat fst; if (stat(fname,&fst)==0) return(fst.st_size); else return((off_t) 0); } #ifndef BSD42 int rename(f1, f2) char *f1, *f2; { unlink(f2); if (link(f1, f2) == 0 && unlink(f1) == 0) return(0); else return(-1); } #endif copyfile(from, to) char *from,*to; { char s[2*FILENAMESIZE+4]; sprintf(s,"cp %s %s", from, to); system(s); } Bool filncpy(file, tdot, n, mode) /* Copy n chars from tdot to file. */ char *file; char *tdot; long n; unsigned int mode; { int f; Bool flg; flg = FALSE; if ((f=creat(file, mode)) >= 0) { /* What if n > max int ? */ if (write(f, tdot, (int) n) == n) flg = TRUE; close(f); } if (!flg) errmes(CCF); return(flg); } Bool filncat(file, tdot, n) /* Append n chars from tdot to file. */ char *file; char *tdot; long n; { int f; Bool flg; flg = FALSE; if ((f=open(file, 1)) >= 0) { lseek(f,0L,2); /* What if n > max int ? */ if (write(f, tdot, (int) n) == n) flg = TRUE; close(f); } if (!flg) echo("System error, can't save"); return(flg); } Bool filnprep(file, tdot, n) /* Prepend n chars from tdot to file. */ char *file; char *tdot; long n; { int f,tf; Bool flg; char tfile[FILENAMESIZE]; char tbuf[512]; int j; flg = FALSE; sprintf(tfile, tempfile, ppid, uid); strcat(tfile,"t"); if ((tf=creat(tfile, 0600)) >= 0) { /* What if n > max int ? */ if (write(tf, tdot, (int) n) == n) { if ((f = open(file,0)) >= 0) { j = read(f, tbuf, (int)(512 - n % 512)); write(tf, tbuf, j); do { j = read(f, tbuf, 512); write(tf, tbuf, j); } while (j == 512); close(f); unlink(file); flg = TRUE; } close(tf); rename(tfile,file); } } if (!flg) echo("System error, can't save"); return(flg); } @//E*O*F files.c// chmod u=rw,g=r,o= files.c echo x - macro.c sed 's/^@//' > "macro.c" <<'@//E*O*F macro.c//' /* SCAME macro.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; #include "scame.h" definekbdmac(flg) Bool flg; { if (flg) { if (defining_kbd_mac) errmes(RKM); else { if ((kbdmfd = creat(kbdmacfile, 0600)) >= 0) defining_kbd_mac = TRUE; else echo("can't create tempfile!"); } } else if (defining_kbd_mac) { close(kbdmfd); #ifdef BSD42 truncate(kbdmacfile, (int) filesize(kbdmacfile)-2); #endif defining_kbd_mac = FALSE; } modeline(); } savekbdmac(fname) char *fname; { if (fileexists(kbdmacfile)) copyfile(kbdmacfile, fname); else errmes(NKM); } loadkbdmac(fname) char *fname; { if (fileexists(fname)) copyfile(fname, kbdmacfile); else errmes(NSF); } execfile(fn) char *fn; { char cc, fname[FILENAMESIZE]; off_t fz; int tfd, c; tfd = execfd; sprintf(fname,fn); if ((execfd=open(fname,0)) < 0) { sprintf(fname,"%s/%s",getenv("HOME"),fn); if ((execfd=open(fname,0)) < 0) { sprintf(fname,"%s/%s",SCAMELIB,fn); execfd=open(fname,0); } } if (execfd < 0 || (fz = filesize(fname)) == 0) return; quiet = TRUE; editloop(); close(execfd); quiet = FALSE; execfd = tfd; } @//E*O*F macro.c// chmod u=rw,g=r,o=r macro.c echo x - k_funcs.c sed 's/^@//' > "k_funcs.c" <<'@//E*O*F k_funcs.c//' /* SCAME k_funcs.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; /* Functions normally bound to keys */ # include "scame.h" k_void() { pchar(BELL); echo("Internal error. Illegal character: "); outchar(cmdchar, TRUE); } k_ubk() { errmes(UBK); savehpos = TRUE; } k_c_x_dispatch() { strcat(commandprompt, "C-X "); (*c_x_disptab[upcasearr[inchar(FALSE)]])(); } k_m_o_dispatch() { strcat(commandprompt, "O "); (*m_o_disptab[inchar(FALSE)])(); } k_pushpopmark() /* CHECK THIS! */ { pushpopmark(arg); } k_begli() /* Beginning of line */ { begofline(); } k_backchar() { if (arg > 0L) backchar(arg); else forwchar(-arg); } k_exit() { pop_pending=TRUE; } k_exit_to_shell() { exitscame(0); } k_delchar() { if (xarg) killchar(arg); else { delchar(1L); killing=FALSE; } } k_endli() { endofline(); } k_forwchar() { if (arg >0L) forwchar(arg); else backchar(-arg); } k_bell() { pchar(BELL); savehpos = TRUE; } k_tab() { if (gvars.tab_self_insert) insertc('\t',arg); else indent(arg); } k_indnewline() { delhorizspace(); if (cb.minormodes.autofill) breakline(); insertc('\n',1L); if (*fillprefix == '\0') indent(arg); else insertstr(fillprefix, (long) strlen(fillprefix)); } k_killline() { killline(arg); } k_newwindow() { newwindow(arg); } k_newline() { if (cb.minormodes.overwrite) { if (cb.minormodes.autofill && (*dot == '\n' || dot == z)) breakline(); downline(arg); begofline(); } else { if (cb.minormodes.autofill) breakline(); insertc('\n', arg); } } k_downline() { if (arg > 0L) downline(arg); else upline(-arg); savehpos = TRUE; } k_openline() { if (insertc('\n', arg)) { backchar(arg); findxy(); if (cury < screenlen-2) /* can't scroll last line */ vtscroll(-min(winbot+1-cury,(int) arg), cury+1-(curx==0)); } } k_upline() { if (arg > 0L) upline(arg); else downline(-arg); savehpos = TRUE; } k_quote() { strcat(commandprompt,"C-Q "); insertc(inchar(FALSE),arg); } k_risearch() { isearch(TRUE); } k_isearch() { isearch(FALSE); } k_transchar() { transchar(); } k_trnsword() { errmes(NYI); } k_nextscreen() { if (arg < 0L) { arg = -arg; k_prevscreen(); } else if (away < z) { if (xarg) { if (arg < 2 * (winbot-wintop+1) / 3) vtscroll((int)arg, wintop); scroll(arg); while(dot < z && dot < home) dot++; } else nextscreen(); killing=FALSE; } else pchar(BELL); } k_killregion() { killregion(); } k_listbuffers() { listbuffers(); } k_listdir() { exec("ls -c"); } k_findfile() { fixbuftab(PUT); if (getfilename("Find File", cb.filename)) findfile(); } k_indentregion() { saveforundo(k_indentregion); indentregion(arg); } k_lowcaseregion() { saveforundo(k_lowcaseregion); upcaseregion(FALSE); } k_delblanklines() { /* delblanklines(); */ errmes(NYI); } k_savefile() { if (cb.modified) { if (fileexists(cb.filename) && filemodified(cb.filename) > cb.mtime) { vfile(scamelib,"changedfile",FALSE,FALSE,NIL); if (yesorno("Save anyway") != 1) return; } writefile(); } else echo("(No Changes)"); } k_upcaseregion() { saveforundo(k_upcaseregion); upcaseregion(TRUE); } k_visitfile() { if (getfilename("Visit file", cb.filename)) { readfile(); findmode(); } } k_writefile() { if (getfilename("Write file", cb.filename)) { writefile(); findmode(); } } k_exchgdotmark() { exchgdotmark(); } k_startdefkbdmac() { definekbdmac(TRUE); } k_enddefkbdmac() { definekbdmac(FALSE); } k_setfillprefix() { setfillprefix(); } k_onewindow() { onewindow(); } k_twowindows() { twowindows(); } k_setcommcol() { if (xarg) gvars.commcol = min(75L, arg); else gvars.commcol = curx; if (!quiet) { echo("Comment Column = "); printf("%ld",gvars.commcol); fflush(stdout); } } k_whatcursorpos() { whatcursorposition(); } k_selectbuffer() { selectbuffer(); } k_dired() { exec("dired"); } k_executekbdmac() { long targ = arg; if (targ >= 0) { if (defining_kbd_mac) errmes(RKM); else if (fileexists(kbdmacfile)) while (targ--) execfile(kbdmacfile); else errmes(NKM); } } k_setfcol() { if (arg < 0) errmes(ILA); else { findxy(); cb.lvars.fillcolumn = xarg ? arg : linpos; if (!quiet) { echo("Fill Column = "); printf("%ld",cb.lvars.fillcolumn); fflush(stdout); } } } k_markbuffer() { markquant(BUFFER, 1L, TRUE); } k_killbuffer() { kbuffer(); } k_cntlpg() { register char *tdot=dot; register int lines=0; int beflines=0; closegap(); echo("Page has "); while (tdot>buf && *(tdot-1) !='\f')tdot--; while (tdot<z && *tdot != '\f') { if (*tdot == '\n') lines++; if (tdot==dot) beflines=lines; tdot++; } printf("%d lines (%d+%d)",lines,beflines,lines-beflines); fflush(stdout); } k_mailbuffer() { mailbuffer(); } k_otherwindow() { otherwindow(); } k_readmail() { exec("mail"); } k_growwindow() { growwindow(arg); } k_yank() { yank(); } k_logout() { if (yesorno("Logout") == 1) kill(ppid, 9); } k_backtoindent() { backtoindent(); } k_queryreplace() { char old[SCRDIMX],new[SCRDIMX], tprompt[15]; typing = FALSE; tmodlin("- Query Replace -"); strcpy(tprompt,"Replace: "); if (instring(tprompt,old,0,NIL,"\r\007") != '\007' && *old !='\0') { if (strlen(old) <= 20) sprintf(&tprompt[strlen(tprompt)-2]," %s ",old); else *tprompt='\0'; strcat(tprompt,"With: "); if (instring(tprompt,new,0,NIL,"\r\007") != '\007') { saveforundo(k_queryreplace); replace(old, new, TRUE); } } tmodlin(NIL); echo(NIL); } k_dispdate() { char s[26]; long t; time(&t); strcpy(s,ctime(&t)); s[24] = '\0'; echo(s); } k_scrollotherwindow() { scrollotherwindow(arg); } k_appendnextkill() { killing=TRUE; } k_extended() { char tprompt[80]; funcp fp; *tprompt = '\0'; if (xarg) sprintf(tprompt,"%ld ",arg); strcat(tprompt,"M-X "); fp = getfuncname(tprompt); if (fp != (funcp) 0) (*fp)(); } k_help() { help(); } k_backdelchar() { if (xarg) killchar(-arg); else delchar(backchar(1L)); } k_shellcmd() { shellcommand(); } k_makeparens() { insertstr("()",2L); backchar(1L); } k_push() { push(); } k_comment() { comment(); } k_begofbuf() { pushpopmark(1L); gotobegin(); } k_countlregion() { register char *tdot, *tmark; register int lines=0; int beflines=0; closegap(); adjustmark(); echo("Region has "); tdot = min(dot,*mark); tmark = max(dot, *mark); while (tdot<z && tdot < tmark) { if (*tdot == '\n') lines++; if (tdot==dot) beflines=lines; tdot++; } printf("%d lines (%d+%d)",lines,beflines,lines-beflines); fflush(stdout); } k_endofbuf() { pushpopmark(1L); gotoend(); } k_markword() { markquant(WORD, arg, FALSE); } k_begse() { backquant(SENTENCE,arg); } k_backword() { if (arg > 0L) backquant(WORD,arg); else forwquant(WORD,-arg); } k_capitalizeword() { upcaseword(arg,2); } k_killword() { killquant(WORD,arg); } k_endse() { forwquant(SENTENCE,arg); } k_forwword() { if (arg > 0L) forwquant(WORD, arg); else backquant(WORD, -arg); } k_fillregion() { saveforundo(k_fillregion); if (xarg) justifyregion(); else fillregion(); } k_instab() { insertc('\t',arg); } k_killsentence() { killquant(SENTENCE,arg); } k_locasw() { upcaseword(arg,FALSE); } k_ascii() { int i,j; vt100a(TRUE); for (i=wintop; i <= winbot; i++) for (j=0; j<screenwidth; j++) oldscreen[i][j] = 128; } k_sis() { int i,j; vt100a(FALSE); for (i=wintop; i <= winbot; i++) for (j=0; j<screenwidth; j++) oldscreen[i][j] = 128; } /* EDT compatible commands */ k_edt_pf4() { killing = FALSE; xarg = TRUE; killline(arg); } k_edt_comma() { killing = FALSE; killchar(arg); } k_edt_dash() { killing = FALSE; killquant(WORD,arg); } k_edt_0() { passline(arg); } k_edt_8() { passline(16L); } k_upcwd() { upcaseword(arg,TRUE); } k_prevscreen() { char *tdot; if (arg < 0L) { arg = -arg; k_nextscreen(); } else if (home > buf) { if (xarg) { tdot = dot; if (arg < 2 * (winbot-wintop+1) / 3) vtscroll((int)-arg, wintop); scroll(-arg); dot = home; upd2(); if (tdot < away) dot = tdot; else { dot = away; begofline(); } } else prevscreen(); killing=FALSE; } else pchar(BELL); } k_copyregion() { copyregion(); } k_delhorizspace() { delhorizspace(); } k_delindent() { delindent(); } k_notmodified() { cb.modified = FALSE; modeline(); } k_backkillword() { killquant(WORD,-arg); } k_insertc() { if (cmdchar == ' ' && (*dot=='\n' || dot==z)) { if (cb.minormodes.autofill) breakline(); insertc(cmdchar, arg); } else if (cmdchar < 128) { if (!cb.minormodes.overwrite || *dot=='\n' || dot==z) insertc(cmdchar,arg); else { *dot++ = (char) cmdchar; updateflag = TRUE; cb.modified = TRUE; } } if (cmdchar == ')') showrightparen(); } k_c_m_prefix() { control_prefix = TRUE; meta_prefix = TRUE; savearg = TRUE; } k_c_prefix() { control_prefix = TRUE; savearg = TRUE; } k_m_prefix() { meta_prefix = TRUE; savearg = TRUE; } static Bool negarg; k_univarg() { if (xarg) xxarg = TRUE; else { *commandprompt = '\0'; xarg = TRUE; negarg=FALSE; } arg *= 4; strcat(commandprompt, "C-U "); savearg = TRUE; } k_negarg() { if (xarg && !xxarg) { negarg = TRUE; arg = 0; xxarg = TRUE; if (strlen(commandprompt) < 76) { commandprompt[strlen(commandprompt)+1]='\0'; commandprompt[strlen(commandprompt)]='-'; strcat(commandprompt," "); } savearg = TRUE; } else k_insertc(); } k_digit() { if (xarg) { if (xxarg) arg = 10 * arg + (1-2*negarg)*(cmdchar - '0'); else { arg = cmdchar - '0'; xxarg = TRUE; } if (strlen(commandprompt) < 76) { commandprompt[strlen(commandprompt)+1]='\0'; commandprompt[strlen(commandprompt)]=cmdchar; strcat(commandprompt," "); } savearg = TRUE; } else k_insertc(); } k_metadigit() { char c; c = cmdchar & 0177; if (!xxarg) { *commandprompt = '\0'; xarg = TRUE; xxarg= TRUE; negarg=FALSE; arg=0; } arg = 10 * arg + (1-2*negarg)*(c - '0'); if (strlen(commandprompt) < 76) { commandprompt[strlen(commandprompt)+1] = '\0'; commandprompt[strlen(commandprompt)] = c; strcat(commandprompt," "); } savearg = TRUE; } k_teco() { #ifdef TECO static char tecofile[FILENAMESIZE] = ""; if (getfilename("Teco File", tecofile)) teco(tecofile); #else errmes(NYI); #endif } @//E*O*F k_funcs.c// chmod u=rw,g=r,o= k_funcs.c echo Inspecting for damage in transit... temp=/tmp/shar$$; dtemp=/tmp/.shar$$ trap "rm -f $temp $dtemp; exit" 0 1 2 3 15 cat > $temp <<\!!! 581 1489 10914 scame2.c 134 421 2409 strings.c 858 2607 17027 io.c 211 630 3945 files.c 68 142 1184 macro.c 823 1258 10332 k_funcs.c 2675 6547 45811 total !!! wc scame2.c strings.c io.c files.c macro.c k_funcs.c | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp if [ -s $dtemp ] then echo "Ouch [diff of wc output]:" ; cat $dtemp else echo "No problems found." fi exit 0
leif@erix.UUCP (Leif Samuelsson) (02/16/85)
# This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by erisun!leif on Sat Feb 9 18:15:04 MET 1985 # Contents: x_funcs.c disptab.c help.c search.c vars.c scame-reaper.c echo x - x_funcs.c sed 's/^@//' > "x_funcs.c" <<'@//E*O*F x_funcs.c//' /* SCAME x_funcs.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; /* Functions normally not bound to keys */ # include "scame.h" extern int k_ubk(), k_void(), k_insertc(); x_set_key() { funcp fp, *table; int c; char s[80], ts[40]; fp = getfuncname("Function Name: "); if (fp != (funcp) 0) { sprintf(s, "Put %s on key", func_name(fp, ts)); c = b_getkey(s); if (c == b_control('X')) { if (!quiet) strout("C-X "); c = inchar(FALSE); c = upcase(c,FALSE); table = c_x_disptab; } else if (c == b_meta('O')) { if (!quiet) outchar(' ',FALSE); c = inchar(FALSE); table = m_o_disptab; } else table = disptab; if (c != -1 && yesorno("Go Ahead") == 1) table[c] = fp; } } x_viewfile() { static char tfile[FILENAMESIZE] = ""; if (getfilename("View File", tfile)) vfile(NIL, tfile,TRUE,TRUE,NIL); modeline(); } x_wallchart() { register int i; funcp fp; char s[80]; Bool same=FALSE; for (i=0; i<512; i++) { fp = disptab[i]; if (fp != k_ubk && fp != k_void && fp != k_insertc) { if (i > 0 && i < 511 && fp == disptab[i-1] && fp == disptab[i+1]) same = TRUE; else { if (same) { insertstr("thru\n",4); same = FALSE; } key_name(i, s, FALSE); if (strlen(s) < 8) strcat(s, "\t"); strcat(s, "\t"); func_name(fp, &s[strlen(s)]); strcat(s, "\n"); insertstr(s, strlen(s)); } } } for (i=0; i<128; i++) { fp = c_x_disptab[i]; if (fp != k_ubk && fp != k_void) { strcpy(s, "C-X "); key_name(i, &s[strlen(s)], FALSE); if (strlen(s) < 8) strcat(s, "\t"); strcat(s, "\t"); func_name(fp, &s[strlen(s)]); strcat(s, "\n"); insertstr(s, strlen(s)); } } for (i=0; i<128; i++) { fp = m_o_disptab[i]; if (fp != k_ubk && fp != k_void) { strcpy(s, "M-O "); key_name(i, &s[strlen(s)], FALSE); if (strlen(s) < 8) strcat(s, "\t"); strcat(s, "\t"); func_name(fp, &s[strlen(s)]); strcat(s, "\n"); insertstr(s, strlen(s)); } } } x_insertfile() { static char infilename[FILENAMESIZE]=""; if (getfilename("Insert File",infilename)) insertfile(infilename); } x_adamode() { setmode(ADA); } x_autofillmode() { setminormode(&cb.minormodes.autofill, arg); } x_ovwrtmode() { setminormode(&cb.minormodes.overwrite, arg); } x_cmode() { setmode(C); } x_cbreakmode() { gvars.cbreak_mode = xarg ? arg : (long) !(gvars.cbreak_mode); ttycbreak(); } x_checkmail() { checkmail(TRUE); } x_dired() { exec("dired"); } x_fundamentalmode() { setmode(FUNDAMENTAL); } x_inschr() { if (xarg && arg >= 0 && arg <= 127) insertc((char)arg,1L); else errmes(ILA); } x_lispmode() { setmode(LISP); } x_pascalmode() { setmode(PASCAL); } x_setvariable() { setvariable(arg); } x_swedishmode() { setmode(SWEDISH); } x_revert_file() { if (xarg || yesorno("Restore file from disk") == 1) { saveforundo(x_revert_file); revertfile(); } } x_tabify() { saveforundo(x_tabify); tabify(); } x_sortbuf() { #ifdef SORT saveforundo(x_sortbuf); pipe_through("/usr/bin/sort", NIL, NIL, NIL, buf, z); upd2(); modeline(); #else errmes(NYI); #endif killing = FALSE; } x_flush_matching_lines() { #ifdef GREP char flushstr[80]; saveforundo(x_flush_matching_lines); if (instring("Pattern: ", flushstr, 0, "","\r\007") == '\r') pipe_through("/usr/ucb/grep", "-v", flushstr, NIL, dot, z); upd2(); modeline(); #else errmes(NYI); #endif killing = FALSE; } x_savekbdmac() { char tfile[FILENAMESIZE]; *tfile = '\0'; if (getfilename("Save macro on file", tfile)) savekbdmac(tfile); } x_loadkbdmac() { char tfile[FILENAMESIZE]; *tfile = '\0'; if (getfilename("Load macro from file", tfile)) loadkbdmac(tfile); } x_replace() { char old[SCRDIMX],new[SCRDIMX], tprompt[SCRDIMX], *tmpdot=dot; typing = FALSE; strcpy(tprompt,"Replace: "); if (instring(tprompt,old,0,NIL,"\r\007") != '\007' && *old !='\0') { if (strlen(old) <= 20) sprintf(&tprompt[strlen(tprompt)-2]," %s ",old); else *tprompt='\0'; strcat(tprompt,"With: "); if (instring(tprompt,new,0,NIL,"\r\007") != '\007') { saveforundo(x_replace); replace(old, new, FALSE); } } echo(NIL); dot=tmpdot; } x_rot13_region() { saveforundo(x_rot13_region); rot13_region(); } @//E*O*F x_funcs.c// chmod u=rw,g=r,o= x_funcs.c echo x - disptab.c sed 's/^@//' > "disptab.c" <<'@//E*O*F disptab.c//' /* SCAME disptab.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; /* Command dispatch tables */ #include "scame.h" #include "k_funcs.h" extern int k_teco(); struct comstruct x_comtab[] = { { "Ada Mode", x_adamode }, { "Auto Fill Mode", x_autofillmode }, { "C Mode", x_cmode }, { "CBREAK Mode", x_cbreakmode }, { "Change Directory", changedir }, { "Check Mail", x_checkmail }, { "Default Mode", findmode }, { "Delete Matching Lines", x_flush_matching_lines }, { "Dired", x_dired }, { "Find File", k_findfile }, { "Fundamental Mode", x_fundamentalmode }, { "Insert Character", x_inschr }, { "Insert File", x_insertfile }, { "Kill Buffer", k_killbuffer }, { "Lisp Mode", x_lispmode }, { "List Buffers", k_listbuffers }, { "Load Kbd Macro", x_loadkbdmac }, { "Overwrite Mode", x_ovwrtmode }, { "Pascal Mode", x_pascalmode }, { "Push to Shell", push }, { "Read Mail", k_readmail }, { "Replace String", x_replace }, { "Revert File", x_revert_file }, { "Rot 13 region", x_rot13_region }, { "Save Kbd Macro", x_savekbdmac }, { "Select Buffer", k_selectbuffer }, { "Send Mail", k_mailbuffer }, { "Set Key", x_set_key }, { "Set Variable", x_setvariable }, { "Sort Buffer", x_sortbuf }, { "Stop", stop }, { "Swedish Mode", x_swedishmode }, { "Tabify", x_tabify }, { "Undo", undo }, { "View File", x_viewfile }, { "View Variable", viewvariable }, { "View Working Directory",viewworkingdir }, { "Wall Chart", x_wallchart }, { "What Cursor Position", k_whatcursorpos }, { "Write File", k_writefile }, { "Write Region", writeregion }, { "^R Append Next Kill", k_appendnextkill }, { "^R Argument Digit", k_digit }, { "^R Autoargument", k_metadigit }, { "^R Back to Indentation", k_backtoindent }, { "^R Backward Character", k_backchar }, { "^R Backward Delete Character", k_backdelchar }, { "^R Backward Kill Word", k_backkillword }, { "^R Backward Sentence", k_begse }, { "^R Backward Word", k_backword }, { "^R Beginning of Line", k_begli }, { "^R Buffer Not Modified", k_notmodified }, { "^R Copy Region", k_copyregion }, { "^R Count Lines Page", k_cntlpg }, { "^R Count Lines Region", k_countlregion }, { "^R Delete Blank Lines", k_delblanklines }, { "^R Delete Character", k_delchar }, { "^R Delete Horizontal space", k_delhorizspace }, { "^R Delete Indentation", k_delindent }, { "^R Directory Display", k_listdir }, { "^R Dired", k_dired }, { "^R Display Date", k_dispdate }, { "^R Down Real Line", k_downline }, { "^R End Defining Kbd Macro", k_enddefkbdmac }, { "^R End of Line", k_endli }, { "^R Exchange Point and Mark", k_exchgdotmark }, { "^R Execute Kbd Macro", k_executekbdmac }, { "^R Execute Teco Macro", k_teco }, { "^R Exit", k_exit }, { "^R Exit To Shell", k_exit_to_shell }, { "^R Extended Command", k_extended }, { "^R Fill Region", k_fillregion }, { "^R Forward Character", k_forwchar }, { "^R Forward Sentence", k_endse }, { "^R Forward Word", k_forwword }, { "^R Goto Beginning", k_begofbuf }, { "^R Goto End", k_endofbuf }, { "^R Grow Window", k_growwindow }, { "^R Help", k_help }, { "^R Incremental Search", k_isearch }, { "^R Indent According to Mode", k_tab }, { "^R Indent New Line", k_indnewline }, { "^R Indent Rigidly", k_indentregion }, { "^R Indent for Comment", k_comment }, { "^R Invoke Inferior Shell", k_push }, { "^R Kill Line", k_killline }, { "^R Kill Region", k_killregion }, { "^R Kill Sentence", k_killsentence }, { "^R Kill Word", k_killword }, { "^R Log Out", k_logout }, { "^R Lowercase Region", k_lowcaseregion }, { "^R Lowercase Word", k_locasw }, { "^R Make ()", k_makeparens }, { "^R Mark Whole Buffer", k_markbuffer }, { "^R Mark Word", k_markword }, { "^R Negative Argument", k_negarg }, { "^R New Line", k_newline }, /* self insert for formatting character ? */ { "^R New Window", k_newwindow }, { "^R Next Screen", k_nextscreen }, { "^R One Window", k_onewindow }, { "^R Open Line", k_openline }, { "^R Other Window", k_otherwindow }, { "^R Prefix Control", k_c_prefix }, { "^R Prefix Control-Meta", k_c_m_prefix }, { "^R Prefix Meta", k_m_prefix }, { "^R Previous Screen", k_prevscreen }, { "^R Query Replace", k_queryreplace }, { "^R Quit", k_bell }, { "^R Quoted Insert", k_quote }, { "^R Reverse Search", k_risearch }, { "^R Save File", k_savefile }, { "^R Scroll Other Window", k_scrollotherwindow }, { "^R Self Insert", k_insertc }, { "^R Set Comment Column", k_setcommcol }, { "^R Set Fill Column", k_setfcol }, { "^R Set Fill Prefix", k_setfillprefix }, { "^R Set/Pop Mark", k_pushpopmark }, { "^R Shell Command", k_shellcmd }, { "^R Start Kbd Macro", k_startdefkbdmac }, { "^R Tab to Tab Stop", k_instab }, { "^R Transpose Characters", k_transchar }, { "^R Transpose Words", k_trnsword }, { "^R Two Windows", k_twowindows }, { "^R Un-kill", k_yank }, { "^R Universal Argument", k_univarg }, { "^R Up Real Line", k_upline }, { "^R Uppercase Initial", k_capitalizeword }, { "^R Uppercase Region", k_upcaseregion }, { "^R Uppercase Word", k_upcwd }, { "^R Visit File", k_visitfile }, { "pwd", viewworkingdir }, NIL }; funcp disptab[512] = { /* 000 */ k_void, /* 001 */ k_void, /* 002 */ k_void, /* 003 */ k_void, /* 004 */ k_void, /* 005 */ k_void, /* 006 */ k_void, /* 007 */ k_void, /* 010 */ k_void, /* 011 */ k_void, /* 012 */ k_void, /* 013 */ k_void, /* 014 */ k_void, /* 015 */ k_void, /* 016 */ k_void, /* 017 */ k_void, /* 020 */ k_void, /* 021 */ k_void, /* 022 */ k_void, /* 023 */ k_void, /* 024 */ k_void, /* 025 */ k_void, /* 026 */ k_void, /* 027 */ k_void, /* 030 */ k_void, /* 031 */ k_void, /* 032 */ k_void, /* 033 */ k_void, /* 034 */ k_void, /* 035 */ k_void, /* 036 */ k_void, /* 037 */ k_void, /* 040 */ k_insertc, /* 041 */ k_insertc, /* 042 */ k_insertc, /* 043 */ k_insertc, /* 044 */ k_insertc, /* 045 */ k_insertc, /* 046 */ k_insertc, /* 047 */ k_insertc, /* 050 */ k_insertc, /* 051 */ k_insertc, /* 052 */ k_insertc, /* 053 */ k_insertc, /* 054 */ k_insertc, /* 055 */ k_negarg, /* 056 */ k_insertc, /* 057 */ k_insertc, /* 060 0 */ k_digit, /* 061 */ k_digit, /* 062 */ k_digit, /* 063 */ k_digit, /* 064 */ k_digit, /* 065 */ k_digit, /* 066 */ k_digit, /* 067 */ k_digit, /* 070 */ k_digit, /* 071 9 */ k_digit, /* 072 */ k_insertc, /* 073 */ k_insertc, /* 074 */ k_insertc, /* 075 */ k_insertc, /* 076 */ k_insertc, /* 077 */ k_insertc, /* 100 */ k_insertc, /* 101 */ k_insertc, /* 102 */ k_insertc, /* 103 */ k_insertc, /* 104 */ k_insertc, /* 105 */ k_insertc, /* 106 */ k_insertc, /* 107 */ k_insertc, /* 110 */ k_insertc, /* 111 */ k_insertc, /* 112 */ k_insertc, /* 113 */ k_insertc, /* 114 */ k_insertc, /* 115 */ k_insertc, /* 116 */ k_insertc, /* 117 */ k_insertc, /* 120 */ k_insertc, /* 121 */ k_insertc, /* 122 */ k_insertc, /* 123 */ k_insertc, /* 124 */ k_insertc, /* 125 */ k_insertc, /* 126 */ k_insertc, /* 127 */ k_insertc, /* 130 */ k_insertc, /* 131 */ k_insertc, /* 132 */ k_insertc, /* 133 */ k_insertc, /* 134 */ k_insertc, /* 135 */ k_insertc, /* 136 */ k_insertc, /* 137 */ k_insertc, /* 140 */ k_insertc, /* 141 */ k_insertc, /* 142 */ k_insertc, /* 143 */ k_insertc, /* 144 */ k_insertc, /* 145 */ k_insertc, /* 146 */ k_insertc, /* 147 */ k_insertc, /* 150 */ k_insertc, /* 151 */ k_insertc, /* 152 */ k_insertc, /* 153 */ k_insertc, /* 154 */ k_insertc, /* 155 */ k_insertc, /* 156 */ k_insertc, /* 157 */ k_insertc, /* 160 */ k_insertc, /* 161 */ k_insertc, /* 162 */ k_insertc, /* 163 */ k_insertc, /* 164 */ k_insertc, /* 165 */ k_insertc, /* 166 */ k_insertc, /* 167 */ k_insertc, /* 170 */ k_insertc, /* 171 */ k_insertc, /* 172 */ k_insertc, /* 173 */ k_insertc, /* 174 */ k_insertc, /* 175 */ k_insertc, /* 176 */ k_insertc, /* 177 DEL */ k_backdelchar, /* 200 M-^@ */ k_void, /* 201 */ k_void, /* 202 */ k_void, /* 203 */ k_void, /* 204 */ k_void, /* 205 */ k_void, /* 206 */ k_void, /* 207 */ k_void, /* 210 */ k_void, /* 211 */ k_void, /* 212 */ k_void, /* 213 */ k_void, /* 214 */ k_void, /* 215 */ k_void, /* 216 */ k_void, /* 217 */ k_void, /* 220 */ k_void, /* 221 */ k_void, /* 222 */ k_void, /* 223 */ k_void, /* 224 */ k_void, /* 225 */ k_void, /* 226 */ k_void, /* 227 */ k_void, /* 230 */ k_void, /* 231 */ k_void, /* 232 */ k_void, /* 233 */ k_void, /* 234 */ k_void, /* 235 */ k_void, /* 236 */ k_void, /* 237 M-^_ */ k_void, /* 240 M-sp */ k_ubk, /* 241 M-! */ k_shellcmd, /* 242 */ k_ubk, /* 243 */ k_ubk, /* 244 */ k_ubk, /* 245 */ k_queryreplace, /* 246 */ k_ubk, /* 247 */ k_ubk, /* 250 */ k_makeparens, /* 251 */ k_ubk, /* 252 */ k_ubk, /* 253 */ k_push, /* 254 */ k_ubk, /* 255 */ k_ubk, /* 256 */ k_ubk, /* 257 */ k_ubk, /* 260 M-0 */ k_metadigit, /* 261 */ k_metadigit, /* 262 */ k_metadigit, /* 263 */ k_metadigit, /* 264 */ k_metadigit, /* 265 */ k_metadigit, /* 266 */ k_metadigit, /* 267 */ k_metadigit, /* 270 */ k_metadigit, /* 271 */ k_metadigit, /* 272 */ k_ubk, /* 273 */ k_comment, /* 274 */ k_begofbuf, /* 275 */ k_countlregion, /* 276 */ k_endofbuf, /* 277 */ k_ubk, /* 300 */ k_markword, /* 301 */ k_begse, /* 302 */ k_backword, /* 303 */ k_capitalizeword, /* 304 */ k_killword, /* 305 */ k_endse, /* 306 */ k_forwword, /* 307 */ k_fillregion, /* 310 */ k_ubk, /* 311 */ k_instab, /* 312 */ k_ubk, /* 313 */ k_killsentence, /* 314 */ k_locasw, /* 315 */ k_backtoindent, /* 316 */ k_ubk, /* 317 */ k_m_o_dispatch, /* 320 */ k_ubk, /* 321 */ k_ubk, /* 322 */ k_ubk, /* 323 */ k_ubk, /* 324 M-T */ k_trnsword, /* 325 M-U */ k_upcwd, /* 326 M-V */ k_prevscreen, /* 327 */ k_copyregion, /* 330 */ k_extended, /* 331 */ k_ubk, /* 332 */ k_ubk, /* 333 */ k_ubk, /* 334 */ k_delhorizspace, /* 335 */ k_ubk, /* 336 */ k_delindent, /* 337 */ k_ubk, /* 340 */ k_ubk, /* 341 */ k_void, /* 342 */ k_void, /* 343 */ k_void, /* 344 */ k_void, /* 345 */ k_void, /* 346 */ k_void, /* 347 */ k_void, /* 350 */ k_void, /* 351 */ k_void, /* 352 */ k_void, /* 353 */ k_void, /* 354 */ k_void, /* 355 */ k_void, /* 356 */ k_void, /* 357 */ k_void, /* 360 */ k_void, /* 361 */ k_void, /* 362 */ k_void, /* 363 */ k_void, /* 364 */ k_void, /* 365 */ k_void, /* 366 */ k_void, /* 367 */ k_void, /* 370 */ k_void, /* 371 */ k_void, /* 372 M-z */ k_void, /* 373 M- */ k_ubk, /* 374 */ k_ubk, /* 375 */ k_ubk, /* 376 M-~ */ k_notmodified, /* 377 M-DEL */ k_backkillword, /* 400 C-^@ */ k_void, /* 401 */ k_void, /* 402 */ k_void, /* 403 */ k_void, /* 404 */ k_void, /* 405 */ k_void, /* 406 */ k_void, /* 407 */ k_void, /* 410 */ k_void, /* 411 */ k_void, /* 412 */ k_void, /* 413 */ k_void, /* 414 */ k_void, /* 415 */ k_void, /* 416 */ k_void, /* 417 */ k_void, /* 420 */ k_void, /* 421 */ k_void, /* 422 */ k_void, /* 423 */ k_void, /* 424 */ k_void, /* 425 */ k_void, /* 426 */ k_void, /* 427 */ k_void, /* 430 */ k_void, /* 431 */ k_void, /* 432 */ k_void, /* 433 */ k_void, /* 434 */ k_void, /* 435 */ k_void, /* 436 */ k_void, /* 437 C-^_ */ k_void, /* 440 C-sp */ k_ubk, /* 441 */ k_ubk, /* 442 */ k_ubk, /* 443 */ k_ubk, /* 444 */ k_ubk, /* 445 */ k_ubk, /* 446 */ k_ubk, /* 447 */ k_ubk, /* 450 */ k_ubk, /* 451 */ k_ubk, /* 452 */ k_ubk, /* 453 */ k_ubk, /* 454 */ k_ubk, /* 455 */ k_ubk, /* 456 */ k_ubk, /* 457 */ k_ubk, /* 460 */ k_ubk, /* 461 */ k_ubk, /* 462 */ k_ubk, /* 463 */ k_ubk, /* 464 */ k_ubk, /* 465 */ k_ubk, /* 466 */ k_ubk, /* 467 */ k_ubk, /* 470 */ k_ubk, /* 471 */ k_ubk, /* 472 */ k_ubk, /* 473 */ k_ubk, /* 474 */ k_ubk, /* 475 */ k_ubk, /* 476 */ k_ubk, /* 477 */ k_ubk, /* 500 */ k_pushpopmark, /* 501 */ k_begli, /* 502 */ k_backchar, /* 503 C-C */ k_exit_to_shell, /* 504 */ k_delchar, /* 505 */ k_endli, /* 506 */ k_forwchar, /* 507 */ k_bell, /* 510 */ k_backchar, /* 511 */ k_tab, /* 512 */ k_indnewline, /* 513 */ k_killline, /* 514 */ k_newwindow, /* 515 */ k_newline, /* 516 */ k_downline, /* 517 */ k_openline, /* 520 */ k_upline, /* 521 */ k_quote, /* 522 */ k_risearch, /* 523 */ k_isearch, /* 524 */ k_transchar, /* 525 */ k_univarg, /* 526 */ k_nextscreen, /* 527 */ k_killregion, /* 530 */ k_c_x_dispatch, /* 531 */ k_yank, /* 532 */ k_c_m_prefix, /* 533 */ k_m_prefix, /* 534 */ k_m_prefix, /* 535 */ k_ubk, /* 536 */ k_c_prefix, /* 537 C-_ */ k_help, /* 540 C-` */ k_ubk, /* 541 */ k_void, /* 542 */ k_void, /* 543 */ k_void, /* 544 */ k_void, /* 545 */ k_void, /* 546 */ k_void, /* 547 */ k_void, /* 550 */ k_void, /* 551 */ k_void, /* 552 */ k_void, /* 553 */ k_void, /* 554 */ k_void, /* 555 */ k_void, /* 556 */ k_void, /* 557 */ k_void, /* 560 */ k_void, /* 561 */ k_void, /* 562 */ k_void, /* 563 */ k_void, /* 564 */ k_void, /* 565 */ k_void, /* 566 */ k_void, /* 567 */ k_void, /* 570 */ k_void, /* 571 */ k_void, /* 572 C-z */ k_void, /* 573 C-*/ k_ubk, /* 574 */ k_ubk, /* 575 */ k_ubk, /* 576 */ k_ubk, /* 577 C-DEL */ k_ubk, /* 600 C-M-^@ */k_void, /* 601 */ k_void, /* 602 */ k_void, /* 603 */ k_void, /* 604 */ k_void, /* 605 */ k_void, /* 606 */ k_void, /* 607 */ k_void, /* 610 */ k_void, /* 611 */ k_void, /* 612 */ k_void, /* 613 */ k_void, /* 614 */ k_void, /* 615 */ k_void, /* 616 */ k_void, /* 617 */ k_void, /* 620 */ k_void, /* 621 */ k_void, /* 622 */ k_void, /* 623 */ k_void, /* 624 */ k_void, /* 625 */ k_void, /* 626 */ k_void, /* 627 */ k_void, /* 630 */ k_void, /* 631 */ k_void, /* 632 */ k_void, /* 633 */ k_void, /* 634 */ k_void, /* 635 */ k_void, /* 636 */ k_void, /* 637 C-M-^_ */k_void, /* 640 C-M-sp */k_ubk, /* 641 */ k_ubk, /* 642 */ k_ubk, /* 643 */ k_ubk, /* 644 */ k_ubk, /* 645 */ k_queryreplace, /* 646 */ k_ubk, /* 647 */ k_ubk, /* 650 */ k_ubk, /* 651 */ k_ubk, /* 652 */ k_ubk, /* 653 */ k_ubk, /* 654 */ k_ubk, /* 655 */ k_ubk, /* 656 */ k_ubk, /* 657 */ k_ubk, /* 660 */ k_ubk, /* 661 */ k_ubk, /* 662 */ k_ubk, /* 663 */ k_ubk, /* 664 */ k_ubk, /* 665 */ k_ubk, /* 666 */ k_ubk, /* 667 */ k_ubk, /* 670 */ k_ubk, /* 671 */ k_ubk, /* 672 */ k_ubk, /* 673 */ k_ubk, /* 674 */ k_ubk, /* 675 */ k_ubk, /* 676 */ k_ubk, /* 677 */ k_ubk, /* 700 */ k_ubk, /* 701 */ k_ubk, /* 702 */ k_ubk, /* 703 */ k_ubk, /* 704 */ k_ubk, /* 705 */ k_ubk, /* 706 */ k_ubk, /* 707 */ k_ubk, /* 710 */ k_ubk, /* 711 */ k_ubk, /* 712 */ k_ubk, /* 713 */ k_ubk, /* 714 */ k_logout, /* 715 */ k_backtoindent, /* 716 */ k_ubk, /* 717 */ k_ubk, /* 720 */ k_ubk, /* 721 */ k_ubk, /* 722 */ k_ubk, /* 723 */ k_ubk, /* 724 */ k_dispdate, /* 725 */ k_ubk, /* 726 */ k_scrollotherwindow, /* 727 */ k_appendnextkill, /* 730 */ k_extended, /* 731 */ k_ubk, /* 732 C-M-Z */ k_exit, /* 733 M-ESC */ k_teco, /* 734 */ k_ubk, /* 735 */ k_ubk, /* 736 */ k_ubk, /* 737 C-M-_ */ k_ubk, /* 740 C-M-` */ k_ubk, /* 741 C-M-a */ k_void, /* 742 */ k_void, /* 743 */ k_void, /* 744 */ k_void, /* 745 */ k_void, /* 746 */ k_void, /* 747 */ k_void, /* 750 */ k_void, /* 751 */ k_void, /* 752 */ k_void, /* 753 */ k_void, /* 754 */ k_void, /* 755 */ k_void, /* 756 */ k_void, /* 757 */ k_void, /* 760 */ k_void, /* 761 */ k_void, /* 762 */ k_void, /* 763 */ k_void, /* 764 */ k_void, /* 765 */ k_void, /* 766 */ k_void, /* 767 */ k_void, /* 770 */ k_void, /* 771 */ k_void, /* 772 C-M-z */ k_void, /* 773 C-M-*/ k_ubk, /* 774 C-M-| */ k_ubk, /* 775 C-M-} */ k_ubk, /* 776 C-M-~ */ k_ubk, /* 777 C-M-DEL*/k_ubk }; funcp c_x_disptab[128] = { /* 000 */ k_ubk, /* 001 */ k_ubk, /* 002 */ k_listbuffers, /* 003 */ k_ubk, /* 004 */ k_listdir, /* 005 */ k_ubk, /* 006 */ k_findfile, /* 007 */ k_bell, /* 010 */ k_ubk, /* 011 */ k_indentregion, /* 012 */ k_ubk, /* 013 */ k_ubk, /* 014 */ k_lowcaseregion, /* 015 */ k_ubk, /* 016 */ k_ubk, /* 017 */ k_delblanklines, /* 020 */ k_ubk, /* 021 */ k_ubk, /* 022 */ k_ubk, /* 023 */ k_savefile, /* 024 */ k_ubk, /* 025 */ k_upcaseregion, /* 026 */ k_visitfile, /* 027 */ k_writefile, /* 030 */ k_exchgdotmark, /* 031 */ k_ubk, /* 032 C-Z */ k_exit_to_shell, /* 033 */ k_ubk, /* 034 */ k_ubk, /* 035 */ k_ubk, /* 036 */ k_ubk, /* 037 */ k_ubk, /* 040 */ k_ubk, /* 041 */ k_ubk, /* 042 */ k_ubk, /* 043 */ k_ubk, /* 044 */ k_ubk, /* 045 */ k_ubk, /* 046 */ k_ubk, /* 047 */ k_ubk, /* 050 */ k_startdefkbdmac, /* 051 */ k_enddefkbdmac, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* 056 */ k_setfillprefix, /* */ k_ubk, /* */ k_ubk, /* 061 */ k_onewindow, /* 062 */ k_twowindows, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* 073 */ k_setcommcol, /* */ k_ubk, /* 074 */ k_whatcursorpos, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* 102 */ k_selectbuffer, /* */ k_ubk, /* 104 */ k_dired, /* 105 */ k_executekbdmac, /* 106 */ k_setfcol, /* */ k_ubk, /* 110 */ k_markbuffer, /* */ k_ubk, /* */ k_ubk, /* 113 */ k_killbuffer, /* 114 */ k_cntlpg, /* 115 */ k_mailbuffer, /* */ k_ubk, /* 117 */ k_otherwindow, /* */ k_ubk, /* */ k_ubk, /* 122 R */ k_readmail, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_exit_to_shell, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* 136 */ k_growwindow, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk, /* */ k_ubk }; funcp m_o_disptab[128] = { /* 000 */ k_ubk, /* 001 */ k_ascii, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 007 */ k_bell, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 023 */ k_sis, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 0 */ k_ubk, /* 1 */ k_ubk, /* 101 */ k_upline, /* 102 */ k_downline, /* 103 */ k_forwchar, /* 104 */ k_backchar, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 123 */ k_edt_pf4, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 154 */ k_edt_comma, /* 155 */ k_edt_dash, /* 156 */ k_help, /* 1 */ k_ubk, /* 160 */ k_edt_0, /* 1 */ k_ubk, /* 162 */ k_endli, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 166 */ k_killregion, /* 1 */ k_ubk, /* 170 */ k_edt_8, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk, /* 1 */ k_ubk }; @//E*O*F disptab.c// chmod u=rw,g=r,o= disptab.c echo x - help.c sed 's/^@//' > "help.c" <<'@//E*O*F help.c//' /* SCAME help.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; #include "scame.h" extern int k_void(), k_ubk(); /* HELP! */ help() { int c; *commandprompt = '\0'; echo(NIL); hquery: typing = FALSE; strout("Doc (? for help): "); outchar(c = upcasearr[inchar(FALSE)], TRUE); switch (c) { case '\007': pchar(BELL); break; case '\037': case '?': vfile(scamelib,"helpmenu",FALSE,FALSE,NIL); echo(NIL); goto hquery; case '1': case '2': fixbuftab(PUT); sprintf(cb.filename,"%s/%s%c",scamelib,"tut",c); findfile(); basename(cb.filename,cb.filename,FALSE); modeline(); break; case 'A': apropos(); break; case 'B': vfile(scamelib,"basic",TRUE,TRUE,NIL); break; case 'C': where(); break; case 'L': showlastinput(); break; case 'N': vfile(scamelib,"news",TRUE,TRUE,NIL); break; case 'Q': break; case 'S': vfile(scamelib,"summary", TRUE,TRUE,NIL); break; case DEL: break; default: echo(NIL); outchar(c, TRUE); strout(" is meaningless here. "); pchar(BELL); goto hquery; } echo(NIL); } where() { funcp *table; int c; char s[80]; c = b_getkey("Character"); key_name(c, s, TRUE); if (c == b_control('X')) { if (!quiet) strout("C-X "); c = upcasearr[inchar(FALSE)]; strcat(s, " "); key_name(c, &s[strlen(s)], FALSE); table = c_x_disptab; } else if (c == b_meta('O')) { if (!quiet) outchar(' ', FALSE); c = inchar(FALSE); strcat(s, " "); key_name(c, &s[strlen(s)], FALSE); table = m_o_disptab; } else table = disptab; if (table[c] == k_void) strcat(s, " is an illegal key"); else if (table[c] == k_ubk) strcat(s, " is not bound to any function"); else { strcat(s, " runs the function "); func_name(table[c], &s[strlen(s)]); } strcat(s, "."); typeout(s); } showlastinput() { char outstr[80]; int i; char c; i = lstindex; if (lastinput[i] == (char) 0200) i=0; *outstr = '\0'; do { c = lastinput[i]; if (c == (char) 0200) break; if (c & 0200) { strcat(outstr,"Meta-"); c &= 0177; } if (c == '\010') strcat(outstr,"Backspace"); else if (c == '\011') strcat(outstr,"Tab"); else if (c == '\012') strcat(outstr,"Linefeed"); else if (c == '\r' ) strcat(outstr,"Return"); else if (c == '\033') strcat(outstr,"Escape"); else if (c == ' ' ) strcat(outstr,"Space"); else if (c == DEL ) strcat(outstr,"Rubout"); else { if (c < ' ' || c==DEL) { strcat(outstr,"^"); c = (c+64) & 0177; } sprintf(&outstr[strlen(outstr)],"%c",c); } strcat(outstr," "); if (strlen(outstr) > screenwidth - 15) { typeout(outstr); *outstr = '\0'; } i = (i + 1) % LASTINPUTSIZE; } while (i != lstindex); if (*outstr != '\0') typeout(outstr); } /* apropos */ apropos() { char c, tstr[80]; *tstr = '\0'; c = instring("Apropos: ",tstr,0,"\033","\007\r"); if (c=='\r') vfile(scamelib,"aproposlist",FALSE,TRUE,tstr); } @//E*O*F help.c// chmod u=rw,g=r,o= help.c echo x - search.c sed 's/^@//' > "search.c" <<'@//E*O*F search.c//' /* SCAME search.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; #include "scame.h" /* Incremental Search */ # define FIXCUR cur(screenlen-1,10+rlen+8*(failed<=level)+8*backward); /* a few variables common for isearch() and find() */ # define ISEARCHDEPTH 250 char oldsstr[80]; static char *dotarr[ISEARCHDEPTH]; static int failed=15000; static char sstr[80]; static char iprompt[]="I-Search: ", riprompt[]="Reverse I-Search: "; static int len, rlen, level; void isearch(backward) Bool backward; { char charr[ISEARCHDEPTH]; int faillen=0; Bool done=FALSE; int c; int sb = gvars.search_backward, sf = gvars.search_forward; closegap(); *commandprompt='\0'; if (backward) echo(riprompt); else echo(iprompt); len=rlen=level=0; dotarr[0]=dot; oldhome = home; while (!done) { charr[level]=c=inchar(TRUE); switch (c) { case 7: pchar(BELL); /* ^G */ if (failed <= level) { level = failed - 1; len = faillen; sstr[len] = '\0'; rlen = strsize(sstr); if (backward) echo(riprompt); else echo(iprompt); strout(sstr); dot = dotarr[level] + len*(1-backward); break; } /* else fall through to... */ case EOF:dot= dotarr[0]; done = TRUE; FIXCUR outchar(BELL, FALSE); pchar(BELL); break; case 17: c = inchar(FALSE); /* ^Q */ FIXCUR outchar(c, FALSE); sstr[len++]=c; sstr[len] = '\0'; rlen = rlen + 1 + (c < ' ' || c > '~'); find(dotarr[level],backward); if (failed>level) faillen++; break; case DEL: if (level > 0) { level--; if (charr[level] != sf && charr[level] != sb) { rlen= rlen -1 -(sstr[--len]<' '); sstr[len] = '\0'; FIXCUR cleol(TRUE); if (failed>level+1)faillen--; } dot=dotarr[level] + faillen; if (failed==level+1){ if (backward) echo(riprompt); else echo(iprompt); strout(sstr); } } else pchar(BELL); break; default: if (c == sf || c == sb) { if (level==0) { backward = (c == sb); strcpy(sstr,oldsstr); faillen=len=strlen(sstr); cur(screenlen-1,10+8*backward); strout(sstr); rlen = strsize(sstr); find(dot, backward); } else if (failed<=level && ((c==sf)^backward)) pchar(BELL); else { backward = (c==sb); find(dotarr[level]+1-2*backward,backward); } } else if (c>=' ' && c<='~') { FIXCUR pchar(c); hpos++; sstr[len++]=c; sstr[len] = '\0'; rlen++; find(dotarr[level], backward); if (failed>level) faillen++; } else { done=TRUE; strcpy(oldsstr,sstr); if (c != gvars.search_exit_char) unget(c); } } /* switch */ if (dot < home || dot > away || updateflag) { updateflag = TRUE; update(); modeline(); } else findxy(); refresh(TRUE); /* if (!typeahead() && (cury != vpos || curx != hpos)) cur(cury,curx); */ } /* while */ if (abs(dot - dotarr[0]) > gvars.auto_push_point_option) { FIXCUR outchar('\0', FALSE); cur(cury, curx); pswap(dot,dotarr[0]); pushpopmark(1L); dot = dotarr[0]; } clearecho(); } static find(tdot,backward) register char *tdot; Bool backward; { static int oldway = -1; char *tmpdot; tmpdot = dot; dot = tdot; if (failed <= level && backward == oldway) { dotarr[level+1]=dotarr[level]; level++; } else { if (search(sstr, backward)) { dotarr[++level]=dot; if (!backward) dot += strlen(sstr); failed=15000; } else { pchar(BELL); echo("Failing "); strout(backward ? riprompt : iprompt); strout(sstr); dotarr[level+1]=dotarr[level]; if (failed>++level) failed=level; dot = tmpdot; } } oldway = backward; } Bool search(str,backward) register char *str; Bool backward; { int len=strlen(str); register char *tdot, *end; register Bool swedish = (cb.majormode == SWEDISH); char tstr[80]; /* should be len+1 */ strncpy(tstr, str, min(80-1, len)); end = tstr; while (*end = upcase(*end,swedish)) end++; tdot = dot; if (!backward) { closegap(); end = z - len; while (tdot <= end && (*tstr != upcase(*tdot,swedish) || !strneq(tdot,tstr,len,swedish))) tdot++; if (tdot > end) return(FALSE); else { dot = tdot; return(TRUE); } } else { if (tdot > z - len) tdot = z - len; end = buf; while (tdot >= end && (*tstr != upcase(*tdot,swedish) || !strneq(tdot,tstr,len,swedish))) tdot--; if (tdot < end) return(FALSE); else { dot = tdot; dot= tdot; } } } /* Replace */ void replace(old, new, query) register char *old,*new; Bool query; { register int c, oldlen,newlen; Bool goahead = !query, checkforquit=FALSE; oldlen = strlen(old); newlen = strlen(new); while (TRUE) { if (!checkforquit && typeahead()) { c = inchar(TRUE); checkforquit = TRUE; if (c=='\007') { pchar(BELL); return; } else unget(c); } if (!search(old, FALSE)) return; dot += oldlen; query0: if (goahead) c = ' '; else { update(); modeline(); refresh(TRUE); *commandprompt = '\0'; c = inchar(FALSE); } switch (c) { case '\007': pchar(BELL); /* ^G */ case EOF: case '\033': return; /* ESC */ case '\022': recurse(); /* ^R */ dot = max(dot-oldlen, buf); break; case '\037': /* ^_ */ case '?': vfile(scamelib,"queryrep",FALSE,TRUE,NIL); goto query0; case '!': goahead = TRUE; case '.': case ' ': dot -= oldlen; pushpopmark(1L); if (newlen > oldlen) { insertc('\0',(long)(newlen-oldlen)); dot -= newlen-oldlen; } else if (oldlen > newlen) delchar((long)(oldlen-newlen)); strncpy(dot,new,newlen); cb.modified = TRUE; dot += newlen; updateflag = TRUE; if (c == '.') return; break; case DEL: dot -= oldlen-1; break; default: pchar(BELL); goto query0; } } } @//E*O*F search.c// chmod u=rw,g=r,o= search.c echo x - vars.c sed 's/^@//' > "vars.c" <<'@//E*O*F vars.c//' /* SCAME vars.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; /* Scame Variables */ # include "scame.h" struct { char *name; long *varp; } vartab[] = { { "Auto Fill Mode", &cb.minormodes.autofill }, { "Auto Push Point Option", &gvars.auto_push_point_option }, { "Bottom Display Margin", &gvars.bottom_display_margin }, { "CBREAK Mode", &gvars.cbreak_mode }, { "Comment Column", &gvars.commcol }, { "Display Matching Paren", &cb.lvars.disp_matching_paren }, { "Fill Column", &cb.lvars.fillcolumn }, { "Hackmatic", &gvars.hackmatic }, { "Mail Check Interval", &gvars.mail_check_interval }, { "Overwrite Mode", &cb.minormodes.overwrite }, { "Quote Char", &gvars.quote_char }, { "Search Backward", &gvars.search_backward }, { "Search Exit Char", &gvars.search_exit_char }, { "Search Forward", &gvars.search_forward }, { "System Output Holding", &gvars.system_output_holding }, { "Tab Self Insert", &gvars.tab_self_insert }, { "Top Display Margin", &gvars.top_display_margin }, NIL }; setvariable(a) long a; { char str[80]; int c,i; if (!xarg) { errmes(ILA); return; } *str = '\0'; do { c=instring("Variable: ",str,strlen(str),"\t","\007\033\r?"); if (c == 7 || (c == 13 && *str=='\0')) { typing = FALSE; return; } if (c == '?') listmatching((struct tabstruct *)vartab,str); else if ((i = tablk((struct tabstruct *)vartab,str,0)) <0) pchar(BELL); } while (i<0 || c==ESC || c=='?'); switch (i) { case 2: if (a >=40 && a <=100) gvars.bottom_display_margin = a; else errmes(ILA); break; case 3: *(vartab[i].varp) = a; ttycbreak(); break; case 8: gvars.mail_check_interval = a; chkmailcnt = gvars.mail_check_interval; break; case 15: if (a <= 40 && a >= 0) gvars.top_display_margin = a; else errmes(ILA); break; default: *(vartab[i].varp) = a; } typing = FALSE; } viewvariable() { char str[80]; int c,i; *str = '\0'; do { c=instring("Variable: ", str,strlen(str),"\t","\007\033\r?"); if (c == 7 || (c == 13 && *str=='\0')) { typing = FALSE; return; } if (c == '?') listmatching((struct tabstruct *)vartab,str); else if ((i = tablk((struct tabstruct *)vartab,str,0)) <0) pchar(BELL); } while (i<0 || c==ESC || c=='?'); echo(NIL); printf("%s = %ld", vartab[i].name,*(vartab[i].varp)); fflush(stdout); typing = FALSE; } @//E*O*F vars.c// chmod u=rw,g=r,o=r vars.c echo x - scame-reaper.c sed 's/^@//' > "scame-reaper.c" <<'@//E*O*F scame-reaper.c//' /* SCAME scame-reaper.c */ /* Revision 1.0.0 1985-02-09 */ static char *cpyrid = "@(#)Copyright (C) 1985 by Leif Samuelsson"; #include <stdio.h> #include <sys/types.h> #include <sys/dir.h> #include "config.h" #define MAXPIDS 200 #define min(a,b) ((a)<(b)?(a):(b)) int nentries= 0; int nunlinked= 0; struct direct dirent, *dp = &dirent; extern FILE *popen(); char tempdir[] = TMPFILE; extern char *rindex(); main(argc,argv) int argc; char **argv; { int trace = (argc > 1); int pids[MAXPIDS], i,n,pid; #ifdef DIRBLKSIZ DIR *d; #endif FILE *f; char line[80]; long t; char *ctime(); char *s, *cp; if ((cp = rindex(tempdir, '/')) != (char *)0) *cp = '\0'; chdir(tempdir); if (trace) { printf("Scame-Reaper:\n"); system("date"); system("pwd"); } if ((f = popen("ps -ax", "r")) == NULL) fatal("Can't do ps"); i = 0; fscanf(f, "%*[^\n]"); do fscanf(f, "%d%*[^\n]", &pids[i]); while ((pids[i] != 0 || i == 0) && ++i < MAXPIDS); n=i; pclose(f); #ifdef DIRBLKSIZ if ((d=opendir(".")) == NULL) fatal("Can't open directory file"); while ((dp = readdir(d)) != 0) { #else if ((f=fopen(".", "r")) == NULL) fatal("Can't open directory file"); while (fread(dp, sizeof dirent, 1, f) != 0) { #endif if (dp->d_ino == 0 || dp->d_name[0] != 'S') continue; for (i=1; i <= 10; i++) if (dp->d_name[i] < '0' || dp->d_name[1] > '9') goto loop; nentries++; sscanf(dp->d_name, "%*[^0123456789]%5d", &pid); for (i=0; i<n && pids[i] != pid; i++); if (i==n) if (unlink(dp->d_name) != 0) printf("Can't remove %s\n", dp->d_name); else nunlinked++; loop: continue; } pclose(f); if (trace) printf("Done. %d files, %d removed\n", nentries, nunlinked); } fatal(s) char *s; { printf("%s, ", s); perror(); exit(1); } @//E*O*F scame-reaper.c// chmod u=rw,g=r,o= scame-reaper.c echo Inspecting for damage in transit... temp=/tmp/shar$$; dtemp=/tmp/.shar$$ trap "rm -f $temp $dtemp; exit" 0 1 2 3 15 cat > $temp <<\!!! 254 529 4258 x_funcs.c 929 3869 19390 disptab.c 140 378 2938 help.c 281 737 6096 search.c 92 313 2407 vars.c 90 249 1762 scame-reaper.c 1786 6075 36851 total !!! wc x_funcs.c disptab.c help.c search.c vars.c scame-reaper.c | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp if [ -s $dtemp ] then echo "Ouch [diff of wc output]:" ; cat $dtemp else echo "No problems found." fi exit 0