Mercurial > vim
comparison src/ex_getln.c @ 5966:c476e0ac8b40 v7.4.324
updated for version 7.4.324
Problem: In Ex mode, cyrillic characters are not handled. (Stas Malavin)
Solution: Support multi-byte characters in Ex mode. (Yukihiro Nakadaira)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Thu, 12 Jun 2014 19:44:48 +0200 |
parents | 0fc665889e8f |
children | 0206ac84ff5f |
comparison
equal
deleted
inserted
replaced
5965:fdc26d6de8a2 | 5966:c476e0ac8b40 |
---|---|
2186 int c1 = 0; | 2186 int c1 = 0; |
2187 int escaped = FALSE; /* CTRL-V typed */ | 2187 int escaped = FALSE; /* CTRL-V typed */ |
2188 int vcol = 0; | 2188 int vcol = 0; |
2189 char_u *p; | 2189 char_u *p; |
2190 int prev_char; | 2190 int prev_char; |
2191 int len; | |
2191 | 2192 |
2192 /* Switch cursor on now. This avoids that it happens after the "\n", which | 2193 /* Switch cursor on now. This avoids that it happens after the "\n", which |
2193 * confuses the system function that computes tabstops. */ | 2194 * confuses the system function that computes tabstops. */ |
2194 cursor_on(); | 2195 cursor_on(); |
2195 | 2196 |
2262 if (c1 == BS || c1 == K_BS | 2263 if (c1 == BS || c1 == K_BS |
2263 || c1 == DEL || c1 == K_DEL || c1 == K_KDEL) | 2264 || c1 == DEL || c1 == K_DEL || c1 == K_KDEL) |
2264 { | 2265 { |
2265 if (line_ga.ga_len > 0) | 2266 if (line_ga.ga_len > 0) |
2266 { | 2267 { |
2267 --line_ga.ga_len; | 2268 #ifdef FEAT_MBYTE |
2269 if (has_mbyte) | |
2270 { | |
2271 p = (char_u *)line_ga.ga_data; | |
2272 p[line_ga.ga_len] = NUL; | |
2273 len = (*mb_head_off)(p, p + line_ga.ga_len - 1) + 1; | |
2274 line_ga.ga_len -= len; | |
2275 } | |
2276 else | |
2277 #endif | |
2278 --line_ga.ga_len; | |
2268 goto redraw; | 2279 goto redraw; |
2269 } | 2280 } |
2270 continue; | 2281 continue; |
2271 } | 2282 } |
2272 | 2283 |
2278 continue; | 2289 continue; |
2279 } | 2290 } |
2280 | 2291 |
2281 if (c1 == Ctrl_T) | 2292 if (c1 == Ctrl_T) |
2282 { | 2293 { |
2283 long sw = get_sw_value(curbuf); | 2294 long sw = get_sw_value(curbuf); |
2284 | 2295 |
2285 p = (char_u *)line_ga.ga_data; | 2296 p = (char_u *)line_ga.ga_data; |
2286 p[line_ga.ga_len] = NUL; | 2297 p[line_ga.ga_len] = NUL; |
2287 indent = get_indent_str(p, 8); | 2298 indent = get_indent_str(p, 8); |
2288 indent += sw - indent % sw; | 2299 indent += sw - indent % sw; |
2298 } | 2309 } |
2299 redraw: | 2310 redraw: |
2300 /* redraw the line */ | 2311 /* redraw the line */ |
2301 msg_col = startcol; | 2312 msg_col = startcol; |
2302 vcol = 0; | 2313 vcol = 0; |
2303 for (p = (char_u *)line_ga.ga_data; | 2314 p = (char_u *)line_ga.ga_data; |
2304 p < (char_u *)line_ga.ga_data + line_ga.ga_len; ++p) | 2315 p[line_ga.ga_len] = NUL; |
2316 while (p < (char_u *)line_ga.ga_data + line_ga.ga_len) | |
2305 { | 2317 { |
2306 if (*p == TAB) | 2318 if (*p == TAB) |
2307 { | 2319 { |
2308 do | 2320 do |
2309 { | 2321 { |
2310 msg_putchar(' '); | 2322 msg_putchar(' '); |
2311 } while (++vcol % 8); | 2323 } while (++vcol % 8); |
2324 ++p; | |
2312 } | 2325 } |
2313 else | 2326 else |
2314 { | 2327 { |
2315 msg_outtrans_len(p, 1); | 2328 len = MB_PTR2LEN(p); |
2316 vcol += char2cells(*p); | 2329 msg_outtrans_len(p, len); |
2330 vcol += ptr2cells(p); | |
2331 p += len; | |
2317 } | 2332 } |
2318 } | 2333 } |
2319 msg_clr_eos(); | 2334 msg_clr_eos(); |
2320 windgoto(msg_row, msg_col); | 2335 windgoto(msg_row, msg_col); |
2321 continue; | 2336 continue; |
2360 continue; | 2375 continue; |
2361 } | 2376 } |
2362 | 2377 |
2363 if (IS_SPECIAL(c1)) | 2378 if (IS_SPECIAL(c1)) |
2364 c1 = '?'; | 2379 c1 = '?'; |
2365 ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1; | 2380 #ifdef FEAT_MBYTE |
2381 if (has_mbyte) | |
2382 len = (*mb_char2bytes)(c1, | |
2383 (char_u *)line_ga.ga_data + line_ga.ga_len); | |
2384 else | |
2385 #endif | |
2386 { | |
2387 len = 1; | |
2388 ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1; | |
2389 } | |
2366 if (c1 == '\n') | 2390 if (c1 == '\n') |
2367 msg_putchar('\n'); | 2391 msg_putchar('\n'); |
2368 else if (c1 == TAB) | 2392 else if (c1 == TAB) |
2369 { | 2393 { |
2370 /* Don't use chartabsize(), 'ts' can be different */ | 2394 /* Don't use chartabsize(), 'ts' can be different */ |
2374 } while (++vcol % 8); | 2398 } while (++vcol % 8); |
2375 } | 2399 } |
2376 else | 2400 else |
2377 { | 2401 { |
2378 msg_outtrans_len( | 2402 msg_outtrans_len( |
2379 ((char_u *)line_ga.ga_data) + line_ga.ga_len, 1); | 2403 ((char_u *)line_ga.ga_data) + line_ga.ga_len, len); |
2380 vcol += char2cells(c1); | 2404 vcol += char2cells(c1); |
2381 } | 2405 } |
2382 ++line_ga.ga_len; | 2406 line_ga.ga_len += len; |
2383 escaped = FALSE; | 2407 escaped = FALSE; |
2384 | 2408 |
2385 windgoto(msg_row, msg_col); | 2409 windgoto(msg_row, msg_col); |
2386 pend = (char_u *)(line_ga.ga_data) + line_ga.ga_len; | 2410 pend = (char_u *)(line_ga.ga_data) + line_ga.ga_len; |
2387 | 2411 |