📄 cfgfile.c
字号:
* put the characters into the literal array until we run into the
* end of literal or terminating '\0';
*/
while (*line != '\0' && *line != '\n') {
if (*line != '\"')
*literal++ = *line++;
else {
if (*(line+1) == '\"') {
*literal++ = '\"';
line++;
line++;
} else {
line++;
--quote_state;
break;
}
}
}
*literal = '\0';
/*
* return what's left on the line, if anything.
*/
if (*line != '\0' && *line != '\n')
*residue = line;
else
*residue = NULL;
if (quote_state != 0) {
*residue = NULL;
return( ERROR );
} else
return( OK );
}
/*
* Name: initialize_macro
* Purpose: initialize the first key of a macro def
* Date: June 5, 1992
* Passed: macro_key: key that we are a assigning a macro to
* Notes: this function is ported directly from tde.
*/
void initialize_macro( int macro_key )
{
register int next;
int prev;
next = macros.first_stroke[macro_key];
/*
* initialize the first key in a macro def
*/
if (next != STROKE_LIMIT+1) {
do {
prev = next;
next = macros.strokes[next].next;
macros.strokes[prev].key = MAX_KEYS+1;
macros.strokes[prev].next = STROKE_LIMIT+1;
++stroke_count;
} while (next != -1);
}
/*
* find the first open space and initialize
*/
for (next=0; macros.strokes[next].next != STROKE_LIMIT+1;)
next++;
macros.first_stroke[macro_key] = next;
macros.strokes[next].key = -1;
macros.strokes[next].next = -1;
}
/*
* Name: clear_previous_macro
* Purpose: clear any macro previously assigned to a key
* Date: June 5, 1992
* Passed: macro_key: key that we are a assigning a macro to
* Notes: this function is ported directly from tde.
*/
void clear_previous_macro( int macro_key )
{
register int next;
int prev;
next = macros.first_stroke[macro_key];
/*
* if key has already been assigned to a macro, clear macro def.
*/
if (next != STROKE_LIMIT+1) {
do {
prev = next;
next = macros.strokes[next].next;
macros.strokes[prev].key = MAX_KEYS+1;
macros.strokes[prev].next = STROKE_LIMIT+1;
} while (next != -1);
}
macros.first_stroke[macro_key] = STROKE_LIMIT+1;
}
/*
* Name: check_macro
* Purpose: see if macro def has any valid key. if not, clear macro
* Date: June 5, 1992
* Passed: macro_key: key that we are a assigning a macro to
* Notes: this function is ported directly from tde.
*/
void check_macro( int macro_key )
{
register int next;
register int key;
/*
* see if the macro has any keystrokes. if not, then wipe it out.
*/
key = macro_key;
if (key != 0) {
next = macros.first_stroke[key];
if (macros.strokes[next].key == -1) {
macros.strokes[next].key = MAX_KEYS+1;
macros.strokes[next].next = STROKE_LIMIT+1;
macros.first_stroke[key-256] = STROKE_LIMIT+1;
if (key_func.key[key] == PlayBack)
key_func.key[key] = 0;
}
}
}
/*
* Name: record_keys
* Purpose: save keystrokes in keystroke buffer
* Date: June 5, 1992
* Passed: line: line to display prompts
* Notes: -1 in .next field indicates the end of a recording
* STROKE_LIMIT+1 in .next field indicates an unused space.
* Recall, return codes are for macros. Since we do not allow
* keys to be assigned to macro functions, let's just return OK;
*/
int record_keys( int macro_key, int key )
{
register int next;
register int prev;
int func;
int rc;
rc = OK;
if (stroke_count == 0) {
printf( "==> %s", line_in );
printf( "No more room in macro buffer: line %u\n",
line_no );
rc = ERROR;
} else {
func = getfunc( key );
if (func != RecordMacro && func != SaveMacro && func != LoadMacro &&
func != ClearAllMacros) {
/*
* a -1 in the next field marks the end of the keystroke recording.
*/
next = macros.first_stroke[macro_key];
if (macros.strokes[next].next != STROKE_LIMIT+1) {
while (macros.strokes[next].next != -1)
next = macros.strokes[next].next;
}
prev = next;
/*
* now find an open space to record the current key.
*/
if (macros.strokes[next].key != -1) {
for (; next < STROKE_LIMIT &&
macros.strokes[next].next != STROKE_LIMIT+1;)
next++;
if (next == STROKE_LIMIT) {
for (next=0; next < prev &&
macros.strokes[next].next != STROKE_LIMIT+1;)
next++;
}
}
if (next == prev && macros.strokes[prev].key != -1) {
rc = ERROR;
} else {
/*
* next == prev if we are recording the initial macro node.
*/
macros.strokes[prev].next = next;
macros.strokes[next].next = -1;
macros.strokes[next].key = key;
stroke_count--;
}
}
}
return( rc );
}
/*
* Name: new_sort_order
* Purpose: change the sort order
* Date: October 31, 1992
* Notes: New sort oder starts at the @ sign
*/
void new_sort_order( unsigned char *residue, unsigned char *sort )
{
int i;
sort += 33;
for (i=33; *residue != '\0' && *residue != '\n' && i <= 255; i++)
*sort++ = *residue++;
}
/*
* Name: get_stroke_count
* Purpose: count unassigned nodes in macro buff
* Date: June 5, 1992
* Returns: number of strokes left in macro buffer.
*/
int get_stroke_count( void )
{
int count = 0;
int i;
for (i=0; i<STROKE_LIMIT; i++)
if (macros.strokes[i].next == STROKE_LIMIT+1)
++count;
return( count );
}
/*
* Name: getfunc
* Purpose: get the function assigned to key c
* Date: June 5, 1992
* Passed: c: key just pressed
* Notes: key codes less than 256 or 0x100 are not assigned a function.
* The codes in the range 0-255 are ASCII and extended ASCII chars.
*/
int getfunc( int c )
{
register int i = c;
if (i <= 256)
i = 0;
else
i = key_func.key[i-256];
return( i );
}
/*
* Name: clear_previous_twokey
* Purpose: clear any previously assigned two-key combos
* Date: April 1, 1993
* Passed: macro_key: key that we are clearing
*/
void clear_previous_twokey( int two_key )
{
int i;
for (i=0; i < MAX_TWO_KEYS; i++) {
if (two_key == two_key_list.key[i].parent_key) {
two_key_list.key[i].parent_key = 0;
two_key_list.key[i].child_key = 0;
two_key_list.key[i].func = 0;
}
}
}
/*
* Name: insert_twokey
* Purpose: find an open slot and insert the new two-key combination
* Date: April 1, 1993
* Passed: parent_key: 1st key
* child_key: 2nd key
* func_no: function number to assign to this combo
* Notes: find the first avaible open slot. clear any previously defined
* previous parent-child combo.
*/
int insert_twokey( int parent_key, int child_key, int func_no )
{
register int i;
int rc;
for (i=0; i < MAX_TWO_KEYS; i++) {
if (parent_key == two_key_list.key[i].parent_key) {
if (child_key == two_key_list.key[i].child_key) {
two_key_list.key[i].parent_key = 0;
two_key_list.key[i].child_key = 0;
two_key_list.key[i].func = 0;
}
}
}
for (i=0; i < MAX_TWO_KEYS; i++) {
if (two_key_list.key[i].parent_key == 0) {
two_key_list.key[i].parent_key = parent_key;
two_key_list.key[i].child_key = child_key;
two_key_list.key[i].func = func_no;
break;
}
}
rc = OK;
if (i == MAX_TWO_KEYS)
rc = ERROR;
return( rc );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -