Mercurial > vim
comparison src/gui_gtk_x11.c @ 26207:c3b046ce88fd v8.2.3635
patch 8.2.3635: GTK: composing underline does not show
Commit: https://github.com/vim/vim/commit/3c19b5050040fb74e4e39048f17dce853fdafc08
Author: Dusan Popovic <dpx@binaryapparatus.com>
Date: Sat Nov 20 22:03:30 2021 +0000
patch 8.2.3635: GTK: composing underline does not show
Problem: GTK: composing underline does not show.
Solution: Include composing character in pango call. A few more
optimizations for ligatures. (Dusan Popovic, closes #9171,
closes #9147)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 20 Nov 2021 23:15:03 +0100 |
parents | a0f4b96a813a |
children | 2dd449b9c1c7 |
comparison
equal
deleted
inserted
replaced
26206:851db50bd99b | 26207:c3b046ce88fd |
---|---|
5502 char_u *cs; // current *s pointer | 5502 char_u *cs; // current *s pointer |
5503 int needs_pango; // look ahead, 0=ascii 1=unicode/ligatures | 5503 int needs_pango; // look ahead, 0=ascii 1=unicode/ligatures |
5504 int should_need_pango = FALSE; | 5504 int should_need_pango = FALSE; |
5505 int slen; | 5505 int slen; |
5506 int is_ligature; | 5506 int is_ligature; |
5507 int next_is_ligature; | |
5508 int is_utf8; | 5507 int is_utf8; |
5509 char_u backup_ch; | 5508 char_u backup_ch; |
5510 | 5509 |
5511 if (gui.text_context == NULL || gtk_widget_get_window(gui.drawarea) == NULL) | 5510 if (gui.text_context == NULL || gtk_widget_get_window(gui.drawarea) == NULL) |
5512 return len; | 5511 return len; |
5562 */ | 5561 */ |
5563 len_sum = 0; // return value needs to add up since we are printing | 5562 len_sum = 0; // return value needs to add up since we are printing |
5564 // substrings | 5563 // substrings |
5565 byte_sum = 0; | 5564 byte_sum = 0; |
5566 cs = s; | 5565 cs = s; |
5567 // look ahead, 0=ascii 1=unicode/ligatures | 5566 // First char decides starting needs_pango mode, 0=ascii 1=utf8/ligatures. |
5568 needs_pango = ((*cs & 0x80) || gui.ligatures_map[*cs]); | 5567 // Even if it is ligature char, two chars or more make ligature. |
5568 // Ascii followed by utf8 is also going trough pango. | |
5569 is_utf8 = (*cs & 0x80); | |
5570 is_ligature = gui.ligatures_map[*cs] && (len > 1); | |
5571 if (is_ligature) | |
5572 is_ligature = gui.ligatures_map[*(cs + 1)]; | |
5573 if (!is_utf8 && len > 1) | |
5574 is_utf8 = (*(cs + 1) & 0x80) != 0; | |
5575 needs_pango = is_utf8 || is_ligature; | |
5569 | 5576 |
5570 // split string into ascii and non-ascii (ligatures + utf-8) substrings, | 5577 // split string into ascii and non-ascii (ligatures + utf-8) substrings, |
5571 // print glyphs or use Pango | 5578 // print glyphs or use Pango |
5572 while (cs < s + len) | 5579 while (cs < s + len) |
5573 { | 5580 { |
5577 is_ligature = gui.ligatures_map[*(cs + slen)]; | 5584 is_ligature = gui.ligatures_map[*(cs + slen)]; |
5578 // look ahead, single ligature char between ascii is ascii | 5585 // look ahead, single ligature char between ascii is ascii |
5579 if (is_ligature && !needs_pango) | 5586 if (is_ligature && !needs_pango) |
5580 { | 5587 { |
5581 if ((slen + 1) < (len - byte_sum)) | 5588 if ((slen + 1) < (len - byte_sum)) |
5582 { | 5589 is_ligature = gui.ligatures_map[*(cs + slen + 1)]; |
5583 next_is_ligature = gui.ligatures_map[*(cs + slen + 1)]; | |
5584 if (!next_is_ligature) | |
5585 is_ligature = 0; | |
5586 } | |
5587 else | 5590 else |
5588 { | |
5589 is_ligature = 0; | 5591 is_ligature = 0; |
5590 } | |
5591 } | 5592 } |
5592 is_utf8 = *(cs + slen) & 0x80; | 5593 is_utf8 = *(cs + slen) & 0x80; |
5594 // ascii followed by utf8 could be combining | |
5595 // if so send it trough pango | |
5596 if ((!is_utf8) && ((slen + 1) < (len - byte_sum))) | |
5597 is_utf8 = (*(cs + slen + 1) & 0x80); | |
5593 should_need_pango = (is_ligature || is_utf8); | 5598 should_need_pango = (is_ligature || is_utf8); |
5594 if (needs_pango != should_need_pango) // mode switch | 5599 if (needs_pango != should_need_pango) // mode switch |
5595 break; | 5600 break; |
5596 if (needs_pango) | 5601 if (needs_pango) |
5597 { | 5602 { |
5598 if (is_ligature) | 5603 if (is_ligature) |
5599 { | 5604 { |
5600 slen++; // ligature char by char | 5605 slen++; // ligature char by char |
5601 } | 5606 } |
5602 else | 5607 else if (is_utf8) |
5603 { | 5608 { |
5604 if ((*(cs + slen) & 0xC0) == 0x80) | 5609 if ((*(cs + slen) & 0xC0) == 0x80) |
5605 { | 5610 { |
5606 // a continuation, find next 0xC0 != 0x80 but don't | 5611 // a continuation, find next 0xC0 != 0x80 but don't |
5607 // include it | 5612 // include it |
5631 // this should not happen, try moving forward, Pango | 5636 // this should not happen, try moving forward, Pango |
5632 // will catch it | 5637 // will catch it |
5633 slen++; | 5638 slen++; |
5634 } | 5639 } |
5635 } | 5640 } |
5641 else | |
5642 { | |
5643 slen++; | |
5644 } | |
5636 } | 5645 } |
5637 else | 5646 else |
5638 { | 5647 { |
5639 slen++; // ascii | 5648 slen++; // ascii |
5640 } | 5649 } |