📄 minedaux.c
字号:
while (* text != '\0') if (printlim_char (* text ++, limit) == ERRORS) return;}voidprint_string (text) register char * text;{ lpos = 0; while (* text != '\0') print_char (* text ++);}voidput_blanks (endpos) int endpos;{ int startpos = 0; while (startpos ++ <= endpos) putchar (' ');}voidclear_wholeline (){ if (can_clear_eol == TRUE) clear_eol (); else put_blanks (XMAX);}voidclear_lastline (){ if (can_clear_eol == TRUE) clear_eol (); else put_blanks (XMAX - 1);}/* ================================================================== * * Buffer oriented output * * ================================================================== *//* * Put_line prints the given line on the standard output. * If offset is not zero, printing will start at that x-coordinate. * If the FLAG clear_line is TRUE, then the screen line will be cleared * when the end of the line has been reached.line_print (line) is put_line (line, 0, TRUE, FALSE) * put_line is directly called only by S () and delete_text () */voidput_line (line, offset, clear_line, positioning) LINE * line; /* Line to print */ int offset; /* Offset to start if positioning == FALSE */ /* position if positioning == TRUE */ FLAG clear_line; /* Clear to eoln if TRUE */ FLAG positioning; /* positioning inside line if TRUE (for prop. fonts) */{ register char * textp = line->text; register int count = get_shift (line->shift_count) * - SHIFT_SIZE; int count_ini = count; int tab_count; /* Used in tab expansion */ int offset_start; int offset_stop; if (positioning == TRUE) { offset_start = 0; offset_stop = offset; } else { offset_start = offset; offset_stop = XBREAK; }/* Skip all chars as indicated by the offset_start and the shift_count field */ while (count < offset_start) { if (is_tab (* textp ++)) count = tab (count); else count ++; } if (count == 0 && count_ini < 0 && SHIFT_BEG != '\0') { putchar (SHIFT_BEG); count ++; if (! is_tab (* textp)) textp ++; } while (* textp != '\n' && count < offset_stop) { if (is_tab (* textp)) { /* Expand tabs to spaces */ tab_count = tab (count); while (count < offset_stop && count < tab_count) { count ++; putchar (TABchar); } textp ++; } else { if (iscontrol (* textp)) { reverse_on (); putchar (controlchar (* textp)); reverse_off (); textp ++; } else putchar (* textp ++); count ++; } } if (positioning == TRUE) { /* self-made cursor for terminals (such as xterm) which have display problems with proportional screen fonts and their cursor */ reverse_on (); if (* textp != '\n') putchar (* textp); else if (RET_MARK != '\0') putchar (RET_MARK); else putchar (' '); reverse_off (); set_cursor (0, YMAX); } else /* (positioning == FALSE) */ { /* If line is longer than XBREAK chars, print the shift_mark */ if (count == XBREAK && * textp != '\n') { putchar (SHIFT_MARK); count ++; } /* Mark end of line if so desired */ if (* textp == '\n' && RET_MARK != '\0') { putchar (RET_MARK); count ++; if (RET_BLANK) { while (count < XBREAK) { putchar (RET_BLANK); count ++; } if (RET_BLANK2 && count <= XBREAK) { putchar (RET_BLANK2); count ++; } } } /* Clear the rest of the line if clear_line is TRUE */ if (clear_line == TRUE) { if (can_clear_eol == TRUE) { if (count <= XBREAK) clear_eol (); } else { while (count ++ <= XBREAK) /* clear up to XMAX */ putchar (' '); } } }}/* * set_cursor_xy sets the cursor by either directly calling set_cursor * or, in the case of proportional font support, reprinting the line * up to the x position */voidset_cursor_xy (){ if (proportional == TRUE) { set_cursor (0, y); if (x != 0) put_line (cur_line, x, FALSE, TRUE); /* cur_line may still be undefined if x == 0 */ } else set_cursor (x, y);}/* * Proceed returns the count'th line after `line'. When count is negative * it returns the count'th line before `line'. When the next (previous) * line is the tail (header) indicating EOF (tof) it stops. */LINE *proceed (line, count) register LINE * line; register int count;{ if (count < 0) while (count ++ < 0 && line != header) line = line->prev; else while (count -- > 0 && line != tail) line = line->next; return line;}/* * Reset assigns bot_line, top_line and cur_line according to `head_line' * which must be the first line of the screen, and a y-coordinate, * which will be the current y-coordinate (if it isn't larger than last_y) */voidreset (head_line, screen_y) LINE * head_line; int screen_y;{ register LINE * line; top_line = line = head_line;/* Search for bot_line (might be last line in file) */ for (last_y = 0; last_y < total_lines - 1 && last_y < SCREENMAX && line->next != tail; last_y ++) line = line->next; bot_line = line; y = (screen_y > last_y) ? last_y : screen_y;/* Set cur_line according to the new y value */ cur_line = proceed (top_line, y);}/* * Display line at screen line y_pos if it lies between y_min and y_max. * If it is no text line (end of file), clear screen line. */voiddisplay_line_at (y_pos, line, y_min, y_max, first) int y_pos, y_min, y_max; register LINE * line; FLAG first;{ line = proceed (line, y_pos - y_min); if (y_pos >= y_min && y_pos <= y_max) { set_cursor (0, y_pos); if (line == tail) clear_wholeline (); else { if (first == FALSE) { if (display_delay >= 0) flush (); if (display_delay > 0)#ifdef msdos delay (display_delay);#else (void) usleep (1000 * display_delay);#endif } line_print (line); } }}/* * Display () shows count + 1 lines on the terminal starting at the given * coordinates. At end of file, the rest of the screen is blanked. * When count is negative, a backwards print from `line' will be done. */voiddisplay (y_coord, line, count, new_pos) int y_coord, new_pos; register LINE * line; register int count;{ int y_max = y_coord + count; int y_off;/* Find new startline if count is negative */ if (count < 0) { line = proceed (line, count); count = - count; } display_line_at (new_pos, line, y_coord, y_max, TRUE); y_off = 0; while (y_off < count) { y_off ++; display_line_at (new_pos - y_off, line, y_coord, y_max, FALSE); display_line_at (new_pos + y_off, line, y_coord, y_max, FALSE); }#ifdef UNUSED/* old code, building the display from top to bottom (how boring): *//* with this code, XBREAK must be set to XMAX - 1 *//* Print the lines */ set_cursor (0, y_coord); while (line != tail && count -- >= 0) { line_print (line); line = line->next; }/* Print the blank lines (if any) */ if (loading == FALSE) { while (count -- >= 0) { clear_eol (); putchar ('\n'); } }#endif}/* ================================================================== * * Mined Terminal Dialog * * ================================================================== *//* * promptyn reads in a 'y' or 'n' character. */ucharpromptyn (){ register uchar c; while ((c = readchar ()) != 'y' && c != 'n' && c != '\033' && quit == FALSE) { ring_bell (); flush (); } if (c == '\033') quit = TRUE; return c;}/* * In case of a QUIT signal, swallow the dummy char generated by catchquit () * called by re_search () and change () */voidswallow_dummy_quit_char (){#ifdef UNUSED (void) readchar (); /* Swallow away a quit character delivered by QUIT *//* Not needed because this character is ignored by being the CANCEL command */#endif}/* * Readchar () reads one character from the terminal. * There are problems due to interruption of the read operation by signals * (QUIT, WINCH). The waitingforinput flag is only a partial solution. * Unix doesn't provide sufficient facilities to handle these situations * neatly and properly. Moreover, different Unix versions yield different * surprising effects. However, the use of select () could still be * an improvement. */intreadchar (){ register uchar c;#ifdef msdos FLAG waiting; if (winchg == TRUE && waitingforinput == FALSE) RDwin (); /* In the Unix version, this is now done in __readchar () */ waiting = waitingforinput; /* must be saved since in the MSDOS version, readchar can be called recursively */#endif waitingforinput = TRUE; c = _readchar ();#ifdef msdos waitingforinput = waiting;#else waitingforinput = FALSE;#endif /* the modification if (quit == TRUE) c = QUITCHAR; (now in __readchar) must not be placed after resetting the flag waitingforinput = FALSE; . Otherwise a QUIT signal coming in just between these two would discard the last valid character just taken up. */ return c;}/*-------------------------------------------------------------------------*/#ifndef msdosextern struct { char * fk; void (* fp) ();} keycode [];#define MAXCODELEN 7 /* max. length of function key sequence to be detected, depending on the keycode table *//* * queue collects the keys of an Escape sequence typed in until the * sequence can be detected or rejected. * If the queue is not empty, queue [0] contains the character next * to be delivered by _readchar () (it's not a ring buffer). * The queue contents is always terminated by a '\0', so queue can also * be taken as a character string. */static uchar queue [MAXCODELEN + 1], * endp = queue;intq_empty (){ return (endp == queue ? 1 : 0);}intq_notfull (){ return (endp - queue == MAXCODELEN ? 0 : 1);}voidq_clear (){ endp = queue;}intq_len (){ return endp - queue;}voidq_put (c) uchar c;/* queue must not be full prior to this call! */{ * endp = c; * ++ endp = '\0';}ucharq_get (){ uchar c; register uchar * pd, * ps; c = * queue; pd = queue; ps = pd + 1; while (ps <= endp) * pd ++ = * ps ++; if (endp > queue) endp --; return c;}/* * Look up key sequence in keycode table. * findkey (str) >= 0: str == keycode [findkey (str)].fk * == -1: str is prefix of some entry in keycode * == -2: str is not contained in keycode */intfindkey (str) char * str;{ static int lastmatch = 0; /* last index with string matching prefix */ register int i; if (keycode [0].fk == NIL_PTR) return -2; i = lastmatch; do { if (strncmp (str, keycode [i].fk, strlen (str)) == 0) { lastmatch = i; return (strlen (str) == strlen (keycode [i].fk) ? i : -1); } ++ i; if (keycode [i].fk == NIL_PTR) i = 0; } while (i != lastmatch); return -2;}/* * Is a character available within a specified number of milliseconds ? */intchar_ready_within (msec) int msec;{ return (q_len () > 0) || inputreadyafter (input_fd, msec);}#else /* def msdos: */intchar_ready_within (msec) int msec;{ return inputreadyafter (input_fd, msec);}#endif /* def msdos */void (* keyproc) () = I;uchar (* accentproc) ();/* * Read a character from terminal, considering function keys and * composing special character of an 8 bit character set. * _readchar () takes the following actions: * - function key sequences according to the table 'keycode' are * transformed into a special controlling character which is * assigned the function FUNKEY. Also the intended editor function, * as taken from the table 'keycode', is saved in a variable for * use by FUNKEY. * - the prefix keys for diacritic and special characters are * combined with the following key to make up the character. */int_readchar (){ register uchar ch;#ifndef msdos int res;#endif#ifndef msdos if (q_len () > 0) return q_get ();#endif ch = __readchar (); if (ch == '\000') { ch = __readchar (); keyproc = pc_key_map [ch];#ifdef DEBUG if ((voidfunc) keyproc == (voidfunc) I) return ch; /* (voidfunc) is an identity cast here. It seems to be required for the sake of the apparently totally rotten microvax compiler */#endif accentproc = (charfunc) keyproc; if ((accentproc == grave) || (accentproc == circumflex) || (accentproc == acute) || (accentproc == diaeresis) || (accentproc == tilde) || (accentproc == angstrom)) {ch = (* accentproc) (readchar ()); keyproc = I; return ch; } else return FUNcmd /* index of FUNKEY */; }#ifndef msdos else if (ch == '\033') { /* q_clear (); */ q_put (ch); while ((res = findkey (queue)) == -1 /* prefix of table entry */ && q_notfull () && inputreadyafter (input_fd, 300) ) q_put (__readchar ()); if (quit == TRUE) return '\0'; else if (res < 0) /* key pattern not detected in keycode table */ /* {if (q_len () > 1) return 0; else return ch;} */ return q_get () /* just deliver the typed characters */; else { q_clear (); keyproc = keycode [res].fp; accentproc = (charfunc) keyproc; if ((accentproc == grave) || (accentproc == circumflex) || (accentproc == acute) || (accentproc == diaeresis) || (accentproc == tilde) || (accentproc == angstrom)) {ch = (* accentproc) (readchar ()); keyproc = I; return ch; } else return FUNcmd /* index of FUNKEY */; } }#endif else return ch;}/* ================================================================== * * Status Line Dialog * * ================================================================== *//* * Display a line telling how many chars and lines the file contains. Also tell * whether the file is readonly and/or modified.fstatus (mess, cnt) is file_status ((mess), (cnt), file_name, \ total_lines, TRUE, writable, modified, viewonly) *//* directly called only from WB: file_status (msg_done, chars_saved, file_name, lines_saved, FALSE, TRUE, FALSE, FALSE); */voidfile_status (message, count, file, lines, textstat, writefl, changed, viewing) char * message; register long count; /* Contains number of characters in file */ char * file; int lines; FLAG textstat, writefl, changed, viewing;{ register LINE * line; register int line_num = 0; int line_number = 1; static char msg [maxLINE_LEN + 40]; /* Buffer to hold line */ char yank_msg [maxLINE_LEN]; /* Buffer for msg of yank_file */ if (count < 0) /* Not valid. Count chars in file */ for (line = header->next; line != tail; line = line->next) { count += length_of (line->text); line_num ++; if (line == cur_line) line_number = line_num; } if (yank_status == VALID && textstat == TRUE) /* Append buffer info */ /* build_string (yank_msg, " Buffer: %ld char%s.", chars_saved, (chars_saved == 1L) ? "" : "s"); */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -