📄 disp_hnd.c
字号:
hi_light[FILE_TYPE].comment_fc,
strlen(hi_light[FILE_TYPE].comment_fc)) == 0)
{
if (start_index == 0)
{
inside_fc = 1;
}
else if ((buff[ii-1] == 0x0d) || (buff[ii-1] == 0x0a))
{
inside_fc = 1;
}
}
}
if (hi_light[FILE_TYPE].comment_ml1 != NULL)
{
if (strnicmp(&buff[ii],
hi_light[FILE_TYPE].comment_ml1,
strlen(hi_light[FILE_TYPE].comment_ml1)) == 0)
{
inside_ml = 1;
}
}
if (hi_light[FILE_TYPE].comment_ml2 != NULL)
{
if (strnicmp(&buff[ii],
hi_light[FILE_TYPE].comment_ml2,
strlen(hi_light[FILE_TYPE].comment_ml2)) == 0)
{
inside_ml = 0;
}
}
}
}
} /* if first */
else
{
if ((is_string_character(buff, start_index, max_index) == 1) && (!inside_s2))
inside_s1 = (inside_s1 + 1) & 0x01; /* toggle each time */
if ((is_string_character(buff, start_index, max_index) == 2) && (!inside_s1))
inside_s2 = (inside_s2 + 1) & 0x01; /* toggle each time */
if ((inside_s1 == 0) && (inside_s2 == 0))
{
if (hi_light[FILE_TYPE].comment_sl != NULL)
{
if (strnicmp(&buff[start_index],
hi_light[FILE_TYPE].comment_sl,
strlen(hi_light[FILE_TYPE].comment_sl)) == 0)
{
inside_sl = (direction == 1) ? 1 : 0;
}
}
if (hi_light[FILE_TYPE].comment_fc != NULL)
{
if (strnicmp(&buff[start_index],
hi_light[FILE_TYPE].comment_fc,
strlen(hi_light[FILE_TYPE].comment_fc)) == 0)
{
if (start_index == 0)
{
inside_fc = 1;
}
else if ((buff[start_index-1] == 0x0d) || (buff[start_index-1] == 0x0a))
{
inside_fc = 1;
}
}
}
if (hi_light[FILE_TYPE].comment_ml1 != NULL)
{
if (strnicmp(&buff[start_index],
hi_light[FILE_TYPE].comment_ml1,
strlen(hi_light[FILE_TYPE].comment_ml1)) == 0)
{
inside_ml = (direction == 1) ? 1 : 0;
}
}
if (hi_light[FILE_TYPE].comment_ml2 != NULL)
{
if (strnicmp(&buff[start_index],
hi_light[FILE_TYPE].comment_ml2,
strlen(hi_light[FILE_TYPE].comment_ml2)) == 0)
{
inside_ml = (direction == 1) ? 0 : 1;
}
}
}
if ((buff[start_index] == 0x0d) || (buff[start_index] == 0x0a))
{
inside_s1 = 0;
inside_s2 = 0;
inside_sl = 0;
inside_fc = 0;
inside_ml = 0;
}
}
return (inside_s1 || inside_s2 || inside_sl || inside_fc || inside_ml);
} /* is_inside_string_or_comment */
/* -FF- */
int is_inside_comment_multi(char FA_HU *buff_0, long start_index, long max_index, int first, int direction)
{
/* check, if cursor position is inside comment (type multiple lines) */
static int is_comment, inside_s1, inside_s2;
int ii;
if ((hi_light[FILE_TYPE].comment_ml1 == NULL) ||
(hi_light[FILE_TYPE].comment_ml2 == NULL))
{
return 0;
}
if (first)
{
is_comment = 0; /* off */
inside_s1 = 0;
inside_s2 = 0;
for (ii = start_index; ii >= 0; ii--)
{
if ((is_string_character(buff_0, ii, max_index) == 1) && (!inside_s2))
inside_s1 = (inside_s1 + 1) & 0x01; /* toggle each time */
if ((is_string_character(buff_0, ii, max_index) == 2) && (!inside_s1))
inside_s2 = (inside_s2 + 1) & 0x01; /* toggle each time */
if ((inside_s1 == 0) && (inside_s2 == 0))
{
if (strnicmp(&buff_0[ii], hi_light[FILE_TYPE].comment_ml1,
strlen(hi_light[FILE_TYPE].comment_ml1)) == 0)
{
is_comment = 1; /* on */
break;
}
if((strnicmp(&buff_0[ii], hi_light[FILE_TYPE].comment_ml2,
strlen(hi_light[FILE_TYPE].comment_ml2)) == 0) &&
(strnicmp(&buff_0[ii-1],hi_light[FILE_TYPE].comment_ml1,
strlen(hi_light[FILE_TYPE].comment_ml1)) != 0))
{
is_comment = 0; /* off */
break;
}
}
} /* for buf */
}
else
{
if ((is_string_character(buff_0, start_index, max_index) == 1) && (!inside_s2))
inside_s1 = (inside_s1 + 1) & 0x01; /* toggle each time */
if ((is_string_character(buff_0, start_index, max_index) == 2) && (!inside_s1))
inside_s2 = (inside_s2 + 1) & 0x01; /* toggle each time */
if ((inside_s1 == 0) && (inside_s2 == 0))
{
if (strnicmp(&buff_0 [start_index], hi_light[FILE_TYPE].comment_ml1,
strlen(hi_light[FILE_TYPE].comment_ml1)) == 0)
{
is_comment = ((direction == 1) ? 1 : 0);
}
if((strnicmp(&buff_0 [start_index], hi_light[FILE_TYPE].comment_ml2,
strlen(hi_light[FILE_TYPE].comment_ml2)) == 0) &&
(strnicmp(&buff_0 [start_index-1],hi_light[FILE_TYPE].comment_ml1,
strlen(hi_light[FILE_TYPE].comment_ml1)) != 0))
{
is_comment = ((direction == 1) ? 0 : 1);
}
}
}
return is_comment;
} /* is_inside_comment_multi */
/* -FF- */
static void disp_memory (char FA_HU * buff_0, long start_index,
long byte_anz, int left_col,
int start_row, int end_row)
{
int row;
int start_comment; /* 2 : 1st line, comment: ON */
/* 1 : 1st line, comment: OFF */
/* 0 : all other lines */
/* anzeige bei macro execution nur, wenn gewuenscht */
if (!get_video_active (0))
return; /* don't display */
#if (WITH_SYNTAX_HIGHLIGHTING)
set_normal_mode ();
/* check backwards for begin of comment (invisible on actual screen) */
if (is_comment_active ())
{
start_comment = is_inside_comment_multi(buff_0, start_index, byte_anz, 1, -1) + 1;
}
#endif
push_cursor ();
for (row = start_row ; row <= end_row ; row++)
{
start_index = disp_1_line (buff_0, start_index, byte_anz,
row, left_col, start_comment);
#if (DISPLAY_PAUSE)
fflush(stdout); /* NEW ! 19.04.03 */
#endif
start_comment = 0; /* from now on */
} /* for row */
pop_cursor ();
#if (DISPLAY_PAUSE)
fflush(stdout); /* NEW ! 17.10.02 */
sleep_msec(DISPLAY_PAUSE); /* avoid, that display hangs */
#endif
#if (WITH_SYNTAX_HIGHLIGHTING)
set_normal_mode ();
#endif
return;
} /* disp_memory */
/* -FF- */
int has_single_quote_string (void)
{
int single_quote_string;
/* Visual Basic uses single quote for comments, not strings */
single_quote_string = 1; /* default */
if (hi_light[FILE_TYPE].comment_sl)
{
if (strnicmp("'", hi_light[FILE_TYPE].comment_sl,
strlen(hi_light[FILE_TYPE].comment_sl)) == 0)
single_quote_string = 0;
}
return single_quote_string;
} /* has_single_quote_string */
/* -FF- */
static long disp_1_line (char FA_HU * buff_0, long start_index, long byte_anz,
int row, int left_col, int start_comment)
{
long index;
int column, col_diff, tab_diff, char_cnt, sav_eol, mark_0_flag, eof_flag, ii;
int cr_flag, is_string, inside_str, inside_1, inside_2, inside_keyword;
char ckey;
char FA_HU *buffer;
static char text [LIMIT_COLUMNS+1];
static int comment_type; /* 0 : no comment */
/* 1 : c style */
/* 2 : c++ style */
#define REL_COL (column - left_col)
#if (WITH_SYNTAX_HIGHLIGHTING)
int len, comment_count_1, comment_count_2;
#endif
/* anzeige bei macro execution nur, wenn gewuenscht */
if (!get_video_active (0))
return (0L); /* don't display */
push_cursor ();
buffer = &buff_0 [start_index];
column = 0;
cr_flag = 0;
memset (text, 0, sizeof (text));
memset (attr, 0, sizeof (attr));
if (start_comment > 0)
comment_type = start_comment - 1;
#if (WITH_SYNTAX_HIGHLIGHTING)
if (start_comment == 2) /* begin of comment ? */
{
if (is_comment_active ())
{
attr [min (max (REL_COL, 0), COLUMNS)] |= BEG_COMMENT;
attr [min (max (REL_COL, 0), COLUMNS)] &= ~END_COMMENT;
/* comment_type = 1; */
}
}
comment_count_1 = 0;
comment_count_2 = 0;
inside_keyword = 0;
#endif
/* display all chars on this line */
inside_str = 0;
inside_1 = 0;
inside_2 = 0;
for (index = start_index ; index <= byte_anz ; index++)
{
/* line partially invers ? */
if ((index >= fc->find[0]) &&
(fc->find[0] != -1))
{
fc->find[0] = -1;
attr [min (max (REL_COL, 0), COLUMNS)] |= BEG_INVERS;
}
if ((index >= fc->find[1]) &&
(fc->find[1] != -1))
{
fc->find[1] = -1;
attr [min (max (REL_COL, 0), COLUMNS)] |= END_INVERS;
}
#if (WITH_SYNTAX_HIGHLIGHTING)
if (!comment_type && !inside_keyword)
is_string = is_string_character(buff_0, index, byte_anz);
else
is_string = 0;
if (is_string)
{
if ((is_string == 1) && (!inside_2))
inside_1 = (inside_1 + 1) & 0x01; /* toggle each time */
if ((is_string == 2) && (!inside_1))
inside_2 = (inside_2 + 1) & 0x01; /* toggle each time */
inside_str = (inside_1 || inside_2);
if (is_string_active() && inside_str)
attr [min (max ( REL_COL , 0), COLUMNS)] |= BEG_STRING;
else
attr [min (max ((REL_COL+1), 0), COLUMNS)] |= END_STRING;
}
else if (!comment_type && !inside_str && !inside_keyword)
{
/* check for keyword */
if ((len = is_keyword (buffer, index, byte_anz)) != 0)
{
if (is_keyword_active ())
{
attr [min (max ( REL_COL , 0), COLUMNS)] |= BEG_KEYWORD;
attr [min (max ((REL_COL+len), 0), COLUMNS)] |= END_KEYWORD;
}
inside_keyword = len + 1;
}
}
#endif
/* get character */
ckey = *buffer;
#if (WITH_SYNTAX_HIGHLIGHTING)
/* count down keyword length */
if (inside_keyword)
{
inside_keyword--;
}
if (!inside_str && !inside_keyword)
{
/* check for comments */
/* end of comment ? */
if (comment_type == 1)
{
/* count down */
if (comment_count_2)
{
comment_count_2--;
if (comment_count_2 == 0)
{
if (is_comment_active ())
{
attr [min (max (REL_COL, 0), COLUMNS)] |= END_COMMENT;
attr [min (max (REL_COL, 0), COLUMNS)] &= ~BEG_COMMENT;
}
comment_type = 0;
}
}
/* c style */
if (comment_count_1) /* bugfix 24.04.03 */ /*/ this is now a comment */
{
comment_count_1--;
}
if (comment_count_1 == 0)
{
if (hi_light[FILE_TYPE].comment_ml2)
{
if (strnicmp(buffer,hi_light[FILE_TYPE].comment_ml2,
strlen(hi_light[FILE_TYPE].comment_ml2)) == 0)
{ /* n characters from here */
comment_count_2 = strlen(hi_light[FILE_TYPE].comment_ml2);
}
}
}
}
if (comment_type == 2)
{
/* c++ style */
if (ckey == EOLN_LOW)
{
if (is_comment_active ())
{
attr [min (max (REL_COL, 0), COLUMNS)] |= END_COMMENT;
attr [min (max (REL_COL, 0), COLUMNS)] &= ~BEG_COMMENT;
}
comment_type = 0;
}
}
/* begin of comment ? */
if (comment_type == 0)
{
/* c style */
if (hi_light[FILE_TYPE].comment_ml1)
{
if (strnicmp(buffer,hi_light[FILE_TYPE].comment_ml1,
strlen(hi_light[FILE_TYPE].comment_ml1)) == 0)
{
if (is_comment_active ())
{
attr [min (max (REL_COL, 0), COLUMNS)] |= BEG_COMMENT;
attr [min (max (REL_COL, 0), COLUMNS)] &= ~END_COMMENT;
}
comment_type = 1;
comment_count_1 = strlen(hi_light[FILE_TYPE].comment_ml1);
}
}
/* c++ style */
if (hi_light[FILE_TYPE].comment_sl)
{
if (strnicmp(buffer,hi_light[FILE_TYPE].comment_sl,
strlen(hi_light[FILE_TYPE].comment_sl)) == 0)
{
if (is_comment_active ())
{
attr [min (max (REL_COL, 0), COLUMNS)] |= BEG_COMMENT;
attr [min (max (REL_COL, 0), COLUMNS)] &= ~END_COMMENT;
}
comment_type = 2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -