📄 layout.c
字号:
if (l1 > first_width)
first_width = l1;
}
l1 = strlen (title1) + 1;
if (l1 > first_width)
first_width = l1;
l1 = strlen (title2) + 1;
if (l1 > first_width)
first_width = l1;
second_width = strlen (title3) + 1;
for (i = 0; i < 6; i++)
{
check_options[i].text = _(check_options[i].text);
l1 = strlen (check_options[i].text) + 7;
if (l1 > second_width)
second_width = l1;
}
if (console_flag)
{
l1 = strlen (output_lines_label) + 13;
if (l1 > second_width)
second_width = l1;
}
/*
* alex@bcs.zp.ua:
* To be completely correct, one need to check if layout_title
* does not exceed dialog length and total length of 3 buttons
* allows their placement in one row. But assuming this dialog
* is wide enough, I don't include such a tests.
*
* Now the last thing to do - properly space buttons...
*/
l1 = 11 + strlen (ok_button) /* 14 - all brackets and inner space */
+ strlen (save_button) /* notice: it is 3 char less because */
+ strlen (cancel_button); /* of '&' char in button text */
i = (first_width + second_width - l1) / 4;
b1 = 5 + i;
b2 = b1 + strlen(ok_button) + i + 6;
b3 = b2 + strlen(save_button) + i + 4;
i18n_layt_flag = 1;
}
layout_dlg = create_dlg (0, 0, 15, first_width + second_width + 9,
dialog_colors, layout_callback,
"[Layout]", "layout", DLG_CENTER | DLG_GRID);
x_set_dialog_title (layout_dlg, _("Layout"));
add_widgetl (layout_dlg,
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, 0, 0, "c"),
XV_WLAY_RIGHTOF);
add_widgetl (layout_dlg,
button_new (BY, b2, B_EXIT, NORMAL_BUTTON, save_button, 0, 0, "s"),
XV_WLAY_RIGHTOF);
add_widgetl (layout_dlg,
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, 0, 0, "o"),
XV_WLAY_CENTERROW);
#ifndef HAVE_X
if (console_flag){
add_widget (layout_dlg,
button_new (9, 12 + first_width, B_MINUS, NARROW_BUTTON, "&-",
bminus_cback, 0, NULL));
add_widget (layout_dlg,
button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON, "&+",
bplus_cback, 0, NULL));
}
#endif
#define XTRACT(i) *check_options[i].variable, check_options[i].text, check_options[i].tkname
for (i = 0; i < 6; i++){
check_options [i].widget = check_new (8 - i, 7 + first_width, XTRACT(i));
add_widgetl (layout_dlg, check_options [i].widget, XV_WLAY_BELOWCLOSE);
}
#ifdef HAVE_XVIEW
add_widgetl (layout_dlg, label_new (2, 7 + first_width, _("Other options"), "oo"),
XV_WLAY_NEXTCOLUMN);
add_widgetl (layout_dlg, label_new (8, 5, _("Highlight..."), "hl"),
XV_WLAY_NEXTCOLUMN);
add_widgetl (layout_dlg, label_new (2, 5, _("Panel split"), "ps"),
XV_WLAY_NEXTCOLUMN);
#endif
check_options [8].widget = check_new (10, 6, XTRACT(8));
add_widgetl (layout_dlg, check_options [8].widget, XV_WLAY_BELOWCLOSE);
check_options [7].widget = check_new (9, 6, XTRACT(7));
add_widgetl (layout_dlg, check_options [7].widget, XV_WLAY_BELOWCLOSE);
_filetype_mode = filetype_mode;
_permission_mode = permission_mode;
_equal_split = equal_split;
_menubar_visible = menubar_visible;
_command_prompt = command_prompt;
_keybar_visible = keybar_visible;
_message_visible = message_visible;
_xterm_hintbar = xterm_hintbar;
#ifndef HAVE_X
bright_widget = button_new(6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback, 0, ">");
add_widgetl (layout_dlg, bright_widget, XV_WLAY_RIGHTOF);
bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback, 0, "<");
add_widgetl (layout_dlg, bleft_widget, XV_WLAY_RIGHTOF);
check_options [6].widget = check_new (5, 6, XTRACT(6));
#endif
old_first_panel_size = -1;
old_horizontal_split = -1;
old_output_lines = -1;
_first_panel_size = first_panel_size;
_output_lines = output_lines;
#ifndef HAVE_X
add_widget (layout_dlg, check_options [6].widget);
radio_widget = radio_new (3, 6, 2, s_split_direction, 1, "r");
add_widget (layout_dlg, radio_widget);
radio_widget->sel = horizontal_split;
#endif
}
void layout_change (void)
{
setup_panels ();
layout_do_change = 0;
#ifndef HAVE_X
/* re-init the menu, because perhaps there was a change in the way
how the panel are split (horizontal/vertical). */
done_menu();
init_menu();
menubar_arrange(the_menubar);
#endif
}
void layout_cmd (void)
{
int result;
int i;
init_layout ();
run_dlg (layout_dlg);
result = layout_dlg->ret_value;
if (result == B_ENTER || result == B_EXIT){
for (i = 0; check_options [i].text; i++)
if (check_options [i].widget)
*check_options [i].variable = check_options [i].widget->state & C_BOOL;
#ifndef HAVE_X
horizontal_split = radio_widget->sel;
first_panel_size = _first_panel_size;
output_lines = _output_lines;
layout_do_change = 1;
#endif
}
if (result == B_EXIT){
save_layout ();
sync_profiles ();
}
destroy_dlg (layout_dlg);
if (layout_do_change)
layout_change ();
}
static void check_split (void)
{
if (horizontal_split){
if (equal_split)
first_panel_size = height / 2;
else if (first_panel_size < MINHEIGHT)
first_panel_size = MINHEIGHT;
else if (first_panel_size > height - MINHEIGHT)
first_panel_size = height - MINHEIGHT;
} else {
if (equal_split)
first_panel_size = COLS / 2;
else if (first_panel_size < MINWIDTH)
first_panel_size = MINWIDTH;
else if (first_panel_size > COLS - MINWIDTH)
first_panel_size = COLS - MINWIDTH;
}
}
int panel_event (Gpm_Event *event, WPanel *panel);
int menu_bar_event (Gpm_Event *event, void *);
extern char *prompt;
#ifndef HAVE_X
#ifdef HAVE_SLANG
void init_curses ()
{
extern int force_ugly_line_drawing;
extern int SLtt_Has_Alt_Charset;
SLtt_get_terminfo ();
#ifndef OS2_NT
if (force_ugly_line_drawing)
SLtt_Has_Alt_Charset = 0;
#endif
SLsmg_init_smg ();
do_enter_ca_mode ();
init_colors ();
keypad (stdscr, TRUE);
nodelay (stdscr, FALSE);
}
#else
void init_curses (void)
{
initscr();
if (!status_using_ncurses)
do_enter_ca_mode ();
mc_raw_mode ();
noecho ();
keypad (stdscr, TRUE);
nodelay (stdscr, FALSE);
init_colors ();
}
#endif /* ! HAVE_SLANG */
void done_screen ()
{
if (!(quit & SUBSHELL_EXIT))
clr_scr ();
reset_shell_mode ();
mc_noraw_mode ();
if (use_mouse_p)
shut_mouse ();
keypad (stdscr, FALSE);
}
#else
void init_curses ()
{
}
void done_screen ()
{
}
#endif /* HAVE_X */
void panel_do_cols (int index)
{
if (get_display_type (index) == view_listing)
set_panel_formats ((WPanel *) panels [index].widget);
else {
panel_update_cols (panels [index].widget, frame_half);
}
}
#ifdef HAVE_X
void
setup_panels (void)
{
Widget *w = panels [0].widget;
winput_set_origin (&cmdline->input, 0, 60);
/* Only needed by the startup code */
if (panels [0].type == view_listing){
x_panel_set_size (0);
}
if (panels [1].type == view_listing){
x_panel_set_size (1);
}
load_hint ();
#ifdef HAVE_XVIEW
panel_do_cols (0);
panel_do_cols (1);
#endif
}
#else
void setup_panels (void)
{
int start_y;
int promptl; /* the prompt len */
if (console_flag){
int minimum;
if (output_lines < 0)
output_lines = 0;
height = LINES - keybar_visible - command_prompt - menubar_visible
- output_lines - message_visible;
if (message_visible && xterm_hintbar && xterm_flag) height++;
minimum = MINHEIGHT * (1 + horizontal_split);
if (height < minimum){
output_lines -= minimum - height;
height = minimum;
}
} else {
height = LINES - menubar_visible - command_prompt -
keybar_visible - message_visible;
if (message_visible && xterm_hintbar && xterm_flag) height++;
}
check_split ();
start_y = menubar_visible;
/* The column computing is defered until panel_do_cols */
if (horizontal_split){
widget_set_size (panels [0].widget, start_y, 0,
first_panel_size, 0);
widget_set_size (panels [1].widget, start_y+first_panel_size, 0,
height-first_panel_size, 0);
} else {
int first_x = first_panel_size;
widget_set_size (panels [0].widget, start_y, 0,
height, 0);
widget_set_size (panels [1].widget, start_y, first_x,
height, 0);
}
panel_do_cols (0);
panel_do_cols (1);
promptl = strlen (prompt);
widget_set_size (&the_menubar->widget, 0, 0, 1, COLS);
if (command_prompt) {
widget_set_size (&cmdline->input.widget,
LINES-1-keybar_visible, promptl,
1, COLS-promptl-(keybar_visible ? 0 : 1));
winput_set_origin (&cmdline->input, promptl, COLS-promptl-(keybar_visible ? 0 : 1));
widget_set_size (&the_prompt->widget,
LINES-1-keybar_visible, 0,
1, promptl);
} else {
widget_set_size (&cmdline->input.widget, 0, 0, 0, 0);
winput_set_origin (&cmdline->input, 0, 0);
widget_set_size (&the_prompt->widget, LINES, COLS, 0, 0);
}
widget_set_size (&the_bar->widget, LINES-1, 0, 1, COLS);
the_bar->visible = keybar_visible;
/* Output window */
if (console_flag && output_lines){
output_start_y = LINES -command_prompt-keybar_visible-
output_lines;
show_console_contents (output_start_y,
LINES-output_lines-keybar_visible-1,
LINES-keybar_visible-1);
}
if (message_visible && (!xterm_hintbar || !xterm_flag))
widget_set_size (&the_hint->widget, height+start_y, 0, 1,COLS);
else
widget_set_size (&the_hint->widget, 0, 0, 0, 0);
load_hint ();
}
#endif
void flag_winch (int dummy)
{
winch_flag = 1;
}
void edit_adjust_size (Dlg_head * h);
#ifdef PORT_NEEDS_CHANGE_SCREEN_SIZE
void low_level_change_screen_size (void)
{
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
#if defined TIOCGWINSZ && !defined SCO_FLAVOR
struct winsize winsz;
winsz.ws_col = winsz.ws_row = 0;
/* Ioctl on the STDIN_FILENO */
ioctl (0, TIOCGWINSZ, &winsz);
if (winsz.ws_col && winsz.ws_row){
#if defined(NCURSES_VERSION) && defined(HAVE_RESIZETERM)
resizeterm(winsz.ws_row, winsz.ws_col);
clearok(stdscr,TRUE); /* FIXME: sigwinch's should use a semaphore! */
#else
COLS = winsz.ws_col;
LINES = winsz.ws_row;
#endif
#ifdef HAVE_SUBSHELL_SUPPORT
resize_subshell ();
#endif
}
#endif /* TIOCGWINSZ && !SCO_FLAVOR */
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
}
void change_screen_size (void)
{
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
#if defined TIOCGWINSZ && !defined SCO_FLAVOR
extern Dlg_head *view_dlg;
extern Dlg_head *edit_dlg;
#ifndef NCURSES_VERSION
mc_noraw_mode ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -