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

📄 uedit.c

📁 举世闻名的joe记事本源程序
💻 C
📖 第 1 页 / 共 4 页
字号:
				k = utf8_decode_string(buf);			}		}				binsc(bw->cursor, k);		/* We need x position before we move cursor */		x = piscol(bw->cursor) - bw->offset;		pgetc(bw->cursor);		/* Tabs are weird here... */		if (bw->o.overtype && !piseol(bw->cursor) && k != '\t')			udelch(bw);		/* Not sure if we're in right position for wordwrap when we're in overtype mode */		if (bw->o.wordwrap && piscol(bw->cursor) > bw->o.rmargin && !joe_isblank(map,k)) {			wrapword(bw, bw->cursor, (long) bw->o.lmargin, bw->o.french, NULL);			simple = 0;		}		bw->cursor->xcol = piscol(bw->cursor);#ifndef __MSDOS__		if (x < 0 || x >= bw->w)			simple = 0;		if (bw->cursor->line < bw->top->line || bw->cursor->line >= bw->top->line + bw->h)			simple = 0;		if (simple && bw->parent->t->t->sary[bw->y + bw->cursor->line - bw->top->line])			simple = 0;		if (simple && k != '\t' && k != '\n' && !curmacro) {			int atr;			SCRN *t = bw->parent->t->t;			int y = bw->y + bw->cursor->line - bw->top->line;			int *screen = t->scrn + y * t->co;			int *attr = t->attr + y * t->co;			x += bw->x;			atr = BG_COLOR(bg_text);			if (!upd && piseol(bw->cursor) && !bw->o.highlight)				t->updtab[y] = 0;			if (markb &&			    markk &&			    markb->b == bw->b &&			    markk->b == bw->b &&			   ((!square && bw->cursor->byte >= markb->byte && bw->cursor->byte < markk->byte) ||			    ( square && bw->cursor->line >= markb->line && bw->cursor->line <= markk->line && piscol(bw->cursor) >= markb->xcol && piscol(bw->cursor) < markk->xcol)))				atr |= INVERSE;			outatr(bw->b->o.charmap, t, screen + x, attr + x, x, y, k, atr);		}#endif	}	return 0;}int utypebw(BW *bw, int k){	return utypebw_raw(bw, k, 0);}/* Quoting */static B *unicodehist = NULL;	/* History of previously entered unicode characters */static int dounicode(BW *bw, unsigned char *s, void *object, int *notify){	int num;	sscanf((char *)s,"%x",(unsigned  *)&num);	if (notify)		*notify = 1;	vsrm(s);	utypebw_raw(bw, num, 1);	bw->cursor->xcol = piscol(bw->cursor);	return 0;}int quotestate;int quoteval;static int doquote(BW *bw, int c, void *object, int *notify){	unsigned char buf[40];	if (c < 0 || c >= 256) {		nungetc(c);		return -1;	}	switch (quotestate) {	case 0:		if (c >= '0' && c <= '9') {			quoteval = c - '0';			quotestate = 1;			joe_snprintf_1(buf, sizeof(buf), "ASCII %c--", c);			if (!mkqwna(bw->parent, sz(buf), doquote, NULL, NULL, notify))				return -1;			else				return 0;		} else if (c == 'x' || c == 'X') {			if (bw->b->o.charmap->type) {				if (!wmkpw(bw->parent, joe_gettext(_("Unicode (ISO-10646) character in hex (^C to abort): ")), &unicodehist, dounicode,				           NULL, NULL, NULL, NULL, NULL, locale_map, 0))					return 0;				else					return -1;			} else {				quotestate = 3;				if (!mkqwna(bw->parent, sc("ASCII 0x--"), doquote, NULL, NULL, notify))					return -1;				else					return 0;			}		} else if (c == 'o' || c == 'O') {			quotestate = 5;			if (!mkqwna(bw->parent, sc("ASCII 0---"), doquote, NULL, NULL, notify))				return -1;			else				return 0;		} else {			if ((c >= 0x40 && c <= 0x5F) || (c >= 'a' && c <= 'z'))				c &= 0x1F;			if (c == '?')				c = 127;			utypebw_raw(bw, c, 1);			bw->cursor->xcol = piscol(bw->cursor);		}		break;	case 1:		if (c >= '0' && c <= '9') {			joe_snprintf_2(buf, sizeof(buf), "ASCII %c%c-", quoteval + '0', c);			quoteval = quoteval * 10 + c - '0';			quotestate = 2;			if (!mkqwna(bw->parent, sz(buf), doquote, NULL, NULL, notify))				return -1;			else				return 0;		}		break;	case 2:		if (c >= '0' && c <= '9') {			quoteval = quoteval * 10 + c - '0';			utypebw_raw(bw, quoteval, 1);			bw->cursor->xcol = piscol(bw->cursor);		}		break;	case 3:		if (c >= '0' && c <= '9') {			joe_snprintf_1(buf, sizeof(buf), "ASCII 0x%c-", c);			quoteval = c - '0';			quotestate = 4;			if (!mkqwna(bw->parent, sz(buf), doquote, NULL, NULL, notify))				return -1;			else				return 0;		} else if (c >= 'a' && c <= 'f') {			joe_snprintf_1(buf, sizeof(buf), "ASCII 0x%c-", c + 'A' - 'a');			quoteval = c - 'a' + 10;			quotestate = 4;			if (!mkqwna(bw->parent, sz(buf), doquote, NULL, NULL, notify))				return -1;			else				return 0;		} else if (c >= 'A' && c <= 'F') {			joe_snprintf_1(buf, sizeof(buf), "ASCII 0x%c-", c);			quoteval = c - 'A' + 10;			quotestate = 4;			if (!mkqwna(bw->parent, sz(buf), doquote, NULL, NULL, notify))				return -1;			else				return 0;		}		break;	case 4:		if (c >= '0' && c <= '9') {			quoteval = quoteval * 16 + c - '0';			utypebw_raw(bw, quoteval, 1);			bw->cursor->xcol = piscol(bw->cursor);		} else if (c >= 'a' && c <= 'f') {			quoteval = quoteval * 16 + c - 'a' + 10;			utypebw_raw(bw, quoteval, 1);			bw->cursor->xcol = piscol(bw->cursor);		} else if (c >= 'A' && c <= 'F') {			quoteval = quoteval * 16 + c - 'A' + 10;			utypebw_raw(bw, quoteval, 1);			bw->cursor->xcol = piscol(bw->cursor);		}		break;	case 5:		if (c >= '0' && c <= '7') {			joe_snprintf_1(buf, sizeof(buf), "ASCII 0%c--", c);			quoteval = c - '0';			quotestate = 6;			if (!mkqwna(bw->parent, sz(buf), doquote, NULL, NULL, notify))				return -1;			else				return 0;		}		break;	case 6:		if (c >= '0' && c <= '7') {			joe_snprintf_2(buf, sizeof(buf), "ASCII 0%c%c-", quoteval + '0', c);			quoteval = quoteval * 8 + c - '0';			quotestate = 7;			if (!mkqwna(bw->parent, sz(buf), doquote, NULL, NULL, notify))				return -1;			else				return 0;		}		break;	case 7:		if (c >= '0' && c <= '7') {			quoteval = quoteval * 8 + c - '0';			utypebw_raw(bw, quoteval, 1);			bw->cursor->xcol = piscol(bw->cursor);		}		break;	}	if (notify)		*notify = 1;	return 0;}int uquote(BW *bw){	quotestate = 0;	if (mkqwna(bw->parent, sz(joe_gettext(_("Ctrl- (or 0-9 for dec. ascii, x for hex, or o for octal)"))), doquote, NULL, NULL, NULL))		return 0;	else		return -1;}static int doquote9(BW *bw, int c, void *object, int *notify){	if (notify)		*notify = 1;	if ((c >= 0x40 && c <= 0x5F) || (c >= 'a' && c <= 'z'))		c &= 0x1F;	if (c == '?')		c = 127;	c |= 128;	utypebw_raw(bw, c, 1);	bw->cursor->xcol = piscol(bw->cursor);	return 0;}static int doquote8(BW *bw, int c, void *object, int *notify){	if (c == '`') {		if (mkqwna(bw->parent, sc("Meta-Ctrl-"), doquote9, NULL, NULL, notify))			return 0;		else			return -1;	}	if (notify)		*notify = 1;	c |= 128;	utypebw_raw(bw, c, 1);	bw->cursor->xcol = piscol(bw->cursor);	return 0;}int uquote8(BW *bw){	if (mkqwna(bw->parent, sc("Meta-"), doquote8, NULL, NULL, NULL))		return 0;	else		return -1;}static int doctrl(BW *bw, int c, void *object, int *notify){	int org = bw->o.overtype;	if (notify)		*notify = 1;	bw->o.overtype = 0;	if (bw->parent->huh == srchstr && c == '\n') {		utypebw(bw, '\\');		utypebw(bw, 'n');	} else		utypebw_raw(bw, c, 1);	bw->o.overtype = org;	bw->cursor->xcol = piscol(bw->cursor);	return 0;}int uctrl(BW *bw){	if (mkqwna(bw->parent, sz(joe_gettext(_("Quote"))), doctrl, NULL, NULL, NULL))		return 0;	else		return -1;}/* User hit Return.  Deal with autoindent. */int rtntw(BW *bw){	if (bw->o.overtype) {		p_goto_eol(bw->cursor);		if (piseof(bw->cursor))			binsc(bw->cursor, '\n');		pgetc(bw->cursor);		bw->cursor->xcol = piscol(bw->cursor);	} else {		P *p = pdup(bw->cursor, USTR "rtntw");		unsigned char c;		binsc(bw->cursor, '\n'), pgetc(bw->cursor);		/* Suppress autoindent if we're on a space or tab... */		if (bw->o.autoindent /* && (brch(bw->cursor)!=' ' && brch(bw->cursor)!='\t')*/) {			p_goto_bol(p);			while (joe_isspace(bw->b->o.charmap,(c = pgetc(p))) && c != '\n') {				binsc(bw->cursor, c);				pgetc(bw->cursor);			}		}		prm(p);		bw->cursor->xcol = piscol(bw->cursor);	}	return 0;}/* Open a line */int uopen(BW *bw){	binsc(bw->cursor,'\n');	if (bw->o.autoindent && (brch(bw->cursor)!=' ' && brch(bw->cursor)!='\t')) {		P *p = pdup(bw->cursor, USTR "uopen");		P *q = pdup(p, USTR "uopen");		int c;		pgetc(q);		p_goto_bol(p);		while (joe_isspace(bw->b->o.charmap,(c = pgetc(p))) && c != '\n') {			binsc(q, c);			pgetc(q);		}		prm(p); prm(q);	}		return 0;}/* Set book-mark */static int dosetmark(BW *bw, int c, void *object, int *notify){	if (notify)		*notify = 1;	if (c >= '0' && c <= ':') {		pdupown(bw->cursor, bw->b->marks + c - '0', USTR "dosetmark");		poffline(bw->b->marks[c - '0']);		if (c!=':') {			joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("Mark %d set")), c - '0');			msgnw(bw->parent, msgbuf);		}		return 0;	} else {		nungetc(c);		return -1;	}}int usetmark(BW *bw, int c){	if (c >= '0' && c <= ':')		return dosetmark(bw, c, NULL, NULL);	else if (mkqwna(bw->parent, sz(joe_gettext(_("Set mark (0-9):"))), dosetmark, NULL, NULL, NULL))		return 0;	else		return -1;}/* Goto book-mark */static int dogomark(BW *bw, int c, void *object, int *notify){	if (notify)		*notify = 1;	if (c >= '0' && c <= ':')		if (bw->b->marks[c - '0']) {			pset(bw->cursor, bw->b->marks[c - '0']);			bw->cursor->xcol = piscol(bw->cursor);			return 0;		} else {			joe_snprintf_1(msgbuf, JOE_MSGBUFSIZE, joe_gettext(_("Mark %d not set")), c - '0');			msgnw(bw->parent, msgbuf);			return -1;	} else {		nungetc(c);		return -1;	}}int ugomark(BW *bw, int c){	if (c >= '0' && c <= '9')		return dogomark(bw, c, NULL, NULL);	else if (mkqwna(bw->parent, sz(joe_gettext(_("Goto bookmark (0-9):"))), dogomark, NULL, NULL, NULL))		return 0;	else		return -1;}/* Goto next instance of character */static int dobkwdc;static int dofwrdc(BW *bw, int k, void *object, int *notify){	int c;	P *q;	if (notify)		*notify = 1;	if (k < 0 || k >= 256) {		nungetc(k);		return -1;	}	q = pdup(bw->cursor, USTR "dofwrdc");	if (dobkwdc) {		while ((c = prgetc(q)) != NO_MORE_DATA)			if (c == k)				break;	} else {		while ((c = pgetc(q)) != NO_MORE_DATA)			if (c == k)				break;	}	if (c == NO_MORE_DATA) {		msgnw(bw->parent, joe_gettext(_("Not found")));		prm(q);		return -1;	} else {		pset(bw->cursor, q);		bw->cursor->xcol = piscol(bw->cursor);		prm(q);		return 0;	}}int ufwrdc(BW *bw, int k){	dobkwdc = 0;	if (k >= 0 && k < 256)		return dofwrdc(bw, k, NULL, NULL);	else if (mkqw(bw->parent, sz(joe_gettext(_("Forward to char: "))), dofwrdc, NULL, NULL, NULL))		return 0;	else		return -1;}int ubkwdc(BW *bw, int k){	dobkwdc = 1;	if (k >= 0 && k < 256)		return dofwrdc(bw, k, NULL, NULL);	else if (mkqw(bw->parent, sz(joe_gettext(_("Backward to char: "))), dofwrdc, NULL, NULL, NULL))		return 0;	else		return -1;}/* Display a message */static int domsg(BASE *b, unsigned char *s, void *object, int *notify){	if (notify)		*notify = 1;	zcpy(msgbuf, s);	vsrm(s);	msgnw(b->parent, msgbuf);	return 0;}int umsg(BASE *b){	if (wmkpw(b->parent, joe_gettext(_("Message (^C to abort): ")), NULL, domsg, NULL, NULL, NULL, NULL, NULL, locale_map, 0))		return 0;	else		return -1;}/* Insert text */static int dotxt(BW *bw, unsigned char *s, void *object, int *notify){	int x;	if (notify)		*notify = 1;	for (x = 0; x != sLEN(s); ++x)		utypebw(bw, s[x]);	vsrm(s);	return 0;}int utxt(BW *bw){	if (wmkpw(bw->parent, joe_gettext(_("Insert (^C to abort): ")), NULL, dotxt, NULL, NULL, utypebw, NULL, NULL, bw->b->o.charmap, 0))		return 0;	else		return -1;}/* Insert current file name */int uname_joe(BW *bw){	unsigned char *s;	W *w=bw->parent->main;	s=((BW *)w->object)->b->name;	if (!s || !*s)		return -1;	while (*s)		if (utypebw(bw,*s++))			return -1;	return 0;}/* Insert until non-base64 character received */int upaste(BW  *bw, int k){	int c;	int accu = 0;	int count;	int tmp_ww = bw->o.wordwrap;	int tmp_ai = bw->o.autoindent;	bw->o.wordwrap = 0;	bw->o.autoindent = 0;	count = 0;	/* We have to wait for the second ';' */	while ((c = ttgetc()) != -1)		if (c == ';')			break;	if (c == -1)		goto bye;	while ((c = ttgetc()) != -1) {		if (c >= 'A' && c <= 'Z')			c = c - 'A';		else if (c >= 'a' && c <= 'z')			c = c - 'a' + 26;		else if (c >= '0' && c <= '9')			c = c - '0' + 52;		else if (c == '+')			c = 62;		else if (c == '/')			c = 63;		else if (c == '=')			continue;		else			break;		switch (count) {			case 0:				accu = c;				count = 6;				break;			case 2:				accu = (accu << 6) + c;				if (accu == 13)					rtntw(bw);				else					utypebw(bw, accu);				count = 0;				break;			case 4:				accu = (accu << 4) + (c >> 2);				if (accu == 13)					rtntw(bw);				else					utypebw(bw, accu);				accu = (c & 0x3);				count = 2;				break;			case 6:				accu = (accu << 2) + (c >> 4);				if (accu == 13)					rtntw(bw);				else					utypebw(bw, accu);				accu = (c & 0xF);				count = 4;				break;		}	}	/* Terminator is ESC \ */	if (c == 033) {		ttgetc();	}	bye:	bw->o.wordwrap = tmp_ww;	bw->o.autoindent = tmp_ai;	return 0;}

⌨️ 快捷键说明

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