📄 ed.c
字号:
i = entab_adjust_rcol( g_status.line_buff, g_status.line_buff_len, i, file->ptab_size ); if (i < g_status.line_buff_len) k = g_status.line_buff[i]; else if (i == g_status.line_buff_len) k = -1; } else { if (file->inflate_tabs && window->ll->len != EOF) i = entab_adjust_rcol( window->ll->line, window->ll->len, i, file->ptab_size ); if (i < window->ll->len) k = window->ll->line[i]; else if (i == window->ll->len) k = -1; } if (k >= 0) { line_col[0] = k; line_col[2] = hex_digit[(k >> 4)]; line_col[3] = hex_digit[(k & 0x0f)]; line_col[4] = 'x'; } else if (k == -1) strcpy( line_col+2, EOL_TEXT ); c_output( *line_col, 58, g_display.mode_line, Color( Mode ) ); s_output( line_col+1, g_display.mode_line, 59, Color( Mode ) ); } /* * if file was opened in binary mode, show offset from beginning of file. */ if (file->crlf == BINARY && !window->vertical) { k = window->ll->line == NULL ? 0 : window->rcol; if (file->inflate_tabs && k != 0) { if (g_status.copied) k = entab_adjust_rcol( g_status.line_buff, g_status.line_buff_len, k, file->ptab_size ); else k = entab_adjust_rcol( window->ll->line, window->ll->len, k, file->ptab_size ); } n_output( window->bin_offset + k, 7, window->end_col - 18, window->top, Color( Head ) ); } show_asterisk( window ); /* * Indicate if the line has a marker by displaying its number in the * mode line, using the diagnostic color. Number 0 represents previous * position. */ if (!g_status.wrapped && do_mode) { for (i = 0, k = 0; k < NO_MARKERS; ++k) { if (file->marker[k].marked && file->marker[k].rline == window->rline) line_col[i++] = k + '0'; } if (old_rline != window->rline) { show_search_message( CLR_SEARCH ); old_rline = window->rline; } if (i) { line_col[i] = '\0'; s_output( line_col, g_display.mode_line, 75 - i, Color( Diag ) ); } }}/* * Name: show_asterisk * Purpose: give user an indication if file is dirty * Date: September 16, 1991 * Passed: window: pointer to current window * * jmh 990428: if in read-only mode, display an exclamation mark. * jmh 991108: take into account line number display. * jmh 030323: display '!' beside '*'; use '#' for scratch windows. */void show_asterisk( TDE_WIN *window ){char buf[3]; buf[0] = ' '; buf[1] = (window->file_info->scratch) ? '#' : (window->file_info->modified) ? '*' : ' '; buf[2] = '\0'; if (window->file_info->read_only) buf[(buf[1] == ' ')] = '!'; s_output( buf, window->top, window->left+3, Color( Head ) );}/* * Name: toggle_overwrite * Purpose: toggle overwrite-insert mode * Date: September 16, 1991 * Passed: arg_filler: argument to satisfy function prototype * jmh 981130: disable toggling when cursor update direction is not normal. * jmh 990404: move set_cursor_size() to show_insert_mode(). */int toggle_overwrite( TDE_WIN *arg_filler ){ if (mode.cur_dir == CUR_RIGHT) { mode.insert = !mode.insert; show_insert_mode( ); } return( OK );}/* * Name: toggle_smart_tabs * Purpose: toggle smart tab mode * Date: June 5, 1992 * Passed: arg_filler: argument to satisfy function prototype */int toggle_smart_tabs( TDE_WIN *arg_filler ){ mode.smart_tab = !mode.smart_tab; show_tab_modes( ); return( OK );}/* * Name: toggle_indent * Purpose: toggle indent mode * Date: September 16, 1991 * Passed: arg_filler: argument to satisfy function prototype */int toggle_indent( TDE_WIN *arg_filler ){ mode.indent = !mode.indent; show_indent_mode( ); return( OK );}/* * Name: set_margins * Purpose: set left, paragraph and right margin for word wrap * Date: November 27, 1991 * Passed: window * * jmh 031115: combined the three individual margins into one function. */int set_margins( TDE_WIN *window ){int rc; set_dlg_num( EF_Left, mode.left_margin + 1 ); set_dlg_num( EF_Right, mode.right_margin + 1 ); set_dlg_num( EF_Para, mode.parg_margin + 1 ); CB_Justify = mode.right_justify; rc = do_dialog( margins_dialog, margins_proc ); if (rc == OK) { mode.left_margin = (int)get_dlg_num( EF_Left ) - 1; mode.right_margin = (int)get_dlg_num( EF_Right ) - 1; mode.parg_margin = (int)get_dlg_num( EF_Para ) - 1; mode.right_justify = CB_Justify; show_all_rulers( ); } return( rc );}/* * Name: margins_proc * Purpose: dialog callback for SetMargins * Author: Jason Hood * Date: November 30, 2003 * Notes: ensure left and paragraph margins are less than right margin; * ensure right margin is less than maximum line length. */int margins_proc( int id, char *text ){int left, right, para;int rc = OK; if (id == 0) { left = (int)get_dlg_num( EF_Left ); right = (int)get_dlg_num( EF_Right ); para = (int)get_dlg_num( EF_Para ); if (right < 1 || right > MAX_LINE_LENGTH || (right <= left && right <= para)) { /* * right margin out of range */ error( WARNING, g_display.end_line, ed12 ); rc = IDE_RIGHT; } else if (left < 1 || left >= right) { /* * left margin out of range */ error( WARNING, g_display.end_line, ed10 ); rc = IDE_LEFT; } else if (para < 1 || para >= right) { /* * paragraph margin out of range */ error( WARNING, g_display.end_line, ed14 ); rc = IDE_PARA; } } return( rc );}/* * Name: toggle_crlf * Purpose: toggle crlf mode * Date: November 27, 1991 * Passed: arg_filler: argument to satisfy function prototype * * jmh 980702: display size to remove offset when changing from binary */int toggle_crlf( TDE_WIN *window ){register TDE_WIN *w; ++window->file_info->crlf; if (window->file_info->crlf > BINARY) window->file_info->crlf = CRLF; w = g_status.window_list; while (w != NULL) { if (w->file_info == window->file_info && w->visible) { show_crlf_mode( w ); show_size( w ); } w = w->next; } return( OK );}/* * Name: toggle_ww * Purpose: toggle word wrap mode * Date: November 27, 1991 * Passed: arg_filler: argument to satisfy function prototype */int toggle_ww( TDE_WIN *arg_filler ){ ++mode.word_wrap; if (mode.word_wrap > DYNAMIC_WRAP) mode.word_wrap = NO_WRAP; show_wordwrap_mode( ); return( OK );}/* * Name: toggle_trailing * Purpose: toggle eleminating trainling space at eol * Date: November 25, 1991 * Passed: arg_filler: argument to satisfy function prototype */int toggle_trailing( TDE_WIN *arg_filler ){ mode.trailing = !mode.trailing; show_trailing( ); return( OK );}/* * Name: toggle_z * Purpose: toggle writing control z at eof * Date: November 25, 1991 * Passed: arg_filler: argument to satisfy function prototype */int toggle_z( TDE_WIN *arg_filler ){ mode.control_z = !mode.control_z; show_control_z( ); return( OK );}/* * Name: toggle_eol * Purpose: toggle writing eol character at eol * Date: November 25, 1991 * Passed: arg_filler: argument to satisfy function prototype * jmh 980725: added a third state - display a character if the line * extends beyond the window edge. */int toggle_eol( TDE_WIN *arg_filler ){register file_infos *file; if (++mode.show_eol == 3) mode.show_eol = 0; for (file=g_status.file_list; file != NULL; file=file->next) file->dirty = GLOBAL; return( OK );}/* * Name: toggle_search_case * Purpose: toggle search case * Date: September 16, 1991 * Passed: arg_filler: argument to satisfy function prototype * * jmh 010704: work with regx. */int toggle_search_case( TDE_WIN *arg_filler ){ mode.search_case = (mode.search_case == IGNORE) ? MATCH : IGNORE; show_search_case( ); build_boyer_array( ); if (regx.search_defined == OK) build_nfa( ); return( OK );}/* * Name: toggle_sync * Purpose: toggle sync mode * Date: January 15, 1992 * Passed: arg_filler: argument to satisfy function prototype */int toggle_sync( TDE_WIN *arg_filler ){ mode.sync = !mode.sync; show_sync_mode( ); return( OK );}/* * Name: toggle_ruler * Purpose: toggle ruler * Date: March 5, 1992 * Passed: arg_filler: argument to satisfy function prototype */int toggle_ruler( TDE_WIN *arg_filler ){register TDE_WIN *wp; mode.ruler = !mode.ruler; wp = g_status.window_list; while (wp != NULL) { /* * there has to be more than one line in a window to display a ruler. * even if the ruler mode is on, we need to check the num of lines. */ wp->ruler = (mode.ruler && wp->bottom_line != wp->top_line); setup_window( wp ); check_cline( wp, wp->cline ); if (wp->visible) redraw_current_window( wp ); wp = wp->next; } return( OK );}/* * Name: toggle_tabinflate * Purpose: toggle inflating tabs * Date: October 31, 1992 * Passed: window: pointer to current window */int toggle_tabinflate( TDE_WIN *window ){register file_infos *file; file = window->file_info; ++file->inflate_tabs; if (file->inflate_tabs > 2) file->inflate_tabs = 0; file->dirty = GLOBAL; show_tab_modes( ); return( OK );}/* * Name: toggle_cursor_cross * Purpose: toggle cursor cross * Author: Jason Hood * Date: July 24, 1998 * Passed: arg_filler: argument to satisfy function prototype */int toggle_cursor_cross( TDE_WIN *arg_filler ){register file_infos *file; mode.cursor_cross = !mode.cursor_cross; for (file=g_status.file_list; file != NULL; file=file->next) file->dirty = GLOBAL; return( OK );}/* * Name: toggle_graphic_chars * Purpose: toggle graphic characters (on/off - not different sets) * Author: Jason Hood * Date: July 24, 1998 * Passed: arg_filler: argument to satisfy function prototype */int toggle_graphic_chars( TDE_WIN *arg_filler ){ mode.graphics = -mode.graphics; show_graphic_chars( ); return( OK );}/* * Name: change
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -