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

📄 rc.c

📁 举世闻名的joe记事本源程序
💻 C
📖 第 1 页 / 共 3 页
字号:
					*(unsigned char **) opt->set = 0;			}			break;		case 4: /* Local option flag */			if (options)				*(int *) ((unsigned char *) options + opt->ofst) = st;			break;		case 5: /* Local option integer */			if (arg) {				if (options) {					sscanf((char *)arg, "%d", &val);					if (val >= opt->low && val <= opt->high)						*(int *) ((unsigned char *)							  options + opt->ofst) = val;				} 			}			break;		case 6: /* Local string option */			if (options) {				if (arg) {					*(unsigned char **) ((unsigned char *)							  options + opt->ofst) = zdup(arg);				} else {					*(unsigned char **) ((unsigned char *)							  options + opt->ofst) = 0;				}			}			break;		case 7: /* Local option numeric + 1, with range checking */			if (arg) {				int zz = 0;				sscanf((char *)arg, "%d", &zz);				if (zz >= opt->low && zz <= opt->high) {					--zz;					if (options)						*(int *) ((unsigned char *)							  options + opt->ofst) = zz;				}			}			break;		case 9: /* Set syntax */			if (arg && options)				options->syntax_name = zdup(arg);			/* this was causing all syntax files to be loaded...			if (arg && options)				options->syntax = load_dfa(arg); */			break;		case 13: /* Set byte mode encoding */			if (arg && options)				options->map_name = zdup(arg);			break;		}		/* This is a stupid hack... */		if ((opt->type & 3) == 0 || !arg)			return 1;		else			return 2;	} else {		/* Why no case 6, string option? */		/* Keymap, mold, mnew, etc. are not strings */		/* These options do not show up in ^T */		if (!zcmp(s, USTR "lmsg")) {			if (arg) {				if (options)					options->lmsg = zdup(arg);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "rmsg")) {			if (arg) {				if (options)					options->rmsg = zdup(arg);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "keymap")) {			if (arg) {				int y;				for (y = 0; !joe_isspace(locale_map,arg[y]); ++y) ;				if (!arg[y])					arg[y] = 0;				if (options && y)					options->context = zdup(arg);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "mnew")) {			if (arg) {				int sta;				if (options)					options->mnew = mparse(NULL, arg, &sta);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "mfirst")) {			if (arg) {				int sta;				if (options)					options->mfirst = mparse(NULL, arg, &sta);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "mold")) {			if (arg) {				int sta;				if (options)					options->mold = mparse(NULL, arg, &sta);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "msnew")) {			if (arg) {				int sta;				if (options)					options->msnew = mparse(NULL, arg, &sta);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "msold")) {			if (arg) {				int sta;				if (options)					options->msold = mparse(NULL, arg, &sta);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "text_color")) {			if (arg) {				bg_text = meta_color(arg);				bg_help = bg_text;				bg_prompt = bg_text;				bg_menu = bg_text;				bg_msg = bg_text;				bg_stalin = bg_text;				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "help_color")) {			if (arg) {				bg_help = meta_color(arg);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "status_color")) {			if (arg) {				bg_stalin = meta_color(arg);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "menu_color")) {			if (arg) {				bg_menu = meta_color(arg);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "prompt_color")) {			if (arg) {				bg_prompt = meta_color(arg);				ret = 2;			} else				ret = 1;		} else if (!zcmp(s, USTR "msg_color")) {			if (arg) {				bg_msg = meta_color(arg);				ret = 2;			} else				ret = 1;		}	}	return ret;}/* Option setting user interface (^T command) */static int optx = 0; /* Menu cursor position: remember it for next time */static int doabrt1(BW *bw, int *xx){	joe_free(xx);	return -1;}static int doopt1(BW *bw, unsigned char *s, int *xx, int *notify){	int ret = 0;	int x = *xx;	int v;	joe_free(xx);	switch (glopts[x].type) {	case 1:		v = calc(bw, s);		if (merr) {			msgnw(bw->parent, merr);			ret = -1;		} else if (v >= glopts[x].low && v <= glopts[x].high)			*(int *)glopts[x].set = v;		else {			msgnw(bw->parent, joe_gettext(_("Value out of range")));			ret = -1;		}		break;	case 2:		if (s[0])			*(unsigned char **) glopts[x].set = zdup(s);		break;	case 6:		*(unsigned char **)((unsigned char *)&bw->o+glopts[x].ofst) = zdup(s);		break;	case 5:		v = calc(bw, s);		if (merr) {			msgnw(bw->parent, merr);			ret = -1;		} else if (v >= glopts[x].low && v <= glopts[x].high)			*(int *) ((unsigned char *) &bw->o + glopts[x].ofst) = v;		else {			msgnw(bw->parent, joe_gettext(_("Value out of range")));			ret = -1;		}		break;	case 7:		v = calc(bw, s) - 1.0;		if (merr) {			msgnw(bw->parent, merr);			ret = -1;		} else if (v >= glopts[x].low && v <= glopts[x].high)			*(int *) ((unsigned char *) &bw->o + glopts[x].ofst) = v;		else {			msgnw(bw->parent, joe_gettext(_("Value out of range")));			ret = -1;		}		break;	}	vsrm(s);	bw->b->o = bw->o;	wfit(bw->parent->t);	updall();	if (notify)		*notify = 1;	return ret;}static int dosyntax(BW *bw, unsigned char *s, int *xx, int *notify){	int ret = 0;	struct high_syntax *syn;	syn = load_dfa(s);	if (syn)		bw->o.syntax = syn;	else		msgnw(bw->parent, joe_gettext(_("Syntax definition file not found")));	vsrm(s);	bw->b->o = bw->o;	updall();	if (notify)		*notify = 1;	return ret;}unsigned char **syntaxes = NULL; /* Array of available syntaxes */static int syntaxcmplt(BW *bw){	if (!syntaxes) {		unsigned char *oldpwd = pwd();		unsigned char **t;		unsigned char *p;		int x, y;		if (chpwd(USTR (JOERC "syntax")))			return -1;		t = rexpnd(USTR "*.jsf");		if (!t) {			chpwd(oldpwd);			return -1;		}		if (!aLEN(t)) {			varm(t);			chpwd(oldpwd);			return -1;		}		for (x = 0; x != aLEN(t); ++x) {			unsigned char *r = vsncpy(NULL,0,t[x],(unsigned char *)strrchr((char *)(t[x]),'.')-t[x]);			syntaxes = vaadd(syntaxes,r);		}		varm(t);		p = (unsigned char *)getenv("HOME");		if (p) {			unsigned char buf[1024];			joe_snprintf_1(buf,sizeof(buf),"%s/.joe/syntax",p);			if (!chpwd(buf) && (t = rexpnd(USTR "*.jsf"))) {				for (x = 0; x != aLEN(t); ++x)					*strrchr((char *)t[x],'.') = 0;				for (x = 0; x != aLEN(t); ++x) {					for (y = 0; y != aLEN(syntaxes); ++y)						if (!zcmp(t[x],syntaxes[y]))							break;					if (y == aLEN(syntaxes)) {						unsigned char *r = vsncpy(NULL,0,sv(t[x]));						syntaxes = vaadd(syntaxes,r);					}				}				varm(t);			}		}		vasort(av(syntaxes));		chpwd(oldpwd);	}	return simple_cmplt(bw,syntaxes);}static int doencoding(BW *bw, unsigned char *s, int *xx, int *notify){	int ret = 0;	struct charmap *map;	map = find_charmap(s);	if (map) {		bw->o.charmap = map;		joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("%s encoding assumed for this file")), map->name);		msgnw(bw->parent, msgbuf);	} else		msgnw(bw->parent, joe_gettext(_("Character set not found")));	vsrm(s);	bw->b->o = bw->o;	updall();	if (notify)		*notify = 1;	return ret;}unsigned char **encodings = NULL; /* Array of available encodinges */static int encodingcmplt(BW *bw){	if (!encodings) {		encodings = get_encodings();		vasort(av(encodings));	}	return simple_cmplt(bw,encodings);}static int doopt(MENU *m, int x, void *object, int flg){	BW *bw = m->parent->win->object;	int *xx;	unsigned char buf[OPT_BUF_SIZE];	int *notify = m->parent->notify;	switch (glopts[x].type) {	case 0:		if (!flg)			*(int *)glopts[x].set = !*(int *)glopts[x].set;		else if (flg == 1)			*(int *)glopts[x].set = 1;		else			*(int *)glopts[x].set = 0;		wabort(m->parent);		msgnw(bw->parent, *(int *)glopts[x].set ? joe_gettext(glopts[x].yes) : joe_gettext(glopts[x].no));		break;	case 4:		if (!flg)			*(int *) ((unsigned char *) &bw->o + glopts[x].ofst) = !*(int *) ((unsigned char *) &bw->o + glopts[x].ofst);		else if (flg == 1)			*(int *) ((unsigned char *) &bw->o + glopts[x].ofst) = 1;		else			*(int *) ((unsigned char *) &bw->o + glopts[x].ofst) = 0;		wabort(m->parent);		msgnw(bw->parent, *(int *) ((unsigned char *) &bw->o + glopts[x].ofst) ? joe_gettext(glopts[x].yes) : joe_gettext(glopts[x].no));		if (glopts[x].ofst == (unsigned char *) &fdefault.readonly - (unsigned char *) &fdefault)			bw->b->rdonly = bw->o.readonly;		break;	case 6:		wabort(m->parent);		xx = (int *) joe_malloc(sizeof(int));		*xx = x;		if(*(unsigned char **)((unsigned char *)&bw->o+glopts[x].ofst))			joe_snprintf_1(buf, OPT_BUF_SIZE, glopts[x].yes,*(unsigned char **)((unsigned char *)&bw->o+glopts[x].ofst));		else			joe_snprintf_1(buf, OPT_BUF_SIZE, glopts[x].yes,"");		if(wmkpw(bw->parent, buf, NULL, doopt1, NULL, doabrt1, utypebw, xx, notify, locale_map, 0))			return 0;		else			return -1;		/* break; warns on some systems */	case 1:		joe_snprintf_1(buf, OPT_BUF_SIZE, joe_gettext(glopts[x].yes), *(int *)glopts[x].set);		xx = (int *) joe_malloc(sizeof(int));		*xx = x;		m->parent->notify = 0;		wabort(m->parent);		if (wmkpw(bw->parent, buf, NULL, doopt1, NULL, doabrt1, utypebw, xx, notify, locale_map, 0))			return 0;		else			return -1;	case 2:		if (*(unsigned char **) glopts[x].set)			joe_snprintf_1(buf, OPT_BUF_SIZE, joe_gettext(glopts[x].yes), *(unsigned char **) glopts[x].set);		else			joe_snprintf_1(buf, OPT_BUF_SIZE, joe_gettext(glopts[x].yes), "");		xx = (int *) joe_malloc(sizeof(int));		*xx = x;		m->parent->notify = 0;		wabort(m->parent);		if (wmkpw(bw->parent, buf, NULL, doopt1, NULL, doabrt1, utypebw, xx, notify, locale_map, 0))			return 0;		else			return -1;	case 5:		joe_snprintf_1(buf, OPT_BUF_SIZE, joe_gettext(glopts[x].yes), *(int *) ((unsigned char *) &bw->o + glopts[x].ofst));		goto in;	case 7:		joe_snprintf_1(buf, OPT_BUF_SIZE, joe_gettext(glopts[x].yes), *(int *) ((unsigned char *) &bw->o + glopts[x].ofst) + 1);	      in:xx = (int *) joe_malloc(sizeof(int));		*xx = x;		m->parent->notify = 0;		wabort(m->parent);		if (wmkpw(bw->parent, buf, NULL, doopt1, NULL, doabrt1, utypebw, xx, notify, locale_map, 0))			return 0;		else			return -1;	case 9:		joe_snprintf_1(buf, OPT_BUF_SIZE, joe_gettext(glopts[x].yes), "");		m->parent->notify = 0;		wabort(m->parent);		if (wmkpw(bw->parent, buf, NULL, dosyntax, NULL, NULL, syntaxcmplt, NULL, notify, locale_map, 0))			return 0;		else			return -1;	case 13:		joe_snprintf_1(buf, OPT_BUF_SIZE, joe_gettext(glopts[x].yes), "");		m->parent->notify = 0;		wabort(m->parent);		if (wmkpw(bw->parent, buf, NULL, doencoding, NULL, NULL, encodingcmplt, NULL, notify, locale_map, 0))			return 0;		else

⌨️ 快捷键说明

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