From c1542744e788d96fed24dd421f43009288092504 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 20 Jul 2016 21:44:37 +0200 Subject: [PATCH 1/9] patch 7.4.2081 Problem: Line numbers in the error list are not always adjusted. Solution: Set b_has_qf_entry properly. (Yegappan Lakshmanan) --- src/quickfix.c | 11 +++++++---- src/structs.h | 2 ++ src/testdir/test_quickfix.vim | 17 ++++++++++------- src/version.c | 2 ++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/quickfix.c b/src/quickfix.c index fecc2c9eb0..51f96dcaa4 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -1408,7 +1408,8 @@ qf_add_entry( qfp->qf_fnum = bufnum; if (buf != NULL) - buf->b_has_qf_entry = TRUE; + buf->b_has_qf_entry |= + (qi == &ql_info) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; } else qfp->qf_fnum = qf_get_fnum(qi, dir, fname); @@ -1680,7 +1681,8 @@ qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname) if (buf == NULL) return 0; - buf->b_has_qf_entry = TRUE; + buf->b_has_qf_entry = + (qi == &ql_info) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; return buf->b_fnum; } @@ -2728,8 +2730,9 @@ qf_mark_adjust( int idx; qf_info_T *qi = &ql_info; int found_one = FALSE; + int buf_has_flag = wp == NULL ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; - if (!curbuf->b_has_qf_entry) + if (!(curbuf->b_has_qf_entry & buf_has_flag)) return; if (wp != NULL) { @@ -2758,7 +2761,7 @@ qf_mark_adjust( } if (!found_one) - curbuf->b_has_qf_entry = FALSE; + curbuf->b_has_qf_entry &= ~buf_has_flag; } /* diff --git a/src/structs.h b/src/structs.h index 00a8e035b4..191fa1f923 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1906,6 +1906,8 @@ struct file_buffer #ifdef FEAT_QUICKFIX char_u *b_p_bh; /* 'bufhidden' */ char_u *b_p_bt; /* 'buftype' */ +#define BUF_HAS_QF_ENTRY 1 +#define BUF_HAS_LL_ENTRY 2 int b_has_qf_entry; #endif int b_p_bl; /* 'buflisted' */ diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index 83f4d0cbef..e79315b969 100644 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -1341,13 +1341,14 @@ function! Xadjust_qflnum(cchar) enew | only - call s:create_test_file('Xqftestfile') - edit Xqftestfile + let fname = 'Xqftestfile' . a:cchar + call s:create_test_file(fname) + exe 'edit ' . fname - Xgetexpr ['Xqftestfile:5:Line5', - \ 'Xqftestfile:10:Line10', - \ 'Xqftestfile:15:Line15', - \ 'Xqftestfile:20:Line20'] + Xgetexpr [fname . ':5:Line5', + \ fname . ':10:Line10', + \ fname . ':15:Line15', + \ fname . ':20:Line20'] 6,14delete call append(6, ['Buffer', 'Window']) @@ -1359,11 +1360,13 @@ function! Xadjust_qflnum(cchar) call assert_equal(13, l[3].lnum) enew! - call delete('Xqftestfile') + call delete(fname) endfunction function! Test_adjust_lnum() + call setloclist(0, []) call Xadjust_qflnum('c') + call setqflist([]) call Xadjust_qflnum('l') endfunction diff --git a/src/version.c b/src/version.c index 742f78b295..4a8235599c 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2081, /**/ 2080, /**/ From 397eadbe25370394e0dc3cb18766533a15b8d1c0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 20 Jul 2016 22:01:12 +0200 Subject: [PATCH 2/9] patch 7.4.2082 Problem: Not much test coverage for digraphs. Solution: Add a new style digraph test. (Christian Brabandt) --- src/Makefile | 1 + src/testdir/test_alot.vim | 1 + src/testdir/test_digraph.vim | 430 +++++++++++++++++++++++++++++++++++ src/version.c | 2 + 4 files changed, 434 insertions(+) create mode 100644 src/testdir/test_digraph.vim diff --git a/src/Makefile b/src/Makefile index 80a15b977e..316c0e62a9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2061,6 +2061,7 @@ test_arglist \ test_cscope \ test_cursor_func \ test_delete \ + test_digraph \ test_ex_undo \ test_execute_func \ test_expand \ diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index e9c84398e8..e87ff90ebf 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -5,6 +5,7 @@ source test_assign.vim source test_autocmd.vim source test_cursor_func.vim source test_delete.vim +source test_digraph.vim source test_execute_func.vim source test_ex_undo.vim source test_expand.vim diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim new file mode 100644 index 0000000000..01180b6c25 --- /dev/null +++ b/src/testdir/test_digraph.vim @@ -0,0 +1,430 @@ +" Tests for digraphs + +if !has("digraphs") || !has("multi_byte") + finish +endif + +func! Put_Dig(chars) + exe "norm! o\".a:chars +endfu + +func! Put_Dig_BS(char1, char2) + exe "norm! o".a:char1."\".a:char2 +endfu + +func! Test_digraphs() + let _enc=&enc + set nocp enc=utf8 + new + call Put_Dig("00") + call assert_equal("∞", getline('.')) + " not a digraph + call Put_Dig("el") + call assert_equal("l", getline('.')) + call Put_Dig("ht") + call assert_equal("þ", getline('.')) + " digraph "ab" is the same as "ba" + call Put_Dig("ab") + call Put_Dig("ba") + call assert_equal(["ば","ば"], getline(line('.')-1,line('.'))) + " Euro sign + call Put_Dig("e=") + call Put_Dig("=e") + call Put_Dig("Eu") + call Put_Dig("uE") + call assert_equal(['е']+repeat(["€"],3), getline(line('.')-3,line('.'))) + " Rouble sign + call Put_Dig("R=") + call Put_Dig("=R") + call Put_Dig("=P") + call Put_Dig("P=") + call assert_equal(['Р']+repeat(["₽"],2)+['П'], getline(line('.')-3,line('.'))) + " Not a digraph + call Put_Dig("a\") + call Put_Dig("\a") + call assert_equal(["", "a"], getline(line('.')-1,line('.'))) + " Grave + call Put_Dig("a!") + call Put_Dig("!e") + call Put_Dig("b!") " not defined + call assert_equal(["à", "è", "!"], getline(line('.')-2,line('.'))) + " Acute accent + call Put_Dig("a'") + call Put_Dig("'e") + call Put_Dig("b'") " not defined + call assert_equal(["á", "é", "'"], getline(line('.')-2,line('.'))) + " Cicumflex + call Put_Dig("a>") + call Put_Dig(">e") + call Put_Dig("b>") " not defined + call assert_equal(['â', 'ê', '>'], getline(line('.')-2,line('.'))) + " Tilde + call Put_Dig("o~") + call Put_Dig("~u") " not defined + call Put_Dig("z~") " not defined + call assert_equal(['õ', 'u', '~'], getline(line('.')-2,line('.'))) + " Tilde + call Put_Dig("o?") + call Put_Dig("?u") + call Put_Dig("z?") " not defined + call assert_equal(['õ', 'ũ', '?'], getline(line('.')-2,line('.'))) + " Macron + call Put_Dig("o-") + call Put_Dig("-u") + call Put_Dig("z-") " not defined + call assert_equal(['ō', 'ū', '-'], getline(line('.')-2,line('.'))) + " Breve + call Put_Dig("o(") + call Put_Dig("(u") + call Put_Dig("z(") " not defined + call assert_equal(['ŏ', 'ŭ', '('], getline(line('.')-2,line('.'))) + " Dot above + call Put_Dig("b.") + call Put_Dig(".e") + call Put_Dig("a.") " not defined + call assert_equal(['ḃ', 'ė', '.'], getline(line('.')-2,line('.'))) + " Diaresis + call Put_Dig("a:") + call Put_Dig(":u") + call Put_Dig("b:") " not defined + call assert_equal(['ä', 'ü', ':'], getline(line('.')-2,line('.'))) + " Cedilla + call Put_Dig("',") + call Put_Dig(",C") + call Put_Dig("b,") " not defined + call assert_equal(['¸', 'Ç', ','], getline(line('.')-2,line('.'))) + " Underline + call Put_Dig("B_") + call Put_Dig("_t") + call Put_Dig("a_") " not defined + call assert_equal(['Ḇ', 'ṯ', '_'], getline(line('.')-2,line('.'))) + " Stroke + call Put_Dig("j/") + call Put_Dig("/l") + call Put_Dig("b/") " not defined + call assert_equal(['/', 'ł', '/'], getline(line('.')-2,line('.'))) + " Double acute + call Put_Dig('O"') + call Put_Dig('"y') + call Put_Dig('b"') " not defined + call assert_equal(['Ő', 'ÿ', '"'], getline(line('.')-2,line('.'))) + " Ogonek + call Put_Dig('u;') + call Put_Dig(';E') + call Put_Dig('b;') " not defined + call assert_equal(['ų', 'Ę', ';'], getline(line('.')-2,line('.'))) + " Caron + call Put_Dig('u<') + call Put_Dig('") + call Put_Dig("\A") + call assert_equal(['', 'A'], getline(line('.')-1,line('.'))) + " define some custom digraphs + " old: 00 ∞ + " old: el l + digraph 00 9216 + digraph el 0252 + call Put_Dig("00") + call Put_Dig("el") + " Reset digraphs + digraph 00 8734 + digraph el 108 + call Put_Dig("00") + call Put_Dig("el") + call assert_equal(['␀', 'ü', '∞', 'l'], getline(line('.')-3,line('.'))) + " reset encoding option + let &enc=_enc + bw! +endfunc + +func! Test_digraphs_option() + let _enc=&enc + " reset whichwrap option, so that testing A works, + " without moving up a line + set nocp enc=utf8 digraph ww= + new + call Put_Dig_BS("0","0") + call assert_equal("∞", getline('.')) + " not a digraph + call Put_Dig_BS("e","l") + call assert_equal("l", getline('.')) + call Put_Dig_BS("h","t") + call assert_equal("þ", getline('.')) + " digraph "ab" is the same as "ba" + call Put_Dig_BS("a","b") + call Put_Dig_BS("b","a") + call assert_equal(["ば","ば"], getline(line('.')-1,line('.'))) + " Euro sign + call Put_Dig_BS("e","=") + call Put_Dig_BS("=","e") + call Put_Dig_BS("E","u") + call Put_Dig_BS("u","E") + call assert_equal(['е']+repeat(["€"],3), getline(line('.')-3,line('.'))) + " Rouble sign + call Put_Dig_BS("R","=") + call Put_Dig_BS("=","R") + call Put_Dig_BS("=","P") + call Put_Dig_BS("P","=") + call assert_equal(['Р']+repeat(["₽"],2)+['П'], getline(line('.')-3,line('.'))) + " Not a digraph: this is different from ! + call Put_Dig_BS("a","\") + call Put_Dig_BS("\","a") + call assert_equal(['','a'], getline(line('.')-1,line('.'))) + " Grave + call Put_Dig_BS("a","!") + call Put_Dig_BS("!","e") + call Put_Dig_BS("b","!") " not defined + call assert_equal(["à", "è", "!"], getline(line('.')-2,line('.'))) + " Acute accent + call Put_Dig_BS("a","'") + call Put_Dig_BS("'","e") + call Put_Dig_BS("b","'") " not defined + call assert_equal(["á", "é", "'"], getline(line('.')-2,line('.'))) + " Cicumflex + call Put_Dig_BS("a",">") + call Put_Dig_BS(">","e") + call Put_Dig_BS("b",">") " not defined + call assert_equal(['â', 'ê', '>'], getline(line('.')-2,line('.'))) + " Tilde + call Put_Dig_BS("o","~") + call Put_Dig_BS("~","u") " not defined + call Put_Dig_BS("z","~") " not defined + call assert_equal(['õ', 'u', '~'], getline(line('.')-2,line('.'))) + " Tilde + call Put_Dig_BS("o","?") + call Put_Dig_BS("?","u") + call Put_Dig_BS("z","?") " not defined + call assert_equal(['õ', 'ũ', '?'], getline(line('.')-2,line('.'))) + " Macron + call Put_Dig_BS("o","-") + call Put_Dig_BS("-","u") + call Put_Dig_BS("z","-") " not defined + call assert_equal(['ō', 'ū', '-'], getline(line('.')-2,line('.'))) + " Breve + call Put_Dig_BS("o","(") + call Put_Dig_BS("(","u") + call Put_Dig_BS("z","(") " not defined + call assert_equal(['ŏ', 'ŭ', '('], getline(line('.')-2,line('.'))) + " Dot above + call Put_Dig_BS("b",".") + call Put_Dig_BS(".","e") + call Put_Dig_BS("a",".") " not defined + call assert_equal(['ḃ', 'ė', '.'], getline(line('.')-2,line('.'))) + " Diaresis + call Put_Dig_BS("a",":") + call Put_Dig_BS(":","u") + call Put_Dig_BS("b",":") " not defined + call assert_equal(['ä', 'ü', ':'], getline(line('.')-2,line('.'))) + " Cedilla + call Put_Dig_BS("'",",") + call Put_Dig_BS(",","C") + call Put_Dig_BS("b",",") " not defined + call assert_equal(['¸', 'Ç', ','], getline(line('.')-2,line('.'))) + " Underline + call Put_Dig_BS("B","_") + call Put_Dig_BS("_","t") + call Put_Dig_BS("a","_") " not defined + call assert_equal(['Ḇ', 'ṯ', '_'], getline(line('.')-2,line('.'))) + " Stroke + call Put_Dig_BS("j","/") + call Put_Dig_BS("/","l") + call Put_Dig_BS("b","/") " not defined + call assert_equal(['/', 'ł', '/'], getline(line('.')-2,line('.'))) + " Double acute + call Put_Dig_BS('O','"') + call Put_Dig_BS('"','y') + call Put_Dig_BS('b','"') " not defined + call assert_equal(['Ő', 'ÿ', '"'], getline(line('.')-2,line('.'))) + " Ogonek + call Put_Dig_BS('u',';') + call Put_Dig_BS(';','E') + call Put_Dig_BS('b',';') " not defined + call assert_equal(['ų', 'Ę', ';'], getline(line('.')-2,line('.'))) + " Caron + call Put_Dig_BS('u','<') + call Put_Dig_BS('<','E') + call Put_Dig_BS('b','<') " not defined + call assert_equal(['ǔ', 'Ě', '<'], getline(line('.')-2,line('.'))) + " Ring above + call Put_Dig_BS('u','0') + call Put_Dig_BS('0','E') " not defined + call Put_Dig_BS('b','0') " not defined + call assert_equal(['ů', 'E', '0'], getline(line('.')-2,line('.'))) + " Hook + call Put_Dig_BS('u','2') + call Put_Dig_BS('2','E') + call Put_Dig_BS('b','2') " not defined + call assert_equal(['ủ', 'Ẻ', '2'], getline(line('.')-2,line('.'))) + " Horn + call Put_Dig_BS('u','9') + call Put_Dig_BS('9','E') " not defined + call Put_Dig_BS('b','9') " not defined + call assert_equal(['ư', 'E', '9'], getline(line('.')-2,line('.'))) + " Cyrillic + call Put_Dig_BS('u','=') + call Put_Dig_BS('=','b') + call Put_Dig_BS('=','_') + call assert_equal(['у', 'б', '〓'], getline(line('.')-2,line('.'))) + " Greek + call Put_Dig_BS('u','*') + call Put_Dig_BS('*','b') + call Put_Dig_BS('*','_') + call assert_equal(['υ', 'β', '々'], getline(line('.')-2,line('.'))) + " Greek/Cyrillic special + call Put_Dig_BS('u','%') + call Put_Dig_BS('%','b') " not defined + call Put_Dig_BS('%','_') " not defined + call assert_equal(['ύ', 'b', '_'], getline(line('.')-2,line('.'))) + " Arabic + call Put_Dig_BS('u','+') + call Put_Dig_BS('+','b') + call Put_Dig_BS('+','_') " japanese industrial symbol + call assert_equal(['+', 'ب', '〄'], getline(line('.')-2,line('.'))) + " Hebrew + call Put_Dig_BS('Q','+') + call Put_Dig_BS('+','B') + call Put_Dig_BS('+','X') + call assert_equal(['ק', 'ב', 'ח'], getline(line('.')-2,line('.'))) + " Latin + call Put_Dig_BS('a','3') + call Put_Dig_BS('A','3') + call Put_Dig_BS('3','X') + call assert_equal(['ǣ', 'Ǣ', 'X'], getline(line('.')-2,line('.'))) + " Bopomofo + call Put_Dig_BS('a','4') + call Put_Dig_BS('A','4') + call Put_Dig_BS('4','X') + call assert_equal(['ㄚ', '4', 'X'], getline(line('.')-2,line('.'))) + " Hiragana + call Put_Dig_BS('a','5') + call Put_Dig_BS('A','5') + call Put_Dig_BS('5','X') + call assert_equal(['あ', 'ぁ', 'X'], getline(line('.')-2,line('.'))) + " Katakana + call Put_Dig_BS('a','6') + call Put_Dig_BS('A','6') + call Put_Dig_BS('6','X') + call assert_equal(['ァ', 'ア', 'X'], getline(line('.')-2,line('.'))) + " Superscripts + call Put_Dig_BS('1','S') + call Put_Dig_BS('2','S') + call Put_Dig_BS('3','S') + call assert_equal(['¹', '²', '³'], getline(line('.')-2,line('.'))) + " Subscripts + call Put_Dig_BS('1','s') + call Put_Dig_BS('2','s') + call Put_Dig_BS('3','s') + call assert_equal(['₁', '₂', '₃'], getline(line('.')-2,line('.'))) + " Eszet (only lowercase) + call Put_Dig_BS("s","s") + call Put_Dig_BS("S","S") " start of string + call assert_equal(["ß", "˜"], getline(line('.')-1,line('.'))) + " High bit set (different from ) + call Put_Dig_BS("a"," ") + call Put_Dig_BS(" ","A") + call assert_equal([' ', 'A'], getline(line('.')-1,line('.'))) + " Escape is not part of a digraph (different from ) + call Put_Dig_BS("a","\") + call Put_Dig_BS("\","A") + call assert_equal(['', ''], getline(line('.')-1,line('.'))) + " define some custom digraphs + " old: 00 ∞ + " old: el l + digraph 00 9216 + digraph el 0252 + call Put_Dig_BS("0","0") + call Put_Dig_BS("e","l") + " Reset digraphs + digraph 00 8734 + digraph el 108 + call Put_Dig_BS("0","0") + call Put_Dig_BS("e","l") + call assert_equal(['␀', 'ü', '∞', 'l'], getline(line('.')-3,line('.'))) + " reset encoding option + let &enc=_enc + set nodigraph ww&vim + bw! +endfunc + +" vim: tabstop=2 shiftwidth=0 sts=-1 expandtab diff --git a/src/version.c b/src/version.c index 4a8235599c..acc5c33d11 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2082, /**/ 2081, /**/ From 19df5cc04de93519145901d9cbc78c44d0c47c5d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 20 Jul 2016 22:11:06 +0200 Subject: [PATCH 3/9] patch 7.4.2083 Problem: Coverity complains about not restoring a value. Solution: Restore the value, although it's not really needed. Change return to jump to cleanup, might leak memory. --- src/userfunc.c | 5 ++++- src/version.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/userfunc.c b/src/userfunc.c index 9ffafc3714..ffbbc2d21f 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -199,14 +199,17 @@ get_function_args( break; } if (newargs != NULL && ga_grow(newargs, 1) == FAIL) - return FAIL; + goto err_ret; if (newargs != NULL) { c = *p; *p = NUL; arg = vim_strsave(arg); if (arg == NULL) + { + *p = c; goto err_ret; + } /* Check for duplicate argument name. */ for (i = 0; i < newargs->ga_len; ++i) diff --git a/src/version.c b/src/version.c index acc5c33d11..69da119210 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2083, /**/ 2082, /**/ From 60084333816c585d5858bc085b2942f813102ae3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 20 Jul 2016 22:23:49 +0200 Subject: [PATCH 4/9] patch 7.4.2084 Problem: New digraph test makes testing hang. Solution: Don't set "nocp". --- src/testdir/test_digraph.vim | 12 +++++++----- src/version.c | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim index 01180b6c25..b12e19fa7c 100644 --- a/src/testdir/test_digraph.vim +++ b/src/testdir/test_digraph.vim @@ -4,6 +4,8 @@ if !has("digraphs") || !has("multi_byte") finish endif +scriptencoding utf-8 + func! Put_Dig(chars) exe "norm! o\".a:chars endfu @@ -13,8 +15,8 @@ func! Put_Dig_BS(char1, char2) endfu func! Test_digraphs() - let _enc=&enc - set nocp enc=utf8 + let _enc = &enc + set enc=utf8 new call Put_Dig("00") call assert_equal("∞", getline('.')) @@ -214,7 +216,7 @@ func! Test_digraphs() call Put_Dig("el") call assert_equal(['␀', 'ü', '∞', 'l'], getline(line('.')-3,line('.'))) " reset encoding option - let &enc=_enc + let &enc = _enc bw! endfunc @@ -222,7 +224,7 @@ func! Test_digraphs_option() let _enc=&enc " reset whichwrap option, so that testing A works, " without moving up a line - set nocp enc=utf8 digraph ww= + set enc=utf8 digraph ww= new call Put_Dig_BS("0","0") call assert_equal("∞", getline('.')) @@ -422,7 +424,7 @@ func! Test_digraphs_option() call Put_Dig_BS("e","l") call assert_equal(['␀', 'ü', '∞', 'l'], getline(line('.')-3,line('.'))) " reset encoding option - let &enc=_enc + let &enc = _enc set nodigraph ww&vim bw! endfunc diff --git a/src/version.c b/src/version.c index 69da119210..167d405589 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2084, /**/ 2083, /**/ From dfd63e30d13fff5603416b6c7e247cebeb003eb0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 21 Jul 2016 10:11:03 +0200 Subject: [PATCH 5/9] patch 7.4.2085 Problem: Digraph tests fails on some systems. Solution: Run it separately and set 'encoding' early. --- src/testdir/Make_all.mak | 1 + src/testdir/test_alot.vim | 1 - src/testdir/test_digraph.vim | 10 ++-------- src/version.c | 2 ++ 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 9b8770d53b..11cc93429e 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -170,6 +170,7 @@ NEW_TESTS = test_arglist.res \ test_channel.res \ test_cmdline.res \ test_cscope.res \ + test_digraph.res \ test_farsi.res \ test_hardcopy.res \ test_history.res \ diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index e87ff90ebf..e9c84398e8 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -5,7 +5,6 @@ source test_assign.vim source test_autocmd.vim source test_cursor_func.vim source test_delete.vim -source test_digraph.vim source test_execute_func.vim source test_ex_undo.vim source test_expand.vim diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim index b12e19fa7c..60ae1fd3f4 100644 --- a/src/testdir/test_digraph.vim +++ b/src/testdir/test_digraph.vim @@ -4,6 +4,7 @@ if !has("digraphs") || !has("multi_byte") finish endif +set enc=utf-8 scriptencoding utf-8 func! Put_Dig(chars) @@ -15,8 +16,6 @@ func! Put_Dig_BS(char1, char2) endfu func! Test_digraphs() - let _enc = &enc - set enc=utf8 new call Put_Dig("00") call assert_equal("∞", getline('.')) @@ -215,16 +214,13 @@ func! Test_digraphs() call Put_Dig("00") call Put_Dig("el") call assert_equal(['␀', 'ü', '∞', 'l'], getline(line('.')-3,line('.'))) - " reset encoding option - let &enc = _enc bw! endfunc func! Test_digraphs_option() - let _enc=&enc " reset whichwrap option, so that testing A works, " without moving up a line - set enc=utf8 digraph ww= + set digraph ww= new call Put_Dig_BS("0","0") call assert_equal("∞", getline('.')) @@ -423,8 +419,6 @@ func! Test_digraphs_option() call Put_Dig_BS("0","0") call Put_Dig_BS("e","l") call assert_equal(['␀', 'ü', '∞', 'l'], getline(line('.')-3,line('.'))) - " reset encoding option - let &enc = _enc set nodigraph ww&vim bw! endfunc diff --git a/src/version.c b/src/version.c index 167d405589..6f9ce5d30d 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2085, /**/ 2084, /**/ From ac105ed3c420660ddbddc501c97875c48220817e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 21 Jul 2016 20:33:32 +0200 Subject: [PATCH 6/9] patch 7.4.2086 Problem: Using the system default encoding makes tests unpredictable. Solution: Always use utf-8 or latin1 in the new style tests. Remove setting encoding and scriptencoding where it is not needed. --- src/testdir/runtest.vim | 8 ++++++++ src/testdir/test_alot_utf8.vim | 3 ++- src/testdir/test_channel.vim | 1 - src/testdir/test_digraph.vim | 3 --- src/testdir/test_expand_dllpath.vim | 2 -- src/testdir/test_expr_utf8.vim | 2 -- src/testdir/test_json.vim | 5 +---- src/testdir/test_matchadd_conceal_utf8.vim | 2 -- src/testdir/test_regexp_utf8.vim | 2 -- src/testdir/test_visual.vim | 4 +--- src/version.c | 2 ++ 11 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index 559d5f875a..e06e0cbdf9 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -49,6 +49,14 @@ source setup.vim " This also enables use of line continuation. set nocp viminfo+=nviminfo +" Use utf-8 or latin1 be default, instead of whatever the system default +" happens to be. Individual tests can overrule this at the top of the file. +if has('multi_byte') + set encoding=utf-8 +else + set encoding=latin1 +endif + " Avoid stopping at the "hit enter" prompt set nomore diff --git a/src/testdir/test_alot_utf8.vim b/src/testdir/test_alot_utf8.vim index 8824ee5e15..049251f9a7 100644 --- a/src/testdir/test_alot_utf8.vim +++ b/src/testdir/test_alot_utf8.vim @@ -1,7 +1,8 @@ " A series of tests that can run in one Vim invocation. " This makes testing go faster, since Vim doesn't need to restart. -" These tests use utf8 'encoding'. Setting 'encoding' is in the individual +" These tests use utf8 'encoding'. Setting 'encoding' is already done in +" runtest.vim. Checking for the multi_byte feature is in the individual " files, so that they can be run by themselves. source test_expr_utf8.vim diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index af9060a78f..e00cc502b5 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -1,5 +1,4 @@ " Test for channel functions. -scriptencoding utf-8 if !has('channel') finish diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim index 60ae1fd3f4..12cda4d461 100644 --- a/src/testdir/test_digraph.vim +++ b/src/testdir/test_digraph.vim @@ -4,9 +4,6 @@ if !has("digraphs") || !has("multi_byte") finish endif -set enc=utf-8 -scriptencoding utf-8 - func! Put_Dig(chars) exe "norm! o\".a:chars endfu diff --git a/src/testdir/test_expand_dllpath.vim b/src/testdir/test_expand_dllpath.vim index e69e7e1b31..d8ab416681 100644 --- a/src/testdir/test_expand_dllpath.vim +++ b/src/testdir/test_expand_dllpath.vim @@ -1,5 +1,3 @@ -scriptencoding utf-8 - func s:test_expand_dllpath(optname) let $TEST_EXPAND_DLLPATH = '/dllpath/lib' . substitute(a:optname, '\zedll$', '.', '') execute 'let dllpath_save = &' . a:optname diff --git a/src/testdir/test_expr_utf8.vim b/src/testdir/test_expr_utf8.vim index e8246ef383..1737a9f745 100644 --- a/src/testdir/test_expr_utf8.vim +++ b/src/testdir/test_expr_utf8.vim @@ -2,8 +2,6 @@ if !has('multi_byte') finish endif -set encoding=utf-8 -scriptencoding utf-8 func Test_strgetchar() call assert_equal(char2nr('á'), strgetchar('áxb', 0)) diff --git a/src/testdir/test_json.vim b/src/testdir/test_json.vim index 589fcb9edc..e149036460 100644 --- a/src/testdir/test_json.vim +++ b/src/testdir/test_json.vim @@ -1,12 +1,9 @@ " Test for JSON functions. -" JSON requires using utf-8. Conversion breaks the asserts, therefore set -" 'encoding' to utf-8. +" JSON requires using utf-8, because conversion breaks the asserts. if !has('multi_byte') finish endif -set encoding=utf-8 -scriptencoding utf-8 let s:json1 = '"str\"in\\g"' let s:var1 = "str\"in\\g" diff --git a/src/testdir/test_matchadd_conceal_utf8.vim b/src/testdir/test_matchadd_conceal_utf8.vim index 8293fbe75c..34d3ee28f0 100644 --- a/src/testdir/test_matchadd_conceal_utf8.vim +++ b/src/testdir/test_matchadd_conceal_utf8.vim @@ -2,8 +2,6 @@ if !has('conceal') || !has('multi_byte') finish endif -set encoding=utf-8 -scriptencoding utf-8 if !has('gui_running') && has('unix') set term=ansi diff --git a/src/testdir/test_regexp_utf8.vim b/src/testdir/test_regexp_utf8.vim index 6247b30e6c..81d8f5b04a 100644 --- a/src/testdir/test_regexp_utf8.vim +++ b/src/testdir/test_regexp_utf8.vim @@ -2,8 +2,6 @@ if !has('multi_byte') finish endif -set encoding=utf-8 -scriptencoding utf-8 func s:equivalence_test() let str = "AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐẔ aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑẕ" diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim index 177f571454..240546bc23 100644 --- a/src/testdir/test_visual.vim +++ b/src/testdir/test_visual.vim @@ -1,9 +1,7 @@ -" Tests for Visual mode +" Tests for Visual mode. Uses double-wide character. if !has('multi_byte') finish endif -set encoding=utf-8 -scriptencoding utf-8 if !has('visual') finish diff --git a/src/version.c b/src/version.c index 6f9ce5d30d..9af59e55c5 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2086, /**/ 2085, /**/ From e25bc5abb4621c6263b0248988a207d53b57fc54 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 21 Jul 2016 21:23:38 +0200 Subject: [PATCH 7/9] patch 7.4.2087 Problem: Digraph code test coverage is still low. Solution: Add more tests. (Christian Brabandt) --- src/testdir/test_digraph.vim | 35 +++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 2 files changed, 37 insertions(+) diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim index 12cda4d461..2840229007 100644 --- a/src/testdir/test_digraph.vim +++ b/src/testdir/test_digraph.vim @@ -420,4 +420,39 @@ func! Test_digraphs_option() bw! endfunc +func! Test_digraphs_output() + new + let out = execute(':digraph') + call assert_equal('Eu € 8364', matchstr(out, '\C\')) + call assert_equal('=e € 8364', matchstr(out, '\C=e\D*8364\>')) + call assert_equal('=R ₽ 8381', matchstr(out, '\C=R\D*8381\>')) + call assert_equal('=P ₽ 8381', matchstr(out, '\C=P\D*8381\>')) + call assert_equal('o: ö 246', matchstr(out, '\C\')) + call assert_equal('v4 ㄪ 12586', matchstr(out, '\C\')) + call assert_equal("'0 ˚ 730", matchstr(out, '\C''0\D*730\>')) + call assert_equal('Z% Ж 1046', matchstr(out, '\C\')) + call assert_equal('u- ū 363', matchstr(out, '\C\')) + call assert_equal('SH ^A 1', matchstr(out, '\C\')) + bw! +endfunc + +func! Test_loadkeymap() + new + set keymap=czech + set iminsert=0 + call feedkeys("o|\|01234567890|\", 'tx') + call assert_equal("|'é+ěščřžýáíé'", getline('.')) + " reset keymap and encoding option + set keymap= + bw! +endfunc + +func! Test_digraph_cmndline() + " Create digraph on commandline + " This is a hack, to let Vim create the digraph in commandline mode + let s = '' + exe "sil! norm! :let s.='\Eu'\" + call assert_equal("€", s) +endfunc + " vim: tabstop=2 shiftwidth=0 sts=-1 expandtab diff --git a/src/version.c b/src/version.c index 9af59e55c5..8f60ccd411 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2087, /**/ 2086, /**/ From f36213597d737ab500771e87edcf121acd55e277 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 21 Jul 2016 22:03:02 +0200 Subject: [PATCH 8/9] patch 7.4.2088 Problem: Keymap test fails with normal features. Solution: Bail out if the keymap feature is not supported. --- src/testdir/test_digraph.vim | 3 +++ src/version.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim index 2840229007..95500853f2 100644 --- a/src/testdir/test_digraph.vim +++ b/src/testdir/test_digraph.vim @@ -437,6 +437,9 @@ func! Test_digraphs_output() endfunc func! Test_loadkeymap() + if !has('keymap') + return + endif new set keymap=czech set iminsert=0 diff --git a/src/version.c b/src/version.c index 8f60ccd411..8883c29f08 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2088, /**/ 2087, /**/ From 36edf0685c8b55ee3ce709058d83ada8027fec1e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 21 Jul 2016 22:10:12 +0200 Subject: [PATCH 9/9] patch 7.4.2089 Problem: Color handling of X11 GUIs is too complicated. Solution: Simplify the code. Use RGBA where appropriate. (Kazunobu Kuriyama) --- src/gui.h | 6 ++ src/gui_beval.c | 49 +++++----- src/gui_gtk_x11.c | 244 +++++++++++++++++----------------------------- src/netbeans.c | 21 +--- src/version.c | 2 + 5 files changed, 125 insertions(+), 197 deletions(-) diff --git a/src/gui.h b/src/gui.h index 4e557ad3b5..81c6b9ab5c 100644 --- a/src/gui.h +++ b/src/gui.h @@ -380,9 +380,15 @@ typedef struct Gui GtkWidget *menubar_h; /* menubar handle */ GtkWidget *toolbar_h; /* toolbar handle */ # endif +# ifdef USE_GTK3 + GdkRGBA *fgcolor; /* GDK-styled foreground color */ + GdkRGBA *bgcolor; /* GDK-styled background color */ + GdkRGBA *spcolor; /* GDK-styled special color */ +# else GdkColor *fgcolor; /* GDK-styled foreground color */ GdkColor *bgcolor; /* GDK-styled background color */ GdkColor *spcolor; /* GDK-styled special color */ +# endif # ifdef USE_GTK3 cairo_surface_t *surface; /* drawarea surface */ gboolean by_signal; /* cause of draw operation */ diff --git a/src/gui_beval.c b/src/gui_beval.c index 4525dde7a0..74da90893e 100644 --- a/src/gui_beval.c +++ b/src/gui_beval.c @@ -1044,7 +1044,12 @@ set_printable_label_text(GtkLabel *label, char_u *text) attrentry_T *aep; PangoAttribute *attr; guicolor_T pixel; +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA color = { 0.0, 0.0, 0.0, 1.0 }; + PangoAttribute *attr_alpha; +#else GdkColor color = { 0, 0, 0, 0 }; +#endif /* Look up the RGB values of the SpecialKey foreground color. */ aep = syn_gui_attr2entry(hl_attr(HLF_8)); @@ -1052,30 +1057,10 @@ set_printable_label_text(GtkLabel *label, char_u *text) if (pixel != INVALCOLOR) # if GTK_CHECK_VERSION(3,0,0) { - GdkVisual * const visual = gtk_widget_get_visual(gui.drawarea); - - if (visual == NULL) - { - color.red = 0; - color.green = 0; - color.blue = 0; - } - else - { - guint32 r_mask, g_mask, b_mask; - gint r_shift, g_shift, b_shift; - - gdk_visual_get_red_pixel_details(visual, &r_mask, &r_shift, - NULL); - gdk_visual_get_green_pixel_details(visual, &g_mask, &g_shift, - NULL); - gdk_visual_get_blue_pixel_details(visual, &b_mask, &b_shift, - NULL); - - color.red = ((pixel & r_mask) >> r_shift) / 255.0 * 65535; - color.green = ((pixel & g_mask) >> g_shift) / 255.0 * 65535; - color.blue = ((pixel & b_mask) >> b_shift) / 255.0 * 65535; - } + color.red = ((pixel & 0xff0000) >> 16) / 255.0; + color.green = ((pixel & 0xff00) >> 8) / 255.0; + color.blue = (pixel & 0xff) / 255.0; + color.alpha = 1.0; } # else gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea), @@ -1124,11 +1109,27 @@ set_printable_label_text(GtkLabel *label, char_u *text) } if (pixel != INVALCOLOR) { +#if GTK_CHECK_VERSION(3,0,0) +# define DOUBLE2UINT16(val) ((guint16)((val) * 65535 + 0.5)) + attr = pango_attr_foreground_new( + DOUBLE2UINT16(color.red), + DOUBLE2UINT16(color.green), + DOUBLE2UINT16(color.blue)); + attr_alpha = pango_attr_foreground_alpha_new( + DOUBLE2UINT16(color.alpha)); +# undef DOUBLE2UINT16 +#else attr = pango_attr_foreground_new( color.red, color.green, color.blue); +#endif attr->start_index = pdest - buf; attr->end_index = pdest - buf + outlen; pango_attr_list_insert(attr_list, attr); +#if GTK_CHECK_VERSION(3,0,0) + attr_alpha->start_index = pdest - buf; + attr_alpha->end_index = pdest - buf + outlen; + pango_attr_list_insert(attr_list, attr_alpha); +#endif } pdest += outlen; p += charlen; diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index fa99f151ff..939ecde7ee 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -2865,8 +2865,10 @@ create_blank_pointer(void) GdkPixmap *blank_mask; #endif GdkCursor *cursor; +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA color = { 0.0, 0.0, 0.0, 1.0 }; +#else GdkColor color = { 0, 0, 0, 0 }; -#if !GTK_CHECK_VERSION(3,0,0) char blank_data[] = { 0x0 }; #endif @@ -2892,10 +2894,11 @@ create_blank_pointer(void) surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 1, 1); cr = cairo_create(surf); - cairo_set_source_rgb(cr, - color.red / 65535.0, - color.green / 65535.0, - color.blue / 65535.0); + cairo_set_source_rgba(cr, + color.red, + color.green, + color.blue, + color.alpha); cairo_rectangle(cr, 0, 0, 1, 1); cairo_fill(cr); cairo_destroy(cr); @@ -3824,12 +3827,18 @@ gui_mch_init(void) gui.border_width = 2; gui.scrollbar_width = SB_DEFAULT_WIDTH; gui.scrollbar_height = SB_DEFAULT_WIDTH; +#if GTK_CHECK_VERSION(3,0,0) + gui.fgcolor = g_new(GdkRGBA, 1); + gui.bgcolor = g_new(GdkRGBA, 1); + gui.spcolor = g_new(GdkRGBA, 1); +#else /* LINTED: avoid warning: conversion to 'unsigned long' */ gui.fgcolor = g_new0(GdkColor, 1); /* LINTED: avoid warning: conversion to 'unsigned long' */ gui.bgcolor = g_new0(GdkColor, 1); /* LINTED: avoid warning: conversion to 'unsigned long' */ gui.spcolor = g_new0(GdkColor, 1); +#endif /* Initialise atoms */ html_atom = gdk_atom_intern("text/html", FALSE); @@ -4344,63 +4353,22 @@ gui_mch_forked(void) #endif /* FEAT_GUI_GNOME && FEAT_SESSION */ #if GTK_CHECK_VERSION(3,0,0) - static void -gui_gtk_get_rgb_from_pixel(guint32 pixel, GdkRGBA *result) + static GdkRGBA +color_to_rgba(guicolor_T color) { - GdkVisual * const visual = gtk_widget_get_visual(gui.drawarea); - guint32 r_mask, g_mask, b_mask; - gint r_shift, g_shift, b_shift; - - if (visual == NULL) - { - result->red = 0.0; - result->green = 0.0; - result->blue = 0.0; - result->alpha = 0.0; - return; - } - - gdk_visual_get_red_pixel_details(visual, &r_mask, &r_shift, NULL); - gdk_visual_get_green_pixel_details(visual, &g_mask, &g_shift, NULL); - gdk_visual_get_blue_pixel_details(visual, &b_mask, &b_shift, NULL); - - result->red = ((pixel & r_mask) >> r_shift) / 255.0; - result->green = ((pixel & g_mask) >> g_shift) / 255.0; - result->blue = ((pixel & b_mask) >> b_shift) / 255.0; - result->alpha = 1.0; -} - -/* Convert a GdRGBA into a pixel value using drawarea's visual */ - static guint32 -gui_gtk_get_pixel_from_rgb(const GdkRGBA *rgba) -{ - GdkVisual * const visual = gtk_widget_get_visual(gui.drawarea); - guint32 r_mask, g_mask, b_mask; - gint r_shift, g_shift, b_shift; - guint32 r, g, b; - - if (visual == NULL) - return 0; - - gdk_visual_get_red_pixel_details(visual, &r_mask, &r_shift, NULL); - gdk_visual_get_green_pixel_details(visual, &g_mask, &g_shift, NULL); - gdk_visual_get_blue_pixel_details(visual, &b_mask, &b_shift, NULL); - - r = rgba->red * 65535; - g = rgba->green * 65535; - b = rgba->blue * 65535; - - return ((r << r_shift) & r_mask) | - ((g << g_shift) & g_mask) | - ((b << b_shift) & b_mask); + GdkRGBA rgba; + rgba.red = ((color & 0xff0000) >> 16) / 255.0; + rgba.green = ((color & 0xff00) >> 8) / 255.0; + rgba.blue = ((color & 0xff)) / 255.0; + rgba.alpha = 1.0; + return rgba; } static void -set_cairo_source_rgb_from_pixel(cairo_t *cr, guint32 pixel) +set_cairo_source_rgba_from_color(cairo_t *cr, guicolor_T color) { - GdkRGBA result; - gui_gtk_get_rgb_from_pixel(pixel, &result); - cairo_set_source_rgb(cr, result.red, result.green, result.blue); + const GdkRGBA rgba = color_to_rgba(color); + cairo_set_source_rgba(cr, rgba.red, rgba.green, rgba.blue, rgba.alpha); } #endif /* GTK_CHECK_VERSION(3,0,0) */ @@ -4421,19 +4389,19 @@ gui_mch_new_colors(void) #endif { #if GTK_CHECK_VERSION(3,4,0) - GdkRGBA color; + GdkRGBA rgba; - gui_gtk_get_rgb_from_pixel(gui.back_pixel, &color); + rgba = color_to_rgba(gui.back_pixel); { cairo_pattern_t * const pat = cairo_pattern_create_rgba( - color.red, color.green, color.blue, color.alpha); + rgba.red, rgba.green, rgba.blue, rgba.alpha); if (pat != NULL) { gdk_window_set_background_pattern(da_win, pat); cairo_pattern_destroy(pat); } else - gdk_window_set_background_rgba(da_win, &color); + gdk_window_set_background_rgba(da_win, &rgba); } #else /* !GTK_CHECK_VERSION(3,4,0) */ GdkColor color = { 0, 0, 0, 0 }; @@ -5518,93 +5486,36 @@ gui_mch_free_font(GuiFont font) } /* - * Return the Pixel value (color) for the given color name. This routine was - * pretty much taken from example code in the Silicon Graphics OSF/Motif - * Programmer's Guide. + * Return the Pixel value (color) for the given color name. + * * Return INVALCOLOR for error. */ guicolor_T gui_mch_get_color(char_u *name) { - /* A number of colors that some X11 systems don't have */ - static const char *const vimnames[][2] = - { - {"LightRed", "#FFBBBB"}, - {"LightGreen", "#88FF88"}, - {"LightMagenta","#FFBBFF"}, - {"DarkCyan", "#008888"}, - {"DarkBlue", "#0000BB"}, - {"DarkRed", "#BB0000"}, - {"DarkMagenta", "#BB00BB"}, - {"DarkGrey", "#BBBBBB"}, - {"DarkYellow", "#BBBB00"}, - {"Gray10", "#1A1A1A"}, - {"Grey10", "#1A1A1A"}, - {"Gray20", "#333333"}, - {"Grey20", "#333333"}, - {"Gray30", "#4D4D4D"}, - {"Grey30", "#4D4D4D"}, - {"Gray40", "#666666"}, - {"Grey40", "#666666"}, - {"Gray50", "#7F7F7F"}, - {"Grey50", "#7F7F7F"}, - {"Gray60", "#999999"}, - {"Grey60", "#999999"}, - {"Gray70", "#B3B3B3"}, - {"Grey70", "#B3B3B3"}, - {"Gray80", "#CCCCCC"}, - {"Grey80", "#CCCCCC"}, - {"Gray90", "#E5E5E5"}, - {"Grey90", "#E5E5E5"}, - {NULL, NULL} - }; - if (!gui.in_use) /* can't do this when GUI not running */ return INVALCOLOR; - while (name != NULL) - { #if GTK_CHECK_VERSION(3,0,0) - GdkRGBA color; + return name != NULL ? gui_get_color_cmn(name) : INVALCOLOR; #else - GdkColor color; -#endif - int parsed; - int i; + guicolor_T color; + GdkColor gcolor; + int ret; -#if GTK_CHECK_VERSION(3,0,0) - parsed = gdk_rgba_parse(&color, (const gchar *)name); -#else - parsed = gdk_color_parse((const char *)name, &color); -#endif + color = (name != NULL) ? gui_get_color_cmn(name) : INVALCOLOR; + if (color == INVALCOLOR) + return INVALCOLOR; - if (parsed) - { -#if GTK_CHECK_VERSION(3,0,0) - return (guicolor_T)gui_gtk_get_pixel_from_rgb(&color); -#else - gdk_colormap_alloc_color(gtk_widget_get_colormap(gui.drawarea), - &color, FALSE, TRUE); - return (guicolor_T)color.pixel; -#endif - } - /* add a few builtin names and try again */ - for (i = 0; ; ++i) - { - if (vimnames[i][0] == NULL) - { - name = NULL; - break; - } - if (STRICMP(name, vimnames[i][0]) == 0) - { - name = (char_u *)vimnames[i][1]; - break; - } - } - } + gcolor.red = (guint16)(((color & 0xff0000) >> 16) / 255.0 * 65535 + 0.5); + gcolor.green = (guint16)(((color & 0xff00) >> 8) / 255.0 * 65535 + 0.5); + gcolor.blue = (guint16)((color & 0xff) / 255.0 * 65535 + 0.5); - return INVALCOLOR; + ret = gdk_colormap_alloc_color(gtk_widget_get_colormap(gui.drawarea), + &gcolor, FALSE, TRUE); + + return ret != 0 ? (guicolor_T)gcolor.pixel : INVALCOLOR; +#endif } /* @@ -5613,7 +5524,11 @@ gui_mch_get_color(char_u *name) void gui_mch_set_fg_color(guicolor_T color) { +#if GTK_CHECK_VERSION(3,0,0) + *gui.fgcolor = color_to_rgba(color); +#else gui.fgcolor->pixel = (unsigned long)color; +#endif } /* @@ -5622,7 +5537,11 @@ gui_mch_set_fg_color(guicolor_T color) void gui_mch_set_bg_color(guicolor_T color) { +#if GTK_CHECK_VERSION(3,0,0) + *gui.bgcolor = color_to_rgba(color); +#else gui.bgcolor->pixel = (unsigned long)color; +#endif } /* @@ -5631,7 +5550,11 @@ gui_mch_set_bg_color(guicolor_T color) void gui_mch_set_sp_color(guicolor_T color) { +#if GTK_CHECK_VERSION(3,0,0) + *gui.spcolor = color_to_rgba(color); +#else gui.spcolor->pixel = (unsigned long)color; +#endif } /* @@ -5792,7 +5715,9 @@ draw_glyph_string(int row, int col, int num_cells, int flags, if (!(flags & DRAW_TRANSP)) { #if GTK_CHECK_VERSION(3,0,0) - set_cairo_source_rgb_from_pixel(cr, gui.bgcolor->pixel); + cairo_set_source_rgba(cr, + gui.bgcolor->red, gui.bgcolor->green, gui.bgcolor->blue, + gui.bgcolor->alpha); cairo_rectangle(cr, FILL_X(col), FILL_Y(row), num_cells * gui.char_width, gui.char_height); @@ -5811,7 +5736,9 @@ draw_glyph_string(int row, int col, int num_cells, int flags, } #if GTK_CHECK_VERSION(3,0,0) - set_cairo_source_rgb_from_pixel(cr, gui.fgcolor->pixel); + cairo_set_source_rgba(cr, + gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue, + gui.fgcolor->alpha); cairo_move_to(cr, TEXT_X(col), TEXT_Y(row)); pango_cairo_show_glyph_string(cr, font, glyphs); #else @@ -5829,7 +5756,9 @@ draw_glyph_string(int row, int col, int num_cells, int flags, if ((flags & DRAW_BOLD) && !gui.font_can_bold) #if GTK_CHECK_VERSION(3,0,0) { - set_cairo_source_rgb_from_pixel(cr, gui.fgcolor->pixel); + cairo_set_source_rgba(cr, + gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue, + gui.fgcolor->alpha); cairo_move_to(cr, TEXT_X(col) + 1, TEXT_Y(row)); pango_cairo_show_glyph_string(cr, font, glyphs); } @@ -5865,7 +5794,9 @@ draw_under(int flags, int row, int col, int cells) #if GTK_CHECK_VERSION(3,0,0) cairo_set_line_width(cr, 1.0); cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT); - set_cairo_source_rgb_from_pixel(cr, gui.spcolor->pixel); + cairo_set_source_rgba(cr, + gui.spcolor->red, gui.spcolor->green, gui.spcolor->blue, + gui.spcolor->alpha); for (i = FILL_X(col); i < FILL_X(col + cells); ++i) { offset = val[i % 8]; @@ -5894,7 +5825,9 @@ draw_under(int flags, int row, int col, int cells) { cairo_set_line_width(cr, 1.0); cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT); - set_cairo_source_rgb_from_pixel(cr, gui.fgcolor->pixel); + cairo_set_source_rgba(cr, + gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue, + gui.fgcolor->alpha); cairo_move_to(cr, FILL_X(col), y + 0.5); cairo_line_to(cr, FILL_X(col + cells), y + 0.5); cairo_stroke(cr); @@ -6361,7 +6294,7 @@ gui_mch_invert_rectangle(int r, int c, int nr, int nc) }; cairo_t * const cr = cairo_create(gui.surface); - set_cairo_source_rgb_from_pixel(cr, gui.norm_pixel ^ gui.back_pixel); + set_cairo_source_rgba_from_color(cr, gui.norm_pixel ^ gui.back_pixel); # if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,2) cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); # else @@ -6445,7 +6378,9 @@ gui_mch_draw_hollow_cursor(guicolor_T color) gui_mch_set_fg_color(color); #if GTK_CHECK_VERSION(3,0,0) - set_cairo_source_rgb_from_pixel(cr, gui.fgcolor->pixel); + cairo_set_source_rgba(cr, + gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue, + gui.fgcolor->alpha); #else gdk_gc_set_foreground(gui.text_gc, gui.fgcolor); #endif @@ -6488,7 +6423,9 @@ gui_mch_draw_part_cursor(int w, int h, guicolor_T color) cairo_t *cr; cr = cairo_create(gui.surface); - set_cairo_source_rgb_from_pixel(cr, gui.fgcolor->pixel); + cairo_set_source_rgba(cr, + gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue, + gui.fgcolor->alpha); cairo_rectangle(cr, # ifdef FEAT_RIGHTLEFT /* vertical line should be on the right of current point */ @@ -6686,7 +6623,7 @@ gui_mch_clear_block(int row1, int col1, int row2, int col2) if (pat != NULL) cairo_set_source(cr, pat); else - set_cairo_source_rgb_from_pixel(cr, gui.back_pixel); + set_cairo_source_rgba_from_color(cr, gui.back_pixel); gdk_cairo_rectangle(cr, &rect); cairo_fill(cr); cairo_destroy(cr); @@ -6719,7 +6656,7 @@ gui_gtk_window_clear(GdkWindow *win) if (pat != NULL) cairo_set_source(cr, pat); else - set_cairo_source_rgb_from_pixel(cr, gui.back_pixel); + set_cairo_source_rgba_from_color(cr, gui.back_pixel); gdk_cairo_rectangle(cr, &rect); cairo_fill(cr); cairo_destroy(cr); @@ -7079,23 +7016,18 @@ gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) long_u gui_mch_get_rgb(guicolor_T pixel) { - GdkColor color; #if GTK_CHECK_VERSION(3,0,0) - GdkRGBA rgba; - - gui_gtk_get_rgb_from_pixel(pixel, &rgba); - - color.red = rgba.red * 65535; - color.green = rgba.green * 65535; - color.blue = rgba.blue * 65535; + return (long_u)pixel; #else + GdkColor color; + gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea), (unsigned long)pixel, &color); -#endif return (((unsigned)color.red & 0xff00) << 8) | ((unsigned)color.green & 0xff00) | (((unsigned)color.blue & 0xff00) >> 8); +#endif } /* @@ -7355,7 +7287,9 @@ gui_mch_drawsign(int row, int col, int typenr) cairo_surface_get_content(gui.surface), SIGN_WIDTH, SIGN_HEIGHT); bg_cr = cairo_create(bg_surf); - set_cairo_source_rgb_from_pixel(bg_cr, gui.bgcolor->pixel); + cairo_set_source_rgba(bg_cr, + gui.bgcolor->red, gui.bgcolor->green, gui.bgcolor->blue, + gui.bgcolor->alpha); cairo_paint(bg_cr); sign_surf = cairo_surface_create_similar(gui.surface, diff --git a/src/netbeans.c b/src/netbeans.c index 736bb16b09..7d6ec43444 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -3097,24 +3097,9 @@ netbeans_draw_multisign_indicator(int row) #if GTK_CHECK_VERSION(3,0,0) cr = cairo_create(gui.surface); - { - GdkVisual *visual = NULL; - guint32 r_mask, g_mask, b_mask; - gint r_shift, g_shift, b_shift; - - visual = gdk_window_get_visual(gtk_widget_get_window(gui.drawarea)); - if (visual != NULL) - { - gdk_visual_get_red_pixel_details(visual, &r_mask, &r_shift, NULL); - gdk_visual_get_green_pixel_details(visual, &g_mask, &g_shift, NULL); - gdk_visual_get_blue_pixel_details(visual, &b_mask, &b_shift, NULL); - - cairo_set_source_rgb(cr, - ((gui.fgcolor->red & r_mask) >> r_shift) / 255.0, - ((gui.fgcolor->green & g_mask) >> g_shift) / 255.0, - ((gui.fgcolor->blue & b_mask) >> b_shift) / 255.0); - } - } + cairo_set_source_rgba(cr, + gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue, + gui.fgcolor->alpha); #endif x = 0; diff --git a/src/version.c b/src/version.c index 8883c29f08..dccf2ce3dc 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2089, /**/ 2088, /**/