Mercurial > vim
annotate src/testdir/test_matchadd_conceal_utf8.vim @ 9483:d735119cc327 v7.4.2022
commit https://github.com/vim/vim/commit/25065ec375a8a55462f6c07c76dc1a72a770ac19
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 10 19:22:53 2016 +0200
patch 7.4.2022
Problem: Warnings from 64 bit compiler.
Solution: Add type casts. (Mike Williams)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 10 Jul 2016 19:30:06 +0200 |
parents | 5deb9e8f4292 |
children | 81ba6e4eb72b |
rev | line source |
---|---|
8907
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for matchadd() and conceal feature using utf-8. |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 if !has('conceal') || !has('multi_byte') |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 finish |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 endif |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 set encoding=utf-8 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 scriptencoding utf-8 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 if !has('gui_running') && has('unix') |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 set term=ansi |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 endif |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 function! s:screenline(lnum) abort |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 let line = [] |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 for c in range(1, winwidth(0)) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call add(line, nr2char(screenchar(a:lnum, c))) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 endfor |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 return s:trim(join(line, '')) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 endfunction |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 function! s:trim(str) abort |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 endfunction |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 function! Test_match_using_multibyte_conceal_char() |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 new |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 setlocal concealcursor=n conceallevel=1 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 1put='# This is a Test' |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 " 1234567890123456 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 let expect = '#ˑThisˑisˑaˑTest' |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 call cursor(1, 1) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"}) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 redraw! |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 let lnum = 2 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 call assert_equal(expect, s:screenline(lnum)) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 quit! |
5deb9e8f4292
commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 endfunction |