📄 aee.c
字号:
temp_buf->changed = FALSE; temp_buf->main_buffer = FALSE; temp_buf->edit_buffer = FALSE; temp_buf->dos_file = FALSE; return (temp_buf);}char *next_word(string) /* move to next word in string */char *string;{ while ((*string != (char) NULL) && ((*string != 32) && (*string != 9))) string++; while ((*string != (char) NULL) && ((*string == 32) || (*string == 9))) string++; return(string);}int scan(line, offset, column) /* determine horizontal position for get_string */char *line;int offset;int column;{ char *stemp; int i; int j; stemp = line; i = 0; j = column; while (i < offset) { i++; j += len_char(*stemp, j); stemp++; } return(j);}char *get_string(prompt, advance) /* read string from input on command line */char *prompt; /* string containing user prompt message */int advance; /* if true, skip leading spaces and tabs */{ char *string; char *tmp_string; char *nam_str; char *g_point; int tmp_int; int g_horz, g_position, g_pos; int esc_flag; g_point = tmp_string = xalloc(512); wmove(com_win,0,0); wclrtoeol(com_win); waddstr(com_win, prompt); wrefresh(com_win); nam_str = tmp_string; clr_cmd_line = TRUE; g_horz = g_position = scan(prompt, strlen(prompt), 0); g_pos = 0; do { esc_flag = FALSE; get_input(com_win); if (((in == 8) || (in == 127) || (in == KEY_BACKSPACE)) && (g_pos > 0)) { tmp_int = g_horz; g_pos--; g_horz = scan(g_point, g_pos, g_position); tmp_int = tmp_int - g_horz; for (; 0 < tmp_int; tmp_int--) { if ((g_horz+tmp_int) < (curr_buff->last_col - 1)) { waddch(com_win, '\010'); waddch(com_win, ' '); waddch(com_win, '\010'); } } nam_str--; } else if ((in != 8) && (in != 127) && (in != '\n') && (in != '\r') && (in < 256)) { if (in == '\026') /* control-v, accept next character verbatim */ { /* allows entry of ^m, ^j, and ^h */ esc_flag = TRUE; get_input(com_win); } *nam_str = in; g_pos++; if (((in < 32) || (in > 126)) && (g_horz < (curr_buff->last_col - 1))) g_horz += out_char(com_win, in, g_horz, curr_buff->last_line, 0); else { g_horz++; if (g_horz < (curr_buff->last_col - 1)) waddch(com_win, in); } nam_str++; } wrefresh(com_win); if (esc_flag) in = (char) NULL; } while ((in != '\n') && (in != '\r')); *nam_str = (char) NULL; nam_str = tmp_string; if (((*nam_str == ' ') || (*nam_str == 9)) && (advance)) nam_str = next_word(nam_str); string = xalloc(strlen(nam_str) + 1); copy_str(nam_str, string); free(tmp_string); wrefresh(com_win); return(string);}int len_char(character, column) /* return the length of the character */char character;int column; /* the column must be known to provide spacing for tabs */{ int length; if (character == '\t') length = tabshift(column); else if ((character >= 0) && (character < 32)) length = 2; else if ((character >= 32) && (character <= 126)) length = 1; else if (character == 127) length = 2; else if (((character > 126) || (character < 0)) && (!eightbit)) length = 5; else length = 1; return(length);}void ascii() /* get ascii code from user and insert into file */{ int i; char *string, *t; i = 0; t = string = get_string(ascii_code_str, TRUE); if (*t != (char) NULL) { while ((*string >= '0') && (*string <= '9')) { i= i * 10 + (*string - '0'); string++; } in = i; wmove(curr_buff->win, curr_buff->scr_vert, curr_buff->scr_horz); insert(in); } free(t);}void print_buffer(){ char buffer[256]; sprintf(buffer, ">!%s", print_command); wmove(com_win, 0, 0); wclrtoeol(com_win); wprintw(com_win, printing_msg, curr_buff->name, print_command); wrefresh(com_win); command(buffer);}int compare(string1, string2, sensitive) /* compare two strings */char *string1;char *string2;int sensitive;{ char *strng1; char *strng2; int tmp; int equal; strng1 = string1; strng2 = string2; tmp = 0; if ((strng1 == NULL) || (strng2 == NULL) || (*strng1 == (char) NULL) || (*strng2 == (char) NULL)) return(FALSE); equal = TRUE; while (equal) { if (sensitive) { if (*strng1 != *strng2) equal = FALSE; } else { if (toupper(*strng1) != toupper(*strng2)) equal = FALSE; } strng1++; strng2++; if ((*strng1 == (char) NULL) || (*strng2 == (char) NULL) || (*strng1 == ' ') || (*strng2 == ' ')) break; tmp++; } return(equal);}void goto_line(cmd_str) /* goto first line with the given number */char *cmd_str;{ int number; int i; char *ptr; char *direction; struct text *t_line; ptr = cmd_str; i= 0; while ((*ptr >='0') && (*ptr <= '9')) { i= i * 10 + (*ptr - '0'); ptr++; } number = i; i = 0; t_line = curr_buff->curr_line; while ((t_line->line_number > number) && (t_line->prev_line != NULL)) { i++; t_line = t_line->prev_line; direction = "u"; } if (i == 0) { while ((t_line->line_number < number) && (t_line->next_line != NULL)) { i++; direction = "d"; t_line = t_line->next_line; } } if (i != 0) move_rel(direction, i); wmove(com_win,0,0); wclrtoeol(com_win); wprintw(com_win, line_num_str, curr_buff->curr_line->line_number); wrefresh(com_win); clr_cmd_line = TRUE; wmove(curr_buff->win, curr_buff->scr_vert, curr_buff->scr_horz);}void make_win() /* allow windows */{ if (((!windows) && (!mark_text)) && (num_of_bufs <= ((LINES - 1)/2))) { windows = TRUE; if (num_of_bufs > 1) { werase(first_buff->win); wrefresh(first_buff->win); delwin(first_buff->win); t_buff = first_buff; while (t_buff != NULL) { t_buff->win = NULL; t_buff = t_buff->next_buff; } redo_win(); new_screen(); curr_buff->win = curr_buff->win; } }}void no_windows() /* disallow windows */{ int temp; if ((windows) && (!mark_text)) { windows = FALSE; if (num_of_bufs > 1) { t_buff = first_buff; werase(t_buff->win); wrefresh(t_buff->win); delwin(t_buff->win); werase(t_buff->footer); wrefresh(t_buff->footer); delwin(t_buff->footer); t_buff->footer = NULL; if (info_window) { temp = info_win_height; if (info_win == NULL) { info_win = newwin(info_win_height, COLS, 0, 0); paint_info_win(); } } else temp = 0; t_buff->win = newwin(LINES - temp - 1, COLS, temp, 0); t_buff->window_top = temp; keypad(t_buff->win, TRUE); idlok(t_buff->win, TRUE); t_buff->lines = LINES - temp - 1; t_buff->last_col = COLS - 1; t_buff->last_line = t_buff->lines - 1; t_buff = t_buff->next_buff; while (t_buff != NULL) { werase(t_buff->win); wrefresh(t_buff->win); werase(t_buff->footer); wrefresh(t_buff->footer); delwin(t_buff->footer); delwin(t_buff->win); t_buff->footer = NULL; t_buff->win = first_buff->win; t_buff->window_top = first_buff->window_top; t_buff->lines = first_buff->lines; t_buff->last_line = first_buff->last_line; t_buff->last_col = first_buff->last_col; t_buff = t_buff->next_buff; } new_screen(); } }}void midscreen(line, count) /* repaint window with current line at the specified line */int line;int count;{ struct text *mid_line; struct text *a_line; struct text *b_line; char *tp; /* temporary pointer */ int abs_column; /* the number of columns from start of line */ int ti; /* temporary integer */ int ti1; /* another temporary integer */ int tppos; /* temporary paste position */ int m; int i; mid_line = curr_buff->curr_line; /* | find the first line visible on the screen (from the top) */ i = (curr_buff->scr_pos / COLS); while ((i < line) && (curr_buff->curr_line->prev_line != NULL) && (i < curr_buff->last_line)) { curr_buff->curr_line = curr_buff->curr_line->prev_line; i += curr_buff->curr_line->vert_len; } /* | set up temporary pointers to store the current information */ tp = curr_buff->curr_line->line; tppos = 1; ti1 = ti = 0; curr_buff->scr_vert = curr_buff->scr_horz = 0; wmove(curr_buff->win, 0, 0); a_line = curr_buff->curr_line; if (i > line) ti = line - i; else ti = 0; /* | erase the window and paint the information */ werase(curr_buff->win); while ((a_line != NULL) && (ti <= curr_buff->last_line)) { draw_line(ti, 0, tp, 1, a_line); ti += a_line->vert_len; a_line = a_line->next_line; if (a_line != NULL) tp = a_line->line; } if (i > line) curr_buff->scr_vert = line; else curr_buff->scr_vert = i; curr_buff->curr_line = mid_line; /* | Now highlight areas that have been marked. */ if (mark_text) /* paint selected text */ { b_line = cpste_line; a_line = curr_buff->curr_line; tppos = pst_pos; /* | if the marked areas are before the cursor... */ if ((pst_pos == cpste_line->line_length) && (cpste_line->next_line == NULL)) { /* | if there are multiple marked lines, find out | how much vertical space they use */ if (cpste_line->prev_line != NULL) { i = scanline(curr_buff->curr_line, count) / COLS; while ((i <= curr_buff->scr_vert) && (cpste_line->prev_line!= NULL)) { curr_buff->curr_line = curr_buff->curr_line->prev_line; cpste_line = cpste_line->prev_line; i += curr_buff->curr_line->vert_len; } } else i = 0; tp = curr_buff->curr_line->line; ti = 1; /* | set up to highlight a partial line */ if (curr_buff->curr_line->line_length != cpste_line->line_length) { if (i != 0) { ti = curr_buff->curr_line->line_length - cpste_line->line_length; ti++; for (ti1=1; ti1<ti; ti1++) tp++; } else { for (ti = 1; ti <= (curr_buff->position - cpste_line->line_length); ti++) tp++; } } abs_column = curr_buff->scr_horz = scanline(curr_buff->curr_line, ti); m = curr_buff->scr_horz / COLS; curr_buff->scr_horz = curr_buff->scr_horz % COLS; wmove(curr_buff->win, (m + curr_buff->scr_vert - 1), curr_buff->scr_horz); wstandout(curr_buff->win); curr_buff->pointer = tp; pst_pos = 1; if (i == 0) i = scanline(curr_buff->curr_line, curr_buff->position) / COLS; draw_line(m + curr_buff->scr_vert - i, abs_column, curr_buff->pointer, ti, curr_buff->curr_line); for (ti = i - curr_buff->curr_line->vert_len; ti >= 0; ti -= curr_buff->curr_line->vert_len) { cpste_line = cpste_line->next_line; curr_buff->curr_line = curr_buff->curr_line->next_line; pst_pos = 1; curr_buff->pointer = curr_buff->curr_line->line; draw_line(curr_buff->scr_vert-ti, 0, curr_buff->curr_line->line, 1, curr_buff->curr_line); } } /* | or the marked text is after the cursor... */ else { pst_pos = 1; i = curr_buff->scr_vert; draw_line(curr_buff->scr_vert, curr_buff->scr_pos, curr_buff->pointer, curr_buff->position, curr_buff->curr_line); i += curr_buff->curr_line->vert_len - (scanline(curr_buff->curr_line, curr_buff->position) / COLS); if (curr_buff->curr_line->next_line != NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -