📄 disp_hnd.c
字号:
sprintf (err_text, " (line %d)", line_no);
err_message_1 (OUT_OF_MEMORY, err_text);
break;
}
break;
} /* switch parse_line[0] */
/* save last file position */
filpos = ftell(fp);
} /* while loop */
/* close datafile */
fclose (fp);
#if BIG_BUFFER
read_level--;
#endif
if (err_line)
{
sprintf (err_text, " (line %d)", err_line);
err_message_1 (INVALID_SYNTAX_ENTRY, err_text);
return (- err_line); /* error */
}
else
{
show_status_line_2 ("*** got syntax file ***", 0, -2, 0);
return 1; /* o.k. */
}
} /* read_syntax_file */
/* -FF- */
int search_syntax_file (void)
{
static char filename [BUF_256];
FILE *fp;
/* search sequence, without return between searches. */
/* 1.) search in PATH (not in ms/dos, only unix + os_9) */
/* 2.) search in mbedit path (path of exe-file = argv[0]) */
/* 3.) search in home directory */
#if (ACT_OP_SYSTEM == MS_DOS) /* || (ACT_OP_SYSTEM == WIN_32) */
#define SEARCH_IN_PATH 0
#else
#define SEARCH_IN_PATH 1
#endif
#if SEARCH_IN_PATH
static char path [BUF_256];
char *name_stt, *name_end;
#endif
#if SEARCH_IN_PATH
/* 1.) search in PATH */
/* get environment variable "PATH" */
strncpy (path, getenv ("PATH"), sizeof (path));
path [sizeof(path) - 1] = '\0'; /* forced end of string */
/* example: */
/* PATH=H:;D:\USR.PC\BIN;C:\SYSTEM;C:\PCLINK3;C:\BIN;D:\BIN;D:\BAT;D:\UTIL; */
/* parse environment variable */
name_stt = path;
name_end = path;
while (*name_stt != 0)
{
while (*name_end != PATH_SEPARATOR)
{
if (*name_end == '\0') /* missing last separator ? */
break; /* for safety reasons */
name_end++;
}
*name_end = '\0';
/* build syntax filename */
strncpy (filename, name_stt, sizeof(filename));
strcat (filename, FILE_SEPARATOR);
strcat (filename, SYNTX_FILENAME);
#if MAC_TEST
printf ("\015\012 filename = %s\015\012", filename);
#endif
/* test, if file exists */
if ((fp = fopen (filename, "r")) != NULL)
{ /* found file in search path */
fclose (fp);
strncpy (str_synt, filename, sizeof(str_synt));
return read_syntax_file (filename); /* get it + return */
break;
}
/* next pathname */
name_end++;
name_stt = name_end;
} /* while name_stt */
#endif
/* 2.) search in mbedit path */
/* build syntax filename */
strcpy (filename, get_exe_path ());
strcat (filename, FILE_SEPARATOR);
strcat (filename, SYNTX_FILENAME);
#if MAC_TEST
printf ("\015\012 filename = %s\015\012", filename);
#endif
/* test, if file exists */
if ((fp = fopen (filename, "r")) != NULL)
{ /* found file in search path */
fclose (fp);
strncpy (str_synt, filename, sizeof(str_synt));
return read_syntax_file (filename); /* get it + return */
}
/* 3.) search in home directory */
/* build syntax filename */
strcpy (filename, HOME_DIR);
strcat (filename, FILE_SEPARATOR);
strcat (filename, SYNTX_FILENAME);
#if MAC_TEST
printf ("\015\012 filename = %s\015\012", filename);
#endif
/* test, if file exists */
if ((fp = fopen (filename, "r")) != NULL)
{ /* found file in search path */
fclose (fp);
strncpy (str_synt, filename, sizeof(str_synt));
return read_syntax_file (filename); /* get it + return */
}
/* no syntax file found: use default setting from header file */
strncpy (str_synt, "<internal data>", sizeof(str_synt));
hi_light = hi_light_default;
num_file_types = lengthof(hi_light_default);
return -1; /* nothing found */
} /* search_syntax_file */
/* -FF- */
/***************************************************************/
/* calculate file type from extension */
/***************************************************************/
int get_file_type (char *pathname)
{
int ii, jj, index;
for (jj = 0 ; jj < ACTUAL_NUMBER_FILETYPES ; jj++)
{
for (ii = 0 ; ii < hi_light[jj].num_file_ext ; ii++)
{
/* index to possible file extension */
index = strlen (pathname) - strlen((char *)hi_light[jj].file_ext[ii]);
index = max (0, index); /* avoid neg. numbers (very short filenames) */
if (stricmp (&pathname[index], (char *)hi_light[jj].file_ext[ii]) == 0)
{
if (index >= 1)
{
if ((pathname[index-1] == '.') ||
(pathname[index-1] == FILE_SEPARATOR[0]))
{
fc->file_type = jj;
return jj;
}
}
/* for files without extension (e.g.: "makefile") */
if (index == 0)
{
fc->file_type = jj;
return jj;
}
}
}
}
return 0;
} /* get_file_type */
/***************************************************************/
/* control of screen update */
/***************************************************************/
struct UPDATE {long start_index;
int first_row;
int last_row;
};
static struct UPDATE update = { 0x7fffffff,
INIT_ROWS,
-1 };
void update_this_line (long lin_left, int row)
{
update.start_index = min (update.start_index, lin_left);
update.first_row = min (update.first_row , row);
update.last_row = max (update.last_row , row);
return;
} /* update_this_line */
void update_rest_of_window (long lin_left, int row)
{
update.start_index = min (update.start_index, lin_left);
update.first_row = min (update.first_row , row);
update.last_row = max (update.last_row , MAX_ROW);
return;
} /* update_rest_of_window */
void update_entire_window (long top_left)
{
update.start_index = top_left; /* hier kein min !!! */
#if 0
update.first_row = min (update.first_row , MIN_ROW);
update.last_row = max (update.last_row , MAX_ROW);
#else
update.first_row = MIN_ROW; /* NEU !! 25.05.94 */
update.last_row = MAX_ROW;
#endif
return;
} /* update_entire_window */
void perform_update (char FA_HU * buff_0, long byte_anz,
int left_col)
{
/* anzeige bei macro execution nur, wenn gewuenscht */
if (!get_video_active (0))
return; /* don't display */
/* test, if update necessary */
if (update.last_row >= update.first_row)
{
disp_memory (buff_0 , update.start_index,
byte_anz , left_col,
update.first_row, update.last_row);
}
/* set back to invalid */
update.start_index = 0x7fffffff;
update.first_row = ROWS+1;
update.last_row = -1;
return;
} /* perform_update */
/* -FF- */
#if (ACT_OP_SYSTEM == MS_DOS)
#define SAV_LEN 80
#else
#define SAV_LEN LIMIT_COLUMNS
#endif
static char save_text_2 [3][SAV_LEN] =
{
MODE_TEXT_0,
MODE_TEXT_0,
MODE_TEXT_0
};
#if (WITH_ZULU)
static char save_line_2 [SAV_LEN];
void push_status_line_2 (void)
{
strncpy (save_line_2, save_text_2[act_window], SAV_LEN);
save_line_2[SAV_LEN - 1] = '\0';
}
void pop_status_line_2 (int left_justified, int cursor_pos,
int ignore_batch)
{
show_status_line_2 (save_line_2, left_justified,
cursor_pos, ignore_batch);
}
#endif
void refresh_1_window (void)
{
update_entire_window (fc->top_left);
perform_update (fc->buff_0, fc->byte_anz, fc->left_col);
show_status_line_1 (get_line_1_text (), fc); /* @@ 22.09.94 */
show_status_line_2 (save_text_2 [act_window], 0, -2, 0);
return;
} /* refresh_1_window */
void refresh_whole_screen (void)
{
#if WINDOW_COMMAND
if (act_window)
{
window_change ();
refresh_1_window ();
window_change ();
}
#endif
refresh_1_window ();
return;
} /* refresh_whole_screen */
/* -FF- */
/***************************************************************/
/* macro + batch + video control */
/***************************************************************/
static int batch_mode;
static int video_stack;
void set_batch_mode (int mode)
{
batch_mode = mode;
} /* set_batch_mode */
void push_video_stack (void)
{
video_stack++;
return;
} /* push_video_stack */
void pop_video_stack (void)
{
if (video_stack > 0)
{
video_stack--;
}
return;
} /* pop_video_stack */
int get_video_active (int ignore_batch)
{
if ((batch_mode) && (!ignore_batch))
return 0; /* display OFF */
if (video_stack)
return 0; /* display OFF */
if ((get_macro_status () == MACRO_EXECUTE) &&
(set.display == 0))
return 0; /* display OFF */
return 1; /* display ON */
} /* get_video_active */
/* -FF- */
static char action_flag = ' ';
#if (WITH_ACTION_FLAG)
/***************************************************************/
/* display action_flag */
/***************************************************************/
void show_action_flag (char flag)
{
int row, column;
/* anzeige bei macro execution nur, wenn gewuenscht */
if (!get_video_active (0))
return; /* don't display */
push_cursor ();
set_stat_1_mode ();
get_cursor_pos (&row, &column);
set_cursor_to ((BOT_ROW - 1), 0);
action_flag = flag;
out_1_char (action_flag, 0);
set_cursor_to (row, column);
fflush (stdout);
set_normal_mode ();
pop_cursor ();
return;
} /* show_action_flag */
#endif
/* -FF- */
/***************************************************************/
/* display memory */
/***************************************************************/
void show_status_line_1 (char *filename, struct FILE_CONTROL *fc0)
{
static const char modified [2] = {'=', '*'};
char mod_kenn;
char text1 [LIMIT_COLUMNS], text2 [BUF_256], text3 [100], form2 [20];
int len1, len2, len3;
char chartext [5]; /* "<xx>" : 4 + 1 */
int file_id, nam_ind;
char *nam_ptr;
#define LINE_1_DEBUG 0 /* <== 0: normal */
/* 1: test */
/* anzeige bei macro execution nur, wenn gewuenscht */
if (!get_video_active (0))
return; /* don't display */
push_cursor ();
/* aufbereiten text filename (bzw. hilfstext) */
memset (chartext, 0, sizeof(chartext));
if (fc0->byte_index == fc0->byte_anz)
sprintf (chartext, "EOF ");
else
sprintf (chartext, "<%02x>", (((byte) *fc0->buffer) & 0xff));
/* file id : 'A', 'B', 'a', 'b' (Kleinbuchstaben bedeuten: view only) */
if (fc0->view_only)
file_id = fc0->buff_no + 'a';
else
file_id = fc0->buff_no + 'A';
/* file modified ? */
mod_kenn = modified [fc0->change_flag & 1];
/* aufbereiten komplette ausgabe-zeile */
set_stat_1_mode ();
/* zeile aus 3 teilen zusammensetzen */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -