📄 color.vtc
字号:
if (!depend_loaded) Load("depend");register_file("color");Tstyle ?:= new_assoc();styles ?:= new_list();STYLE_BASE = S_HILITE;reset_str ?:= "\33[m";func add_style(name, str) [style] { style = alloc(2, Tstyle); style->name = name; style->str = str; add_list(styles, style);}func find_style(name) [i] { for (i = 1; i <= *styles && strcmp(styles[i]->name, name); i++); return (i <= *styles) ? i + STYLE_BASE : NULL;}func Find_style(name) { return efind(.find_style, "style", name); }func get_style_name(num) { return styles[num - STYLE_BASE]->name; }func get_style_str(num) { return styles[num - STYLE_BASE]->str; }func output(text / style, w) [style, p, left, len] { w ?:= cur_win ? : active; style ?:= S_NORM; if (w->pstate == PG_PAUSED) return add_list(w->buffer, table(text, style)); if (style == S_HILITE) bold(1); else if (style > S_HILITE) write(get_style_str(style)); if (w->pstate == PG_ON) { len = win_bottom(w) - win_top(w); for (; *text && w->pcount <= len; text = p) { left = cols - win_col(w); p = (strchr(text, '\n', left) ? : text + left - 1) + 1; echo(w, strcpy("", text, p - text)); if (p[-1]) w->pcount++; } } else echo(w, text); if (style == S_HILITE) bold(0); else if (style > S_HILITE) write(reset_str); if (w->pstate == PG_ON && *text) { w->pstate = PG_PAUSED; add_status(w, "[PAUSED]"); add_list(w->buffer, table(text, style)); }}func Trig(s) [arg, style, pri, pat, cmd, p, w] { s = getopt(s, "e1hgrPNWS", arg = table(1, 0, 0, 0, 0, "", "")); style = arg[8] ? Find_style(arg[8]) : arg[2] ? S_HILITE : (arg[3] == 2) ? S_NOHISTGAG : arg[3] ? S_GAG : S_NORM; pri = max(atoi(arg[5]), 0); if (arg[7]) { w = find_world(arg[7]); if (!w) return printf("Can't find world %s\n", arg[7]); } p = strchr(s, '=') ? : s + strlen(s); cmd = strdup(skipspaces(p + 1)); while (*--p == ' '); strcpy(pat = "", s, p + 1 - s); add_trig(arg[6], pat, cmd, pri, w, arg[0], !arg[1], style, arg[4]);}func list_trigs(s) [i, trig] { for (i = 1; i <= *trigs; i++) { trig = trigs[i]; if (trig->world && trig->world != cur_world() || *s && !smatch(s, trig->name)) continue; printf("%3d: %4d%c%c %10s %s\n", i, trig->pri, trig->enabled ? '+' : '-', stchars[trig->style] ? : 'C', trig->name, trig->pattern); }}func print_trig(n) [trig, sname] { t = Find_trig(n); trig = *t; if (trig->name) printf("Name: %s\n", trig->name); printf("%s: %s\n", trig->reg ? "Regexp" : "Pattern", trig->pattern); printf("Priority: %d\n", trig->pri); if (trig->world) printf("World: %s\n", trig->world->name); if (type(trig->cmd) == T_FPTR) printf("Function: %s\n", func_name(trig->cmd)); else printf("Command: %s\n", trig->cmd); output("Flags: "); output(trig->enabled ? "Enabled, " : "Disabled, "); output(trig->rearm ? "Permanent, " : "One-shot, "); sname = (trig->style <= S_HILITE) ? style_names[trig->style] : get_style_name(trig->style); printf("%s\n", sname);}add_style("red", "\33[31m");add_style("green", "\33[32m");add_style("yellow", "\33[33m");add_style("blue", "\33[34m");add_style("magenta", "\33[35m");add_style("cyan", "\33[36m");add_style("lred", "\33[1;31m");add_style("lgreen", "\33[1;32m");add_style("lyellow", "\33[1;33m");add_style("lblue", "\33[1;34m");add_style("lmagenta", "\33[1;35m");add_style("lcyan", "\33[1;36m");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -