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

📄 editdraw.c

📁 具有IDE功能的编辑器
💻 C
📖 第 1 页 / 共 2 页
字号:
	    while (col <= end_col - edit->start_col) {		*p = 0;		if (q == edit->curs1)		    *p |= MOD_CURSOR * 256;		if (q >= m1 && q < m2) {		    if (column_highlighting) {			int x;			x = edit_move_forward3 (edit, b, 0, q);			if (x >= c1 && x < c2)			    *p |= MOD_MARKED * 256;		    } else			*p |= MOD_MARKED * 256;		}		if (q == edit->bracket)		    *p |= MOD_BOLD * 256;		if (q >= edit->found_start && q < edit->found_start + edit->found_len)		    *p |= MOD_HIGHLIGHTED * 256;		c = edit_get_byte (edit, q);/* we don't use bg for mc - fg contains both */		if (book_mark == -1) {		    edit_get_syntax_color (edit, q, &fg, &bg);		    *p |= fg << 16;		} else {		    *p |= book_mark << 16;		}		q++;		switch (c) {		case '\n':		    col = end_col - edit->start_col + 1;	/* quit */		    *(p++) |= ' ';		    break;		case '\t':		    i = TAB_SIZE - ((int) col % TAB_SIZE);		    *p |= ' ';		    c = *(p++) & (0xFFFFFFFF - MOD_CURSOR * 256);		    col += i;		    while (--i)			*(p++) = c;		    break;		case '\r':		    break;		default:		    if (is_printable (c)) {			*(p++) |= c;		    } else {			*(p++) = '.';			*p |= (256 * MOD_ABNORMAL);		    }		    col++;		    break;		}	    }	}    } else {	start_col_real = start_col = 0;    }    *p = 0;    print_to_widget (edit, row, start_col, start_col_real, end_col, line);}#endif#ifdef MIDNIGHT#define key_pending(x) (!is_idle())#else#define edit_draw_this_line edit_draw_this_line_proportionalint option_smooth_scrolling = 0;static int key_pending (WEdit * edit){    static int flush = 0, line = 0;#ifdef GTK    /* ******* */#else    if (!edit) {	flush = line = 0;    } else if (!(edit->force & REDRAW_COMPLETELY) && !EditExposeRedraw && !option_smooth_scrolling) {/* this flushes the display in logarithmic intervals - so both fast and   slow machines will get good performance vs nice-refreshing */	if ((1 << flush) == ++line) {	    flush++;	    return CKeyPending ();	}    }#endif    return 0;}#endif/* b for pointer to begining of line */static void edit_draw_this_char (WEdit * edit, long curs, long row){    int b = edit_bol (edit, curs);#ifdef MIDNIGHT    edit_draw_this_line (edit, b, row, 0, edit->num_widget_columns - 1);#else    edit_draw_this_line (edit, b, row, 0, CWidthOf (edit->widget));#endif}/* cursor must be in screen for other than REDRAW_PAGE passed in force */void render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,		       long end_column){    long row = 0, curs_row;    static int prev_curs_row = 0;    static int prev_start_col = 0;    static long prev_curs = 0;    static long prev_start = -1;#ifndef MIDNIGHT    static unsigned long prev_win = 0;#endif    int force = edit->force;    long b;    CPushFont ("editor", 0);#ifndef MIDNIGHT    key_pending (0);#endif/*   if the position of the page has not moved then we can draw the cursor character only.   This will prevent line flicker when using arrow keys. */    if ((!(force & REDRAW_CHAR_ONLY)) || (force & REDRAW_PAGE)#ifndef MIDNIGHT#ifdef GTK	|| prev_win != ((GdkWindowPrivate *) CWindowOf (edit->widget)->text_area)->xwindow#else	|| prev_win != CWindowOf (edit->widget)#endif#endif	) {	int time_division = 5;#if 0	if (CPending ())	    time_division--;#endif#ifndef MIDNIGHT	if (prev_start < 0)	    prev_start = edit->start_line;	if (option_smooth_scrolling && prev_win == CWindowOf (edit->widget) && !edit->screen_modified) {	    int i, t;	    int pos1, pos2;	    i = edit->start_line - prev_start;	    if (i <= time_division && i > 0) {		edit_draw_proportional (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);		for (pos2 = 0, t = 0; t < time_division; t++) {		    int move;		    pos1 = FONT_PIX_PER_LINE * i * (t + 1) / time_division;		    move = pos1 - pos2;		    pos2 += move;		    XCopyArea (CDisplay, edit->widget->winid, edit->widget->winid, CGC,			       EDIT_TEXT_HORIZONTAL_OFFSET,			       EDIT_TEXT_VERTICAL_OFFSET + move,			       edit->widget->width - EDIT_FRAME_W,			       edit->widget->height - EDIT_FRAME_H - move,			       EDIT_TEXT_HORIZONTAL_OFFSET, EDIT_TEXT_VERTICAL_OFFSET);		    XClearArea (CDisplay, edit->widget->winid, EDIT_TEXT_HORIZONTAL_OFFSET,				edit->widget->height - EDIT_FRAME_H +				EDIT_TEXT_VERTICAL_OFFSET - move,				edit->widget->width - EDIT_FRAME_W, move, 0);		    XFlush (CDisplay);		    pause ();		}	    } else if (i >= -time_division && i < 0) {		edit_draw_proportional (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);		i = -i;		for (pos2 = 0, t = 0; t < time_division; t++) {		    int move;		    pos1 = FONT_PIX_PER_LINE * i * (t + 1) / time_division;		    move = pos1 - pos2;		    pos2 += move;		    XCopyArea (CDisplay, edit->widget->winid, edit->widget->winid, CGC,			       EDIT_TEXT_HORIZONTAL_OFFSET, EDIT_TEXT_VERTICAL_OFFSET,			       edit->widget->width - EDIT_FRAME_W,			       edit->widget->height - EDIT_FRAME_H -			       move, EDIT_TEXT_HORIZONTAL_OFFSET, EDIT_TEXT_VERTICAL_OFFSET + move);		    XClearArea (CDisplay, edit->widget->winid, EDIT_TEXT_HORIZONTAL_OFFSET,				EDIT_TEXT_VERTICAL_OFFSET,				edit->widget->width - EDIT_FRAME_W, move, 0);		    XFlush (CDisplay);		    pause ();		}	    }	}#endif	if (!(force & REDRAW_IN_BOUNDS)) {	/* !REDRAW_IN_BOUNDS means to ignore bounds and redraw whole rows */	    start_row = 0;	    end_row = edit->num_widget_lines - 1;	    start_column = 0;#ifdef MIDNIGHT	    end_column = edit->num_widget_columns - 1;#else	    end_column = CWidthOf (edit->widget);#endif	}	if (force & REDRAW_PAGE) {	    row = start_row;	    b = edit_move_forward (edit, edit->start_display, start_row, 0);	    while (row <= end_row) {		if (key_pending (edit))		    goto exit_render;		edit_draw_this_line (edit, b, row, start_column, end_column);		b = edit_move_forward (edit, b, 1, 0);		row++;	    }	} else {	    curs_row = edit->curs_row;	    if (force & REDRAW_BEFORE_CURSOR) {		if (start_row < curs_row) {		    long upto = curs_row - 1 <= end_row ? curs_row - 1 : end_row;		    row = start_row;		    b = edit->start_display;		    while (row <= upto) {			if (key_pending (edit))			    goto exit_render;			edit_draw_this_line (edit, b, row, start_column, end_column);			b = edit_move_forward (edit, b, 1, 0);		    }		}	    }/*          if (force & REDRAW_LINE)          ---> default */	    b = edit_bol (edit, edit->curs1);	    if (curs_row >= start_row && curs_row <= end_row) {		if (key_pending (edit))		    goto exit_render;		edit_draw_this_line (edit, b, curs_row, start_column, end_column);	    }	    if (force & REDRAW_AFTER_CURSOR) {		if (end_row > curs_row) {		    row = curs_row + 1 < start_row ? start_row : curs_row + 1;		    b = edit_move_forward (edit, b, 1, 0);		    while (row <= end_row) {			if (key_pending (edit))			    goto exit_render;			edit_draw_this_line (edit, b, row, start_column, end_column);			b = edit_move_forward (edit, b, 1, 0);			row++;		    }		}	    }	    if (force & REDRAW_LINE_ABOVE && curs_row >= 1) {		row = curs_row - 1;		b = edit_move_backward (edit, edit_bol (edit, edit->curs1), 1);		if (row >= start_row && row <= end_row) {		    if (key_pending (edit))			goto exit_render;		    edit_draw_this_line (edit, b, row, start_column, end_column);		}	    }	    if (force & REDRAW_LINE_BELOW && row < edit->num_widget_lines - 1) {		row = curs_row + 1;		b = edit_bol (edit, edit->curs1);		b = edit_move_forward (edit, b, 1, 0);		if (row >= start_row && row <= end_row) {		    if (key_pending (edit))			goto exit_render;		    edit_draw_this_line (edit, b, row, start_column, end_column);		}	    }	}    } else {	if (prev_curs_row < edit->curs_row) {	/* with the new text highlighting, we must draw from the top down */	    edit_draw_this_char (edit, prev_curs, prev_curs_row);	    edit_draw_this_char (edit, edit->curs1, edit->curs_row);	} else {	    edit_draw_this_char (edit, edit->curs1, edit->curs_row);	    edit_draw_this_char (edit, prev_curs, prev_curs_row);	}    }    edit->force = 0;    prev_curs_row = edit->curs_row;    prev_curs = edit->curs1;    prev_start_col = edit->start_col;#ifndef MIDNIGHT#ifdef GTK    prev_win = ((GdkWindowPrivate *) CWindowOf (edit->widget)->text_area)->xwindow;#else    prev_win = CWindowOf (edit->widget);#endif#endif  exit_render:    edit->screen_modified = 0;    prev_start = edit->start_line;    CPopFont ();    return;}#ifndef MIDNIGHTvoid edit_convert_expose_to_area (XExposeEvent * xexpose, int *row1, int *col1, int *row2, int *col2){    *col1 = xexpose->x - EDIT_TEXT_HORIZONTAL_OFFSET;    *row1 = (xexpose->y - EDIT_TEXT_VERTICAL_OFFSET) / FONT_PIX_PER_LINE;    *col2 = xexpose->x + xexpose->width + EDIT_TEXT_HORIZONTAL_OFFSET + 3;    *row2 = (xexpose->y + xexpose->height - EDIT_TEXT_VERTICAL_OFFSET) / FONT_PIX_PER_LINE;}#ifdef GTKvoid edit_render_tidbits (GtkEdit * edit){    gtk_widget_draw_focus (GTK_WIDGET (edit));}#elsevoid edit_render_tidbits (CWidget * wdt){    (*look->edit_render_tidbits) (wdt);}#endifvoid edit_set_space_width (int s);extern int option_long_whitespace;#endifvoid edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, int col_end){    int f = 0;    if (row_start < 0)	row_start = 0;    if (row_end < row_start)	return;    if (col_start < 0)	col_start = 0;    if (col_end < col_start)	return;    if (row_end > edit->num_widget_lines)	row_end = edit->num_widget_lines;    if (col_end > edit->widget->width)	col_end = edit->widget->width;#ifdef GTK    GtkEdit *win;#endif    if (page)			/* if it was an expose event, 'page' would be set */	edit->force |= REDRAW_PAGE | REDRAW_IN_BOUNDS;    f = edit->force & (REDRAW_PAGE | REDRAW_COMPLETELY);#ifdef MIDNIGHT    if (edit->force & REDRAW_COMPLETELY)	redraw_labels (edit->widget.parent, (Widget *) edit);#else    if (option_long_whitespace)	edit_set_space_width (FONT_PER_CHAR(' ') * 2);    else	edit_set_space_width (FONT_PER_CHAR(' '));#ifdef GTK    win = (GtkEdit *) edit->widget;#endif    edit_set_foreground_colors (				 color_palette (option_editor_fg_normal),				   color_palette (option_editor_fg_bold),				   color_palette (option_editor_fg_italic)	);    edit_set_background_colors (				 color_palette (option_editor_bg_normal),			       color_palette ((option_editor_bg_normal == option_editor_bg_abnormal) ? (option_editor_bg_normal ? 0 : 1) : option_editor_bg_abnormal),				 color_palette (option_editor_bg_marked),			color_palette (option_editor_bg_marked_abnormal),			     color_palette (option_editor_bg_highlighted)	);    edit_set_cursor_color (			      color_palette (option_editor_fg_cursor)	);#ifdef GTK    /* *********** */#else    if (!EditExposeRedraw)	set_cursor_position (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);#endif#endif    render_edit_text (edit, row_start, col_start, row_end, col_end);    if (edit->force)		/* edit->force != 0 means a key was pending and the redraw 				   was halted, so next time we must redraw everything in case stuff				   was left undrawn from a previous key press */	edit->force |= REDRAW_PAGE;#ifndef MIDNIGHT    if (f)	edit_render_tidbits (edit->widget);#endif}#ifndef MIDNIGHTvoid edit_render_expose (WEdit * edit, XExposeEvent * xexpose){    int row_start, col_start, row_end, col_end;    CPushFont ("editor", 0);    EditExposeRedraw = 1;    edit->num_widget_lines = (CHeightOf (edit->widget) - EDIT_FRAME_H) / FONT_PIX_PER_LINE;    edit->num_widget_columns = (CWidthOf (edit->widget) - EDIT_FRAME_W) / FONT_MEAN_WIDTH;    if (edit->force & (REDRAW_PAGE | REDRAW_COMPLETELY)) {	edit->force |= REDRAW_PAGE | REDRAW_COMPLETELY;	edit_render_keypress (edit);    } else {	edit_convert_expose_to_area (xexpose, &row_start, &col_start, &row_end, &col_end);	edit_render (edit, 1, row_start, col_start, row_end, col_end);    }    CPopFont ();    EditExposeRedraw = 0;}void edit_render_keypress (WEdit * edit){    CPushFont ("editor", 0);    edit_render (edit, 0, 0, 0, 0, 0);    CPopFont ();}#elsevoid edit_render_keypress (WEdit * edit){    edit_render (edit, 0, 0, 0, 0, 0);}#endif

⌨️ 快捷键说明

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