📄 intlist.e
字号:
/****************************************************************/
/* EEL code file for editing the Interrupt List */
/* */
/* Written by Ralf Brown */
/* LastEdit: 30 Aug 98 */
/* */
/* This EEL file adds the following keybindings: */
/* Shf-Alt-A add an Access: section to the current entry */
/* Shf-Alt-B add another BUG: to the current entry */
/* Shf-Alt-D add a Desc: section to the current entry */
/* Sft-Alt-I add an InstallCheck: section to current entry */
/* Shf-Alt-R add a Range: section to the current entry */
/* Shf-Alt-S add a Size: section to the current entry */
/* Alt-I add an Index: section to the current entry; */
/* add another Index: line if already on Index: */
/* Alt-N add a new note to current entry or data struct */
/* Alt-P add a Program: section to the current entry */
/* Alt-R insert Return: at start of line */
/* Alt-S insert SeeAlso: at start of line; add another */
/* SeeAlso: line if already on SeeAlso: */
/* F11 insert a blank separator line */
/* ^F11 create Format of: header */
/* Shf-F11 create Values for: header */
/* Alt-F11 create Call with: header */
/* Alt-F12 create Bitfield for: header */
/* F12 add the interrupt number to the separator line */
/* preceding the current entry */
/* ^F12 jump to a specified entry */
/* */
/* It adds the following unbound commands: */
/* renumber-tables */
/* make-distribution */
/* filter-region */
/* run region through a specified command; by */
/* default, the program is given the region on its */
/* stdin and its stdout is used to replace the */
/* region; if one or two "%s" are given, they */
/* will be replaced by the input and output (resp) */
/* file the program should use. */
/* */
/* Other: */
/* adds intlist-mode for .LST and .1ST files */
/* switches current buffer into intlist-mode on loading */
/* maintains a table counter which is inserted each time */
/* a table is created in the text */
/* performs syntax highlighting (Epsilon v7+) */
/****************************************************************/
#include "eel.h"
#if EELVERSION >= 70
#include "colcode.h"
#endif /* Epsilon v7.0+ */
keytable intlist_tab ; /* key table for IntList mode */
/* on repeated F12, how often to display number of entries processed */
/* for fast 386, every 100; for a Pentium, at least 300 or the message */
/* line will lag way behind the actual progress */
#define NUMBER_INT_PROGRESS_INTERVAL 500
/*=============================================================*/
/* Global Variables */
/*=============================================================*/
/* table headings */
char str_format_of[] = "Format of " ;
char str_bitfields_for[] = "Bitfields for " ;
/* section names within an entry */
char size_section[] = "Size:\t" ;
char access_section[] = "Access:\t" ;
char return_section[] = "Return: " ;
char program_section[] = "Program: " ;
char desc_section[] = "Desc:\t" ;
char install_section[] = "InstallCheck:" ;
char range_section[] = "Range:\t" ;
char notes_section[] = "Notes*:\t" ;
char bugs_section[] = "BUGS*:\t" ;
char example_section[] = "Example: " ;
char seealso_section[] = "SeeAlso: " ;
char index_section[] = "Index:\t" ;
#if EELVERSION >= 70
char all_sections[] = "Return:|SeeAlso:|Program:|Desc:|Range:|Notes*:|BUGS*:|Example:|Index:|Access:|InstallCheck:|Size:" ;
char indented_sections[] = "[\t ]*(Return|Notes*):" ;
char table_headers[] = "INT |Format |Values |Bitfields |MEM |CMOS |MSR |CALL |PORT |Call |OPCODE |I2C " ;
#endif /* Epsilon v7.0+ */
/*char table_ID_letters[] = "0123456789CFIMPRS" ;*/
char table_ID_letters[] = "09CFIMPRS" ;
#define ID_LETTER_OFFSET 2
char *(section_order[13]) ;
char *(list_files[13]) ;
#if EELVERSION >= 90
// Lugaru renamed the variable on us!
#define strip_returns translation_type
#endif /* EELVERSION >= 90 */
when_loading()
{
/* list the sections of an entry in the order they should appear (if */
/* present at all) */
section_order[0] = size_section ;
section_order[1] = access_section ;
section_order[2] = return_section ;
section_order[3] = program_section ;
section_order[4] = desc_section ;
section_order[5] = install_section ;
section_order[6] = range_section ;
section_order[7] = notes_section ;
section_order[8] = bugs_section ;
section_order[9] = example_section ;
section_order[10] = seealso_section ;
section_order[11] = index_section ;
section_order[12] = NULL ;
/* list the files comprising the full interrupt list */
list_files[0] = "cmos.lst" ;
list_files[1] = "farcall.lst" ;
list_files[2] = "memory.lst" ;
list_files[3] = "ports.lst" ;
list_files[4] = "interrup.lst" ;
list_files[5] = "tables.lst" ;
list_files[6] = "msr.lst" ;
list_files[7] = "biblio.lst" ;
list_files[8] = "glossary.lst" ;
list_files[9] = "opcodes.lst" ;
list_files[10] = "smm.lst" ;
list_files[11] = "i2c.lst" ;
list_files[12] = NULL ;
}
/*=============================================================*/
/* Buffer-specific variables */
/*=============================================================*/
buffer spot table_counter ;
/*=============================================================*/
/*=============================================================*/
int empty_line()
{
return (character(point-1) == '\n' && character(point) == '\n') ;
}
/*=============================================================*/
/*=============================================================*/
int is_separator_line()
{
return (empty_line() || parse_string(1,"--------",NULL)) ;
}
/*=============================================================*/
/* search in the specified direction (1 = forward, -1 = back) */
/* for the next entry separator line */
/*=============================================================*/
int to_separator_line(dir)
int dir ;
{
nl_reverse() ;
return search(dir,"\n--------") ;
}
/*=============================================================*/
/* move to the location where the specified section of an */
/* entry begins (if present) or should begin (if not) */
/*=============================================================*/
int to_section_start(section)
char *section ;
{
int i, j, len ;
for (i = 0 ; section_order[i] ; i++)
if (strcmp(section,section_order[i]) == 0)
break ;
if (section_order[i])
{
while (!is_separator_line())
{
for (j = i ; section_order[j] ; j++)
if (parse_string(1,section_order[j],NULL))
{
if ((len = parse_string(1,section,NULL)) != 0)
{
point += len ;
return 1 ; /* section already exists */
}
return 0 ; /* section nonexistent, but found position */
}
if (!nl_forward())
break ;
}
return 0 ; /* section does not yet exist */
}
else
return 0 ; /* section not found */
}
/*=============================================================*/
/*=============================================================*/
int make_section(section,start_entry,name)
char *section, *name ;
int start_entry ;
{
int start = point ;
if (start_entry)
{
if (!to_separator_line(-1)) /* find previous separator line */
{
point = start ;
say("Not in an interrupt entry") ;
return 0 ;
}
}
else
{
to_begin_line() ;
while (!empty_line() && !parse_string(1,"\n--------",NULL))
if (!nl_reverse())
break ;
}
point++ ; /* skip the newline */
nl_forward() ; /* advance to first line of entry */
if (!to_section_start(section))
{
if (name)
stuff(name) ;
else
stuff(section) ;
stuff("\n") ;
point-- ; /* back up over inserted newline */
return 1 ;
}
else
return 0 ;
return 2 ; /* just in case */
}
/*=============================================================*/
/*=============================================================*/
int pluralize_section(plural)
char plural ;
{
point -= 3 ;
if (curchar() != plural) /* already plural ? */
{
point++ ;
insert(plural) ;
}
nl_forward() ;
while (!is_separator_line() && parse_string(1,"[ \t]",NULL))
nl_forward() ;
stuff("\t\n") ;
point-- ;
}
/*=============================================================*/
/* Add "SeeAlso: " to the beginning of the current line unless */
/* it is already present; in that case, insert a fresh line */
/* containing just a SeeAlso: and position the cursor at the */
/* end of the new line */
/*=============================================================*/
command see_also() on intlist_tab[ALT('s')]
{
to_begin_line() ;
if (parse_string(1,"SeeAlso: ",NULL) == 0)
stuff("SeeAlso: ") ;
else
{
nl_forward() ;
stuff("SeeAlso: \n") ;
point-- ;
}
}
/*=============================================================*/
/* Add a Desc: section if the current entry does not already */
/* have one; if there is already a Desc: section, move to the */
/* start of it */
/*=============================================================*/
command access() on intlist_tab[ALT('A')]
{
make_section(access_section,1,NULL) ;
}
/*=============================================================*/
/* Add a Desc: section if the current entry does not already */
/* have one; if there is already a Desc: section, move to the */
/* start of it */
/*=============================================================*/
command desc() on intlist_tab[ALT('D')]
{
make_section(desc_section,1,NULL) ;
}
/*=============================================================*/
/* Add a InstallCheck: section if the current entry does not */
/* already have one; if there is already a InstallCheck: */
/* section, move to the start of it */
/*=============================================================*/
command instcheck() on intlist_tab[ALT('I')]
{
make_section(install_section,1,NULL) ;
}
/*=============================================================*/
/* Add a Range: section if the current entry does not already */
/* have one; if there is already a Range: section, move to the */
/* start of it */
/*=============================================================*/
command range() on intlist_tab[ALT('R')]
{
make_section(range_section,1,NULL) ;
}
/*=============================================================*/
/* Add a Size: section if the current entry does not already */
/* have one; if there is already a Size: section, move to the */
/* start of it */
/*=============================================================*/
command memsize() on intlist_tab[ALT('S')]
{
make_section(size_section,1,NULL) ;
}
/*=============================================================*/
/* Add a "Program: " section to the current entry if it does */
/* not have one; otherwise, move to the beginning of the */
/* Program: section */
/*=============================================================*/
command program() on intlist_tab[ALT('p')]
{
make_section(program_section,1,NULL) ;
}
/*=============================================================*/
/* Add an "Index: " section to the current entry if it does */
/* not have one; otherwise, move to the beginning of the */
/* Index: section */
/*=============================================================*/
command add_index() on intlist_tab[ALT('i')]
{
to_begin_line() ;
if (parse_string(1,"Index:",NULL))
{
while (parse_string(1,"Index:",NULL))
nl_forward() ;
stuff("Index:\t\n") ;
point-- ;
}
else
make_section(index_section,1,NULL) ;
}
/*=============================================================*/
/*=============================================================*/
command bug() on intlist_tab[ALT('B')]
{
if (!make_section(bugs_section,1,"BUG:\t"))
pluralize_section('S') ;
}
/*=============================================================*/
/* Add "Note: " section to the current entry; change an */
/* existing Note: to Notes: and position at end of Note: */
/* section. */
/*=============================================================*/
command add_note() on intlist_tab[ALT('n')]
{
if (!make_section(notes_section,0,"Note:\t"))
pluralize_section('s') ;
}
/*=============================================================*/
/* Insert "Return: " at the beginning of the current line, if */
/* not already present */
/*=============================================================*/
command returns() on intlist_tab[ALT('r')]
{
int start = point ;
to_begin_line() ;
if (parse_string(1,return_section,NULL) == 0)
stuff(return_section) ;
else
point = start ;
}
/*=============================================================*/
/* insert a line of dashes prior to the current cursor line */
/*=============================================================*/
command separator_line() on intlist_tab[FKEY(11)]
{
int i ;
to_begin_line() ;
for (i = 0 ; i < 45 ; i++)
insert('-') ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -