bim: sync with upstream
This commit is contained in:
parent
3b5924cc17
commit
c4c5cd163f
89
apps/bim.c
89
apps/bim.c
@ -807,7 +807,7 @@ buffer_t * buffer_close(buffer_t * buf) {
|
||||
* Convert syntax highlighting flag to color code
|
||||
*/
|
||||
const char * flag_to_color(int _flag) {
|
||||
int flag = _flag & 0xF;
|
||||
int flag = _flag & FLAG_MASK_COLORS;
|
||||
switch (flag) {
|
||||
case FLAG_KEYWORD:
|
||||
return COLOR_KEYWORD;
|
||||
@ -829,7 +829,7 @@ const char * flag_to_color(int _flag) {
|
||||
return COLOR_FG;
|
||||
case FLAG_BOLD:
|
||||
return COLOR_BOLD;
|
||||
case FLAG_LINK:
|
||||
case FLAG_LINK_COLOR:
|
||||
return COLOR_LINK;
|
||||
case FLAG_ESCAPE:
|
||||
return COLOR_ESCAPE;
|
||||
@ -1734,6 +1734,9 @@ void set_unbuffered(void) {
|
||||
struct termios new = old;
|
||||
new.c_iflag &= (~ICRNL) & (~IXON);
|
||||
new.c_lflag &= (~ICANON) & (~ECHO) & (~ISIG);
|
||||
#ifdef VLNEXT
|
||||
new.c_cc[VLNEXT] = 0;
|
||||
#endif
|
||||
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &new);
|
||||
}
|
||||
|
||||
@ -1837,7 +1840,7 @@ void place_cursor(int x, int y) {
|
||||
char * color_string(const char * fg, const char * bg) {
|
||||
static char output[100];
|
||||
char * t = output;
|
||||
t += sprintf(t,"\033[22;23;24;");
|
||||
t += sprintf(t,"\033[22;23;");
|
||||
if (*bg == '@') {
|
||||
int _bg = atoi(bg+1);
|
||||
if (_bg < 10) {
|
||||
@ -1880,7 +1883,7 @@ void set_colors(const char * fg, const char * bg) {
|
||||
* (See set_colors above)
|
||||
*/
|
||||
void set_fg_color(const char * fg) {
|
||||
printf("\033[22;23;24;");
|
||||
printf("\033[22;23;");
|
||||
if (*fg == '@') {
|
||||
int _fg = atoi(fg+1);
|
||||
if (_fg < 10) {
|
||||
@ -2262,7 +2265,7 @@ void render_line(line_t * line, int width, int offset, int line_no) {
|
||||
int j = 0; /* Offset in terminal cells */
|
||||
|
||||
const char * last_color = NULL;
|
||||
int was_selecting = 0, was_searching = 0;
|
||||
int was_selecting = 0, was_searching = 0, was_underlining = 0;
|
||||
|
||||
/* Set default text colors */
|
||||
set_colors(COLOR_FG, line->is_current ? COLOR_ALT_BG : COLOR_BG);
|
||||
@ -2283,6 +2286,7 @@ void render_line(line_t * line, int width, int offset, int line_no) {
|
||||
|
||||
/* If we should be drawing by now... */
|
||||
if (j >= offset) {
|
||||
if (was_underlining) printf("\033[24m");
|
||||
/* Fill remainder with -'s */
|
||||
set_colors(COLOR_ALT_FG, COLOR_ALT_BG);
|
||||
printf("-");
|
||||
@ -2318,6 +2322,7 @@ void render_line(line_t * line, int width, int offset, int line_no) {
|
||||
if (j - offset + c.display_width >= width) {
|
||||
/* We draw this with special colors so it isn't ambiguous */
|
||||
set_colors(COLOR_ALT_FG, COLOR_ALT_BG);
|
||||
if (was_underlining) printf("\033[24m");
|
||||
|
||||
/* If it's wide, draw ---> as needed */
|
||||
while (j - offset < width - 1) {
|
||||
@ -2333,8 +2338,10 @@ void render_line(line_t * line, int width, int offset, int line_no) {
|
||||
|
||||
/* Syntax highlighting */
|
||||
const char * color = flag_to_color(c.flags);
|
||||
|
||||
if (c.flags & FLAG_SELECT) {
|
||||
set_colors(COLOR_SELECTFG, COLOR_SELECTBG);
|
||||
if ((c.flags & FLAG_MASK_COLORS) == FLAG_NONE) color = COLOR_SELECTFG;
|
||||
set_colors(color, COLOR_SELECTBG);
|
||||
was_selecting = 1;
|
||||
} else if ((c.flags & FLAG_SEARCH) || (c.flags == FLAG_NOTICE)) {
|
||||
set_colors(COLOR_SEARCH_FG, COLOR_SEARCH_BG);
|
||||
@ -2354,6 +2361,14 @@ void render_line(line_t * line, int width, int offset, int line_no) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((c.flags & FLAG_UNDERLINE) && !was_underlining) {
|
||||
printf("\033[4m");
|
||||
was_underlining = 1;
|
||||
} else if (!(c.flags & FLAG_UNDERLINE) && was_underlining) {
|
||||
printf("\033[24m");
|
||||
was_underlining = 0;
|
||||
}
|
||||
|
||||
if ((env->mode == MODE_COL_SELECTION || env->mode == MODE_COL_INSERT) &&
|
||||
line_no >= ((env->start_line < env->line_no) ? env->start_line : env->line_no) &&
|
||||
line_no <= ((env->start_line < env->line_no) ? env->line_no : env->start_line) &&
|
||||
@ -2442,6 +2457,8 @@ void render_line(line_t * line, int width, int offset, int line_no) {
|
||||
}
|
||||
}
|
||||
|
||||
if (was_underlining) printf("\033[24m");
|
||||
|
||||
/**
|
||||
* Determine what color the rest of the line should be.
|
||||
*/
|
||||
@ -2775,15 +2792,25 @@ int display_width_of_string(const char * str) {
|
||||
return out;
|
||||
}
|
||||
|
||||
int statusbar_append_status(int *remaining_width, char * output, char * base, ...) {
|
||||
int statusbar_append_status(int *remaining_width, size_t *filled, char * output, char * base, ...) {
|
||||
va_list args;
|
||||
va_start(args, base);
|
||||
char tmp[100]; /* should be big enough */
|
||||
char tmp[100] = {0}; /* should be big enough */
|
||||
vsnprintf(tmp, 100, base, args);
|
||||
va_end(args);
|
||||
|
||||
int width = display_width_of_string(tmp) + 2;
|
||||
|
||||
size_t totalWidth = strlen(tmp);
|
||||
totalWidth += strlen(color_string(COLOR_STATUS_ALT, COLOR_STATUS_BG));
|
||||
totalWidth += strlen(color_string(COLOR_STATUS_FG, COLOR_STATUS_BG));
|
||||
totalWidth += strlen(color_string(COLOR_STATUS_ALT, COLOR_STATUS_BG));
|
||||
totalWidth += 3;
|
||||
|
||||
if (totalWidth + *filled >= 2047) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (width < *remaining_width) {
|
||||
strcat(output,color_string(COLOR_STATUS_ALT, COLOR_STATUS_BG));
|
||||
strcat(output,"[");
|
||||
@ -2792,6 +2819,7 @@ int statusbar_append_status(int *remaining_width, char * output, char * base, ..
|
||||
strcat(output,color_string(COLOR_STATUS_ALT, COLOR_STATUS_BG));
|
||||
strcat(output,"]");
|
||||
(*remaining_width) -= width;
|
||||
(*filled) += totalWidth;
|
||||
return width;
|
||||
} else {
|
||||
return 0;
|
||||
@ -2799,7 +2827,7 @@ int statusbar_append_status(int *remaining_width, char * output, char * base, ..
|
||||
}
|
||||
|
||||
int statusbar_build_right(char * right_hand) {
|
||||
char tmp[1024];
|
||||
char tmp[1024] = {0};
|
||||
sprintf(tmp, " Line %d/%d Col: %d ", env->line_no, env->line_count, env->col_no);
|
||||
int out = display_width_of_string(tmp);
|
||||
char * s = right_hand;
|
||||
@ -2840,15 +2868,16 @@ void redraw_statusbar(void) {
|
||||
|
||||
|
||||
/* Pre-render the right hand side of the status bar */
|
||||
char right_hand[1024];
|
||||
char right_hand[1024] = {0};
|
||||
int right_width = statusbar_build_right(right_hand);
|
||||
|
||||
char status_bits[1024] = {0}; /* Sane maximum */
|
||||
char status_bits[2048] = {0}; /* Sane maximum */
|
||||
size_t filled = 0;
|
||||
int status_bits_width = 0;
|
||||
|
||||
int remaining_width = global_config.term_width - right_width;
|
||||
|
||||
#define ADD(...) do { status_bits_width += statusbar_append_status(&remaining_width, status_bits, __VA_ARGS__); } while (0)
|
||||
#define ADD(...) do { status_bits_width += statusbar_append_status(&remaining_width, &filled, status_bits, __VA_ARGS__); } while (0)
|
||||
if (env->syntax) {
|
||||
ADD("%s",env->syntax->name);
|
||||
}
|
||||
@ -3673,7 +3702,7 @@ BIM_ACTION(open_file_from_line, 0,
|
||||
}
|
||||
|
||||
int line_matches(line_t * line, char * string) {
|
||||
uint32_t c, state = 0;
|
||||
uint32_t c = 0, state = 0;
|
||||
int i = 0;
|
||||
while (*string) {
|
||||
if (!decode(&state, &c, *string)) {
|
||||
@ -4765,6 +4794,7 @@ int convert_to_html(void) {
|
||||
html_convert_color(COLOR_BG);
|
||||
add_string("\n");
|
||||
add_string(" }\n");
|
||||
add_string(" .ul { text-decoration: underline; }\n");
|
||||
for (int i = 0; i < 15; ++i) {
|
||||
/* For each of the relevant flags... */
|
||||
char tmp[20];
|
||||
@ -4822,7 +4852,7 @@ int convert_to_html(void) {
|
||||
add_string("\n");
|
||||
add_string(" }\n");
|
||||
for (int i = 1; i <= env->tabstop; ++i) {
|
||||
char tmp[10];
|
||||
char tmp[20];
|
||||
sprintf(tmp, ".tab%d", i);
|
||||
add_string(" ");
|
||||
add_string(tmp);
|
||||
@ -4874,7 +4904,9 @@ int convert_to_html(void) {
|
||||
if (opened) add_string("</span>");
|
||||
opened = 1;
|
||||
char tmp[100];
|
||||
sprintf(tmp, "<span class=\"s%d\">", c.flags & 0x1F);
|
||||
sprintf(tmp, "<span class=\"s%d%s\">",
|
||||
c.flags & FLAG_MASK_COLORS,
|
||||
(c.flags & FLAG_UNDERLINE) ? " ul" : "");
|
||||
add_string(tmp);
|
||||
last_flag = (c.flags & 0x1F);
|
||||
}
|
||||
@ -6118,6 +6150,7 @@ void command_tab_complete(char * buffer) {
|
||||
}
|
||||
|
||||
/* Build the complete argument name to tab complete */
|
||||
int type = Candidate_Normal;
|
||||
char s[1024] = {0};
|
||||
if (last_slash == tmp) {
|
||||
strcat(s,"/");
|
||||
@ -6132,6 +6165,7 @@ void command_tab_complete(char * buffer) {
|
||||
*/
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
strcat(s,"/");
|
||||
type = Candidate_Command;
|
||||
}
|
||||
|
||||
int skip = 0;
|
||||
@ -6142,7 +6176,7 @@ void command_tab_complete(char * buffer) {
|
||||
}
|
||||
}
|
||||
if (!skip) {
|
||||
add_candidate(s, Candidate_Normal);
|
||||
add_candidate(s, type);
|
||||
}
|
||||
}
|
||||
ent = readdir(dirp);
|
||||
@ -10508,6 +10542,25 @@ static KrkValue bim_krk_state_get(int argc, KrkValue argv[], int hasKw) {
|
||||
size_t len = to_eight(charRel, tmp);
|
||||
return OBJECT_VAL(krk_copyString(tmp,len));
|
||||
}
|
||||
static KrkValue bim_krk_state_getslice(int argc, KrkValue argv[], int hasKw) {
|
||||
BIM_STATE();
|
||||
struct StringBuilder sb = {0};
|
||||
if (!(IS_INTEGER(argv[1]) || IS_NONE(argv[1]))) return krk_runtimeError(vm.exceptions->typeError, "Bad index");
|
||||
if (!(IS_INTEGER(argv[2]) || IS_NONE(argv[2]))) return krk_runtimeError(vm.exceptions->typeError, "Bad index");
|
||||
int start = IS_NONE(argv[1]) ? 0 : AS_INTEGER(argv[1]);
|
||||
int end = IS_NONE(argv[2]) ? (krk_integer_type)(state->line->actual - state->i) : AS_INTEGER(argv[2]);
|
||||
if (end < start) end = start;
|
||||
|
||||
for (int i = start; i < end; ++i) {
|
||||
int charRel = charrel(i);
|
||||
if (charRel == -1) break;
|
||||
char tmp[8] = {0};
|
||||
size_t len = to_eight(charRel, tmp);
|
||||
pushStringBuilderStr(&sb, tmp, len);
|
||||
}
|
||||
|
||||
return finishStringBuilder(&sb);
|
||||
}
|
||||
static KrkValue bim_krk_state_isdigit(int argc, KrkValue argv[], int hasKw) {
|
||||
if (IS_NONE(argv[1])) return BOOLEAN_VAL(0);
|
||||
if (!IS_STRING(argv[1])) {
|
||||
@ -10989,6 +11042,7 @@ void initialize(void) {
|
||||
krk_defineNative(&syntaxStateClass->methods, "commentBuzzwords", bim_krk_state_commentBuzzwords);
|
||||
krk_defineNative(&syntaxStateClass->methods, "rewind", bim_krk_state_rewind);
|
||||
krk_defineNative(&syntaxStateClass->methods, "__getitem__", bim_krk_state_get);
|
||||
krk_defineNative(&syntaxStateClass->methods, "__getslice__", bim_krk_state_getslice);
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_NONE", INTEGER_VAL(FLAG_NONE));
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_KEYWORD", INTEGER_VAL(FLAG_KEYWORD));
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_STRING", INTEGER_VAL(FLAG_STRING));
|
||||
@ -11003,6 +11057,9 @@ void initialize(void) {
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_BOLD", INTEGER_VAL(FLAG_BOLD));
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_LINK", INTEGER_VAL(FLAG_LINK));
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_ESCAPE", INTEGER_VAL(FLAG_ESCAPE));
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_EXTRA", INTEGER_VAL(FLAG_EXTRA));
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_SPECIAL", INTEGER_VAL(FLAG_SPECIAL));
|
||||
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_UNDERLINE", INTEGER_VAL(FLAG_UNDERLINE));
|
||||
|
||||
_bim_state_chars = krk_newTuple(95);
|
||||
krk_attachNamedObject(&syntaxStateClass->methods, "__chars__", (KrkObj*)_bim_state_chars);
|
||||
|
10
apps/bim.h
10
apps/bim.h
@ -104,12 +104,20 @@ extern struct key_name_map KeyNames[];
|
||||
#define FLAG_DIFFMINUS 9
|
||||
#define FLAG_NOTICE 10
|
||||
#define FLAG_BOLD 11
|
||||
#define FLAG_LINK 12
|
||||
#define FLAG_LINK (12 + (1<<4))
|
||||
#define FLAG_ESCAPE 13
|
||||
#define FLAG_EXTRA 14
|
||||
#define FLAG_SPECIAL 15
|
||||
|
||||
#define FLAG_LINK_COLOR 12
|
||||
|
||||
#define FLAG_UNDERLINE (1 << 4)
|
||||
#define FLAG_SELECT (1 << 5)
|
||||
#define FLAG_SEARCH (1 << 6)
|
||||
|
||||
#define FLAG_MASK_COLORS 0x0F
|
||||
#define FLAG_MASK_ATTRIB 0x70
|
||||
|
||||
/**
|
||||
* Line buffer definitions
|
||||
*
|
||||
|
@ -18,10 +18,14 @@ class CHighlighter(Highlighter):
|
||||
types = [
|
||||
"static","int","char","short","float","double","void","unsigned","volatile","const",
|
||||
"register","long","inline","restrict","enum","auto","extern","bool","complex",
|
||||
# stdint stuff
|
||||
"uint8_t","uint16_t","uint32_t","uint64_t",
|
||||
"int8_t","int16_t","int32_t","int64_t","FILE",
|
||||
"ssize_t","size_t","uintptr_t","intptr_t","__volatile__",
|
||||
"constexpr"
|
||||
"int8_t","int16_t","int32_t","int64_t",
|
||||
"ssize_t","size_t","uintptr_t","intptr_t",
|
||||
# Extra stuff
|
||||
"constexpr","FILE","__volatile__",
|
||||
# sys/types stuff
|
||||
"gid_t","uid_t","dev_t","ino_t","mode_t","caddr_t","off_t","time_t","pid_t",
|
||||
]
|
||||
|
||||
special = [
|
||||
@ -41,7 +45,7 @@ class CHighlighter(Highlighter):
|
||||
else if self[0] == '\\' and not self[1]:
|
||||
self.paint(1, self.FLAG_ESCAPE)
|
||||
return 4
|
||||
else if self[0] == '\\' and self[1] in 'nr\\':
|
||||
else if self[0] == '\\' and self[1] in 'abfnrtv?\\':
|
||||
self.paint(2, self.FLAG_ESCAPE)
|
||||
last = None
|
||||
else if self[0] == '\\' and self[1] in '01234567':
|
||||
|
37
base/usr/share/bim/syntax/docker.krk
Normal file
37
base/usr/share/bim/syntax/docker.krk
Normal file
@ -0,0 +1,37 @@
|
||||
from syntax import Highlighter, bind
|
||||
from syntax.bash import BashHighlighter
|
||||
|
||||
@bind
|
||||
class DockerfileHighlighter(BashHighlighter):
|
||||
name = "docker"
|
||||
extensions = ('Dockerfile',)
|
||||
spaces = True
|
||||
|
||||
keywords = [
|
||||
'FROM','AS','MAINTAINER','RUN','CMD','COPY','EXPOSE','ADD',
|
||||
'ENTRYPOINT','VOLUME','USER','WORKDIR','ONBUILD','LABEL','ARG',
|
||||
'HEALTHCHECK','SHELL','STOPSIGNAL',
|
||||
]
|
||||
|
||||
def calculate(self):
|
||||
if self.state < 1 and self.i == 0:
|
||||
if self[0] == '#':
|
||||
self.paintComment()
|
||||
else if self.matchAndPaint('RUN', self.FLAG_KEYWORD, self.cKeywordQualifier):
|
||||
let out = super().calculate()
|
||||
if out == None and self[-1] == '\\':
|
||||
return 1
|
||||
return out
|
||||
else if self.findKeywords(self.keywords, self.FLAG_KEYWORD, self.cKeywordQualifier):
|
||||
return 0
|
||||
else:
|
||||
self.skip(1)
|
||||
else:
|
||||
if self.state == 1:
|
||||
self.set_state(0)
|
||||
let out = super().calculate()
|
||||
if out == None and self[-1] == '\\':
|
||||
return 1
|
||||
return out
|
||||
return None
|
||||
|
@ -6,7 +6,8 @@ def _make_dox():
|
||||
"@author","@brief","@class","@short","@retval",
|
||||
"@since","@return","@returns","@throws","@bug",
|
||||
"@version","@deprecated","@attention","@note",
|
||||
"@protected",
|
||||
"@protected","@copyright","@date","@bug","@pre",
|
||||
"@details",
|
||||
]
|
||||
|
||||
let doxygen_word_commands = {
|
||||
@ -20,12 +21,22 @@ def _make_dox():
|
||||
'@memberof': Highlighter.FLAG_TYPE,
|
||||
'@extends': Highlighter.FLAG_TYPE,
|
||||
'@mainpage': Highlighter.FLAG_STRING,
|
||||
'@b': Highlighter.FLAG_BOLD,
|
||||
'@section': Highlighter.FLAG_BOLD,
|
||||
'@subsection': Highlighter.FLAG_BOLD,
|
||||
'@package': Highlighter.FLAG_TYPE,
|
||||
'@ref': Highlighter.FLAG_LINK,
|
||||
'@typedef': Highlighter.FLAG_TYPE,
|
||||
}
|
||||
|
||||
let doxygen_block_commands = {
|
||||
'@warning': Highlighter.FLAG_NOTICE,
|
||||
}
|
||||
|
||||
let doxygen_emphasis_commands = [
|
||||
'@a', '@e', '@em',
|
||||
]
|
||||
|
||||
def doxygen_qualifier(c):
|
||||
if isinstance(c,int):
|
||||
if c > 0: c = chr(c)
|
||||
@ -38,8 +49,21 @@ def _make_dox():
|
||||
for keyword, flag in doxygen_word_commands.items():
|
||||
if b.matchAndPaint(keyword, b.FLAG_ESCAPE, doxygen_qualifier):
|
||||
while b[0] == ' ': b.skip()
|
||||
while b[0] and b[0] != ' ': b.paint(1, flag)
|
||||
while b[0] and b[0] != ' ':
|
||||
if b[0] == '.' and b[1] in (None,' '):
|
||||
return True
|
||||
b.paint(1, flag)
|
||||
return True
|
||||
for keyword, flag in doxygen_block_commands.items():
|
||||
if b.matchAndPaint(keyword, b.FLAG_ESCAPE, doxygen_qualifier):
|
||||
while b[0] == ' ': b.skip()
|
||||
while b[0]: b.paint(1, flag)
|
||||
return True
|
||||
if b.findKeywords(doxygen_emphasis_commands, b.FLAG_ESCAPE, doxygen_qualifier):
|
||||
while b[0] == ' ': b.skip()
|
||||
while b[0] and b[0] != ' ':
|
||||
b.paint(1, defaultflag | b.FLAG_UNDERLINE)
|
||||
return True
|
||||
b.paint(1, defaultflag)
|
||||
return True
|
||||
return False
|
||||
|
531
base/usr/share/bim/syntax/gas.krk
Normal file
531
base/usr/share/bim/syntax/gas.krk
Normal file
@ -0,0 +1,531 @@
|
||||
from syntax import Highlighter, bind
|
||||
|
||||
@bind
|
||||
class GasHighlighter(Highlighter):
|
||||
name = 'gas'
|
||||
extensions = ('.S',)
|
||||
spaces = True
|
||||
|
||||
directives = ['.' + x for x in [
|
||||
'abort','align','balignw','balignl','bundle_align_mode','bundle_lock','bundle_unlock',
|
||||
'bss','cfi_startproc','cfi_sections','cfi_endproc','cfi_personality','cfi_lsda',
|
||||
'cfi_def_cfa','cfi_def_cfa_register','cfi_def_cfa_offset','cfi_adjust_cfa_offset',
|
||||
'cfi_offset','cfi_rel_offset','cfi_register','cfi_restore','cfi_undefined',
|
||||
'cfi_same_value','cfi_remember_state','cfi_return_column','cfi_signal_frame',
|
||||
'cfi_window_save','cfi_escape','cfi_val_encoded_addr','data','def','desc',
|
||||
'dim','eject','else','elseif','endef','endif','endr','qeu','equiv','eqv','err',
|
||||
'error','exitm','extern','fail','file','fill','global','globl','gnu_attribute',
|
||||
'hidden','ident','if','incbin','include','internal','irp','irpc','lcomm','lflags',
|
||||
'line','linkonce','list','ln','loc','loc_mark_labels','local','mri','nolist','org',
|
||||
'p2alignw','p2align1','popsection','previous','print','protected','psize','purgem',
|
||||
'pushsection','reloc','rept','sbttl','scl','section','set','single','size','skip',
|
||||
'sleb128','stabd','stabn','stabs','struct','subsection','symver','tag','text','title',
|
||||
'type','uleb128','val','version','vtable_entry','vtable_inherit','warning','weak',
|
||||
'weakref',
|
||||
'code32','code64',
|
||||
]]
|
||||
|
||||
types = ['.' + x for x in [
|
||||
'byte','hword','word','int','long','double','short','float','quad','octa',
|
||||
'string','string8','string16','ascii','asciz','comm','space'
|
||||
]]
|
||||
|
||||
registers = ['%' + x for x in [
|
||||
'r8','r9','r10','r11','r12','r13','r14','r15',
|
||||
'rax','rbx','rcx','rdx','rdi','rsi','rsp','rbp',
|
||||
'eax','ebx','ecx','edx','ax','bx','cx','dx','ah','al','bh','bl','ch','cl','dh','dl',
|
||||
'edi','esi','esp','ebp','di','si','sp','bp','sph','spl','bph','bpl',
|
||||
'cs','ds','es','fs','gs','ss','ip','eip','rip','eflags',
|
||||
'cr0','cr1','cr2','cr3','cr4',
|
||||
]]
|
||||
|
||||
instructions = [
|
||||
'aaa',
|
||||
'aad','aadb','aadw','aadl','aadq',
|
||||
'aam','aamb','aamw','aaml','aamq',
|
||||
'aas',
|
||||
'adc','adcb','adcw','adcl','adcq',
|
||||
'add','addb','addw','addl','addq',
|
||||
'and','andb','andw','andl','andq',
|
||||
'arpl',
|
||||
'bb0_reset',
|
||||
'bb1_reset',
|
||||
'bound','boundb','boundw','boundl','boundq',
|
||||
'bsf',
|
||||
'bsr',
|
||||
'bswap',
|
||||
'bt','btb','btw','btl','btq',
|
||||
'btc','btcb','btcw','btcl','btcq',
|
||||
'btr','btrb','btrw','btrl','btrq',
|
||||
'bts','btsb','btsw','btsl','btsq',
|
||||
'call','callb','callw','calll','callq',
|
||||
'cbw',
|
||||
'cdq',
|
||||
'cdqe',
|
||||
'clc',
|
||||
'cld',
|
||||
'clgi',
|
||||
'cli',
|
||||
'clts',
|
||||
'cmc',
|
||||
'cmp','cmpb','cmpw','cmpl','cmpq',
|
||||
'cmpsb',
|
||||
'cmpsd',
|
||||
'cmpsq',
|
||||
'cmpsw',
|
||||
'cmpxchg',
|
||||
'cmpxchg486',
|
||||
'cmpxchg8b','cmpxchg8bb','cmpxchg8bw','cmpxchg8bl','cmpxchg8bq',
|
||||
'cmpxchg16b','cmpxchg16bb','cmpxchg16bw','cmpxchg16bl','cmpxchg16bq',
|
||||
'cpuid',
|
||||
'cpu_read',
|
||||
'cpu_write',
|
||||
'cqo',
|
||||
'cwd',
|
||||
'cwde',
|
||||
'daa',
|
||||
'das',
|
||||
'dec',
|
||||
'div',
|
||||
'dmint',
|
||||
'emms',
|
||||
'enter','enterb','enterw','enterl','enterq',
|
||||
'equ',
|
||||
'f2xm1',
|
||||
'fabs',
|
||||
'fadd',
|
||||
'faddp',
|
||||
'fbld','fbldb','fbldw','fbldl','fbldq',
|
||||
'fbstp','fbstpb','fbstpw','fbstpl','fbstpq',
|
||||
'fchs',
|
||||
'fclex',
|
||||
'fcmovb',
|
||||
'fcmovbe',
|
||||
'fcmove',
|
||||
'fcmovnb',
|
||||
'fcmovnbe',
|
||||
'fcmovne',
|
||||
'fcmovnu',
|
||||
'fcmovu',
|
||||
'fcom',
|
||||
'fcomi',
|
||||
'fcomip',
|
||||
'fcomp',
|
||||
'fcompp',
|
||||
'fcos',
|
||||
'fdecstp',
|
||||
'fdisi',
|
||||
'fdiv',
|
||||
'fdivp',
|
||||
'fdivr',
|
||||
'fdivrp',
|
||||
'femms',
|
||||
'feni',
|
||||
'ffree',
|
||||
'ffreep',
|
||||
'fiadd','fiaddb','fiaddw','fiaddl','fiaddq',
|
||||
'ficom','ficomb','ficomw','ficoml','ficomq',
|
||||
'ficomp','ficompb','ficompw','ficompl','ficompq',
|
||||
'fidiv','fidivb','fidivw','fidivl','fidivq',
|
||||
'fidivr','fidivrb','fidivrw','fidivrl','fidivrq',
|
||||
'fild','fildb','fildw','fildl','fildq',
|
||||
'fimul','fimulb','fimulw','fimull','fimulq',
|
||||
'fincstp',
|
||||
'finit',
|
||||
'fist','fistb','fistw','fistl','fistq',
|
||||
'fistp','fistpb','fistpw','fistpl','fistpq',
|
||||
'fisttp','fisttpb','fisttpw','fisttpl','fisttpq',
|
||||
'fisub','fisubb','fisubw','fisubl','fisubq',
|
||||
'fisubr','fisubrb','fisubrw','fisubrl','fisubrq',
|
||||
'fld',
|
||||
'fld1',
|
||||
'fldcw','fldcwb','fldcww','fldcwl','fldcwq',
|
||||
'fldenv','fldenvb','fldenvw','fldenvl','fldenvq',
|
||||
'fldl2e',
|
||||
'fldl2t',
|
||||
'fldlg2',
|
||||
'fldln2',
|
||||
'fldpi',
|
||||
'fldz',
|
||||
'fmul',
|
||||
'fmulp',
|
||||
'fnclex',
|
||||
'fndisi',
|
||||
'fneni',
|
||||
'fninit',
|
||||
'fnop',
|
||||
'fnsave','fnsaveb','fnsavew','fnsavel','fnsaveq',
|
||||
'fnstcw','fnstcwb','fnstcww','fnstcwl','fnstcwq',
|
||||
'fnstenv','fnstenvb','fnstenvw','fnstenvl','fnstenvq',
|
||||
'fnstsw',
|
||||
'fpatan',
|
||||
'fprem',
|
||||
'fprem1',
|
||||
'fptan',
|
||||
'frndint',
|
||||
'frstor','frstorb','frstorw','frstorl','frstorq',
|
||||
'fsave','fsaveb','fsavew','fsavel','fsaveq',
|
||||
'fscale',
|
||||
'fsetpm',
|
||||
'fsin',
|
||||
'fsincos',
|
||||
'fsqrt',
|
||||
'fst',
|
||||
'fstcw','fstcwb','fstcww','fstcwl','fstcwq',
|
||||
'fstenv','fstenvb','fstenvw','fstenvl','fstenvq',
|
||||
'fstp',
|
||||
'fstsw',
|
||||
'fsub',
|
||||
'fsubp',
|
||||
'fsubr',
|
||||
'fsubrp',
|
||||
'ftst',
|
||||
'fucom',
|
||||
'fucomi',
|
||||
'fucomip',
|
||||
'fucomp',
|
||||
'fucompp',
|
||||
'fxam',
|
||||
'fxch',
|
||||
'fxtract',
|
||||
'fyl2x',
|
||||
'fyl2xp1',
|
||||
'hlt',
|
||||
'ibts',
|
||||
'icebp',
|
||||
'idiv',
|
||||
'imul','imulb','imulw','imull','imulq',
|
||||
'in',
|
||||
'inc','incb','incw','incl','incq',
|
||||
'incbin',
|
||||
'insb',
|
||||
'insd',
|
||||
'insw',
|
||||
'int','intb','intw','intl','intq',
|
||||
'int01',
|
||||
'int1',
|
||||
'int03',
|
||||
'int3',
|
||||
'into',
|
||||
'invd',
|
||||
'invlpg','invlpgb','invlpgw','invlpgl','invlpgq',
|
||||
'invlpga',
|
||||
'iret',
|
||||
'iretd',
|
||||
'iretq',
|
||||
'iretw',
|
||||
'jcxz','jcxzb','jcxzw','jcxzl','jcxzq',
|
||||
'jecxz','jecxzb','jecxzw','jecxzl','jecxzq',
|
||||
'jrcxz','jrcxzb','jrcxzw','jrcxzl','jrcxzq',
|
||||
'jmp','jmpb','jmpw','jmpl','jmpq',
|
||||
'jmpe',
|
||||
'lahf',
|
||||
'lar',
|
||||
'lds','ldsb','ldsw','ldsl','ldsq',
|
||||
'lea','leab','leaw','leal','leaq',
|
||||
'leave',
|
||||
'les','lesb','lesw','lesl','lesq',
|
||||
'lfence',
|
||||
'lfs','lfsb','lfsw','lfsl','lfsq',
|
||||
'lgdt','lgdtb','lgdtw','lgdtl','lgdtq',
|
||||
'lgs','lgsb','lgsw','lgsl','lgsq',
|
||||
'lidt','lidtb','lidtw','lidtl','lidtq',
|
||||
'lldt',
|
||||
'lmsw',
|
||||
'loadall',
|
||||
'loadall286',
|
||||
'lodsb',
|
||||
'lodsd',
|
||||
'lodsq',
|
||||
'lodsw',
|
||||
'loop','loopb','loopw','loopl','loopq',
|
||||
'loope','loopeb','loopew','loopel','loopeq',
|
||||
'loopne','loopneb','loopnew','loopnel','loopneq',
|
||||
'loopnz','loopnzb','loopnzw','loopnzl','loopnzq',
|
||||
'loopz','loopzb','loopzw','loopzl','loopzq',
|
||||
'lsl',
|
||||
'lss','lssb','lssw','lssl','lssq',
|
||||
'ltr',
|
||||
'mfence',
|
||||
'monitor',
|
||||
'mov','movb','movw','movl','movq',
|
||||
'movd',
|
||||
'movq',
|
||||
'movsb',
|
||||
'movsd',
|
||||
'movsq',
|
||||
'movsw',
|
||||
'movsx',
|
||||
'movsxd',
|
||||
'movsx',
|
||||
'movzx',
|
||||
'movzbl',
|
||||
'mul',
|
||||
'mwait',
|
||||
'neg',
|
||||
'nop',
|
||||
'not',
|
||||
'or','orb','orw','orl','orq',
|
||||
'out',
|
||||
'outsb',
|
||||
'outsd',
|
||||
'outsw',
|
||||
'packssdw','packssdwb','packssdww','packssdwl','packssdwq',
|
||||
'packsswb','packsswbb','packsswbw','packsswbl','packsswbq',
|
||||
'packuswb','packuswbb','packuswbw','packuswbl','packuswbq',
|
||||
'paddb','paddbb','paddbw','paddbl','paddbq',
|
||||
'paddd','padddb','padddw','padddl','padddq',
|
||||
'paddsb','paddsbb','paddsbw','paddsbl','paddsbq',
|
||||
'paddsiw','paddsiwb','paddsiww','paddsiwl','paddsiwq',
|
||||
'paddsw','paddswb','paddsww','paddswl','paddswq',
|
||||
'paddusb','paddusbb','paddusbw','paddusbl','paddusbq',
|
||||
'paddusw','padduswb','paddusww','padduswl','padduswq',
|
||||
'paddw','paddwb','paddww','paddwl','paddwq',
|
||||
'pand','pandb','pandw','pandl','pandq',
|
||||
'pandn','pandnb','pandnw','pandnl','pandnq',
|
||||
'pause',
|
||||
'paveb','pavebb','pavebw','pavebl','pavebq',
|
||||
'pavgusb','pavgusbb','pavgusbw','pavgusbl','pavgusbq',
|
||||
'pcmpeqb','pcmpeqbb','pcmpeqbw','pcmpeqbl','pcmpeqbq',
|
||||
'pcmpeqd','pcmpeqdb','pcmpeqdw','pcmpeqdl','pcmpeqdq',
|
||||
'pcmpeqw','pcmpeqwb','pcmpeqww','pcmpeqwl','pcmpeqwq',
|
||||
'pcmpgtb','pcmpgtbb','pcmpgtbw','pcmpgtbl','pcmpgtbq',
|
||||
'pcmpgtd','pcmpgtdb','pcmpgtdw','pcmpgtdl','pcmpgtdq',
|
||||
'pcmpgtw','pcmpgtwb','pcmpgtww','pcmpgtwl','pcmpgtwq',
|
||||
'pdistib','pdistibb','pdistibw','pdistibl','pdistibq',
|
||||
'pf2id','pf2idb','pf2idw','pf2idl','pf2idq',
|
||||
'pfacc','pfaccb','pfaccw','pfaccl','pfaccq',
|
||||
'pfadd','pfaddb','pfaddw','pfaddl','pfaddq',
|
||||
'pfcmpeq','pfcmpeqb','pfcmpeqw','pfcmpeql','pfcmpeqq',
|
||||
'pfcmpge','pfcmpgeb','pfcmpgew','pfcmpgel','pfcmpgeq',
|
||||
'pfcmpgt','pfcmpgtb','pfcmpgtw','pfcmpgtl','pfcmpgtq',
|
||||
'pfmax','pfmaxb','pfmaxw','pfmaxl','pfmaxq',
|
||||
'pfmin','pfminb','pfminw','pfminl','pfminq',
|
||||
'pfmul','pfmulb','pfmulw','pfmull','pfmulq',
|
||||
'pfrcp','pfrcpb','pfrcpw','pfrcpl','pfrcpq',
|
||||
'pfrcpit1','pfrcpit1b','pfrcpit1w','pfrcpit1l','pfrcpit1q',
|
||||
'pfrcpit2','pfrcpit2b','pfrcpit2w','pfrcpit2l','pfrcpit2q',
|
||||
'pfrsqit1','pfrsqit1b','pfrsqit1w','pfrsqit1l','pfrsqit1q',
|
||||
'pfrsqrt','pfrsqrtb','pfrsqrtw','pfrsqrtl','pfrsqrtq',
|
||||
'pfsub','pfsubb','pfsubw','pfsubl','pfsubq',
|
||||
'pfsubr','pfsubrb','pfsubrw','pfsubrl','pfsubrq',
|
||||
'pi2fd','pi2fdb','pi2fdw','pi2fdl','pi2fdq',
|
||||
'pmachriw','pmachriwb','pmachriww','pmachriwl','pmachriwq',
|
||||
'pmaddwd','pmaddwdb','pmaddwdw','pmaddwdl','pmaddwdq',
|
||||
'pmagw','pmagwb','pmagww','pmagwl','pmagwq',
|
||||
'pmulhriw','pmulhriwb','pmulhriww','pmulhriwl','pmulhriwq',
|
||||
'pmulhrwa','pmulhrwab','pmulhrwaw','pmulhrwal','pmulhrwaq',
|
||||
'pmulhrwc','pmulhrwcb','pmulhrwcw','pmulhrwcl','pmulhrwcq',
|
||||
'pmulhw','pmulhwb','pmulhww','pmulhwl','pmulhwq',
|
||||
'pmullw','pmullwb','pmullww','pmullwl','pmullwq',
|
||||
'pmvgezb','pmvgezbb','pmvgezbw','pmvgezbl','pmvgezbq',
|
||||
'pmvlzb','pmvlzbb','pmvlzbw','pmvlzbl','pmvlzbq',
|
||||
'pmvnzb','pmvnzbb','pmvnzbw','pmvnzbl','pmvnzbq',
|
||||
'pmvzb','pmvzbb','pmvzbw','pmvzbl','pmvzbq',
|
||||
'pop','popb','popw','popl','popq',
|
||||
'popa',
|
||||
'popal',
|
||||
'popaw',
|
||||
'popf',
|
||||
'popfd','popfl',
|
||||
'popfq',
|
||||
'popfw',
|
||||
'por','porb','porw','porl','porq',
|
||||
'prefetch','prefetchb','prefetchw','prefetchl','prefetchq',
|
||||
'prefetchw','prefetchwb','prefetchww','prefetchwl','prefetchwq',
|
||||
'pslld','pslldb','pslldw','pslldl','pslldq',
|
||||
'psllq','psllqb','psllqw','psllql','psllqq',
|
||||
'psllw','psllwb','psllww','psllwl','psllwq',
|
||||
'psrad','psradb','psradw','psradl','psradq',
|
||||
'psraw','psrawb','psraww','psrawl','psrawq',
|
||||
'psrld','psrldb','psrldw','psrldl','psrldq',
|
||||
'psrlq','psrlqb','psrlqw','psrlql','psrlqq',
|
||||
'psrlw','psrlwb','psrlww','psrlwl','psrlwq',
|
||||
'psubb','psubbb','psubbw','psubbl','psubbq',
|
||||
'psubd','psubdb','psubdw','psubdl','psubdq',
|
||||
'psubsb','psubsbb','psubsbw','psubsbl','psubsbq',
|
||||
'psubsiw','psubsiwb','psubsiww','psubsiwl','psubsiwq',
|
||||
'psubsw','psubswb','psubsww','psubswl','psubswq',
|
||||
'psubusb','psubusbb','psubusbw','psubusbl','psubusbq',
|
||||
'psubusw','psubuswb','psubusww','psubuswl','psubuswq',
|
||||
'psubw','psubwb','psubww','psubwl','psubwq',
|
||||
'punpckhbw','punpckhbwb','punpckhbww','punpckhbwl','punpckhbwq',
|
||||
'punpckhdq','punpckhdqb','punpckhdqw','punpckhdql','punpckhdqq',
|
||||
'punpckhwd','punpckhwdb','punpckhwdw','punpckhwdl','punpckhwdq',
|
||||
'punpcklbw','punpcklbwb','punpcklbww','punpcklbwl','punpcklbwq',
|
||||
'punpckldq','punpckldqb','punpckldqw','punpckldql','punpckldqq',
|
||||
'punpcklwd','punpcklwdb','punpcklwdw','punpcklwdl','punpcklwdq',
|
||||
'push','pushb','pushw','pushl','pushq',
|
||||
'pusha',
|
||||
'pushal',
|
||||
'pushaw',
|
||||
'pushf',
|
||||
'pushfd',
|
||||
'pushfq',
|
||||
'pushfw',
|
||||
'pxor','pxorb','pxorw','pxorl','pxorq',
|
||||
'rcl','rclb','rclw','rcll','rclq',
|
||||
'rcr','rcrb','rcrw','rcrl','rcrq',
|
||||
'rdshr',
|
||||
'rdmsr',
|
||||
'rdpmc',
|
||||
'rdtsc',
|
||||
'rdtscp',
|
||||
'ret','retb','retw','retl','retq',
|
||||
'retf','retfb','retfw','retfl','retfq',
|
||||
'retn','retnb','retnw','retnl','retnq',
|
||||
'rol','rolb','rolw','roll','rolq',
|
||||
'ror','rorb','rorw','rorl','rorq',
|
||||
'rdm',
|
||||
'rsdc','rsdcb','rsdcw','rsdcl','rsdcq',
|
||||
'rsldt','rsldtb','rsldtw','rsldtl','rsldtq',
|
||||
'rsm',
|
||||
'rsts','rstsb','rstsw','rstsl','rstsq',
|
||||
'sahf',
|
||||
'sal','salb','salw','sall','salq',
|
||||
'salc',
|
||||
'sar','sarb','sarw','sarl','sarq',
|
||||
'sbb','sbbb','sbbw','sbbl','sbbq',
|
||||
'scasb',
|
||||
'scasd',
|
||||
'scasq',
|
||||
'scasw',
|
||||
'sfence',
|
||||
'sgdt','sgdtb','sgdtw','sgdtl','sgdtq',
|
||||
'shl','shlb','shlw','shll','shlq',
|
||||
'shld',
|
||||
'shr','shrb','shrw','shrl','shrq',
|
||||
'shrd',
|
||||
'sidt','sidtb','sidtw','sidtl','sidtq',
|
||||
'sldt',
|
||||
'skinit',
|
||||
'smi',
|
||||
'smint',
|
||||
'smintold',
|
||||
'smsw',
|
||||
'stc',
|
||||
'std',
|
||||
'stgi',
|
||||
'sti',
|
||||
'stosb',
|
||||
'stosd','stosl',
|
||||
'stosq',
|
||||
'stosw',
|
||||
'str',
|
||||
'sub','subb','subw','subl','subq',
|
||||
'svdc','svdcb','svdcw','svdcl','svdcq',
|
||||
'svldt','svldtb','svldtw','svldtl','svldtq',
|
||||
'svts','svtsb','svtsw','svtsl','svtsq',
|
||||
'swapgs',
|
||||
'syscall',
|
||||
'sysenter',
|
||||
'sysexit',
|
||||
'sysret',
|
||||
'test','testb','testw','testl','testq',
|
||||
'ud0',
|
||||
'ud1',
|
||||
'ud2b',
|
||||
'ud2',
|
||||
'ud2a',
|
||||
'umov',
|
||||
'verr',
|
||||
'verw',
|
||||
'fwait',
|
||||
'wbinvd',
|
||||
'wrshr',
|
||||
'wrmsr',
|
||||
'xadd',
|
||||
'xbts',
|
||||
'xchg',
|
||||
'xlatb',
|
||||
'xlat',
|
||||
'xor','xorb','xorw','xorl','xorq',
|
||||
'cmovcc',
|
||||
|
||||
'je','jne','ja','jae','jb','jbe','jnbe','jg','jge','jng','jnge','jl','jle','jz','jnz','jc','jnc','jd','jnd','jo','jno','jp','jnp','js','jns',
|
||||
'jeb','jneb','jab','jaeb','jbb','jbeb','jnbeb','jgb','jgeb','jngb','jngeb','jlb','jleb','jzb','jnzb','jcb','jncb','jdb','jndb','job','jnob','jpb','jnpb','jsb','jnsb',
|
||||
'jew','jnew','jaw','jaew','jbw','jbew','jnbew','jgw','jgew','jngw','jngew','jlw','jlew','jzw','jnzw','jcw','jncw','jdw','jndw','jow','jnow','jpw','jnpw','jsw','jnsw',
|
||||
'jel','jnel','jal','jael','jbl','jbel','jnbel','jgl','jgel','jngl','jngel','jll','jlel','jzl','jnzl','jcl','jncl','jdl','jndl','jol','jnol','jpl','jnpl','jsl','jnsl',
|
||||
'jeq','jneq','jaq','jaeq','jbq','jbeq','jnbeq','jgq','jgeq','jngq','jngeq','jlq','jleq','jzq','jnzq','jcq','jncq','jdq','jndq','joq','jnoq','jpq','jnpq','jsq','jnsq',
|
||||
|
||||
'ljmp',
|
||||
'rep', 'stos',
|
||||
]
|
||||
|
||||
def dqualifier(self, c):
|
||||
return self.cKeywordQualifier(c) or c == '.' or c == ord('.')
|
||||
|
||||
def rqualifier(self, c):
|
||||
return self.cKeywordQualifier(c) or c == '%' or c == ord('%')
|
||||
|
||||
def paintCComment(self):
|
||||
let last = None
|
||||
while self[0] != None:
|
||||
if self.commentBuzzwords(): continue
|
||||
else if last == '*' and self[0] == '/':
|
||||
self.paint(1, self.FLAG_COMMENT)
|
||||
return 0
|
||||
else:
|
||||
last = self[0]
|
||||
self.paint(1, self.FLAG_COMMENT)
|
||||
return 1
|
||||
|
||||
def paintCNumeral(self):
|
||||
if self[0] == '0' and (self[1] == 'x' or self[1] == 'X'):
|
||||
self.paint(2, self.FLAG_NUMERAL)
|
||||
while self.isxdigit(self[0]): self.paint(1, self.FLAG_NUMERAL)
|
||||
else if self[0] == '0' and self[1] == '.':
|
||||
self.paint(2, self.FLAG_NUMERAL)
|
||||
while self.isdigit(self[0]): self.paint(1, self.FLAG_NUMERAL)
|
||||
if self[0] == 'f': self.paint(1, self.FLAG_NUMERAL)
|
||||
return 0
|
||||
else if self[0] == '0':
|
||||
self.paint(1, self.FLAG_NUMERAL)
|
||||
while self[0] in '01234567': self.paint(1, self.FLAG_NUMERAL)
|
||||
else:
|
||||
while self.isdigit(self[0]): self.paint(1, self.FLAG_NUMERAL)
|
||||
if self[0] == '.':
|
||||
self.paint(1, self.FLAG_NUMERAL)
|
||||
while self.isdigit(self[0]): self.paint(1, self.FLAG_NUMERAL)
|
||||
if self[0] == 'f': self.paint(1, self.FLAG_NUMERAL)
|
||||
return 0
|
||||
while self[0] in 'uUlL': self.paint(1, self.FLAG_NUMERAL)
|
||||
return 0
|
||||
|
||||
def calculate(self):
|
||||
if self.state <= 0:
|
||||
if self[0] == '/' and self[1] == '/':
|
||||
while self[0]: self.paint(1, self.FLAG_COMMENT)
|
||||
else if self[0] == '/' and self[1] == '*':
|
||||
self.paint(2, self.FLAG_COMMENT)
|
||||
return self.paintCComment()
|
||||
else if not self.cKeywordQualifier(self[-1]) and self.isdigit(self[0]):
|
||||
self.paintCNumeral()
|
||||
return 0
|
||||
else if self[0] == '.':
|
||||
if self.findKeywords(self.directives, self.FLAG_KEYWORD, self.dqualifier):
|
||||
return 0
|
||||
else if self.findKeywords(self.types, self.FLAG_PRAGMA, self.dqualifier):
|
||||
return 0
|
||||
else:
|
||||
self.skip()
|
||||
return 0
|
||||
else if self[0] == '%':
|
||||
if self.findKeywords(self.registers, self.FLAG_ESCAPE, self.rqualifier):
|
||||
return 0
|
||||
else:
|
||||
self.skip()
|
||||
return 0
|
||||
else if not self.cKeywordQualifier(self[-1]) and self.isalpha(self[0]):
|
||||
if self.findKeywords(self.instructions, self.FLAG_TYPE, self.cKeywordQualifier):
|
||||
return 0
|
||||
self.skip()
|
||||
return 0
|
||||
else if self[0] != None:
|
||||
self.skip()
|
||||
return 0
|
||||
else if self.state == 1:
|
||||
return self.paintCComment()
|
||||
return None
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import os
|
||||
from bim import getCommands
|
||||
from syntax import Highlighter, bind
|
||||
from syntax.doxygen import tryDoxygenComment
|
||||
@ -166,8 +167,24 @@ class BimcmdHighlighter(KrkHighlighter):
|
||||
name = 'bimcmd'
|
||||
extensions = ('.bim3rc',)
|
||||
|
||||
file_commands = ['e','tabnew','split','w','runscript','rundir']
|
||||
|
||||
def calculate(self):
|
||||
if self.state <= 0 and self[-1] != '.':
|
||||
if self.i == 0:
|
||||
if self.findKeywords(self.file_commands, self.FLAG_KEYWORD, self.cKeywordQualifier):
|
||||
if self[0] == ' ':
|
||||
while self[0] == ' ': self.skip()
|
||||
let filePath = self[0:]
|
||||
if filePath:
|
||||
if filePath.startswith('~/'):
|
||||
filePath = filePath.replace('~',os.environ.get('HOME','~'),1)
|
||||
try:
|
||||
os.stat(filePath)
|
||||
self.paint(-1, self.FLAG_DIFFPLUS)
|
||||
except:
|
||||
self.paint(-1, self.FLAG_DIFFMINUS)
|
||||
return -1
|
||||
if self.findKeywords(getCommands(), self.FLAG_KEYWORD, self.cKeywordQualifier):
|
||||
return 0
|
||||
return super().calculate()
|
||||
|
Loading…
Reference in New Issue
Block a user