Mercurial > vim
comparison src/drawscreen.c @ 24043:15408ab5fed7 v8.2.2563
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Commit: https://github.com/vim/vim/commit/4fa1175765d55613302fc27d0f65e2c699452b6e
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 3 13:26:02 2021 +0100
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Problem: Cannot use multibyte characters for folding in 'fillchars'.
Solution: Port pull request 11568 to Vim. (Yegappan Lakshmanan,
closes #7924)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 03 Mar 2021 13:30:02 +0100 |
parents | 44be09b25619 |
children | 6062e10a7e72 |
comparison
equal
deleted
inserted
replaced
24042:553271829e46 | 24043:15408ab5fed7 |
---|---|
1042 long fold_count, | 1042 long fold_count, |
1043 foldinfo_T *foldinfo, | 1043 foldinfo_T *foldinfo, |
1044 linenr_T lnum, | 1044 linenr_T lnum, |
1045 int row) | 1045 int row) |
1046 { | 1046 { |
1047 char_u buf[FOLD_TEXT_LEN]; | 1047 // Max value of 'foldcolumn' is 12 and maximum number of bytes in a |
1048 // multi-byte character is MAX_MCO. | |
1049 char_u buf[MAX_MCO * 12 + 1]; | |
1048 pos_T *top, *bot; | 1050 pos_T *top, *bot; |
1049 linenr_T lnume = lnum + fold_count - 1; | 1051 linenr_T lnume = lnum + fold_count - 1; |
1050 int len; | 1052 int len; |
1051 char_u *text; | 1053 char_u *text; |
1052 int fdc; | 1054 int fdc; |
1074 if (enc_utf8) | 1076 if (enc_utf8) |
1075 ScreenLinesUC[off] = 0; | 1077 ScreenLinesUC[off] = 0; |
1076 ++col; | 1078 ++col; |
1077 } | 1079 } |
1078 #endif | 1080 #endif |
1079 | |
1080 // 2. Add the 'foldcolumn' | |
1081 // Reduce the width when there is not enough space. | |
1082 fdc = compute_foldcolumn(wp, col); | |
1083 if (fdc > 0) | |
1084 { | |
1085 fill_foldcolumn(buf, wp, TRUE, lnum); | |
1086 #ifdef FEAT_RIGHTLEFT | |
1087 if (wp->w_p_rl) | |
1088 { | |
1089 int i; | |
1090 | |
1091 copy_text_attr(off + wp->w_width - fdc - col, buf, fdc, | |
1092 HL_ATTR(HLF_FC)); | |
1093 // reverse the fold column | |
1094 for (i = 0; i < fdc; ++i) | |
1095 ScreenLines[off + wp->w_width - i - 1 - col] = buf[i]; | |
1096 } | |
1097 else | |
1098 #endif | |
1099 copy_text_attr(off + col, buf, fdc, HL_ATTR(HLF_FC)); | |
1100 col += fdc; | |
1101 } | |
1102 | 1081 |
1103 #ifdef FEAT_RIGHTLEFT | 1082 #ifdef FEAT_RIGHTLEFT |
1104 # define RL_MEMSET(p, v, l) \ | 1083 # define RL_MEMSET(p, v, l) \ |
1105 do { \ | 1084 do { \ |
1106 if (wp->w_p_rl) \ | 1085 if (wp->w_p_rl) \ |
1115 do { \ | 1094 do { \ |
1116 for (ri = 0; ri < l; ++ri) \ | 1095 for (ri = 0; ri < l; ++ri) \ |
1117 ScreenAttrs[off + (p) + ri] = v; \ | 1096 ScreenAttrs[off + (p) + ri] = v; \ |
1118 } while (0) | 1097 } while (0) |
1119 #endif | 1098 #endif |
1099 | |
1100 // 2. Add the 'foldcolumn' | |
1101 // Reduce the width when there is not enough space. | |
1102 fdc = compute_foldcolumn(wp, col); | |
1103 if (fdc > 0) | |
1104 { | |
1105 char_u *p; | |
1106 int i; | |
1107 int idx; | |
1108 | |
1109 fill_foldcolumn(buf, wp, TRUE, lnum); | |
1110 p = buf; | |
1111 for (i = 0; i < fdc; i++) | |
1112 { | |
1113 int ch; | |
1114 | |
1115 if (has_mbyte) | |
1116 ch = mb_ptr2char_adv(&p); | |
1117 else | |
1118 ch = *p++; | |
1119 #ifdef FEAT_RIGHTLEFT | |
1120 if (wp->w_p_rl) | |
1121 idx = off + wp->w_width - i - 1 - col; | |
1122 else | |
1123 #endif | |
1124 idx = off + col + i; | |
1125 if (enc_utf8) | |
1126 { | |
1127 if (ch >= 0x80) | |
1128 { | |
1129 ScreenLinesUC[idx] = ch; | |
1130 ScreenLinesC[0][idx] = 0; | |
1131 ScreenLines[idx] = 0x80; | |
1132 } | |
1133 else | |
1134 { | |
1135 ScreenLines[idx] = ch; | |
1136 ScreenLinesUC[idx] = 0; | |
1137 } | |
1138 } | |
1139 else | |
1140 ScreenLines[idx] = ch; | |
1141 } | |
1142 | |
1143 RL_MEMSET(col, HL_ATTR(HLF_FC), fdc); | |
1144 col += fdc; | |
1145 } | |
1120 | 1146 |
1121 // Set all attributes of the 'number' or 'relativenumber' column and the | 1147 // Set all attributes of the 'number' or 'relativenumber' column and the |
1122 // text | 1148 // text |
1123 RL_MEMSET(col, HL_ATTR(HLF_FL), wp->w_width - col); | 1149 RL_MEMSET(col, HL_ATTR(HLF_FL), wp->w_width - col); |
1124 | 1150 |