📄 switches.c
字号:
/* switches.c 24.03.04 */
/*
/ --------------------------------------------------------------
/ Copyright (C) 2004: Michael Braun
/ Kaetinger Muehlenweg 103 A
/ D-28816 Stuhr
/ --------------------------------------------------------------
/
/ ausgelagerte functions von mbedit.c
/
/ Verzweigung in die diversen Betriebsarten, Kommandomodes,
/ Macrosequenzen, usw..., je nach Eingabe-Key.
/ Zur Bedeutung der Variablen "end_of_edit" siehe mbedit.c !
/
*/
/************************/
/* include files */
/************************/
#include "config.h"
#include "global.h"
#include "standard.h"
#include "mbedit.h"
#include "calc_var.h"
#include "switches.h"
#include "perform.h"
#include "err_mess.h"
#include "help_opt.h"
#include "mbed_sub.h"
#include "commands.h"
#include "blocks.h"
#include "kb_input.h"
#include "mon_outp.h"
#include "memo_hnd.h"
#include "file_hnd.h"
#include "history.h"
#include "disp_hnd.h"
#include "calc.h"
#include "macro.h"
#include "mb_ctype.h"
#include "window.h"
#include "paragraf.h"
#include "vbios.h"
#include "ansi_out.h"
/************************/
/* some defines */
/************************/
/* most commands are locked, when Buffer/Delete */
/* Command is invoked, especially those commands, */
/* which would modify the memory content. */
#define LOCK_WHEN_BUFFER_ACTIVE if (save_d.toggle == 1) {beep (); break;}
#define REFRESH_WHEN_BUFFER_ACTIVE if (save_d.toggle == 1) {update_this_line (fc->lin_left, fc->lrow);}
#define LOCK_WHEN_VIEW_ONLY if (fc->view_only) {err_message(VIEW_ONLY); break;}
#define BREAK_IF_REPEAT_0 if (repeat_max == 0) {break;}
/************************/
/* local structures */
/************************/
/************************/
/* module definitions */
/************************/
/* for Find / Replace */
static int find_ok;
static int find_count, replace_count;
/* for "Macro Create" */
static struct MACRO *macro_cr;
/* -FF- */
void get_calc_vars_switches (struct CALC_VARS *cv)
{
/* set the calc flags for: Find, Replace */
cv->cntfnd = find_count;
cv->cntrep = replace_count;
cv->lstfnd = -find_ok;
return;
} /* get_calc_vars_switches */
/* -FF- */
int switch_key_0 (int key_0, long repeat_count, long repeat_max)
{
static int last_key;
long new_index;
int end_of_edit;
byte update_cursor;
int row, column, exe_flag;
struct MACRO *macro_ex; /* for "Macro Execute" */
REFRESH_WHEN_BUFFER_ACTIVE
end_of_edit = 0;
update_cursor = (byte)(repeat_max == 1);
switch (key_0)
{
case KEY_PGUP:
BREAK_IF_REPEAT_0
end_of_edit = perform_page_up () - 1;
save_x.index = 0;
break;
case KEY_PGDN:
BREAK_IF_REPEAT_0
end_of_edit = perform_page_down () - 1;
save_x.index = 0;
break;
case KEY_END:
end_of_edit = -2;
BREAK_IF_REPEAT_0
perform_end_of_line (1);
save_x.index = 0;
break;
case KEY_LEFT:
BREAK_IF_REPEAT_0
end_of_edit = (perform_key_left (update_cursor, 1) != 0) - 1;
save_x.index = 0;
break;
case KEY_RIGHT:
BREAK_IF_REPEAT_0
end_of_edit = (perform_key_right (update_cursor, 1) != 0) - 1;
save_x.index = 0;
break;
case KEY_UP:
BREAK_IF_REPEAT_0
end_of_edit = perform_key_up (update_cursor) - 1;
save_x.index = 0;
break;
case KEY_DOWN:
BREAK_IF_REPEAT_0
end_of_edit = perform_key_down (update_cursor) - 1;
save_x.index = 0;
break;
case KEY_HOME:
BREAK_IF_REPEAT_0
key_0 = last_key;
end_of_edit = switch_last_key (key_0);
save_x.index = 0;
break;
case 0x08: /* ^H, Backspace */
#if (ACT_OP_SYSTEM != SCO_UNIX)
case KEY_RUBOUT: /* rubout */
#endif
BREAK_IF_REPEAT_0
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
perform_delete_left_char ();
fc->change_flag = 1;
break;
case 0x06: /* ^F */
case KEY_DEL:
#if (ACT_OP_SYSTEM == SCO_UNIX)
case KEY_RUBOUT: /* rubout */
#endif
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
if (repeat_max > 32)
{
end_of_edit = -2;
err_message (NOT_MORE_THAN_32);
break;
}
perform_delete_right_char ();
fc->change_flag = 1;
save_x.index = 0;
break;
case 0x18: /* ^X */
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
perform_delete_start_of_line (1);
fc->change_flag = 1;
save_x.index = 0;
break;
case 0x01: /* ^A */
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
perform_delete_rest_of_line ();
fc->change_flag = 1;
save_x.index = 0;
break;
case 0x1a: /* ^Z */
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
perform_delete_whole_line ();
fc->change_flag = 1;
save_x.index = 0;
check_dirty_cursor ();
break;
case 0x15: /* ^U */
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
end_of_edit = perform_undo () - 1;
fc->change_flag = 1;
save_x.index = 0;
break;
case 0x04: /* ^D (bei aedit ein macro) */
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
if (fc->byte_index > 0)
{
fc->buffer--;
comm_umlaut (fc->buffer);
fc->buffer++;
update_this_line (fc->lin_left, fc->lrow);
fc->change_flag = 1;
}
break;
case 0x0b: /* ^K (bei aedit ein macro) */
end_of_edit = -2;
BREAK_IF_REPEAT_0
new_index = comm_ctrl_k (fc->buff_0, fc->byte_index, fc->byte_anz);
if (new_index >= 0L)
{
/* zeiger bewegen */
perform_move (new_index);
/* ggf. zeigen */
if ((fc->lrow <= MIN_ROW) || (fc->lrow >= MAX_ROW))
perform_view ();
}
save_x.index = 0;
break;
case KEY_F1: /* help */
end_of_edit = -2;
BREAK_IF_REPEAT_0
show_help_option ();
clear_screen ();
perform_view ();
line_2_flag = 1;
break;
case KEY_F3: /* convert single char to lower case */
LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
*fc->buffer = tolower_german (*fc->buffer);
update_this_line (fc->lin_left, fc->lrow);
end_of_edit = (perform_key_right (update_cursor, 1) != 0) - 1;
save_x.index = 0;
fc->change_flag = 1;
break;
case KEY_F4: /* convert single char to upper case */
LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
*fc->buffer = toupper_german (*fc->buffer);
update_this_line (fc->lin_left, fc->lrow);
end_of_edit = (perform_key_right (update_cursor, 1) != 0) - 1;
save_x.index = 0;
fc->change_flag = 1;
break;
case KEY_F5: /* convert string to lower case */
case KEY_F6: /* convert string to upper case */
LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
new_index = perform_lower_upper (key_0 == KEY_F6);
if (new_index < 0L)
{
end_of_edit = -1;
}
else
{
fc->change_flag = 1;
/* zeiger bewegen */
perform_move (new_index);
/* und zeigen */
if (fc->lrow >= MAX_ROW)
{
perform_view ();
}
else
{
update_this_line (fc->lin_left, fc->lrow);
perform_update (fc->buff_0, fc->byte_anz,
fc->left_col);
}
}
save_x.index = 0;
break;
#if HELP_COMMAND_DIRECT
case ALT_F1: /* system "qh/help/man <topic>" */
end_of_edit = -2;
BREAK_IF_REPEAT_0
save_x.index = 0;
/* build command string */
strcpy (str_syst, HELP_COMMAND);
get_current_string (fc->buff_0, fc->byte_index, fc->byte_anz,
&str_syst[strlen(HELP_COMMAND)]);
/* perform command */
clear_screen ();
fflush (stdout);
kb_echo_on ();
system (str_syst);
kb_echo_off ();
/* return to mbedit */
get_hit_any_key ();
clear_screen ();
perform_view ();
break;
#endif
#if ((CHANGE_LINES_DIRECT) && (WITH_WINCH))
case ALT_F9:
vb_switch_lines ();
set_window_size ();
perform_view ();
break;
#endif
#if INSERT_KEY_DIRECT
case KEY_INS:
end_of_edit = -2;
LOCK_WHEN_BUFFER_ACTIVE LOCK_WHEN_VIEW_ONLY
BREAK_IF_REPEAT_0
if (mode_flag == 1) /* insert mode active ? */
{
mode_flag = 2; /* switch to exchange mode */
save_x.index = 0;
}
else
{
mode_flag = 1; /* switch to insert mode */
}
line_2_flag = 1;
break;
#endif
case 0x05: /* ^E <MEXEC> */
LOCK_WHEN_BUFFER_ACTIVE
/* status line 1 missbrauchen */
get_cursor_pos (&row, &column);
show_status_line_1 (" <MEXEC> ", fc);
set_cursor_to (row, column);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -