📄 mined.doc
字号:
+=====================================================================+| Documentation file of the Mined editor. |+=====================================================================+ Author: Michiel Huisjes. Modified by Achim M黮ler to run on a Unix machine with VT100-like terminals attached and to recognize function key character sequences. Modifications and corrections made by Thomas Wolff: Basic capabilities: Runs with arbitrary terminals on UNIX (using termcap). Responds correctly to changes of window size, including redisplay of status line; keeps position in text. Accepts and displays an 8 bit character set. User interface: Two letter ESCAPE commands are used for less frequent functions. The concept of a HOP key prefix was introduced which fortifies any positioning function that follows. This provides more command flexibility without too much need of key remembering. Command key layout changed to resemble WordMaster/WordStar. Improved behaviour: Stripping off lines too long for the screen implemented also on status line output. If status line input overflows the screen and wraps/scrolls, the screen is redisplayed. Search displays a "wrap around end of file" message for better orientation. In case of system errors, the appropriate error message is fetched and displayed instead of printing numerical hieroglyphs or indistinguished commonplace messages (as many UNIX commands do). Additional features and commands: A HELP command. A SUSPEND command with automatic file saving. A repeat search command. A replace command with confirmation dialogue. A change working directory command. A change file name reference command. Reading from standard input and writing to standard output. Starting up at a given line number. Appending versions of the buffer cut/copy/write commands. Process-independent version of the paste command, thus enabling inter-window paste operations. A view only version of the edit command (not yet very well developed). Commands to print buffer / to perform command with buffer as input. Positioning to a percentage within the text. Accepts control char sequence for absolute positioning (by mouse) Multi-file edit External interrupt handling with attempts to save the text Configurable indicators for line shift left/right, line end, tab. Improved text security: Doesn't quit if a file save fails or even if the question for a filename isn't answered. So you have a chance to try another filename or something. Asks whether to overwrite file whenever a file is to be written to which was not previously read in. Removed abort_mined since no one wants to kill an editor unconditionally without attempt to save the text. Corrections: Some screen positioning errors and inconsistencies have been eliminated, for example: The EF function now really positions to the end of the text, not to the beginning of the last line, The HIGH and LOW functions now stay in the current screen column, as UP and DN do now more consistently. Input routine detects overflow of input buffer. Doesn't crash if a file loaded or inserted contains NULL chars. Scratch file counting and deleting was corrected. The Readonly flag and status message is now based on the really effective circumstances (could show wrong state before if real and effective user id were different). Several minor modifications, e.g.: XBREAK (the screen column limit) was increased by 1, since two columns were left blank on the right screen border. Missing modification: The rightmost screen column is currently unused because linefeed is used as a line positioner. If absolute positioning would be added for each text line output, the screen column limit XBREAK could again be increased by 1. Many further improvements, including special MSDOS adaptations, not further described here. See the help file for information about mined's features. 1. General remarks. Mined is a screen editor designed for the minix operating system. It is meant to be used on files not larger than 50K and to be fast. When mined starts up, it reads the file into its memory to minimize disk access. The only time that disk access is needed is when certain save, write or copy commands are given. Mined has the style of Emacs or Jove, that means that there are no modes. Each character has its own entry in an 256 pointer to function array, which is called when that character is typed. Only ASCII characters are connected with a function that inserts that character at the current location in the file. Two exceptions are <linefeed> and <tab> which are inserted as well. Note that the mapping between commands and functions called is implicit in the table. Changing the mapping just implies changing the pointers in this table. The display consists of SCREENMAX + 1 lines and XMAX + 1 characters. When a line is larger (or gets larger during editing) than XBREAK characters, the line is either shifted SHIFT_SIZE characters to the left (which means that the first SHIFT_SIZE characters are not printed) or the end of the line is marked with the SHIFT_MARK character and the rest of the line is not printed. A line can never exceed MAX_CHARS characters. Mined will always try to keep the cursor on the same line and same (relative) x-coordinate if nothing changed. So if you scroll one line up, the cursor stays on the same line, or when you move one line down, the cursor will move to the same place on the line as it was on the previous. Every character on the line is available for editing including the linefeed at the the of the line. When the linefeed is deleted, the current line and the next line are joined. The last character of the file (which is always a linefeed) can never be deleted. The bottomline (as indicated by YMAX + 1) is used as a status line during editing. This line is usually blank or contains information mined needs during editing. This information (or rather questions) is displayed in reverse video. The terminal modes are changed completely. All signals like start/stop, interrupt etc. are unset. The only signal that remains is the quit signal. The quit signal (^\) is the general abort signal for mined. Typing a ^\ during searching or when mined is asking for filenames, etc. will abort the function and mined will return to the main loop. Sending a quit signal during the main loop will abort the session (after confirmation) and the file is not (!) saved. *removed* The session will also be aborted when an unrecoverable error occurs, e.g. when there is no more memory available. If the file has been modified, mined will ask if the file has to be saved or not. If there is no more space left on the disk, mined will just give an error message and continue. The number of system calls are minimized. This is done to keep the editor as fast as possible. I/O is done in SCREEN_SIZE reads/writes. Accumulated output is also flushed at the end of each character typed. 2. Regular expressions Mined has a built in regular expression matcher, which is used for searching and replace routines. A regular expression consists of a sequence of: 1. A normal character matching that character. 2. A . matching any character. 3. A ^ matching the begin of a line. 4. A $ (as last character of the pattern) mathing the end of a line. 5. A \<character> matching <character>. 6. A number of characters enclosed in [] pairs matching any of these characters. A list of characters can be indicated by a '-'. So [a-z] matches any letter of the alphabet. If the first character after the '[' is a '^' then the set is negated (matching none of the characters). A ']', '^' or '-' can be escaped by putting a '\' in front of it. Of course this means that a \ must be represented by \\. 7. If one of the expressions as described in 1-6 is followed by a '*' than that expressions matches a sequence of 0 or more of that expression. Parsing of regular expression is done in two phases. In the first phase the expression is compiled into a more comprehensible form. In the second phase the actual matching is done. For more details see 3.6. 3. Implementation of mined. 3.1 Data structures. The main data structures are as follows. The whole file is kept in a double linked list of lines. The LINE structure looks like this: typedef struct Line { struct Line * next; struct Line * prev; char * text; unsigned char shift_count; } LINE; Each line entry contains a pointer to the next line, a pointer to the previous line and a pointer to the text of that line. A special field shift_count contains the number of shifts (in units of SHIFT_SIZE) that is performed on that line. The total size of the structure is 7 bytes so a file consisting of 1000 empty lines will waste a lot of memory. A LINE structure is allocated for each line in the file. After that the number of characters of the line is counted and sufficient space is allocated to store them (including a linefeed and a '\0'). The resulting address is assigned to the text field in the structure. A special structure is allocated and its address is assigned to the variable header as well as the variable tail. The text field of this structure is set to NIL_PTR. The tail->prev of this structure points to the last LINE of the file and the header->next to the first LINE. Other LINE * variables are top_line and bot_line which point to the first line resp. the last line on the screen. Two other variables are important as well. First the LINE * cur_line, which points to the LINE currently in use and the char * cur_text, which points to the character at which the cursor stands. Whenever an ASCII character is typed, a new line is build with this character inserted. Then the old data space (pointed to by cur_line->text) is freed, data space for the new line is allocated and assigned to cur_line->text. Two global variables called x and y represent the x and y coordinates from the cursor. The global variable nlines contains the number of lines in the file. Last_y indicates the maximum y coordinate of the screen (which is usually SCREENMAX). A few strings must be initialized by hand before compiling mined. These string are enter_string, which is printed upon entering mined, rev_video (turn on reverse video), normal_video, rev_scroll (perform a reverse scroll) and pos_string. The last string should hold the absolute position string to be printed for cursor motion. The #define X_PLUS and Y_PLUS should contain the characters to be added to the coordinates x and y (both starting at 0) to finish cursor positioning. 3.2 Starting up.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -