diff -pru dillo-kfo/src/dw_page.c dillo/src/dw_page.c --- dillo-kfo/src/dw_page.c Sun Oct 19 11:43:20 2003 +++ dillo/src/dw_page.c Sun Oct 19 13:18:44 2003 @@ -1250,6 +1250,7 @@ static void Dw_page_draw_line (DwPage *p GdkWindow *window; GdkGC *gc, *hl_gc; DwStyleColor *bg_color; + gboolean space_drawn; /* Here's an idea on how to optimize this routine to minimize the number * of calls to gdk_draw_string: @@ -1343,41 +1344,140 @@ static void Dw_page_draw_line (DwPage *p /* todo: This should also be done with spaces after non-text * words, but this is not yet defined very well. */ if (word->hl_end[layer] > eff_hl_end && - word_index < page->num_words && - word_index != line->last_word - 1) + word_index < page->num_words -1 && + word_index != line->last_word - 1) { + space_drawn = TRUE; width_hl += word->eff_space; - - - if (width_hl != 0) { - /* Draw background for highlighted text. */ - gdk_draw_rectangle (window, bg_color->inverse_gc, - TRUE, start_hl, - y_cursor - word->size.ascent, - width_hl, - word->size.ascent + word->size.descent); - - /* Highlight the text. */ - hl_gc = word->style->color->inverse_gc; - gdk_draw_text (window, word->style->font->font, hl_gc, - start_hl, y_cursor + diff, - word->content.data.text - + word->hl_start[layer], - eff_hl_end - word->hl_start[layer]); - - /* underline and strike-through */ - if (word->style->text_decoration - & DW_STYLE_TEXT_DECORATION_UNDERLINE) - gdk_draw_line (window, hl_gc, - start_hl, y_cursor + 1 + diff, - start_hl + width_hl - 1, - y_cursor + 1 + diff); - if (word->style->text_decoration - & DW_STYLE_TEXT_DECORATION_LINE_THROUGH) + } else + space_drawn = FALSE; + + switch (layer) { + case DW_HIGHLIGHT_SELECTION: + case DW_HIGHLIGHT_FINDTEXT: + if (width_hl != 0) { + /* Draw background for highlighted text. */ + gdk_draw_rectangle (window, bg_color->inverse_gc, + TRUE, start_hl, + y_cursor - word->size.ascent, + width_hl, + word->size.ascent + + word->size.descent); + + /* Highlight the text. */ + hl_gc = word->style->color->inverse_gc; + gdk_draw_text (window, word->style->font->font, hl_gc, + start_hl, y_cursor + diff, + word->content.data.text + + word->hl_start[layer], + eff_hl_end - word->hl_start[layer]); + + /* underline and strike-through */ + if (word->style->text_decoration + & DW_STYLE_TEXT_DECORATION_UNDERLINE) + gdk_draw_line (window, hl_gc, + start_hl, y_cursor + 1 + diff, + start_hl + width_hl - 1, + y_cursor + 1 + diff); + if (word->style->text_decoration + & DW_STYLE_TEXT_DECORATION_LINE_THROUGH) + gdk_draw_line (window, hl_gc, + start_hl, + y_cursor - word->size.ascent / 2 + diff, + start_hl + width_hl - 1, + y_cursor - word->size.ascent / 2 + + diff); + } + break; + + case DW_HIGHLIGHT_FOCUS: + hl_gc = bg_color->inverse_gc; + + /* top line */ + gdk_draw_line (window, hl_gc, + start_hl, y_cursor - word->size.ascent, + start_hl + width_hl, + y_cursor - word->size.ascent); + + /* bottom line */ + gdk_draw_line (window, hl_gc, + start_hl, y_cursor + word->size.descent - 1, + start_hl + width_hl, + y_cursor + word->size.descent - 1); + + /* left line */ + if (/* First character focussed? */ + word->hl_start[layer] == 0 && + word_index > line->first_word && + /* Previous character also focussed? */ + /* todo: currently, only text words are considered. */ + page->words[word_index - 1].content.type + == DW_CONTENT_TEXT && + page->words[word_index - 1].hl_start[layer] != -1 && + page->words[word_index - 1].hl_end[layer] + > strlen (page->words[word_index + - 1].content.data.text)) { + /* Left border is not fully drawn, only partially, and + * only when previous word height is "smaller". todo: + * Spaces are drawn wrong, when the space has another + * font etc. than the word. */ + if (word->size.ascent > + page->words[word_index - 1].size.ascent) + gdk_draw_line (window, hl_gc, + start_hl, + y_cursor - word->size.ascent, + start_hl, + y_cursor - page->words[word_index + + 1].size.ascent); + if (word->size.descent > + page->words[word_index - 1].size.descent) + gdk_draw_line (window, hl_gc, + start_hl, + y_cursor + word->size.descent - 1, + start_hl, + y_cursor + + page->words[word_index + + 1].size.descent - 1); + } else + /* Left border is fully drawn. */ gdk_draw_line (window, hl_gc, start_hl, - y_cursor - word->size.ascent / 2 + diff, - start_hl + width_hl - 1, - y_cursor - word->size.ascent / 2 + diff); + y_cursor - word->size.ascent, + start_hl, + y_cursor + word->size.descent - 1); + + /* right line */ + if (space_drawn && + /* Next character also focussed? */ + page->words[word_index + 1].hl_start[layer] == 0) { + /* Right border is not fully drawn, only partially, and + * only when next word height is "smaller". Note: Since + * space_drawn is true, we can assume that there is + * a next word. todo: See above. */ + if (word->size.ascent > + page->words[word_index + 1].size.ascent) + gdk_draw_line (window, hl_gc, + start_hl + width_hl, + y_cursor - word->size.ascent, + start_hl + width_hl, + y_cursor - page->words[word_index + + 1].size.ascent); + if (word->size.descent > + page->words[word_index + 1].size.descent) + gdk_draw_line (window, hl_gc, + start_hl + width_hl, + y_cursor + word->size.descent - 1, + start_hl + width_hl, + y_cursor + + page->words[word_index + + 1].size.descent - 1); + } else + /* Right border is fully drawn. */ + gdk_draw_line (window, hl_gc, + start_hl + width_hl, + y_cursor - word->size.ascent, + start_hl + width_hl, + y_cursor + word->size.descent - 1); + break; } } } diff -pru dillo-kfo/src/focus.c dillo/src/focus.c --- dillo-kfo/src/focus.c Sun Oct 19 11:43:20 2003 +++ dillo/src/focus.c Sun Oct 19 11:46:09 2003 @@ -200,7 +200,8 @@ Focus_link_highlight (FocusLink *link) do a_Dw_iterator_highlight(hilit, 0, - strlen(hilit->content.data.text), + strlen(hilit->content.data.text) + + (n > 1 ? 1 : 0), DW_HIGHLIGHT_FOCUS); while (--n && a_Dw_iterator_next(hilit));