1 /* propfont.c - editor text drawing for proportional fonts.
2 Copyright (C) 1997 Paul Sheer
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #if defined (HAVE_MAD) && ! defined (MIDNIGHT) && ! defined (GTK)
26 /* this file definatively relies on int being 32 bits or more */
28 int option_long_whitespace
= 0;
30 #define MAX_LINE_LEN 1024
31 #define CACHE_WIDTH 256
32 #define CACHE_HEIGHT 128
37 cache_type data
[CACHE_WIDTH
];
40 extern unsigned char per_char
[256];
42 /* background colors: marked is refers to mouse highlighting, highlighted refers to a found string. */
43 extern unsigned long edit_abnormal_color
, edit_marked_abnormal_color
;
44 extern unsigned long edit_highlighted_color
, edit_marked_color
;
45 extern unsigned long edit_normal_background_color
;
47 /* foreground colors */
48 extern unsigned long edit_normal_foreground_color
, edit_bold_color
;
49 extern unsigned long edit_italic_color
;
52 extern unsigned long edit_cursor_color
;
54 extern int EditExposeRedraw
;
61 cache_type s
, unsigned long *fg
, unsigned long *bg
)
63 int fgp
, bgp
, underlined
= 0;
64 fgp
= (s
& 0xFF000000UL
) >> 24;
65 /* NO_COLOR would give fgp == 255 */
67 *fg
= color_palette (fgp
);
69 *fg
= edit_normal_foreground_color
;
70 bgp
= (s
& 0x00FF0000) >> 16;
74 *bg
= color_palette (bgp
);
76 *bg
= edit_normal_background_color
;
77 if (!(s
& 0xFFFFFF00UL
)) /* check this first as an optimization */
79 if (s
& (MOD_ABNORMAL
* 256)) {
80 *bg
= edit_abnormal_color
;
81 if (s
& (MOD_MARKED
* 256))
82 *bg
= edit_marked_abnormal_color
;
83 } else if (s
& (MOD_HIGHLIGHTED
* 256)) {
84 *bg
= edit_highlighted_color
;
85 } else if (s
& (MOD_MARKED
* 256)) {
86 *bg
= edit_marked_color
;
88 if (s
& (MOD_BOLD
* 256))
89 *fg
= edit_bold_color
;
90 if (s
& (MOD_ITALIC
* 256))
91 *fg
= edit_italic_color
;
92 if (s
& (MOD_INVERSE
* 256)) {
97 if (*bg
== COLOR_BLACK
)
98 *bg
= color_palette (1);
104 #define set_style_color(s,f,b) set_style_color(win,s,f,b)
109 static inline int next_tab_pos (int x
)
111 return x
+= tab_width
- x
% tab_width
;
114 /* this now properly uses ctypes */
115 static inline int convert_to_long_printable (int c
, unsigned char *t
)
123 if (option_long_whitespace
) {
127 return per_char
[' '] + per_char
[' '];
131 return per_char
[' '];
134 if (option_international_characters
&& per_char
[c
]) {
140 t
[0] = ("0123456789ABCDEF")[c
>> 4];
141 t
[1] = ("0123456789ABCDEF")[c
& 0xF];
144 return per_char
[t
[0]] + per_char
[t
[1]] + per_char
[t
[2]];
149 return per_char
[t
[0]] + per_char
[t
[1]];
152 /* same as above but just gets the length */
153 static inline int width_of_long_printable (int c
)
158 if (option_long_whitespace
)
159 return per_char
[' '] + per_char
[' '];
161 return per_char
[' '];
163 if (option_international_characters
&& per_char
[c
])
166 return per_char
[(unsigned char) ("0123456789ABCDEF")[c
>> 4]] + per_char
[(unsigned char) ("0123456789ABCDEF")[c
& 0xF]] + per_char
[(unsigned char) 'h'];
167 return per_char
['^'] + per_char
[c
+ '@'];
170 int edit_width_of_long_printable (int c
)
172 return width_of_long_printable (c
);
175 /* returns x pixel pos of char at offset *q with x not more than l */
176 int calc_text_pos (WEdit
* edit
, long b
, long *q
, int l
)
180 c
= edit_get_byte (edit
, b
);
184 if (x
> edit
->max_column
)
185 edit
->max_column
= x
;
188 xn
= next_tab_pos (x
);
191 xn
= x
+ width_of_long_printable (c
);
200 if (x
> edit
->max_column
)
201 edit
->max_column
= x
;
206 /* calcs pixel length of the line beginning at b up to upto */
207 int calc_text_len (WEdit
* edit
, long b
, long upto
)
212 if (x
> edit
->max_column
)
213 edit
->max_column
= x
;
216 c
= edit_get_byte (edit
, b
);
219 if (x
> edit
->max_column
)
220 edit
->max_column
= x
;
224 x
= next_tab_pos (x
);
227 x
+= width_of_long_printable (c
);
234 /* If pixels is zero this returns the count of pixels from current to upto. */
235 /* If upto is zero returns index of pixels across from current. */
236 long edit_move_forward3 (WEdit
* edit
, long current
, int pixels
, long upto
)
239 return calc_text_len (edit
, current
, upto
);
242 calc_text_pos (edit
, current
, &q
, pixels
);
248 extern int column_highlighting
;
250 /* gets the characters style (eg marked, highlighted) from its position in the edit buffer */
251 static inline cache_type
get_style_fast (WEdit
* edit
, long q
, int c
)
255 if (!(isprint (c
) || (option_international_characters
&& per_char
[c
])))
256 if (c
!= '\n' && c
!= '\t')
257 s
|= MOD_ABNORMAL
* 256;
258 edit_get_syntax_color (edit
, q
, (int *) &fg
, (int *) &bg
);
259 return s
| ((fg
& 0xFF) << 24) | ((bg
& 0xFF) << 16);
262 /* gets the characters style (eg marked, highlighted) from its position in the edit buffer */
263 static inline cache_type
get_style (WEdit
* edit
, long q
, int c
, long m1
, long m2
, int x
)
267 if (q
== edit
->curs1
)
268 s
|= MOD_CURSOR
* 256;
269 if (q
>= m1
&& q
< m2
) {
270 if (column_highlighting
) {
271 if ((x
>= edit
->column1
&& x
< edit
->column2
)
272 || (x
>= edit
->column2
&& x
< edit
->column1
))
273 s
|= MOD_INVERSE
* 256;
275 s
|= MOD_MARKED
* 256;
278 if (q
== edit
->bracket
)
280 if (q
>= edit
->found_start
&& q
< edit
->found_start
+ edit
->found_len
)
281 s
|= MOD_HIGHLIGHTED
* 256;
282 if (!(isprint (c
) || (option_international_characters
&& per_char
[c
])))
283 if (c
!= '\n' && c
!= '\t')
284 s
|= MOD_ABNORMAL
* 256;
285 edit_get_syntax_color (edit
, q
, (int *) &fg
, (int *) &bg
);
286 return s
| ((fg
& 0xFF) << 24) | ((bg
& 0xFF) << 16);
289 void convert_text (WEdit
* edit
, long q
, cache_type
* p
, int x
, int x_max
, int row
)
294 unsigned char *r
, text
[4];
295 int book_mark_colors
[10], book_mark
;
296 eval_marks (edit
, &m1
, &m2
);
297 book_mark
= book_mark_query_all (edit
, edit
->start_line
+ row
, book_mark_colors
);
298 last
= q
+ (x_max
- x
) / 2 + 2; /* for optimization, we say that the last character
299 of this line cannot have an offset greater than this.
300 This can be used to rule out uncommon text styles,
301 like a character with a cursor, or selected text */
303 int the_end
= 0, book_mark_cycle
= 0;
305 c
= edit_get_byte (edit
, q
);
307 *p
= get_style (edit
, q
, c
, m1
, m2
, x
);
310 *p
= (*p
& 0x0000FFFF) | (book_mark_colors
[book_mark_cycle
++ % book_mark
] << 16);
320 t
= next_tab_pos (x
);
329 x
= next_tab_pos (x
);
334 x
+= convert_to_long_printable (c
, text
);
350 } else if ((m2
< q
|| m1
> last
) && (edit
->curs1
< q
|| edit
->curs1
> last
) && \
351 (edit
->found_start
+ edit
->found_len
< q
|| edit
->found_start
> last
) &&
352 (edit
->bracket
< q
|| edit
->bracket
> last
)) {
354 c
= edit_get_byte (edit
, q
);
355 *p
= get_style_fast (edit
, q
, c
);
360 if (x
> edit
->max_column
)
361 edit
->max_column
= x
;
366 t
= next_tab_pos (x
);
375 x
= next_tab_pos (x
);
379 x
+= convert_to_long_printable (c
, text
);
397 c
= edit_get_byte (edit
, q
);
398 *p
= get_style (edit
, q
, c
, m1
, m2
, x
);
403 if (x
> edit
->max_column
)
404 edit
->max_column
= x
;
409 t
= next_tab_pos (x
);
418 x
= next_tab_pos (x
);
422 x
+= convert_to_long_printable (c
, text
);
439 if (x
> edit
->max_column
)
440 edit
->max_column
= x
;
444 void edit_set_cursor (Window win
, int x
, int y
, int bg
, int fg
, int width
, char t
)
447 gdk_gc_set_foreground (win
->gc
, &win
->color
[18]);
448 gdk_draw_rectangle (win
->text_area
, win
->gc
, 0, x
, y
+ FONT_OVERHEAD
, width
- 1, FONT_HEIGHT
- 1);
450 CSetColor (edit_cursor_color
);
451 CLine (win
, x
, y
+ FONT_OVERHEAD
,
452 x
, y
+ FONT_HEIGHT
- 1); /* non focussed cursor form */
453 CLine (win
, x
+ 1, y
+ FONT_OVERHEAD
,
454 x
+ width
- 1, y
+ FONT_OVERHEAD
);
455 set_cursor_position (win
, x
, y
, width
, FONT_HEIGHT
, CURSOR_TYPE_EDITOR
, t
, bg
, fg
); /* widget library's flashing cursor */
459 static inline int next_tab (int x
, int scroll_right
)
461 return next_tab_pos (x
- scroll_right
- EDIT_TEXT_HORIZONTAL_OFFSET
) - x
+ scroll_right
+ EDIT_TEXT_HORIZONTAL_OFFSET
;
464 int draw_tab (Window win
, int x
, int y
, cache_type s
, int scroll_right
)
470 unsigned long fg
, bg
;
472 l
= next_tab (x
, scroll_right
);
474 set_style_color (s
, &fg
.pixel
, &bg
.pixel
);
475 gdk_gc_set_foreground (win
->gc
, &bg
);
476 gdk_draw_rectangle (win
->text_area
, win
->gc
, 1, x
, y
+ FONT_OVERHEAD
, l
, FONT_HEIGHT
);
477 /* if we printed a cursor: */
478 if (s
& (MOD_CURSOR
* 256))
479 edit_set_cursor (win
, x
, y
, bg
.pixel
, fg
.pixel
, per_char
[' '], ' ');
481 set_style_color (s
, &fg
, &bg
);
483 CRectangle (win
, x
, y
+ FONT_OVERHEAD
, l
, FONT_HEIGHT
);
484 /* if we printed a cursor: */
485 if (s
& (MOD_CURSOR
* 256))
486 edit_set_cursor (win
, x
, y
, bg
, fg
, per_char
[' '], ' ');
495 static inline void draw_space (Window win
, int x
, int y
, cache_type s
, int l
)
500 unsigned long fg
, bg
;
503 set_style_color (s
, &fg
.pixel
, &bg
.pixel
);
504 gdk_gc_set_foreground (win
->gc
, &bg
);
505 gdk_draw_rectangle (win
->text_area
, win
->gc
, 1, x
, y
+ FONT_OVERHEAD
, l
, FONT_HEIGHT
);
507 set_style_color (s
, &fg
, &bg
);
509 CRectangle (win
, x
, y
+ FONT_OVERHEAD
, l
, FONT_HEIGHT
);
510 /* if we printed a cursor: */
511 if (s
& (MOD_CURSOR
* 256))
512 edit_set_cursor (win
, x
, y
, bg
, fg
, per_char
[' '], ' ');
519 gdk_draw_image_text (GdkDrawable
*drawable
,
527 GdkWindowPrivate
*drawable_private
;
528 GdkFontPrivate
*font_private
;
529 GdkGCPrivate
*gc_private
;
531 g_return_if_fail (drawable
!= NULL
);
532 g_return_if_fail (font
!= NULL
);
533 g_return_if_fail (gc
!= NULL
);
534 g_return_if_fail (text
!= NULL
);
536 drawable_private
= (GdkWindowPrivate
*) drawable
;
537 if (drawable_private
->destroyed
)
539 gc_private
= (GdkGCPrivate
*) gc
;
540 font_private
= (GdkFontPrivate
*) font
;
542 if (font
->type
== GDK_FONT_FONT
)
544 XFontStruct
*xfont
= (XFontStruct
*) font_private
->xfont
;
545 XSetFont(drawable_private
->xdisplay
, gc_private
->xgc
, xfont
->fid
);
546 if ((xfont
->min_byte1
== 0) && (xfont
->max_byte1
== 0))
548 XDrawImageString (drawable_private
->xdisplay
, drawable_private
->xwindow
,
549 gc_private
->xgc
, x
, y
, text
, text_length
);
553 XDrawImageString16 (drawable_private
->xdisplay
, drawable_private
->xwindow
,
554 gc_private
->xgc
, x
, y
, (XChar2b
*) text
, text_length
/ 2);
557 else if (font
->type
== GDK_FONT_FONTSET
)
559 XFontSet fontset
= (XFontSet
) font_private
->xfont
;
560 XmbDrawImageString (drawable_private
->xdisplay
, drawable_private
->xwindow
,
561 fontset
, gc_private
->xgc
, x
, y
, text
, text_length
);
564 g_error("undefined font type\n");
570 int draw_string (Window win
, int x
, int y
, cache_type s
, unsigned char *text
, int length
)
575 unsigned long fg
, bg
;
579 set_style_color (s
, &fg
.pixel
, &bg
.pixel
);
580 gdk_gc_set_background (win
->gc
, &bg
);
581 gdk_gc_set_foreground (win
->gc
, &fg
);
582 gdk_draw_image_text (win
->text_area
, GTK_WIDGET (win
)->style
->font
, win
->gc
, x
+ FONT_OFFSET_X
, y
+ FONT_OFFSET_Y
, text
, length
);
584 underlined
= set_style_color (s
, &fg
, &bg
);
585 CSetBackgroundColor (bg
);
587 CImageString (win
, x
+ FONT_OFFSET_X
, y
+ FONT_OFFSET_Y
, (char *) text
, length
);
588 l
= CTextWidth (win
, (char *) text
, length
);
591 inc
= FONT_MEAN_WIDTH
* 2 / 3;
592 CSetColor (color_palette (18));
594 CLine (win
, x
, y
+ FONT_HEIGHT
+ FONT_OVERHEAD
- 1 - h
, x
+ min (l
, inc
- (x
% inc
) - 1), y
+ FONT_HEIGHT
+ FONT_OVERHEAD
- 1 - h
);
596 for (i
= inc
- min (l
, (x
% inc
)); i
< l
; i
+= inc
) {
597 CLine (win
, x
+ i
, y
+ FONT_HEIGHT
+ FONT_OVERHEAD
- 1 - h
, x
+ min (l
, i
+ inc
- 1), y
+ FONT_HEIGHT
+ FONT_OVERHEAD
- 1 - h
);
602 /* if we printed a cursor: */
604 if (s
& (MOD_CURSOR
* 256))
605 edit_set_cursor (win
, x
, y
, bg
.pixel
, fg
.pixel
, per_char
[*text
], *text
);
606 return x
+ gdk_text_width (GTK_WIDGET (win
)->style
->font
, text
, length
);
608 if (s
& (MOD_CURSOR
* 256))
609 edit_set_cursor (win
, x
, y
, bg
, fg
, per_char
[*text
], *text
);
614 #define STYLE_DIFF (*cache != *line \
615 || ((*cache | *line) & (MOD_CURSOR * 256)) \
616 || !*cache || !*line)
618 int get_ignore_length (cache_type
*cache
, cache_type
*line
)
621 for (i
= 0; i
< CACHE_WIDTH
; i
++, line
++, cache
++) {
628 static inline size_t lwstrnlen (const cache_type
*s
, size_t count
)
630 const cache_type
*sc
;
631 for (sc
= s
; count
-- && *sc
!= 0; ++sc
);
635 static inline size_t lwstrlen (const cache_type
*s
)
637 const cache_type
*sc
;
638 for (sc
= s
; *sc
!= 0; ++sc
);
642 int get_ignore_trailer (cache_type
*cache
, cache_type
*line
, int length
)
645 int cache_len
, line_len
;
646 cache_len
= lwstrnlen (cache
, CACHE_WIDTH
);
647 line_len
= lwstrlen (line
);
649 if (line_len
> cache_len
)
650 for (i
= line_len
- 1; i
>= cache_len
&& i
>= length
; i
--)
654 for (i
= cache_len
- 1, line
= line
+ i
, cache
= cache
+ i
; i
> length
; i
--, line
--, cache
--)
661 /* erases trailing bit of old line if a new line is printed over a longer old line */
662 static void cover_trail (Window win
, int x_start
, int x_new
, int x_old
, int y
)
664 if (x_new
< EDIT_TEXT_HORIZONTAL_OFFSET
)
665 x_new
= EDIT_TEXT_HORIZONTAL_OFFSET
;
666 if (x_new
< x_old
) { /* no need to print */
668 gdk_gc_set_foreground (win
->gc
, &win
->color
[1]);
669 gdk_draw_rectangle (win
->text_area
, win
->gc
, 1, x_new
, y
+ FONT_OVERHEAD
, x_old
- x_new
, FONT_HEIGHT
);
671 CSetColor (edit_normal_background_color
);
672 CRectangle (win
, x_new
, y
+ FONT_OVERHEAD
, x_old
- x_new
, FONT_HEIGHT
+ (FONT_OVERHEAD
!= 0 && !fixed_font
));
676 gdk_gc_set_foreground (win
->gc
, &win
->color
[1]);
678 CSetColor (edit_normal_background_color
);
681 /* true type fonts print stuff out of the bounding box (aaaaaaaaarrrgh!!) */
683 if (FONT_OVERHEAD
&& x_new
> EDIT_TEXT_HORIZONTAL_OFFSET
)
685 gdk_draw_line (win
->text_area
, win
->gc
, max (x_start
, EDIT_TEXT_HORIZONTAL_OFFSET
), y
+ FONT_HEIGHT
+ FONT_OVERHEAD
, x_new
- 1, y
+ FONT_HEIGHT
+ FONT_OVERHEAD
);
687 CLine (win
, max (x_start
, EDIT_TEXT_HORIZONTAL_OFFSET
), y
+ FONT_HEIGHT
+ FONT_OVERHEAD
, x_new
- 1, y
+ FONT_HEIGHT
+ FONT_OVERHEAD
);
691 cache_type mode_spacing
= 0;
693 #define NOT_VALID (-2000000000)
695 void edit_draw_proportional (void *data
,
696 void (*converttext
) (void *, long, cache_type
*, int, int, int),
697 int calctextpos (void *, long, long *, int),
707 static struct cache_line lines
[CACHE_HEIGHT
];
708 static Window last
= 0;
709 cache_type style
, line
[MAX_LINE_LEN
], *p
;
710 unsigned char text
[128];
711 int x0
, x
, ignore_text
= 0, ignore_trailer
= 2000000000, j
, i
;
714 tab_width
= tabwidth
;
715 if (option_long_whitespace
)
716 tab_width
= tabwidth
*= 2;
720 /* if its not the same window, reset the screen rememberer */
723 for (i
= 0; i
< CACHE_HEIGHT
; i
++) {
724 lines
[i
].x0
= NOT_VALID
;
728 /* get point to start drawing */
729 x0
= (*calctextpos
) (data
, b
, &q
, -scroll_right
+ x_offset
);
730 /* q contains the offset in the edit buffer */
732 /* translate this line into printable characters with a style (=color) high byte */
733 (*converttext
) (data
, q
, line
, x0
, x_max
- scroll_right
- EDIT_TEXT_HORIZONTAL_OFFSET
, row
);
735 /* adjust for the horizontal scroll and border */
736 x0
+= scroll_right
+ EDIT_TEXT_HORIZONTAL_OFFSET
;
739 /* is some of the line identical to that already printed so that we can ignore it? */
740 if (!EditExposeRedraw
) {
741 if (lines
[row
].x0
== x0
&& row
< CACHE_HEIGHT
) { /* i.e. also && lines[row].x0 != NOT_VALID */
742 ignore_text
= get_ignore_length (lines
[row
].data
, line
);
744 ignore_trailer
= get_ignore_trailer (lines
[row
].data
, line
, ignore_text
);
751 if ((*p
& 0x80) && (*p
& mode_spacing
)) {
752 #ifdef STILL_TO_BE_SUPPORTED
753 x
+= edit_insert_pixmap (win
, x
, y
, *p
& 0x7F);
754 /* the pixmap will be clipped, if it's taller than the
755 current font, else centred top to bottom */
762 if ((*p
& 0xFF) == '\t') {
764 if (j
> ignore_text
&& j
< ignore_trailer
+ 1)
765 x
= draw_tab (win
, x
, y
, *p
, scroll_right
);
767 x
+= next_tab (x
, scroll_right
);
771 style
= *p
& 0xFFFFFF00UL
;
774 text
[i
++] = (unsigned char) *p
++;
776 if (j
== ignore_text
|| j
== ignore_trailer
)
778 } while (i
< 128 && *p
&& style
== (*p
& 0xFFFFFF00UL
) && (*p
& 0xFF) != '\t');
780 if (style
& mode_spacing
) {
782 for (k
= 0; k
< i
; k
++) {
783 draw_space (win
, x
, y
, (0xFFFFFF00UL
- mode_spacing
) & style
, text
[k
]);
787 if (j
> ignore_text
&& j
< ignore_trailer
+ 1)
788 x
= draw_string (win
, x
, y
, style
, text
, i
);
791 x
+= gdk_text_width (GTK_WIDGET(win
)->style
->font
, text
, i
);
793 x
+= CTextWidth (win
, (char *) text
, i
);
800 if (!EditExposeRedraw
|| EditClear
)
801 cover_trail (win
, x0
, x
, lines
[row
].x1
, y
);
802 memcpy (&(lines
[row
].data
[ignore_text
]),
803 &(line
[ignore_text
]),
804 (min (j
, CACHE_WIDTH
) - ignore_text
) * sizeof (cache_type
));
806 lines
[row
].data
[min (j
, CACHE_WIDTH
)] = 0;
810 if (EditExposeRedraw
)
817 void edit_draw_this_line_proportional (WEdit
* edit
, long b
, int row
, int start_column
, int end_column
)
820 if (row
< 0 || row
>= edit
->num_widget_lines
)
823 if (row
+ edit
->start_line
> edit
->total_lines
)
824 b
= edit
->last_byte
+ 1; /* force b out of range of the edit buffer for blanks lines */
826 if (end_column
> CWidthOf (edit
->widget
))
827 end_column
= CWidthOf (edit
->widget
);
829 edit_get_syntax_color (edit
, b
- 1, &fg
, &bg
);
831 edit_draw_proportional (edit
,
832 (void (*) (void *, long, cache_type
*, int, int, int)) convert_text
,
833 (int (*) (void *, long, long *, int)) calc_text_pos
,
834 edit
->start_col
, CWindowOf (edit
->widget
),
835 end_column
, b
, row
, row
* FONT_PIX_PER_LINE
+ EDIT_TEXT_VERTICAL_OFFSET
,
836 EditExposeRedraw
? start_column
: 0, per_char
[' '] * TAB_SIZE
);
840 /*********************************************************************************/
841 /* The remainder is for the text box widget */
842 /*********************************************************************************/
844 static inline int nroff_printable (int c
)
850 int calc_text_pos_str (unsigned char *text
, long b
, long *q
, int l
)
852 int x
= 0, c
= 0, xn
= 0, d
;
862 xn
= next_tab_pos (x
);
868 xn
= x
- per_char
[d
];
871 if (!nroff_printable (c
))
873 xn
= x
+ per_char
[c
];
885 int prop_font_strcolmove (unsigned char *str
, int i
, int column
)
888 calc_text_pos_str (str
, i
, &q
, column
* FONT_MEAN_WIDTH
);
894 /* b is the beginning of the line. l is the length in pixels up to a point
895 on some character which is unknown. The character pos is returned in
896 *q and the characters pixel x pos from b is return'ed. */
897 int calc_text_pos2 (CWidget
* w
, long b
, long *q
, int l
)
899 return calc_text_pos_str ((unsigned char *) w
->text
, b
, q
, l
);
902 /* calcs pixel length of the line beginning at b up to upto */
903 int calc_text_len2 (CWidget
*w
, long b
, long upto
)
916 x
= next_tab_pos (x
);
925 if (!nroff_printable (c
))
935 int highlight_this_line
;
937 /* this is for the text widget (i.e. nroff formatting) */
938 void convert_text2 (CWidget
* w
, long q
, cache_type
*line
, int x
, int x_max
, int row
)
944 m1
= min (w
->mark1
, w
->mark2
);
945 m2
= max (w
->mark1
, w
->mark2
);
953 *p
|= 0xFFFF0000UL
; /* default background colors */
954 if (highlight_this_line
)
955 *p
|= MOD_HIGHLIGHTED
* 256;
956 if (q
>= m1
&& q
< m2
)
957 *p
|= MOD_MARKED
* 256;
962 if (highlight_this_line
) {
971 i
= next_tab_pos (x
) - x
;
981 x
= next_tab_pos (x
);
991 *p
|= MOD_ITALIC
* 256;
993 *p
|= MOD_BOLD
* 256;
997 if (!nroff_printable (c
)) {
999 *p
|= MOD_ABNORMAL
* 256;