📄 aee.c
字号:
Auto_Format(); else if ((character != ' ') && (character != '\t')) formatted = FALSE;}int scanline(m_line, pos) /* find the proper horizontal position for the current position in the line */struct text *m_line;int pos;{ int temp; int count; char *ptr; ptr = m_line->line; count = 1; temp = 0; while (count < pos) { if ((*ptr >= 0) && (*ptr <= 8)) temp += 2; else if (*ptr == 9) temp += tabshift(temp); else if ((*ptr >= 10) && (*ptr <= 31)) temp += 2; else if ((*ptr >= 32) && (*ptr < 127)) temp++; else if (*ptr == 127) temp += 2; else if (!eightbit) temp += 5; else temp++; ptr++; count++; } return(temp);}void tab_insert() /* insert a tab or spaces according to value of 'expand' */{ int temp; int counter; if (expand) { counter = tabshift(curr_buff->scr_pos); for (temp = 0; temp < counter; temp++) insert(' '); if (auto_format) Auto_Format(); } else insert('\t');}void unset_tab(string) /* remove tab setting */char *string;{ char *pointer; int column; int loop_on; struct tab_stops *temp_stack_point; struct tab_stops *stack_point; pointer = string; while (*pointer != (char) NULL) { while (((*pointer < '0') || (*pointer > '9')) && (*pointer != (char) NULL)) pointer++; column = atoi(pointer); temp_stack_point = tabs; if (column > 0) { loop_on = TRUE; while ((temp_stack_point->next_stop != NULL) && (loop_on)) { if (temp_stack_point->next_stop->column != column) temp_stack_point = temp_stack_point->next_stop; else loop_on = FALSE; } if (temp_stack_point->next_stop != NULL) { stack_point = temp_stack_point->next_stop; temp_stack_point->next_stop = stack_point->next_stop; free(stack_point); } } while (((*pointer >= '0') && (*pointer <= '9')) && (*pointer != (char) NULL)) pointer++; }}void tab_set(string) /* get tab settings from the string (columns) */char *string;{ char *pointer; int column; int loop_on; struct tab_stops *temp_stack_point; struct tab_stops *stack_point; pointer = string; while (*pointer != (char) NULL) { while (((*pointer < '0') || (*pointer > '9')) && (*pointer != (char) NULL)) pointer++; column = atoi(pointer); temp_stack_point = tabs; if (column > 0) { loop_on = TRUE; while ((temp_stack_point->next_stop != NULL) && (loop_on)) { if (temp_stack_point->next_stop->column <= column) temp_stack_point = temp_stack_point->next_stop; else loop_on = FALSE; } if ((column > temp_stack_point->column) && (column != temp_stack_point->column)) { stack_point = (struct tab_stops *) xalloc(sizeof( struct tab_stops)); stack_point->column = column; stack_point->next_stop = temp_stack_point->next_stop; temp_stack_point->next_stop = stack_point; } } while (((*pointer >= '0') && (*pointer <= '9')) && (*pointer != (char) NULL)) pointer++; }}int tabshift(temp_int) /* give the number of spaces to shift to the next tab stop */int temp_int; /* current column */{ int leftover; struct tab_stops *stack_point; stack_point = tabs; while ((stack_point != NULL) && (stack_point->column <= temp_int)) stack_point = stack_point->next_stop; if (stack_point != NULL) { leftover = (stack_point->column - temp_int); return(leftover); } leftover = ((temp_int + 1) % tab_spacing); if (leftover == 0) return (1); else return ((tab_spacing + 1) - leftover);}int out_char(window, character, abscolumn, row, offset) /* output non-printing character */WINDOW *window;char character;int abscolumn;int row;int offset;{ int i1, i2, iter; int column; int space; char *string; char *tmp; column = abscolumn % COLS; space = FALSE; if ((character >= 0) && (character < 32)) { if (character == '\t') { i1 = tabshift(abscolumn); for (i2=1; (i2 <= i1)&&((((i2+column)<=curr_buff->last_col)&&(row==curr_buff->last_line))||(row<curr_buff->last_line)); i2++) waddch(window, ' '); return(i1); } else string = ctrl_table[(int)character]; } else if ((character < 0) || (character >= 127)) { if (character == 127) string = "^?"; else if (!eightbit) { space = TRUE; tmp = string = xalloc(6); *tmp = '<'; tmp++; if ((i1=character) < 0) i1 = 256 + character; i2 = i1 / 100; i1 -=i2 * 100; *tmp = i2 + '0'; tmp++; i2 = i1 / 10; i1 -= i2 * 10; *tmp = i2 + '0'; tmp++; i2 = i1; *tmp = i2 + '0'; tmp++; *tmp = '>'; tmp++; *tmp = (char) NULL; } else { waddch(window, (unsigned char) character); return(1); } } tmp = string; for (iter=0; (iter < offset) && (tmp != NULL) && (character != '\t'); iter++) tmp++; for (iter = column; (((iter <= curr_buff->last_col) && (row == curr_buff->last_line)) || (row < curr_buff->last_line)) && (*tmp != (char) NULL); iter++, tmp++) waddch(window, *tmp); iter -= column; if (space) free(string); return(iter);}void draw_line(vertical, horiz, ptr, t_pos, dr_l) /* redraw line from current position */int vertical;int horiz;char *ptr;int t_pos;struct text *dr_l;{ int d; char *temp; int abs_column; int column; int row; int tp_pos; int posit; int highlight; int offset; highlight = FALSE; abs_column = horiz; column = abs_column % COLS; row = vertical; temp = ptr; d = 0; posit = t_pos; if (row < 0) { while (row < 0) { abs_column += d = len_char(*temp, abs_column); column += d; if (column > curr_buff->last_col) { row++; if ((d > 1) && (row == 0)) { d = d - (column - COLS); abs_column -= column - COLS; } else { posit++; temp++; d = 0; } column %= COLS; } else { posit++; temp++; } } column = 0; } wmove(curr_buff->win, row, column); wclrtoeol(curr_buff->win); if ((mark_text) && (pst_pos == 1) && (curr_buff->pointer == ptr) && (cpste_line->line_length > 1)) { highlight = TRUE; tp_pos = pst_pos; } else if (mark_text) wstandend(curr_buff->win); while ((posit < dr_l->line_length) && (((column <= curr_buff->last_col) && (row == curr_buff->last_line)) || (row < curr_buff->last_line))) { if ((mark_text) && (pst_pos == 1) && (curr_buff->pointer == ptr) && (highlight)) { if (tp_pos < cpste_line->line_length) wstandout(curr_buff->win); else wstandend(curr_buff->win); tp_pos++; } if ((*temp < 32) || (*temp > 126)) { offset = out_char(curr_buff->win, *temp, abs_column, row, d); column += offset; abs_column += offset; d = 0; } else { abs_column++; column++; waddch(curr_buff->win, *temp); } if (column > curr_buff->last_col) { column = column % COLS; row++; } posit++; temp++; } if (((column < curr_buff->last_col) && (row == curr_buff->last_line)) || (row < curr_buff->last_line)) wclrtoeol(curr_buff->win); wstandend(curr_buff->win); wmove(curr_buff->win, vertical, horiz);}void insert_line(disp) /* insert new line into file and if disp=TRUE, reorganize screen accordingly */int disp;{ int temp_pos; int temp_pos2; int i; char *temp; char *extra; struct text *temp_nod; /* temporary pointer to new line */ int temp_overstrike; i = curr_buff->curr_line->vert_len; wmove(curr_buff->win, curr_buff->scr_vert, curr_buff->scr_horz); wclrtoeol(curr_buff->win); change = TRUE; temp_nod= txtalloc(); temp_nod->line = extra = xalloc(6 + curr_buff->curr_line->line_length - curr_buff->position); temp_nod->line_length = 1 + curr_buff->curr_line->line_length - curr_buff->position; temp_nod->vert_len = 1; temp_nod->max_length = temp_nod->line_length + 5; if (curr_buff->position == 1) temp_nod->line_number = curr_buff->curr_line->line_number; else temp_nod->line_number = curr_buff->curr_line->line_number + 1; temp_nod->next_line = curr_buff->curr_line->next_line; if (temp_nod->next_line != NULL) temp_nod->next_line->prev_line = temp_nod; temp_nod->prev_line = curr_buff->curr_line; curr_buff->curr_line->next_line = temp_nod; temp_pos2 = curr_buff->position; temp = curr_buff->pointer; if (temp_pos2 != curr_buff->curr_line->line_length) { temp_pos = 1; while (temp_pos2 < curr_buff->curr_line->line_length) { temp_pos++; temp_pos2++; *extra= *temp; extra++; temp++; } temp = curr_buff->pointer; *temp = (char) NULL; temp = resiz_line((1 - temp_nod->line_length), curr_buff->curr_line, curr_buff->position); curr_buff->curr_line->line_length = curr_buff->position; curr_buff->curr_line->vert_len = (scanline(curr_buff->curr_line, curr_buff->curr_line->line_length) / COLS) + 1; curr_buff->curr_line->changed = TRUE; } curr_buff->curr_line->line_length = curr_buff->position; curr_buff->curr_line = temp_nod; curr_buff->curr_line->vert_len = (scanline(curr_buff->curr_line, curr_buff->curr_line->line_length) / COLS) + 1; *extra = (char) NULL; curr_buff->position = 1; curr_buff->pointer = curr_buff->curr_line->line; curr_buff->num_of_lines++; curr_buff->absolute_lin++; curr_buff->curr_line->changed = TRUE; curr_buff->changed = TRUE; if (curr_buff->journalling) { write_journal(curr_buff, curr_buff->curr_line); if (curr_buff->curr_line->prev_line->changed) write_journal(curr_buff, curr_buff->curr_line->prev_line); } if (disp) { i = (curr_buff->curr_line->vert_len + curr_buff->curr_line->prev_line->vert_len) - i; if (curr_buff->scr_vert < curr_buff->last_line) { curr_buff->scr_vert++; wclrtoeol(curr_buff->win); wmove(curr_buff->win, curr_buff->scr_vert, 0); if (i > 0) winsertln(curr_buff->win); } else { wmove(curr_buff->win, 0, 0); wdeleteln(curr_buff->win); wmove(curr_buff->win, curr_buff->last_line, 0); wclrtobot(curr_buff->win); } curr_buff->abs_pos = curr_buff->scr_pos = curr_buff->scr_horz = 0; draw_line(curr_buff->scr_vert, curr_buff->scr_pos, curr_buff->pointer, curr_buff->position, curr_buff->curr_line); } curr_buff->abs_pos = curr_buff->scr_pos = curr_buff->scr_horz = 0; if ((mark_text) && (cpste_line->line_length == pst_pos)) { i = mark_text; mark_text = FALSE; left(TRUE); mark_text = i; right(TRUE); } if (indent) { int temp_lm = left_margin; left_margin = 0; if (curr_buff->curr_line->prev_line != NULL) { temp = curr_buff->curr_line->prev_line->line; i = overstrike; overstrike = FALSE; while ((*temp == ' ') || (*temp == '\t')) { insert(*temp); temp++; } overstrike = i; } left_margin = temp_lm; } if ((observ_margins) && (left_margin != 0) && (curr_buff->scr_pos < left_margin)) { temp_overstrike = overstrike; overstrike = FALSE; i = left_margin; left_margin = 0; while (curr_buff->scr_pos < i) insert(' '); left_margin = i; overstrike = temp_overstrike; }}struct text *txtalloc() /* allocate space for line structure */{ struct text *txt_tmp; txt_tmp = (struct text *) xalloc(sizeof( struct text)); txt_tmp->changed = FALSE; txt_tmp->file_info.info_location = NO_FURTHER_LINES; txt_tmp->file_info.prev_info = NO_FURTHER_LINES; txt_tmp->file_info.next_info = NO_FURTHER_LINES; return(txt_tmp);}struct files *name_alloc() /* allocate space for file name list node */{ struct files *temp_name; temp_name = (struct files *) xalloc(sizeof( struct files)); return(temp_name);}struct bufr *buf_alloc() /* allocate space for buffers */{ struct bufr *temp_buf; temp_buf = (struct bufr *) xalloc(sizeof(struct bufr)); temp_buf->journal_file = NULL; temp_buf->file_name = NULL; temp_buf->full_name = ""; temp_buf->orig_dir = NULL; temp_buf->journalling = FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -