1 /* editor text drawing.
3 Copyright (C) 1996, 1997 the Free Software Foundation
5 Authors: 1996, 1997 Paul Sheer
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 #define MAX_LINE_LEN 1024
30 #if ! defined (MIDNIGHT) && ! defined (GTK)
32 #include "coollocal.h"
37 #include "../src/charsets.h"
40 extern int column_highlighting
;
42 #if defined (MIDNIGHT) || defined (GTK)
44 static void status_string (WEdit
* edit
, char *s
, int w
, int fill
, int font_width
)
49 * If we are at the end of file, print <EOF>,
50 * otherwise print the current character as is (if printable),
51 * as decimal and as hex.
53 if (edit
->curs1
< edit
->last_byte
) {
54 unsigned char cur_byte
= edit_get_byte (edit
, edit
->curs1
);
55 g_snprintf (byte_str
, sizeof(byte_str
), "%c %3d 0x%02X",
56 is_printable(cur_byte
) ? cur_byte
: '.',
60 strcpy(byte_str
, "<EOF>");
63 /* The field lengths just prevent the status line from shortening too much */
65 "[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb)= %s",
66 edit
->mark1
!= edit
->mark2
? ( column_highlighting
? 'C' : 'B') : '-',
67 edit
->modified
? 'M' : '-',
68 edit
->macro_i
< 0 ? '-' : 'R',
69 edit
->overwrite
== 0 ? '-' : 'O',
70 edit
->curs_col
/ font_width
,
75 edit
->total_lines
+ 1,
82 #endif /* MIDNIGHT || GTK */
86 /* how to get as much onto the status line as is numerically possible :) */
87 void edit_status (WEdit
* edit
)
91 w
= edit
->widget
.cols
- (edit
->have_frame
* 2);
96 attrset (SELECTED_COLOR
);
98 widget_move (edit
, edit
->have_frame
, edit
->have_frame
);
99 i
= w
> 24 ? 18 : w
- 6;
101 strcpy (s
, (char *) name_trunc (edit
->filename
? edit
->filename
: "", i
));
107 status_string (edit
, s
+ 20, t
, ' ', 1);
111 printw ("%-*s", w
, s
);
112 attrset (NORMAL_COLOR
);
119 void render_status (CWidget
* wdt
, int expose
);
123 void edit_status (WEdit
*edit
)
128 w
= edit
->num_widget_columns
- 1;
135 i
= w
> 24 ? 18 : w
- 6;
137 strcpy (s
, (char *) name_trunc (edit
->filename
? edit
->filename
: "", i
));
144 status_string (edit
, s
+ i
+ 2, t
, 0, FONT_MEAN_WIDTH
);
147 entry
= GTK_ENTRY (edit
->widget
->status
);
148 if (strcmp (s
, gtk_entry_get_text (entry
)))
149 gtk_entry_set_text (entry
, s
);
154 void edit_status (WEdit
* edit
)
156 long start_mark
, end_mark
;
162 if (eval_marks (edit
, &start_mark
, &end_mark
))
163 end_mark
= start_mark
= 0;
164 if ((COptionsOf (edit
->widget
) & EDITOR_NO_TEXT
))
166 CPushFont ("editor", 0);
167 m
= edit
->stat
.st_mode
;
168 p
= edit
->filename
? edit
->filename
: "";
169 sprintf (s
, "\034%c%s\033\035 \034-%c%c%c%c%c%c%c%c%c\035 \034%s%s%s%c\035 \034\030%02ld\033\035 \034%-4ld+%2ld=\030%4ld\033/%3ld\035 \034*%-5ld/%5ldb=%c%3d\035%c \034\001%ld\033\035",
170 *p
? '\033' : '\003', *p
? (char *) name_trunc (p
, max (edit
->num_widget_lines
/ 3, 16)) : _ ("<unnamed>"),
171 m
& S_IRUSR
? 'r' : '-',
172 m
& S_IWUSR
? 'w' : '-',
173 m
& S_IXUSR
? 'x' : '-',
174 m
& S_IRGRP
? 'r' : '-',
175 m
& S_IWGRP
? 'w' : '-',
176 m
& S_IXGRP
? 'x' : '-',
177 m
& S_IROTH
? 'r' : '-',
178 m
& S_IWOTH
? 'w' : '-',
179 m
& S_IXOTH
? 'x' : '-',
180 end_mark
- start_mark
|| (edit
->mark2
== -1 && !edit
->highlight
) ? (column_highlighting
? "\032C\033" : "\001B\033") : "-",
181 edit
->modified
? "\012M\033" : "-", edit
->macro_i
< 0 ? "-" : "\023R\033",
182 edit
->overwrite
== 0 ? '-' : 'O',
183 edit
->curs_col
/ FONT_MEAN_WIDTH
, edit
->start_line
+ 1, edit
->curs_row
,
184 edit
->curs_line
+ 1, edit
->total_lines
+ 1, edit
->curs1
,
185 edit
->last_byte
, edit
->curs1
== edit
->last_byte
? '\014' : '\033', edit
->curs1
< edit
->last_byte
186 ? edit_get_byte (edit
, edit
->curs1
) : -1,
187 end_mark
- start_mark
&& !column_highlighting
? ' ' : '\0',
188 end_mark
- start_mark
);
189 strcpy (id
, CIdentOf (edit
->widget
));
190 strcat (id
, ".text");
193 wdt
->text
= (char *) strdup (s
);
194 CSetWidgetSize (id
, CWidthOf (edit
->widget
), CHeightOf (wdt
));
195 render_status (wdt
, 0);
201 #endif /* !MIDNIGHT */
204 /* result is boolean */
205 int cursor_in_screen (WEdit
* edit
, long row
)
207 if (row
< 0 || row
>= edit
->num_widget_lines
)
213 /* returns rows from the first displayed line to the cursor */
214 int cursor_from_display_top (WEdit
* edit
)
216 if (edit
->curs1
< edit
->start_display
)
217 return -edit_move_forward (edit
, edit
->curs1
, 0, edit
->start_display
);
219 return edit_move_forward (edit
, edit
->start_display
, 0, edit
->curs1
);
222 /* returns how far the cursor is out of the screen */
223 int cursor_out_of_screen (WEdit
* edit
)
225 int row
= cursor_from_display_top (edit
);
226 if (row
>= edit
->num_widget_lines
)
227 return row
- edit
->num_widget_lines
+ 1;
234 int edit_width_of_long_printable (int c
);
237 /* this scrolls the text so that cursor is on the screen */
238 void edit_scroll_screen_over_cursor (WEdit
* edit
)
242 int b_extreme
, t_extreme
, l_extreme
, r_extreme
;
243 r_extreme
= EDIT_RIGHT_EXTREME
;
244 l_extreme
= EDIT_LEFT_EXTREME
;
245 b_extreme
= EDIT_BOTTOM_EXTREME
;
246 t_extreme
= EDIT_TOP_EXTREME
;
247 if (edit
->found_len
) {
248 b_extreme
= max (edit
->num_widget_lines
/ 4, b_extreme
);
249 t_extreme
= max (edit
->num_widget_lines
/ 4, t_extreme
);
251 if (b_extreme
+ t_extreme
+ 1 > edit
->num_widget_lines
) {
253 n
= b_extreme
+ t_extreme
;
254 b_extreme
= (b_extreme
* (edit
->num_widget_lines
- 1)) / n
;
255 t_extreme
= (t_extreme
* (edit
->num_widget_lines
- 1)) / n
;
257 if (l_extreme
+ r_extreme
+ 1 > edit
->num_widget_columns
) {
259 n
= l_extreme
+ t_extreme
;
260 l_extreme
= (l_extreme
* (edit
->num_widget_columns
- 1)) / n
;
261 r_extreme
= (r_extreme
* (edit
->num_widget_columns
- 1)) / n
;
263 p
= edit_get_col (edit
);
264 edit_update_curs_row (edit
);
266 outby
= p
+ edit
->start_col
- edit
->num_widget_columns
+ 1 + (r_extreme
+ edit
->found_len
);
268 outby
= p
+ edit
->start_col
- CWidthOf (edit
->widget
) + 7 + (r_extreme
+ edit
->found_len
) * FONT_MEAN_WIDTH
+ edit_width_of_long_printable (edit_get_byte (edit
, edit
->curs1
));
271 edit_scroll_right (edit
, outby
);
273 outby
= l_extreme
- p
- edit
->start_col
;
275 outby
= l_extreme
* FONT_MEAN_WIDTH
- p
- edit
->start_col
;
278 edit_scroll_left (edit
, outby
);
280 outby
= p
- edit
->num_widget_lines
+ 1 + b_extreme
;
282 edit_scroll_downward (edit
, outby
);
283 outby
= t_extreme
- p
;
285 edit_scroll_upward (edit
, outby
);
286 edit_update_curs_row (edit
);
292 #define CACHE_WIDTH 256
293 #define CACHE_HEIGHT 128
295 int EditExposeRedraw
= 0;
299 * background colors: marked is refers to mouse highlighting,
300 * highlighted refers to a found string.
302 unsigned long edit_abnormal_color
, edit_marked_abnormal_color
;
303 unsigned long edit_highlighted_color
, edit_marked_color
;
304 unsigned long edit_normal_background_color
;
306 /* foreground colors */
307 unsigned long edit_normal_foreground_color
, edit_bold_color
;
308 unsigned long edit_italic_color
;
311 unsigned long edit_cursor_color
;
313 void edit_set_foreground_colors (unsigned long normal
, unsigned long bold
, unsigned long italic
)
315 edit_normal_foreground_color
= normal
;
316 edit_bold_color
= bold
;
317 edit_italic_color
= italic
;
320 void edit_set_background_colors (unsigned long normal
, unsigned long abnormal
, unsigned long marked
, unsigned long marked_abnormal
, unsigned long highlighted
)
322 edit_abnormal_color
= abnormal
;
323 edit_marked_abnormal_color
= marked_abnormal
;
324 edit_marked_color
= marked
;
325 edit_highlighted_color
= highlighted
;
326 edit_normal_background_color
= normal
;
329 void edit_set_cursor_color (unsigned long c
)
331 edit_cursor_color
= c
;
336 #define set_color(font) attrset (font)
338 #define edit_move(x,y) widget_move(edit, y, x);
340 static void print_to_widget (WEdit
* edit
, long row
, int start_col
, float start_col_real
, long end_col
, unsigned int line
[])
342 int x
= (float) start_col_real
+ EDIT_TEXT_HORIZONTAL_OFFSET
;
343 int x1
= start_col
+ EDIT_TEXT_HORIZONTAL_OFFSET
;
344 int y
= row
+ EDIT_TEXT_VERTICAL_OFFSET
;
346 set_color (EDITOR_NORMAL_COLOR
);
348 hline (' ', end_col
+ 1 - EDIT_TEXT_HORIZONTAL_OFFSET
- x1
);
350 edit_move (x
+ FONT_OFFSET_X
, y
+ FONT_OFFSET_Y
);
352 unsigned int *p
= line
;
358 textchar
= *p
& 0xFF;
360 if (!(style
& (0xFF - MOD_ABNORMAL
- MOD_CURSOR
)))
361 SLsmg_set_color ((*p
& 0x007F0000) >> 16);
363 if (style
& MOD_ABNORMAL
)
365 if (style
& MOD_HIGHLIGHTED
) {
366 set_color (EDITOR_BOLD_COLOR
);
367 } else if (style
& MOD_MARKED
) {
368 set_color (EDITOR_MARKED_COLOR
);
370 if (style
& MOD_UNDERLINED
) {
371 set_color (EDITOR_UNDERLINED_COLOR
);
373 if (style
& MOD_BOLD
) {
374 set_color (EDITOR_BOLD_COLOR
);
382 /* b is a pointer to the beginning of the line */
383 static void edit_draw_this_line (WEdit
* edit
, long b
, long row
, long start_col
, long end_col
)
385 static unsigned int line
[MAX_LINE_LEN
];
386 unsigned int *p
= line
;
387 long m1
= 0, m2
= 0, q
, c1
, c2
;
388 int col
, start_col_real
;
391 int i
, book_mark
= -1;
394 if (!book_mark_query (edit
, edit
->start_line
+ row
, &book_mark
))
398 edit_get_syntax_color (edit
, b
- 1, &fg
, &bg
);
399 q
= edit_move_forward3 (edit
, b
, start_col
- edit
->start_col
, 0);
400 start_col_real
= (col
= (int) edit_move_forward3 (edit
, b
, 0, q
)) + edit
->start_col
;
401 c1
= min (edit
->column1
, edit
->column2
);
402 c2
= max (edit
->column1
, edit
->column2
);
404 if (col
+ 16 > -edit
->start_col
) {
405 eval_marks (edit
, &m1
, &m2
);
407 if (row
<= edit
->total_lines
- edit
->start_line
) {
408 while (col
<= end_col
- edit
->start_col
) {
410 if (q
== edit
->curs1
)
411 *p
|= MOD_CURSOR
* 256;
412 if (q
>= m1
&& q
< m2
) {
413 if (column_highlighting
) {
415 x
= edit_move_forward3 (edit
, b
, 0, q
);
416 if (x
>= c1
&& x
< c2
)
417 *p
|= MOD_MARKED
* 256;
419 *p
|= MOD_MARKED
* 256;
421 if (q
== edit
->bracket
)
422 *p
|= MOD_BOLD
* 256;
423 if (q
>= edit
->found_start
&& q
< edit
->found_start
+ edit
->found_len
)
424 *p
|= MOD_HIGHLIGHTED
* 256;
425 c
= edit_get_byte (edit
, q
);
426 /* we don't use bg for mc - fg contains both */
427 if (book_mark
== -1) {
428 edit_get_syntax_color (edit
, q
, &fg
, &bg
);
431 *p
|= book_mark
<< 16;
436 col
= end_col
- edit
->start_col
+ 1; /* quit */
440 i
= TAB_SIZE
- ((int) col
% TAB_SIZE
);
442 c
= *(p
++) & (0xFFFFFFFF - MOD_CURSOR
* 256);
451 if (c
>= 0 && c
<= 255)
454 if (is_printable (c
)) {
458 *p
|= (256 * MOD_ABNORMAL
);
466 start_col_real
= start_col
= 0;
470 print_to_widget (edit
, row
, start_col
, start_col_real
, end_col
, line
);
477 #define key_pending(x) (!is_idle())
481 #define edit_draw_this_line edit_draw_this_line_proportional
483 int option_smooth_scrolling
= 0;
485 static int key_pending (WEdit
* edit
)
490 static int flush
= 0, line
= 0;
493 } else if (!(edit
->force
& REDRAW_COMPLETELY
) && !EditExposeRedraw
&& !option_smooth_scrolling
) {
494 /* this flushes the display in logarithmic intervals - so both fast and
495 slow machines will get good performance vs nice-refreshing */
496 if ((1 << flush
) == ++line
) {
498 return CKeyPending ();
508 static void edit_draw_this_char (WEdit
* edit
, long curs
, long row
)
510 int b
= edit_bol (edit
, curs
);
512 edit_draw_this_line (edit
, b
, row
, 0, edit
->num_widget_columns
- 1);
514 edit_draw_this_line (edit
, b
, row
, 0, CWidthOf (edit
->widget
));
518 /* cursor must be in screen for other than REDRAW_PAGE passed in force */
519 void render_edit_text (WEdit
* edit
, long start_row
, long start_column
, long end_row
,
522 long row
= 0, curs_row
;
523 static int prev_curs_row
= 0;
524 static int prev_start_col
= 0;
525 static long prev_curs
= 0;
526 static long prev_start
= -1;
529 static unsigned long prev_win
= 0;
532 int force
= edit
->force
;
535 CPushFont ("editor", 0);
542 * If the position of the page has not moved then we can draw the cursor
543 * character only. This will prevent line flicker when using arrow keys.
545 if ((!(force
& REDRAW_CHAR_ONLY
)) || (force
& REDRAW_PAGE
)
548 || prev_win
!= ((GdkWindowPrivate
*) CWindowOf (edit
->widget
)->text_area
)->xwindow
550 || prev_win
!= CWindowOf (edit
->widget
)
554 #if !defined(MIDNIGHT) && !defined(GTK)
555 int time_division
= 5;
561 prev_start
= edit
->start_line
;
562 if (option_smooth_scrolling
&& prev_win
== CWindowOf (edit
->widget
) && !edit
->screen_modified
) {
565 i
= edit
->start_line
- prev_start
;
566 if (i
<= time_division
&& i
> 0) {
567 edit_draw_proportional (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
568 for (pos2
= 0, t
= 0; t
< time_division
; t
++) {
570 pos1
= FONT_PIX_PER_LINE
* i
* (t
+ 1) / time_division
;
573 XCopyArea (CDisplay
, edit
->widget
->winid
, edit
->widget
->winid
, CGC
,
574 EDIT_TEXT_HORIZONTAL_OFFSET
,
575 EDIT_TEXT_VERTICAL_OFFSET
+ move
,
576 edit
->widget
->width
- EDIT_FRAME_W
,
577 edit
->widget
->height
- EDIT_FRAME_H
- move
,
578 EDIT_TEXT_HORIZONTAL_OFFSET
, EDIT_TEXT_VERTICAL_OFFSET
);
579 XClearArea (CDisplay
, edit
->widget
->winid
, EDIT_TEXT_HORIZONTAL_OFFSET
,
580 edit
->widget
->height
- EDIT_FRAME_H
+
581 EDIT_TEXT_VERTICAL_OFFSET
- move
,
582 edit
->widget
->width
- EDIT_FRAME_W
, move
, 0);
586 } else if (i
>= -time_division
&& i
< 0) {
587 edit_draw_proportional (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
589 for (pos2
= 0, t
= 0; t
< time_division
; t
++) {
591 pos1
= FONT_PIX_PER_LINE
* i
* (t
+ 1) / time_division
;
594 XCopyArea (CDisplay
, edit
->widget
->winid
, edit
->widget
->winid
, CGC
,
595 EDIT_TEXT_HORIZONTAL_OFFSET
, EDIT_TEXT_VERTICAL_OFFSET
,
596 edit
->widget
->width
- EDIT_FRAME_W
,
597 edit
->widget
->height
- EDIT_FRAME_H
-
598 move
, EDIT_TEXT_HORIZONTAL_OFFSET
, EDIT_TEXT_VERTICAL_OFFSET
+ move
);
599 XClearArea (CDisplay
, edit
->widget
->winid
, EDIT_TEXT_HORIZONTAL_OFFSET
,
600 EDIT_TEXT_VERTICAL_OFFSET
,
601 edit
->widget
->width
- EDIT_FRAME_W
, move
, 0);
608 if (!(force
& REDRAW_IN_BOUNDS
)) { /* !REDRAW_IN_BOUNDS means to ignore bounds and redraw whole rows */
610 end_row
= edit
->num_widget_lines
- 1;
613 end_column
= edit
->num_widget_columns
- 1;
615 end_column
= CWidthOf (edit
->widget
);
618 if (force
& REDRAW_PAGE
) {
620 b
= edit_move_forward (edit
, edit
->start_display
, start_row
, 0);
621 while (row
<= end_row
) {
622 if (key_pending (edit
))
624 edit_draw_this_line (edit
, b
, row
, start_column
, end_column
);
625 b
= edit_move_forward (edit
, b
, 1, 0);
629 curs_row
= edit
->curs_row
;
631 if (force
& REDRAW_BEFORE_CURSOR
) {
632 if (start_row
< curs_row
) {
633 long upto
= curs_row
- 1 <= end_row
? curs_row
- 1 : end_row
;
635 b
= edit
->start_display
;
636 while (row
<= upto
) {
637 if (key_pending (edit
))
639 edit_draw_this_line (edit
, b
, row
, start_column
, end_column
);
640 b
= edit_move_forward (edit
, b
, 1, 0);
644 /* if (force & REDRAW_LINE) ---> default */
645 b
= edit_bol (edit
, edit
->curs1
);
646 if (curs_row
>= start_row
&& curs_row
<= end_row
) {
647 if (key_pending (edit
))
649 edit_draw_this_line (edit
, b
, curs_row
, start_column
, end_column
);
651 if (force
& REDRAW_AFTER_CURSOR
) {
652 if (end_row
> curs_row
) {
653 row
= curs_row
+ 1 < start_row
? start_row
: curs_row
+ 1;
654 b
= edit_move_forward (edit
, b
, 1, 0);
655 while (row
<= end_row
) {
656 if (key_pending (edit
))
658 edit_draw_this_line (edit
, b
, row
, start_column
, end_column
);
659 b
= edit_move_forward (edit
, b
, 1, 0);
664 if (force
& REDRAW_LINE_ABOVE
&& curs_row
>= 1) {
666 b
= edit_move_backward (edit
, edit_bol (edit
, edit
->curs1
), 1);
667 if (row
>= start_row
&& row
<= end_row
) {
668 if (key_pending (edit
))
670 edit_draw_this_line (edit
, b
, row
, start_column
, end_column
);
673 if (force
& REDRAW_LINE_BELOW
&& row
< edit
->num_widget_lines
- 1) {
675 b
= edit_bol (edit
, edit
->curs1
);
676 b
= edit_move_forward (edit
, b
, 1, 0);
677 if (row
>= start_row
&& row
<= end_row
) {
678 if (key_pending (edit
))
680 edit_draw_this_line (edit
, b
, row
, start_column
, end_column
);
685 if (prev_curs_row
< edit
->curs_row
) { /* with the new text highlighting, we must draw from the top down */
686 edit_draw_this_char (edit
, prev_curs
, prev_curs_row
);
687 edit_draw_this_char (edit
, edit
->curs1
, edit
->curs_row
);
689 edit_draw_this_char (edit
, edit
->curs1
, edit
->curs_row
);
690 edit_draw_this_char (edit
, prev_curs
, prev_curs_row
);
696 prev_curs_row
= edit
->curs_row
;
697 prev_curs
= edit
->curs1
;
698 prev_start_col
= edit
->start_col
;
701 prev_win
= ((GdkWindowPrivate
*) CWindowOf (edit
->widget
)->text_area
)->xwindow
;
703 prev_win
= CWindowOf (edit
->widget
);
707 edit
->screen_modified
= 0;
708 prev_start
= edit
->start_line
;
717 void edit_convert_expose_to_area (XExposeEvent
* xexpose
, int *row1
, int *col1
, int *row2
, int *col2
)
719 *col1
= xexpose
->x
- EDIT_TEXT_HORIZONTAL_OFFSET
;
720 *row1
= (xexpose
->y
- EDIT_TEXT_VERTICAL_OFFSET
) / FONT_PIX_PER_LINE
;
721 *col2
= xexpose
->x
+ xexpose
->width
+ EDIT_TEXT_HORIZONTAL_OFFSET
+ 3;
722 *row2
= (xexpose
->y
+ xexpose
->height
- EDIT_TEXT_VERTICAL_OFFSET
) / FONT_PIX_PER_LINE
;
727 void edit_render_tidbits (GtkEdit
* edit
)
729 gtk_widget_draw_focus (GTK_WIDGET (edit
));
734 void edit_render_tidbits (CWidget
* wdt
)
737 int w
= wdt
->width
, h
= wdt
->height
;
741 isfocussed
= (win
== CGetFocus ());
742 CSetColor (COLOR_FLAT
);
744 render_bevel (win
, 0, 0, w
- 1, h
- 1, 1, 1); /*most outer border bevel */
747 render_bevel (win
, 0, 0, w
- 1, h
- 1, 3, 1); /*most outer border bevel */
749 render_bevel (win
, 2, 2, w
- 3, h
- 3, 1, 1); /*border bevel */
750 render_bevel (win
, 0, 0, w
- 1, h
- 1, 2, 0); /*most outer border bevel */
757 void edit_set_space_width (int s
);
758 extern int option_long_whitespace
;
762 void edit_render (WEdit
* edit
, int page
, int row_start
, int col_start
, int row_end
, int col_end
)
768 if (page
) /* if it was an expose event, 'page' would be set */
769 edit
->force
|= REDRAW_PAGE
| REDRAW_IN_BOUNDS
;
770 f
= edit
->force
& (REDRAW_PAGE
| REDRAW_COMPLETELY
);
773 if (edit
->force
& REDRAW_COMPLETELY
)
774 redraw_labels (edit
->widget
.parent
, (Widget
*) edit
);
776 if (option_long_whitespace
)
777 edit_set_space_width (FONT_PER_CHAR
[' '] * 2);
779 edit_set_space_width (FONT_PER_CHAR
[' ']);
781 win
= (GtkEdit
*) edit
->widget
;
783 edit_set_foreground_colors (
784 color_palette (option_editor_fg_normal
),
785 color_palette (option_editor_fg_bold
),
786 color_palette (option_editor_fg_italic
)
788 edit_set_background_colors (
789 color_palette (option_editor_bg_normal
),
790 color_palette (option_editor_bg_abnormal
),
791 color_palette (option_editor_bg_marked
),
792 color_palette (option_editor_bg_marked_abnormal
),
793 color_palette (option_editor_bg_highlighted
)
795 edit_set_cursor_color (
796 color_palette (option_editor_fg_cursor
)
802 if (!EditExposeRedraw
)
803 set_cursor_position (0, 0, 0, 0, 0, 0, 0, 0, 0);
806 render_edit_text (edit
, row_start
, col_start
, row_end
, col_end
);
808 * edit->force != 0 means a key was pending and the redraw
809 * was halted, so next time we must redraw everything in case stuff
810 * was left undrawn from a previous key press.
813 edit
->force
|= REDRAW_PAGE
;
816 edit_render_tidbits (edit
->widget
);
818 /* ***************** */
821 CSetColor (edit_normal_background_color
);
822 CLine (CWindowOf (edit
->widget
), 3, 3, 3, CHeightOf (edit
->widget
) - 4);
830 void edit_render_expose (WEdit
* edit
, XExposeEvent
* xexpose
)
832 int row_start
, col_start
, row_end
, col_end
;
833 CPushFont ("editor", 0);
834 EditExposeRedraw
= 1;
835 edit
->num_widget_lines
= (CHeightOf (edit
->widget
) - EDIT_FRAME_H
) / FONT_PIX_PER_LINE
;
836 edit
->num_widget_columns
= (CWidthOf (edit
->widget
) - EDIT_FRAME_W
) / FONT_MEAN_WIDTH
;
837 if (edit
->force
& (REDRAW_PAGE
| REDRAW_COMPLETELY
)) {
838 edit
->force
|= REDRAW_PAGE
| REDRAW_COMPLETELY
;
839 edit_render_keypress (edit
);
841 edit_convert_expose_to_area (xexpose
, &row_start
, &col_start
, &row_end
, &col_end
);
842 edit_render (edit
, 1, row_start
, col_start
, row_end
, col_end
);
845 EditExposeRedraw
= 0;
848 void edit_render_keypress (WEdit
* edit
)
850 CPushFont ("editor", 0);
851 edit_render (edit
, 0, 0, 0, 0, 0);
857 void edit_render_keypress (WEdit
* edit
)
859 edit_render (edit
, 0, 0, 0, 0, 0);