📄 window.c
字号:
}
setup_window( win );
show_window_header( win );
win->ruler = mode.ruler;
make_ruler( win );
show_ruler( win );
show_ruler_pointer( win );
display_current_window( win );
save_screen_line( 0, win->bottom_line, line_buff );
set_prompt( win4, win->bottom_line );
}
}
new_top_line = win->top_line;
new_bottom_line = above->bottom_line;
for (above=g_status.window_list; above != NULL; above=above->next) {
if (!above->visible) {
if (above->bottom_line == old_bottom_line) {
above->bottom_line = new_bottom_line;
if (above->cline < new_bottom_line)
above->cline = new_bottom_line;
setup_window( above );
} else if (above->top_line == old_top_line) {
above->top_line = new_top_line;
if (above->cline < new_top_line)
above->cline = new_top_line;
if ((long)(above->cline+1L - (above->top_line+above->ruler)) >
above->rline)
above->cline = (int)above->rline + above->top_line +
above->ruler - 1;
setup_window( above );
}
}
}
}
restore_screen_line( 0, win->bottom_line, line_buff );
} else {
if (win->vertical)
error( WARNING, win->bottom_line, win5 );
else
error( WARNING, win->bottom_line, win6 );
}
return( OK );
}
int zoom_window( WINDOW *window )
{
register WINDOW *wp;
if (window != NULL) {
entab_linebuff( );
un_copy_line( window->ll, window, TRUE );
for (wp=g_status.window_list; wp != NULL; wp=wp->next) {
if (wp != window && wp->visible)
wp->visible = FALSE;
diff.defined = FALSE;
if (wp->top_line != 1)
wp->cline = wp->cline - (wp->top_line+wp->ruler) + 1;
wp->top_line = 1;
wp->bottom_line = g_display.nlines;
wp->end_col = g_display.ncols - 1;
wp->start_col = 0;
wp->vertical = FALSE;
check_virtual_col( wp, wp->rcol, wp->ccol );
make_ruler( wp );
}
redraw_screen( window );
show_ruler( window );
}
return( OK );
}
int next_hidden_window( WINDOW *window )
{
int poof = FALSE;
register WINDOW *wp;
if (window != NULL) {
wp = window;
for (wp=window->next; wp != NULL && !poof; ) {
if (!wp->visible)
poof = TRUE;
else
wp = wp->next;
}
if (!poof) {
for (wp=g_status.window_list; wp != NULL && !poof; ) {
if (!wp->visible)
poof = TRUE;
else
wp = wp->next;
}
}
if (poof) {
entab_linebuff( );
un_copy_line( window->ll, window, TRUE );
wp->cline = window->top_line + window->ruler +
(wp->cline - (wp->top_line + wp->ruler));
wp->top_line = window->top_line;
wp->bottom_line = window->bottom_line;
wp->start_col = window->start_col;
wp->end_col = window->end_col;
wp->vertical = window->vertical;
if (wp->cline < wp->top_line + wp->ruler)
wp->cline = wp->top_line + wp->ruler;
if (wp->cline > wp->bottom_line)
wp->cline = wp->bottom_line;
if ((wp->cline+1L - (wp->top_line+wp->ruler)) > wp->rline)
wp->cline = (int)wp->rline + wp->top_line + wp->ruler - 1;
check_virtual_col( wp, wp->rcol, wp->ccol );
wp->visible = TRUE;
window->visible = FALSE;
if (diff.defined && (diff.w1 == window || diff.w2 == window))
diff.defined = FALSE;
g_status.current_window = wp;
redraw_current_window( wp );
make_ruler( wp );
show_ruler( wp );
}
}
return( OK );
}
void setup_window( WINDOW *window )
{
window->page = window->bottom_line - (window->top_line + window->ruler) -
g_status.overlap + 1;
if (window->page < 1)
window->page = 1;
}
void finish( WINDOW *window )
{
register WINDOW *wp;
register WINDOW *win;
file_infos *file, *fp;
int poof;
int cline;
int top;
int bottom;
int start_col;
int end_col;
int max_letter;
int file_change = FALSE;
line_list_ptr ll;
line_list_ptr temp_ll;
win = window;
entab_linebuff( );
if (un_copy_line( win->ll, win, TRUE ) == ERROR)
return;
file = win->file_info;
file = win->file_info;
for (wp=g_status.window_list; wp != NULL; wp=wp->next) {
if (wp->file_info == file) {
if (!wp->visible) {
if (wp->prev == NULL) {
if (wp->next == NULL)
g_status.stop = TRUE;
else
g_status.window_list = wp->next;
} else
wp->prev->next = wp->next;
if (wp->next)
wp->next->prev = wp->prev;
--wp->file_info->ref_count;
free( wp );
--g_status.window_count;
}
}
}
if (win->prev == NULL && win->next == NULL)
g_status.stop = TRUE;
poof = FALSE;
if (g_status.stop != TRUE) {
top = win->top_line;
bottom = win->bottom_line;
start_col = win->start_col;
end_col = win->end_col;
wp = g_status.window_list;
if (wp != NULL) {
while (wp->next != NULL)
wp = wp->next;
}
while (wp != NULL && poof == FALSE) {
if (wp->top_line == top && wp->bottom_line == bottom &&
wp->start_col == start_col && wp->end_col == end_col &&
!wp->visible)
poof = TRUE;
else
wp = wp->prev;
}
if (poof == FALSE) {
wp = g_status.window_list;
while (wp != NULL && poof == FALSE) {
if (wp->bottom_line+2 == win->top_line &&
wp->start_col == win->start_col &&
wp->end_col == win->end_col && wp->visible) {
poof = TRUE;
top = wp->top_line;
} else
wp = wp->next;
}
if (poof == FALSE) {
wp = g_status.window_list;
while (wp != NULL && poof == FALSE) {
if (wp->top_line-2 == win->bottom_line &&
wp->start_col == win->start_col &&
wp->end_col == win->end_col && wp->visible) {
poof = TRUE;
bottom = wp->bottom_line;
} else
wp = wp->next;
}
}
if (poof == FALSE) {
wp = g_status.window_list;
while (wp != NULL && poof == FALSE) {
if (wp->top_line == win->top_line &&
wp->bottom_line == win->bottom_line &&
wp->start_col-2 == win->end_col && wp->visible) {
poof = TRUE;
end_col = wp->end_col;
} else
wp = wp->next;
}
}
if (poof == FALSE) {
wp = g_status.window_list;
while (wp != NULL && poof == FALSE) {
if (wp->top_line == win->top_line &&
wp->bottom_line == win->bottom_line &&
wp->end_col+2 == win->start_col && wp->visible) {
poof = TRUE;
start_col = wp->start_col;
} else
wp = wp->next;
}
}
if (poof == FALSE) {
wp = g_status.window_list;
if (wp != NULL) {
while (wp->next != NULL)
wp = wp->next;
}
while (wp != NULL && poof == FALSE) {
if (!wp->visible)
poof = TRUE;
else
wp = wp->prev;
}
}
}
if (poof) {
wp->visible = TRUE;
cline = wp->cline - (wp->top_line+wp->ruler);
wp->top_line = top;
wp->bottom_line = bottom;
wp->cline = (wp->top_line+wp->ruler) + cline;
if (wp->cline > wp->bottom_line)
wp->cline = wp->top_line+wp->ruler;
wp->start_col = start_col;
wp->end_col = end_col;
if (start_col == 0 && end_col == g_display.ncols - 1)
wp->vertical = FALSE;
else
wp->vertical = TRUE;
check_virtual_col( wp, wp->rcol, wp->ccol );
setup_window( wp );
show_window_header( wp );
if (wp->vertical)
show_vertical_separator( wp );
g_status.current_window = wp;
}
}
if (!poof && g_status.stop != TRUE)
error( WARNING, win->bottom_line, win7 );
else {
if (--file->ref_count == 0) {
if (file == g_status.marked_file) {
g_status.marked = FALSE;
g_status.marked_file = NULL;
}
for (fp=g_status.file_list; fp != NULL; fp=fp->next) {
if (fp->file_no > file->file_no)
fp->file_no--;
}
file_change = file->file_no;
if (file->prev == NULL)
g_status.file_list = file->next;
else
file->prev->next = file->next;
if (file->next)
file->next->prev = file->prev;
ll = file->undo_top;
while (ll != NULL) {
temp_ll = ll->next;
if (ll->line != NULL)
my_free( ll->line );
my_free( ll );
ll = temp_ll;
}
ll = file->line_list;
while (ll != NULL) {
temp_ll = ll->next;
if (ll->line != NULL)
my_free( ll->line );
my_free( ll );
ll = temp_ll;
}
#if defined( __MSC__ )
_fheapmin( );
#endif
free( file );
if (--g_status.file_count) {
show_file_count( g_status.file_count );
show_avail_mem( );
}
}
if (win->prev == NULL)
g_status.window_list = win->next;
else
win->prev->next = win->next;
if (win->next)
win->next->prev = win->prev;
if (diff.defined && (diff.w1 == win || diff.w2 == win))
diff.defined = FALSE;
free( win );
--g_status.window_count;
if (g_status.stop == FALSE) {
g_status.current_file = wp->file_info;
wp->file_info->dirty = LOCAL;
make_ruler( wp );
show_ruler( wp );
show_window_count( g_status.window_count );
if (file_change) {
for (wp=g_status.window_list; wp!=NULL; wp=wp->next)
if (wp->visible)
show_window_number_letter( wp );
} else {
max_letter = 'a';
for (wp=g_status.window_list; wp!=NULL; wp=wp->next) {
if (wp->file_info == file && wp->letter > max_letter)
max_letter = wp->letter;
}
if (max_letter < file->next_letter - 1)
file->next_letter = max_letter + 1;
}
}
}
if (g_status.stop == TRUE) {
if (g_status.sas_defined && g_status.sas_arg < g_status.sas_argc) {
show_avail_mem( );
for (bottom=0; bottom <= g_display.nlines; bottom++)
eol_clear( 0, bottom, g_display.text_color );
bottom = g_display.nlines;
set_prompt( win18, bottom );
top = getkey( );
top = getfunc( top );
eol_clear( 0, bottom, g_display.text_color );
if (top == RepeatGrep) {
g_status.command = RepeatGrep;
g_status.window_list = g_status.current_window = NULL;
if (search_and_seize( g_status.window_list ) != ERROR)
g_status.stop = FALSE;
}
}
}
}
int create_window( WINDOW **window, int top, int bottom, int start_col,
int end_col, file_infos *file )
{
WINDOW *wp;
register WINDOW *prev;
int rc;
rc = OK;
if ((*window = (WINDOW *)calloc( 1, sizeof(WINDOW) )) == NULL) {
error( WARNING, g_display.nlines, main4 );
rc = ERROR;
} else {
wp = *window;
wp->file_info = file;
wp->top_line = top+1;
wp->bottom_line = bottom;
wp->start_col = start_col;
wp->end_col = end_col;
wp->bin_offset = 0;
wp->ruler = mode.ruler;
make_ruler( wp );
wp->cline = wp->top_line + wp->ruler;
if (start_col == 0 && end_col == g_display.ncols-1)
wp->vertical = FALSE;
else
wp->vertical = TRUE;
wp->prev = NULL;
wp->next = NULL;
setup_window( wp );
prev = g_status.current_window;
if (prev) {
(*window)->prev = prev;
if (prev->next)
prev->next->prev = *window;
(*window)->next = prev->next;
prev->next = *window;
}
if (g_status.window_list == NULL)
g_status.window_list = *window;
++file->ref_count;
file->dirty = LOCAL;
++g_status.window_count;
}
return( rc );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -