📄 hwind.c
字号:
} xygoto( -1, -1 ); SAVE_LINE( g_display.mode_line ); eol_clear( 0, g_display.mode_line, Color( Help ) ); i = (g_display.ncols - (int)strlen( ruler_help )) / 2; if (i < 0) i = 0; s_output( ruler_help, g_display.mode_line, i, Color( Help ) ); dup_window_info( &ruler_win, window ); ruler_win.bcol = 0; /* * move dw to the top line */ while (dw.cline != dw.top_line) { dw.ll = dw.ll->prev; --dw.rline; --dw.cline; } /* * if EOF occurs in the top three lines, scroll back */ i = 0; if (ruler_win.cline == dw.top_line && (dw.rline == dw.file_info->length || dw.rline == dw.file_info->length+1)) i = 2; else if (ruler_win.cline == dw.top_line+1 && (dw.rline == dw.file_info->length || dw.rline == dw.file_info->length-1)) i = 1; if (i) { dw.file_info->dirty = TRUE; do { if (dw.rline == 0 || dw.top_line + (int)(ruler_win.rline - dw.rline) == dw.bottom_line) break; --dw.rline; dw.ll = dw.ll->prev; } while (--i != 0); } /* * find the top line of the last page */ last = dw.file_info->length + 1 - hyt; if (last < 0) last = 0; wid = dw.end_col - dw.start_col + 1; rline = dw.rline; if (mode.cursor_cross) bcol = -1; else { bcol = dw.bcol; if (!dw.file_info->dirty) dw.file_info->dirty = (mode.line_numbers) ? LOCAL | RULER : RULER; } for (;;) { if (dw.bcol < 0) dw.bcol = 0; else if (dw.bcol > MAX_LINE_LENGTH - wid) dw.bcol = MAX_LINE_LENGTH - wid; if (bcol != dw.bcol || rline != dw.rline || dw.file_info->dirty) { display_current_window( &dw ); show_line_col( &ruler_win ); bcol = dw.bcol; rline = dw.rline; dw.file_info->dirty = FALSE; } key = getkey(); func = (key == RTURN) ? Rturn : (key == ESC) ? AbortCommand : getfunc( key ); if (func == Rturn || func == AbortCommand) break; switch (func) { /* Left */ case CharLeft: case StreamCharLeft: if (ruler_win.rcol > 0) { --ruler_win.rcol; if (ruler_win.rcol < dw.bcol) --dw.bcol; else dw.file_info->dirty = RULER; } break; /* Right */ case CharRight: case StreamCharRight: if (ruler_win.rcol < MAX_LINE_LENGTH) { ++ruler_win.rcol; /* keep half the ruler visible */ if (ruler_win.rcol >= dw.bcol + wid/2) ++dw.bcol; else dw.file_info->dirty = RULER; } break; /* Up */ case LineUp: if (ruler_win.rline < dw.rline || ruler_win.rline > dw.rline + hyt){ move_to_line( &ruler_win, (ruler_win.rline < dw.rline) ? dw.rline : dw.rline + hyt, FALSE ); dw.file_info->dirty = LOCAL | RULER; } else if (dec_line( &ruler_win, TRUE )) { if (ruler_win.rline == dw.rline - 1) { --dw.rline; dw.ll = dw.ll->prev; } else dw.file_info->dirty = LOCAL | RULER; } break; /* Down */ case LineDown: if (ruler_win.rline < dw.rline || ruler_win.rline > dw.rline + hyt){ move_to_line( &ruler_win, (ruler_win.rline < dw.rline) ? dw.rline : dw.rline + hyt, FALSE ); dw.file_info->dirty = LOCAL | RULER; } else if (inc_line( &ruler_win, TRUE )) { if (ruler_win.rline == dw.rline + hyt + 1) { ++dw.rline; dw.ll = dw.ll->next; } else dw.file_info->dirty = NOT_LOCAL | RULER; } break; case StartOfLine: ruler_win.rcol = 0; dw.file_info->dirty = RULER; break; /* Ctrl+Left */ case WordLeft: --dw.bcol; break; /* Ctrl+Right */ case WordRight: ++dw.bcol; break; /* Ctrl+Up */ case ScrollUpLine: if (dw.rline > 0) { --dw.rline; dw.ll = dw.ll->prev; } break; /* Ctrl+Down */ case ScrollDnLine: if (dw.rline < last) { ++dw.rline; dw.ll = dw.ll->next; } break; /* Home */ case BegOfLine: dw.bcol = 0; break; /* End */ case EndOfLine: /* * find the longest line on the screen */ max = 0; ll = dw.ll; for (i = hyt; i >= 0; --i) { len = find_end( ll->line, ll->len, dw.file_info->inflate_tabs, dw.file_info->ptab_size ); if (len > max) max = len; ll = ll->next; if (ll->len == EOF) break; } dw.bcol = max - wid; break; case HalfScreenLeft: dw.bcol -= wid / 2; break; case ScreenLeft: dw.bcol -= wid; break; case HalfScreenRight: dw.bcol += wid / 2; /*if (dw.bcol < 0) dw.bcol = INT_MAX;*/ break; case ScreenRight: dw.bcol += wid; /*if (dw.bcol < 0) dw.bcol = INT_MAX;*/ break; /* PgUp */ case ScreenUp: case HalfScreenUp: if (dw.rline > 0) { i = hyt; if (func == HalfScreenUp) i /= 2; for (; i >= 0; --i) { dw.ll = dw.ll->prev; if (--dw.rline == 0) break; } } break; /* PgDn */ case ScreenDown: case HalfScreenDown: if (dw.rline < last) { i = hyt; if (func == HalfScreenDown) i /= 2; for (; i >= 0; --i) { dw.ll = dw.ll->next; if (++dw.rline == last) break; } } break; case TopOfFile: dw.rline = 0; dw.ll = dw.file_info->line_list; break; case EndOfFile: move_to_line( &dw, last, TRUE ); break; case ToggleLineNumbers: if (!mode.line_numbers) { lnum = mode.line_numbers = TRUE; dw.file_info->len_len = numlen( dw.file_info->length ) + 1; dw.start_col += dw.file_info->len_len; wid -= dw.file_info->len_len; bcol = -1; } break; } } ruler_win.rline = -1; RESTORE_LINE( g_display.mode_line ); xygoto( window->ccol, window->cline ); if (lnum) { mode.line_numbers = FALSE; dw.start_col -= dw.file_info->len_len; } display_current_window( window ); return( OK );}/* * Name: show_help * Purpose: display help screen for certain functions * Author: Jason Hood * Date: August 9, 1998 * Passed: nothing (uses g_status.command) * Returns: OK if screen was restored; * ERROR if screen was redrawn; * 1 if key pressed was Help. * Notes: center the help display horizontally (assuming all strings are * equal length), but above center vertically. * if there's enough memory, save and restore screen contents, * otherwise just redraw the screen. * * jmh 990410: added Status screen. * jmh 991022: added Help and Credit screens. * jmh 991025: display the credit screen a bit higher. * jmh 991110: added CharacterSet. * jmh 010605: added Statistics screen. * jmh 010607: removed extra keypress at viewer help. * jmh 050710: moved the normal help after viewer help to get_help. */int show_help( void ){const char * const *pp;int row;int col;Char *buffer;int wid;int len;int rc = OK; switch (g_status.command) { case RegXForward: case RegXBackward: case RepeatRegXForward: case RepeatRegXBackward: case DefineSearch: case RepeatSearch: pp = regx_help; break; case DefineGrep: case RepeatGrep: if (grep_dialog->n == IDE_G_FILES) pp = wildcard_help; else if (CB_G_RegX) pp = regx_help; else return( OK ); break; case ReplaceString: if (!CB_R_RegX) return( OK ); pp = (replace_dialog->n == IDE_R_PATTERN) ? regx_help : replace_help; break; case StampFormat: pp = stamp_help; break; case BorderBlock: pp = border_help; break; case Execute: pp = exec_help; break; case Status: case Statistics: pp = (const char**)stat_screen; break; case CharacterSet: pp = char_help; break; case 0: /* Don't call help when in insert_overwrite() */ case About: pp = credit_screen; break; default: pp = NULL; break; } if (pp == NULL) { if (g_status.command != Help) return( OK ); len = help_dim[g_status.current_file->read_only][0]; wid = help_dim[g_status.current_file->read_only][1]; } else { for (len = 0; pp[len] != NULL; ++len) ; wid = strlen( pp[0] ); } row = (g_display.mode_line - len) / (2 + (g_status.command == 0)); col = (g_display.ncols - wid) / 2; if (row < 0) row = 0; if (col < 0) col = 0; g_display.output_space = g_display.frame_space; buffer = (g_status.command == 0) ? NULL : (Char *)malloc( (wid + 4) * (len + 1) * sizeof(Char) ); if (buffer != NULL) save_area( buffer, wid, len, row, col ); xygoto( -1, -1 ); show_strings( pp, len, row, col ); if (g_status.command == CharacterSet) c_output( '\0', col+ZERO_COL, row+ZERO_ROW, Color( Help ) ); shadow_area( wid, len, row, col ); if (g_status.command == Help && g_status.current_file->read_only) { g_status.viewer_key = TRUE; if (getfunc( getkey( ) ) == Help) rc = 1; } else if (g_status.command != 0) /* No pause required for credits */ getkey( ); if (buffer != NULL) { restore_area( buffer, wid, len, row, col ); g_display.output_space = FALSE; free( buffer ); } else { g_display.output_space = FALSE; if (g_status.current_window != NULL) { redraw_screen( g_status.current_window ); if (rc != 1) rc = ERROR; } } return( rc );}/* * Name: show_strings * Purpose: display strings from an array * Author: Jason Hood * Date: August 9, 1998 * Passed: strings: the array to display * num: number of strings to display * row: starting line position * col: starting column position * Returns: nothing * Notes: Assumes there are at least num strings in the array. * Will stop should the bottom line be reached. * Uses the help color. * jmh 991022: special case for Help. */void show_strings( const char * const *strings, int num, int row, int col ){int max_row = g_display.mode_line + 1;int line; if (max_row > row + num) max_row = row + num; if (strings == NULL) for (line = 0; row < max_row; ++line, ++row) s_output( help_screen[g_status.current_file->read_only][line], row, col, Color( Help ) ); else for (; row < max_row; strings++, row++) s_output( *strings, row, col, Color( Help ) );}/* * Name: adjust_area * Purpose: modify the area to take into account spacing and shadow * Author: Jason Hood * Date: October 23, 1999 * Passed: wid: pointer to width * len: pointer to length * row: pointer to starting row * col: pointer to starting column * swd: pointer to shadow width * Returns: none, but may modify above * Notes: Assumes the values are valid on entry, but adjusts them to take * into account spaces and shadow and ensure they remain valid. * If swd is not NULL, set it to the width of the shadow being used. * To determine if the bottom shadow is to be drawn, compare the old * length with the new. */void adjust_area( int *wid, int *len, int *row, int *col, int *swd ){int sw; if (g_display.output_space) { if (*col + *wid < g_display.ncols) ++*wid; if (*col != 0) { --*col; ++*wid; } } if (g_display.shadow) { sw = g_display.ncols - (*col + *wid); if (sw > g_display.shadow_width) sw = g_display.shadow_width; *wid += sw; if (swd != NULL) *swd = sw; if (*row + *len < g_display.nlines) ++*len; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -