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

📄 xif.c

📁 aee是一种易使用的文本编辑器。你可以不用说明书来使用它。它提供终端接口和本地的X-windows接口。它的特性包括即弹的菜单
💻 C
📖 第 1 页 / 共 2 页
字号:
				timeout.tv_usec = 500000;				FD_ZERO(&ttymask);				FD_SET(xfd, &ttymask);				temp = select((xfd+1), &ttymask, NULL, NULL, &timeout);				if (temp == 0)				{					draw_cursor(FALSE);					XFlush(dp);				}				else				{					draw_cursor(TRUE);					XFlush(dp);				}			} while (temp == 0);		}#endif /* ifndef XIF_DEBUG */		XNextEvent(dp, &event);		if (event.type == KeyPress)		{#ifdef hide_cursor			if (cursor_on)			{				XDefineCursor(dp, wid, blank_cursor);				XFlush(dp);				cursor_on = FALSE;			}#endif			valid = wgetch(stdscr);		}		else if ((event.type == MotionNotify) && ((eventmotion->state == (ShiftMask | Button2MotionMask)) || (eventmotion->state == Button1MotionMask)))		{#ifdef hide_cursor			if (!cursor_on)			{				cursor_on = TRUE;				XDefineCursor(dp, wid, ae_cursor);			}#endif			tempx = eventbutton->x / fontwidth;			tempy = eventbutton->y / fontheight;			tempy -= curr_buff->window_top;			if (tempy < 0)				tempy = 0;			if (tempy > curr_buff->last_line)				tempy = curr_buff->last_line;			move_to_xy(tempx, tempy);			if ((!cut_paste) && (!mark_text))			{				cut_paste = TRUE;				slct(1);			}			wrefresh(curr_buff->win);		}#ifdef hide_cursor		else if ((event.type == MotionNotify) && (!cursor_on))		{			XDefineCursor(dp, wid, ae_cursor);			XFlush(dp);			cursor_on = TRUE;		}#endif		else if ((event.type == ButtonRelease) && (((eventbutton->button == Button2) && (eventbutton->button == ShiftMask)) || (eventbutton->button == Button1)) && (cut_paste))		{			cut_text();			cut_paste = FALSE;		}		else if ((event.type == ButtonPress) && (((eventbutton->button == Button3) && (eventbutton->state == ShiftMask)) || ((eventbutton->button == Button2) && (!(eventbutton->state & ShiftMask)))))		{			temp_indent = indent;			if (indent)			{				indent = FALSE;			}			temp_buff = XFetchBytes(dp, &buff_counter);			temp_point = temp_buff;			counter = 0;			while ((counter < buff_counter) && (temp_buff != NULL))			{				in = *temp_point;				if ((in == '\n') || (in == '\r'))					insert_line(TRUE);				else					insert(in);				if (counter < buff_counter)					temp_point++;				counter++;			}			indent = temp_indent;			if (temp_buff != NULL)				free(temp_buff);			wmove(curr_buff->win, curr_buff->scr_vert, curr_buff->scr_horz);			wrefresh(curr_buff->win);		}		else if ((event.type == ButtonPress) && (eventbutton->button == Button1))		{			tempy = (eventbutton->y / fontheight);			/* make sure cursor is in window	*/			if ((!mark_text) && (tempy < curr_buff->window_top) && 					(curr_buff->window_top > 0))			{				if (!((info_win != 0) && 						(tempy < info_win_height)))				{					while ((tempy < curr_buff->window_top) 					   && (curr_buff->window_top > 0))					     parse(fn_PB_str); /* prev buffer */				}			}			else if ((!mark_text) && (tempy > 			     (curr_buff->window_top + curr_buff->lines)) && 			     (curr_buff->next_buff != NULL))			{				while ((curr_buff->next_buff != NULL) && 				   (tempy >= curr_buff->next_buff->window_top))					parse(fn_NB_str);  /* next buffer  */			}			else			{				tempy -= curr_buff->window_top;				if (tempy < 0)					tempy = 0;				if (tempy > curr_buff->last_line)					tempy = curr_buff->last_line;				move_to_xy((eventbutton->x / fontwidth), tempy);			}			status_display();			wrefresh(curr_buff->win);		}		else if (event.type == Expose)		{			while (XCheckTypedEvent(dp, Expose, &event))				;			/*			 |	time to cheat, we know which is the last 			 |	window that was refreshed			 */			clearok(curr_buff->win, TRUE);			touchwin(last_window_refreshed);			touchwin(last_window_refreshed);			wrefresh(last_window_refreshed);			XFlush(dp);		}		else if (event.type == GraphicsExpose)		{			while (XCheckTypedEvent(dp, GraphicsExpose, &event))				;			/*			 |	A real hack to handle situation when 			 |	window is partially obscured by another 			 |	window.  There are better ways to handle 			 |	this that completely redrawing the 			 |	window.			 */			clearok(curr_buff->win, TRUE);			touchwin(last_window_refreshed);			wrefresh(last_window_refreshed);			XFlush(dp);		}		else if (event.type == ConfigureNotify)	/* resize of window */		{			if ((xae_window_height != event.xconfigure.height ) || 			    (xae_window_width != event.xconfigure.width ))			{				LINES = event.xconfigure.height / fontheight;				COLS = event.xconfigure.width / fontwidth;				XClearWindow(dp, wid);				XFlush(dp);				reinitscr();				resize_check();				wrefresh(curr_buff->win);				XFlush(dp);				xae_window_height = event.xconfigure.height;				xae_window_width = event.xconfigure.width;			}		}		else if (event.type == FocusOut)	/* loss of focus */		{			xae_in_focus = FALSE;			draw_cursor(TRUE);			if (curr_buff->curr_line->changed && curr_buff->journalling)				write_journal(curr_buff, curr_buff->curr_line);		}		else if (event.type == FocusIn)	/* acquisition of focus */		{			xae_in_focus = TRUE;		}		else if (cut_paste)		{			cut_text();			cut_paste = FALSE;		}	} while (!valid);}void move_to_xy(x, y)	/* move text cursor to mouse cursor position	*/int x, y;	/* horizontal and vertical position of the mouse	*/{	if ((curr_buff->scr_vert > y) || ((curr_buff->scr_vert == y) && (curr_buff->scr_horz > x)))	{		if ((curr_buff->position != 1) && ((curr_buff->scr_vert - (curr_buff->scr_pos / COLS)) > y))			bol();			/* bol	*/		while ((curr_buff->position == 1) && (curr_buff->curr_line->prev_line != NULL) && 			((curr_buff->scr_vert - curr_buff->curr_line->prev_line->vert_len) > y))			bol();			/* bol	*/		if ((curr_buff->position == 1) && ((curr_buff->scr_vert - 		      curr_buff->curr_line->prev_line->vert_len) <= y) && (curr_buff->scr_vert > y))			eopl();			/* end of prev line	*/		while ((curr_buff->scr_vert != y) && (curr_buff->position > 1))			left(TRUE);		/* left	*/		while ((curr_buff->scr_vert == y) && (curr_buff->scr_horz > x) && (curr_buff->position > 1))			left(TRUE);	/* left	*/		if (curr_buff->scr_vert < y)			adv_line();	/* adv line	*/	}	else	{		if (((curr_buff->curr_line->vert_len - (curr_buff->scr_pos / COLS)) + curr_buff->scr_vert) <= y)			adv_line();	/* adv line	*/		while (((curr_buff->scr_vert + curr_buff->curr_line->vert_len) <= y) && 						(curr_buff->curr_line->next_line != NULL))			adv_line();	/* adv line	*/		while ((curr_buff->scr_vert < y) && (curr_buff->position < curr_buff->curr_line->line_length))			right(TRUE);	/* right	*/		while ((curr_buff->scr_horz < x) && (curr_buff->scr_vert == y) && 					(curr_buff->position < curr_buff->curr_line->line_length))			right(TRUE);	/* right	*/		if (curr_buff->scr_vert > y)			left(TRUE);	}}void eopl()		/* move to end of previous line without shifting screen	*/{	if (curr_buff->position != 1)		bol();	if ((curr_buff->curr_line->prev_line != NULL) && (curr_buff->scr_vert - curr_buff->curr_line->prev_line->vert_len) < 0)	{		curr_buff->curr_line = curr_buff->curr_line->prev_line;		curr_buff->pointer = curr_buff->curr_line->line;		curr_buff->position = 1;		curr_buff->scr_pos = 0;		curr_buff->scr_vert -= curr_buff->curr_line->vert_len;		while (curr_buff->position < curr_buff->curr_line->line_length)		{			curr_buff->pointer++;			curr_buff->position++;		}		curr_buff->scr_pos = scanline(curr_buff->curr_line, curr_buff->position);		curr_buff->abs_pos = curr_buff->scr_pos;		curr_buff->scr_vert += curr_buff->scr_pos / COLS;		curr_buff->scr_horz = curr_buff->scr_pos % COLS;		if (mark_text)			slct_line("u");	}	else		left(TRUE);}void cut_text(){	int counter;	int buff_counter;	char *out_buff;	char *temp_point;	char *temp_buff;	struct text *temp_paste;	struct text *temp_text;	temp_paste = paste_buff;	paste_buff = NULL;	copy();	temp_text = paste_buff;	counter = 0;	while (temp_text != NULL)	{		counter += temp_text->line_length;		temp_text = temp_text->next_line;	}	out_buff = malloc(counter + 1);	temp_point = out_buff;	temp_text = paste_buff;	while (temp_text != NULL)	{		buff_counter = 1;		temp_buff = temp_text->line;		while (buff_counter < temp_text->line_length)		{			*temp_point = *temp_buff;			temp_point++;			temp_buff++;			buff_counter++;		}		if (temp_text->next_line != NULL)		{			*temp_point = '\n';			temp_point++;			temp_text = temp_text->next_line;			free(temp_text->prev_line->line);			free(temp_text->prev_line);		}		else		{			counter -= 1;			*temp_point = (char) NULL;			free(temp_text->line);			free(temp_text);			temp_text = NULL;		}	}	if (counter > 0)		XStoreBytes(dp, out_buff, counter);	free(out_buff);	paste_buff = temp_paste;	midscreen(curr_buff->scr_vert, curr_buff->position);	wrefresh(curr_buff->win);}void raise_window(){	XRaiseWindow(dp, wid);}void set_window_name(name)char *name;{	static char *window_name = NULL;	if (window_name != NULL)		free(window_name);	window_name = xalloc(strlen("xae:") + strlen(name) + 1);	strcpy(window_name, "xae:");	strcat(window_name, name);	XStoreName(dp, wid, window_name);	XSetIconName(dp, wid, window_name);}

⌨️ 快捷键说明

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