Patch 8.0.0447
Problem:    Getting font name does not work on X11.
Solution:   Implement gui_mch_get_fontname() for X11.  Add more GUI tests.
            (Kazunobu Kuriyama)
Files:      src/gui_x11.c, src/syntax.c, src/testdir/Make_dos.mak,
            src/testdir/Make_ming.mak, src/testdir/Makefile,
            src/testdir/gui_init.vim, src/testdir/gui_preinit.vim,
            src/testdir/test_gui.vim, src/testdir/test_gui_init.vim,
            Filelist


*** ../vim-8.0.0446/src/gui_x11.c       2017-02-25 16:01:41.062484813 +0100
--- src/gui_x11.c       2017-03-12 16:47:26.975813581 +0100
***************
*** 1992,2005 ****
  #if defined(FEAT_EVAL) || defined(PROTO)
  /*
   * Return the name of font "font" in allocated memory.
-  * Don't know how to get the actual name, thus use the provided name.
   */
      char_u *
! gui_mch_get_fontname(GuiFont font UNUSED, char_u *name)
  {
!     if (name == NULL)
!       return NULL;
!     return vim_strsave(name);
  }
  #endif
  
--- 1992,2031 ----
  #if defined(FEAT_EVAL) || defined(PROTO)
  /*
   * Return the name of font "font" in allocated memory.
   */
      char_u *
! gui_mch_get_fontname(GuiFont font, char_u *name)
  {
!     char_u *ret = NULL;
! 
!     if (name != NULL && font == NULL)
!     {
!       /* In this case, there's no way other than doing this. */
!       ret = vim_strsave(name);
!     }
!     else if (font != NULL)
!     {
!       /* In this case, try to retrieve the XLFD corresponding to 'font'->fid;
!        * if failed, use 'name' unless it's NULL. */
!       unsigned long value = 0L;
! 
!       if (XGetFontProperty(font, XA_FONT, &value))
!       {
!           char *xa_font_name = NULL;
! 
!           xa_font_name = XGetAtomName(gui.dpy, value);
!           if (xa_font_name != NULL)
!           {
!               ret = vim_strsave((char_u *)xa_font_name);
!               XFree(xa_font_name);
!           }
!           else if (name != NULL)
!               ret = vim_strsave(name);
!       }
!       else if (name != NULL)
!           ret = vim_strsave(name);
!     }
!     return ret;
  }
  #endif
  
*** ../vim-8.0.0446/src/syntax.c        2017-03-05 21:18:21.885452125 +0100
--- src/syntax.c        2017-03-12 16:47:26.975813581 +0100
***************
*** 8169,8175 ****
            || HL_TABLE()[idx].sg_gui_fg_name != NULL
            || HL_TABLE()[idx].sg_gui_bg_name != NULL
            || HL_TABLE()[idx].sg_gui_sp_name != NULL
!           || HL_TABLE()[idx].sg_font_name != NUL
  #endif
            || (check_link && (HL_TABLE()[idx].sg_set & SG_LINK)));
  }
--- 8169,8175 ----
            || HL_TABLE()[idx].sg_gui_fg_name != NULL
            || HL_TABLE()[idx].sg_gui_bg_name != NULL
            || HL_TABLE()[idx].sg_gui_sp_name != NULL
!           || HL_TABLE()[idx].sg_font_name != NULL
  #endif
            || (check_link && (HL_TABLE()[idx].sg_set & SG_LINK)));
  }
*** ../vim-8.0.0446/src/testdir/Make_dos.mak    2017-03-08 00:01:31.489347798 
+0100
--- src/testdir/Make_dos.mak    2017-03-12 16:47:26.975813581 +0100
***************
*** 126,132 ****
  
  test_gui_init.res: test_gui_init.vim
        @echo "$(VIMPROG)" > vimcmd
!       $(VIMPROG) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $*.vim
        @del vimcmd
  
  opt_test.vim: ../option.c gen_opt_test.vim
--- 126,132 ----
  
  test_gui_init.res: test_gui_init.vim
        @echo "$(VIMPROG)" > vimcmd
!       $(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S 
runtest.vim $*.vim
        @del vimcmd
  
  opt_test.vim: ../option.c gen_opt_test.vim
*** ../vim-8.0.0446/src/testdir/Make_ming.mak   2017-03-08 00:01:31.489347798 
+0100
--- src/testdir/Make_ming.mak   2017-03-12 16:47:26.975813581 +0100
***************
*** 129,135 ****
  
  test_gui_init.res: test_gui_init.vim
        @echo "$(VIMPROG)" > vimcmd
!       $(VIMPROG) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
        @$(DEL) vimcmd
  
  opt_test.vim: ../option.c gen_opt_test.vim
--- 129,135 ----
  
  test_gui_init.res: test_gui_init.vim
        @echo "$(VIMPROG)" > vimcmd
!       $(VIMPROG) -u gui_preinit_vim -U gui_init.vim $(NO_PLUGINS) -S 
runtest.vim $<
        @$(DEL) vimcmd
  
  opt_test.vim: ../option.c gen_opt_test.vim
*** ../vim-8.0.0446/src/testdir/Makefile        2017-03-08 00:01:31.489347798 
+0100
--- src/testdir/Makefile        2017-03-12 16:47:26.975813581 +0100
***************
*** 138,144 ****
  
  test_gui_init.res: test_gui_init.vim
        @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" > vimcmd
!       $(RUN_VIMTEST) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
        @rm vimcmd
  
  opt_test.vim: ../option.c gen_opt_test.vim
--- 138,144 ----
  
  test_gui_init.res: test_gui_init.vim
        @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" > vimcmd
!       $(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S 
runtest.vim $<
        @rm vimcmd
  
  opt_test.vim: ../option.c gen_opt_test.vim
*** ../vim-8.0.0446/src/testdir/gui_init.vim    2017-02-23 19:32:18.068709554 
+0100
--- src/testdir/gui_init.vim    2017-03-12 16:47:26.975813581 +0100
***************
*** 2,5 ****
--- 2,6 ----
  
  if has('gui_athena') || has('gui_motif') || has('gui_gtk2') || has('gui_gtk3')
    set guiheadroom=0
+   set guioptions+=p
  endif
*** ../vim-8.0.0446/src/testdir/gui_preinit.vim 2017-03-12 17:09:32.182230067 
+0100
--- src/testdir/gui_preinit.vim 2017-03-12 16:47:26.975813581 +0100
***************
*** 0 ****
--- 1,7 ----
+ " vimrc for test_gui_init.vim
+ 
+ " Note that this flag must be added in the .vimrc file, before switching on
+ " syntax or filetype recognition (when the |gvimrc| file is sourced the system
+ " menu has already been loaded; the ":syntax on" and ":filetype on" commands
+ " load the menu too).
+ set guioptions+=M
*** ../vim-8.0.0446/src/testdir/test_gui.vim    2017-03-05 13:48:04.667867105 
+0100
--- src/testdir/test_gui.vim    2017-03-12 16:47:26.975813581 +0100
***************
*** 30,35 ****
--- 30,47 ----
    endif
  endfunc
  
+ func Test_colorscheme()
+   let colorscheme_saved = exists('g:colors_name') ? g:colors_name : 'default'
+ 
+   colorscheme torte
+   redraw!
+   sleep 200m
+   call assert_equal('dark', &background)
+ 
+   exec 'colorscheme' colorscheme_saved
+   redraw!
+ endfunc
+ 
  func Test_getfontname_with_arg()
    let skipped = ''
  
***************
*** 40,47 ****
      call assert_equal('', getfontname('notexist'))
  
      " Valid font name. This is usually the real name of 7x13 by default.
!     let fname = '-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-1'
!     call assert_equal(fname, getfontname(fname))
  
    elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
      " Invalid font name. The result should be the name plus the default size.
--- 52,59 ----
      call assert_equal('', getfontname('notexist'))
  
      " Valid font name. This is usually the real name of 7x13 by default.
!     let fname = '-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1'
!     call assert_match(fname, getfontname(fname))
  
    elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
      " Invalid font name. The result should be the name plus the default size.
***************
*** 68,75 ****
      " 'expected' is the value specified by SetUp() above.
      call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname)
    elseif has('gui_athena') || has('gui_motif')
!     " 'expected' is DFLT_FONT of gui_x11.c.
!     call assert_equal('7x13', fname)
    elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
      " 'expected' is DEFAULT_FONT of gui_gtk_x11.c.
      call assert_equal('Monospace 10', fname)
--- 80,88 ----
      " 'expected' is the value specified by SetUp() above.
      call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname)
    elseif has('gui_athena') || has('gui_motif')
!     " 'expected' is DFLT_FONT of gui_x11.c or its real name.
!     let pat = 
'\(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)'
!     call assert_match(pat, fname)
    elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
      " 'expected' is DEFAULT_FONT of gui_gtk_x11.c.
      call assert_equal('Monospace 10', fname)
***************
*** 80,85 ****
--- 93,104 ----
    endif
  endfunc
  
+ func Test_getwinpos()
+   call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
+   call assert_true(getwinposx() >= 0)
+   call assert_true(getwinposy() >= 0)
+ endfunc
+ 
  func Test_quoteplus()
    let skipped = ''
  
***************
*** 125,130 ****
--- 144,161 ----
    endif
  endfunc
  
+ func Test_set_background()
+   let background_saved = &background
+ 
+   set background&
+   call assert_equal('light', &background)
+ 
+   set background=dark
+   call assert_equal('dark', &background)
+ 
+   let &background = background_saved
+ endfunc
+ 
  func Test_set_balloondelay()
    if !exists('+balloondelay')
      return
***************
*** 248,253 ****
--- 279,324 ----
    let &balloonexpr = balloonexpr_saved
  endfunc
  
+ " Invalid arguments are tested with test_options in conjunction with segfaults
+ " caused by them (Patch 8.0.0357, 24922ec233).
+ func Test_set_guicursor()
+   let guicursor_saved = &guicursor
+ 
+   let default = [
+         \ "n-v-c:block-Cursor/lCursor",
+         \ "ve:ver35-Cursor",
+         \ "o:hor50-Cursor",
+         \ "i-ci:ver25-Cursor/lCursor",
+         \ "r-cr:hor20-Cursor/lCursor",
+         \ "sm:block-Cursor-blinkwait175-blinkoff150-blinkon175"
+         \ ]
+ 
+   " Default Value
+   set guicursor&
+   call assert_equal(join(default, ','), &guicursor)
+ 
+   " Argument List Example 1
+   let opt_list = copy(default)
+   let opt_list[0] = "n-c-v:block-nCursor"
+   exec "set guicursor=" . join(opt_list, ',')
+   call assert_equal(join(opt_list, ','), &guicursor)
+   unlet opt_list
+ 
+   " Argument List Example 2
+   let opt_list = copy(default)
+   let opt_list[3] = "i-ci:ver30-iCursor-blinkwait300-blinkon200-blinkoff150"
+   exec "set guicursor=" . join(opt_list, ',')
+   call assert_equal(join(opt_list, ','), &guicursor)
+   unlet opt_list
+ 
+   " 'a' Mode
+   set guicursor&
+   let &guicursor .= ',a:blinkon0'
+   call assert_equal(join(default, ',') . ",a:blinkon0", &guicursor)
+ 
+   let &guicursor = guicursor_saved
+ endfunc
+ 
  func Test_set_guifont()
    let skipped = ''
  
***************
*** 274,284 ****
      " Non-empty font list with a valid font name.  Should pick up the first
      " valid font.
      set guifont=-notexist1-*,fixed,-notexist2-*
!     call assert_equal('fixed', getfontname())
  
      " Empty list. Should fallback to the built-in default.
      set guifont=
!     call assert_equal('7x13', getfontname())
  
    elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
      " For GTK, what we refer to as 'font names' in our manual are actually
--- 345,357 ----
      " Non-empty font list with a valid font name.  Should pick up the first
      " valid font.
      set guifont=-notexist1-*,fixed,-notexist2-*
!     let pat = 
'\(fixed\)\|\(\c-Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO8859-1\)'
!     call assert_match(pat, getfontname())
  
      " Empty list. Should fallback to the built-in default.
      set guifont=
!     let pat = 
'\(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)'
!     call assert_match(pat, getfontname())
  
    elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
      " For GTK, what we refer to as 'font names' in our manual are actually
***************
*** 477,486 ****
    endif
  endfunc
  
! func Test_getwinpos()
!   call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
!   call assert_true(getwinposx() >= 0)
!   call assert_true(getwinposy() >= 0)
  endfunc
  
  func Test_shell_command()
--- 550,669 ----
    endif
  endfunc
  
! func Test_set_guioptions()
!   let guioptions_saved = &guioptions
!   let duration = '200m'
! 
!   if has('win32')
!     " Default Value
!     set guioptions&
!     call assert_equal('egmrLtT', &guioptions)
! 
!   else
!     " Default Value
!     set guioptions&
!     call assert_equal('aegimrLtT', &guioptions)
! 
!     " To activate scrollbars of type 'L' or 'R'.
!     wincmd v
!     redraw!
! 
!     " Remove all default GUI ornaments
!     set guioptions-=T
!     exec 'sleep' . duration
!     call assert_equal('aegimrLt', &guioptions)
!     set guioptions-=t
!     exec 'sleep' . duration
!     call assert_equal('aegimrL', &guioptions)
!     set guioptions-=L
!     exec 'sleep' . duration
!     call assert_equal('aegimr', &guioptions)
!     set guioptions-=r
!     exec 'sleep' . duration
!     call assert_equal('aegim', &guioptions)
!     set guioptions-=m
!     exec 'sleep' . duration
!     call assert_equal('aegi', &guioptions)
! 
!     " Try non-default GUI ornaments
!     set guioptions+=l
!     exec 'sleep' . duration
!     call assert_equal('aegil', &guioptions)
!     set guioptions-=l
!     exec 'sleep' . duration
!     call assert_equal('aegi', &guioptions)
! 
!     set guioptions+=R
!     exec 'sleep' . duration
!     call assert_equal('aegiR', &guioptions)
!     set guioptions-=R
!     exec 'sleep' . duration
!     call assert_equal('aegi', &guioptions)
! 
!     set guioptions+=b
!     exec 'sleep' . duration
!     call assert_equal('aegib', &guioptions)
!     set guioptions+=h
!     exec 'sleep' . duration
!     call assert_equal('aegibh', &guioptions)
!     set guioptions-=h
!     exec 'sleep' . duration
!     call assert_equal('aegib', &guioptions)
!     set guioptions-=b
!     exec 'sleep' . duration
!     call assert_equal('aegi', &guioptions)
! 
!     set guioptions+=v
!     exec 'sleep' . duration
!     call assert_equal('aegiv', &guioptions)
!     set guioptions-=v
!     exec 'sleep' . duration
!     call assert_equal('aegi', &guioptions)
! 
!     if has('gui_motif')
!       set guioptions+=F
!       exec 'sleep' . duration
!       call assert_equal('aegiF', &guioptions)
!       set guioptions-=F
!       exec 'sleep' . duration
!       call assert_equal('aegi', &guioptions)
!     endif
! 
!     " Restore GUI ornaments to the default state.
!     set guioptions+=m
!     exec 'sleep' . duration
!     call assert_equal('aegim', &guioptions)
!     set guioptions+=r
!     exec 'sleep' . duration
!     call assert_equal('aegimr', &guioptions)
!     set guioptions+=L
!     exec 'sleep' . duration
!     call assert_equal('aegimrL', &guioptions)
!     set guioptions+=t
!     exec 'sleep' . duration
!     call assert_equal('aegimrLt', &guioptions)
!     set guioptions+=T
!     exec 'sleep' . duration
!     call assert_equal("aegimrLtT", &guioptions)
! 
!     wincmd o
!     redraw!
!   endif
! 
!   let &guioptions = guioptions_saved
! endfunc
! 
! func Test_set_guipty()
!   let guipty_saved = &guipty
! 
!   " Default Value
!   set guipty&
!   call assert_equal(1, &guipty)
! 
!   set noguipty
!   call assert_equal(0, &guipty)
! 
!   let &guipty = guipty_saved
  endfunc
  
  func Test_shell_command()
***************
*** 490,495 ****
--- 673,691 ----
    bwipe!
  endfunc
  
+ func Test_syntax_colortest()
+   runtime syntax/colortest.vim
+   redraw!
+   sleep 200m
+   bwipe!
+ endfunc
+ 
+ func Test_set_term()
+   " It's enough to check the current value since setting 'term' to anything
+   " other than builtin_gui makes no sense at all.
+   call assert_equal('builtin_gui', &term)
+ endfunc
+ 
  func Test_windowid_variable()
    if g:x11_based_gui || has('win32')
      call assert_true(v:windowid > 0)
*** ../vim-8.0.0446/src/testdir/test_gui_init.vim       2017-03-04 
13:32:06.967801328 +0100
--- src/testdir/test_gui_init.vim       2017-03-12 16:47:26.975813581 +0100
***************
*** 36,38 ****
--- 36,60 ----
      throw skipped
    endif
  endfunc
+ 
+ func Test_set_guioptions_for_M()
+   sleep 200ms
+   " Check if the 'M' option is included.
+   call assert_match('.*M.*', &guioptions)
+ endfunc
+ 
+ func Test_set_guioptions_for_p()
+   let skipped = ''
+ 
+   if !g:x11_based_gui
+     let skipped = g:not_supported . '''p'' of guioptions'
+   else
+     sleep 200ms
+     " Check if the 'p' option is included.
+     call assert_match('.*p.*', &guioptions)
+   endif
+ 
+   if !empty(skipped)
+     throw skipped
+   endif
+ endfunc
*** ../vim-8.0.0446/Filelist    2017-03-07 21:27:01.347786655 +0100
--- Filelist    2017-03-12 16:51:31.186046835 +0100
***************
*** 110,115 ****
--- 110,116 ----
                src/testdir/setup.vim \
                src/testdir/gui_init.vim \
                src/testdir/setup_gui.vim \
+               src/testdir/gui_preinit.vim \
                src/testdir/test[0-9]*.ok \
                src/testdir/test[0-9]*a.ok \
                src/testdir/test_[a-z]*.ok \
*** ../vim-8.0.0446/src/version.c       2017-03-12 16:37:50.623999577 +0100
--- src/version.c       2017-03-12 16:49:48.210791546 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     447,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
99. The hum of a cooling fan and the click of keys is comforting to you.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui