⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hist.vtc

📁 Unix下的MUD客户端程序
💻 VTC
字号:
RHMAX ?:= 1000;rh ?:= alloc(RHMAX);rhpos ?:= 0;rhsize ?:= 0;lineno ?:= 1;Tline ?:= new_assoc();func add_hist(line / style, world) [histline] {	rh[rhpos] = alloc(2, Tline);	rh[rhpos]->text = bprintf("%c%s", (style ? : S_NORM) + 1, line);	rh[rhpos]->world = world ? : cur_world();	rhpos = (rhpos + 1) % RHMAX;	if (rhsize < RHMAX)		rhsize++;	lineno++;}func lstyle(l) --> *l->text - 1func lline(l) --> l->text + 1func get_histline(num) {	if (lineno - num > RHMAX || lineno <= num)		return NULL;	return lline(rh[(rhpos - (lineno - num) + rhsize) % rhsize]);}func recall(n, pat, all, gag, hil, names, lnos, world) [p, start, i, l] {	if (n <= 0)		return;	p = alloc(n);	start = i = (rhpos - 1 + rhsize) % rhsize;	do {		l = rh[i];		if ((all || l->world == world) && (!*pat || 		    smatch(pat, lline(l))) && (!gag || lstyle(l) != S_GAG)) {			*p++ = i;			n--;		}		i = (i - 1 + rhsize) % rhsize;	} while (n && i != start);	while (*--p != NULL)		hdisp(*p, hil, names, lnos);}func hdisp(offset, hil, names, lnos) [rname, i, s, l] {	l = rh[offset];	buf = "";	i = 1;	if (lnos || line_numbers) {		printf("%6d ", lineno - (rhpos - offset + rhsize) % rhsize);		i = 7;	}	if (names) {		rname = l->world ? l->world->name : "defunct";		printf("<%s> ", rname);		i += strlen(rname) + 3;	}	s = (i == 1) ? 0 : i;	output(wrap(lline(l), cols - 1, i, s), hil ? lstyle(l) : S_NORM);}func histdump(s, e) {	output("--- History dump begin ---\n");	for (s = max(s, lineno - RHMAX), e = min(e, lineno); s <= e; s++)		hdisp((rhpos - (lineno - s) + rhsize) % rhsize, 1, 1, 1);	output("--- History dump end ---\n");}func Recall(str) [reg, arg, num, world] {	str = getopt(str, "aghnlW", arg = alloc(6));	if (arg[5]) {		world = find_world(arg[5]);		if (!world)			return printf("Couldn't find world %s\n", arg[5]);	} else		world = cur_world();	num = atoi(str);	str = skipspaces(strchr(str, ' ') ? : "");	output("--- Recall begin ---\n");	recall(num, str, arg[0], arg[1], arg[2], arg[3], arg[4], world);	output("--- Recall end ---\n");}add_cmd("recall", -1, .Recall, \	"/recall [-aghnl] [-w<world>] <number lines> [<pattern>]");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -