📄 switches.c
字号:
}
break;
#if (WITH_HEX_FIND)
case 'F':
if (repeat_count == 0)
{
do_it = get_line_2_string ("Hex Find (hexval_1 [hexval_2]):",
str_numb, C_R, ID_NUMB);
if (!do_it)
{
end_of_edit = -1;
break;
}
}
BREAK_IF_REPEAT_0
if ((repeat_count == 0) || (repeat_max == 1))
{
find_count = 0;
replace_count = -1;
first_call = 1;
}
else
{
first_call = 0;
}
if ((num = sscanf (str_numb, "%x %x",
&help_int, &help_int2)) < 1)
{
err_message (INVALID_HEX_VALUE);
break;
}
c1 = (char) help_int;
if (num >= 2) c2 = (char) help_int2;
else c2 = c1;
#if (EXCHANGE_HEX_CHARS)
if (c1 > c2)
exchange_chars (&c1, &c2);
#endif
new_index = perform_find_byte (c1, c2);
save_find_indizes (1, new_index, 1);
if (new_index < 0L)
{
find_ok = 0;
replace_count = -1;
end_of_edit = -1;
}
else
{
find_ok = 1;
find_count++;
/* zeiger bewegen */
perform_move (new_index);
}
/* letzter durchlauf ? */
last_call = ((repeat_count >= (repeat_max - 1)) ||
(find_ok == 0));
abort = show_find_display (key_1, 0, 0,
first_call, last_call, find_ok);
if (abort)
end_of_edit = -1;
if (last_call)
show_find_result (str_numb, find_count, replace_count);
break;
#else
case 'F':
err_message (NOT_IMPLEMENTED);
break;
#endif
#if (WITH_HEX_VIEW)
case 'V':
hex_view ();
perform_view ();
break;
case 'E':
LOCK_WHEN_VIEW_ONLY
hex_edit ();
perform_view ();
break;
#else
case 'V':
case 'E':
err_message (NOT_IMPLEMENTED);
break;
#endif
case 0x1b: /* <esc> */
case 0x03: /* ^C */
break; /* do nothing */
default:
err_message (ILLEGAL_COMMAND);
break;
}
break;
case 'I': /* Insert */
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
mode_flag = 1;
line_2_flag = 1;
break;
case 'X': /* eXchange */
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
mode_flag = 2;
line_2_flag = 1;
save_x.index = 0;
break;
case 'Q': /* Quit */
quit_mode = 1;
while (quit_mode)
{
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE
line_2_flag = 1;
/* display status line 1 + 2 */
show_status_line_1 (fc->filename, fc);
if (fc->view_only)
show_status_line_2
("Quit:Abort Init Write <esc>", 0, -1, 0);
else
show_status_line_2
("Quit:Abort Exit Init Update Write <esc>", 0, -1, 0);
key_1 = toupper(get_1_key (1));
switch (key_1)
{
case 'E':
LOCK_WHEN_VIEW_ONLY
if (fc->change_flag)
{
line_2_flag = 2;
write_flag = write_datafile (fc->filename,
fc->buff_0, fc->byte_anz,
1, set.bak_file);
if (write_flag == 0) /* 0, if write ok */
fc->change_flag = 0;
if (write_flag == -10) /* -10, if aborted with ^C */
{
quit_mode = 0;
line_2_flag = 1;
break; /* --> */
}
}
else
{
write_flag = 0;
}
/* no break !! fall through to case 'A' */
case 'A':
/* before Abort, check all files for modifications */
quit_allowed = 1;
abort_flag = 0;
for (ii = 0 ; ii < MAX_FC_NUM ; ii++)
{
if (fc->change_flag)
{
err_message (MODIFIED_ABORT_ANYWAY);
key_2 = get_1_key (0);
switch (toupper (key_2))
{
case 'W':
line_2_flag = 2;
write_flag = write_datafile (fc->filename,
fc->buff_0, fc->byte_anz,
1, set.bak_file);
if (write_flag == 0)
fc->change_flag = 0; /* write o.k. */
else
quit_allowed = 0; /* write error */
line_2_flag = 1;
break;
case 'Y':
fc->change_flag = 0;
break;
default: /* wg. Peter Stoeckigt */
ii = MAX_FC_NUM; /* abort for loop */
quit_allowed = 0;
abort_flag = 1;
break;
}
}
/* check next file */
if (!abort_flag)
{
exchange_file_control (MAX_FC_NUM, 1);
if (fc->change_flag)
{
/* display file buffer */
perform_view ();
#if 0 /* ueberfluessig */
/* display status line 1 */
show_status_line_1 (fc->filename, fc);
#endif
}
}
} /* for ii */
/* all files o.k. ? */
if (quit_allowed)
{
end_of_edit = 1;
}
else
{
/* display file buffer */
perform_view ();
/* display status line 1 */
show_status_line_1 (fc->filename, fc);
}
quit_mode = 0;
break;
case 'I':
/* take over the actual filename */
if (first == 0)
{
first = 1;
memcpy (str_q_i1, fc->filename, sizeof (fc->filename));
}
/* test edit buffer */
read_flag = 1;
if (fc->change_flag)
{
err_message (MODIFIED_ABORT_ANYWAY);
key_2 = get_1_key (0);
read_flag = 0;
switch (toupper (key_2))
{
case 'W':
line_2_flag = 1;
write_flag = write_datafile (fc->filename,
fc->buff_0, fc->byte_anz,
1, set.bak_file);
if (write_flag != 0) /* 0, if write ok */
break;
else
fc->change_flag = 0;
/* fall through */
case 'Y':
read_flag = 1;
break;
default:
/* read_flag = 0; @@ ueberfluessig */
break;
}
}
if (read_flag == 1)
{
do_it = get_line_2_string ("Read Filename:",
str_q_i1, C_R, ID_FILE);
if (!do_it)
{
quit_mode = 0;
break;
}
fc->change_flag = 0;
init_file_control (fc, 1);
memcpy (str_q_i2, str_q_i1, sizeof(str_q_i2));
fc->view_only = parse_input_string (str_q_i2);
memcpy (fc->filename, str_q_i2, sizeof(fc->filename));
fc->filename [sizeof(fc->filename)-1] = '\0';
if ((*fc->filename == ' ') ||
(*fc->filename == '\0'))
{
check_and_increase_buffer (fc, INIT_FILESIZE,
0L, 1);
}
else
{
/* read datafile */
ok_flag = get_1_datafile ();
}
update_entire_window (fc->top_left);
#if WINDOW_COMMAND
window_set (1);
#endif
}
quit_mode = 0;
break;
case 'W':
do_it = get_line_2_string ("Write Filename:",
str_q_wr, C_R, ID_FILE);
if (!do_it)
{
quit_mode = 0;
break;
}
line_2_flag = 2;
write_flag = write_datafile (str_q_wr, fc->buff_0,
fc->byte_anz, 0, 0);
if (write_flag == 0) /* 0, if write ok */
fc->change_flag = 0;
break;
case 'U':
LOCK_WHEN_VIEW_ONLY
line_2_flag = 2;
write_flag = write_datafile (fc->filename,
fc->buff_0, fc->byte_anz,
1, set.bak_file);
if (write_flag == 0) /* 0, if write ok */
fc->change_flag = 0;
if (write_flag == -10) /* -10, if aborted with ^C */
{
quit_mode = 0;
line_2_flag = 1;
}
break;
case 0x1b: /* <esc> */
case 0x03: /* ^C */
quit_mode = 0;
break;
default:
err_message (ILLEGAL_COMMAND);
break;
}
}
break;
case 'S': /* Set */
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE
line_2_flag = 1;
show_status_line_2 ("Set: AB CD EF HI KL MN OR ST VW Y *~", 0, -1, 0);
key_1 = toupper(get_1_key (1));
switch (key_1)
{
case 'A':
show_status_line_2 ("Insert <nl> automatically [Y/N]",
0, -1, 0);
key_2 = get_1_key (1);
set.autonl = (toupper (key_2) == 'Y');
break;
case 'B':
show_status_line_2 ("Bak_file [Y/N]", 0, -1, 0);
key_2 = get_1_key (1);
set.bak_file = (toupper (key_2) == 'Y');
break;
case 'C':
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -