Loading ...
Sorry, an error occurred while loading the content.

[BUG] color of visual selection

Expand Messages
  • Markus Heidelberg
    In non-gui vim the color of the visual selection is reverse instead of grey, if t_Co 8. It should only be reversed if t_Co
    Message 1 of 3 , Aug 3, 2008
    • 0 Attachment
      In non-gui vim the color of the visual selection is reverse instead of grey,
      if t_Co > 8. It should only be reversed if t_Co <= 8.

      ":hi Visual" still contains cterm=reverse after setting t_Co to >8, so I think
      this is used instead of ctermbg=7 (grey). After ":hi clear" it's cleaned up
      and the color is shown as intended.

      to reproduce it:
      vim -u NONE

      :set t_Co?
      t_Co=8 (for me)
      :hi Visual
      Visual xxx term=reverse cterm=reverse guibg=LightGrey
      write some text and test visual mode, it's reversed (correct)

      :set t_Co=16
      :hi Visual
      Visual xxx term=reverse cterm=reverse ctermbg=7 guibg=LightGrey
      test visual mode, it's still reversed (wrong)

      :hi clear
      :hi Visual
      Visual xxx term=reverse ctermbg=7 guibg=LightGrey
      test visual mode, now it's grey (correct)

      :set t_Co=8
      :hi Visual
      Visual xxx term=reverse cterm=reverse ctermbg=7 guibg=LightGrey
      test visual mode, it's already (in contrast to t_Co=16) reversed (correct)

      :hi clear
      :hi Visual
      Visual xxx term=reverse cterm=reverse guibg=LightGrey
      test visual mode, it's still reversed (correct)


      I have two solutions and think the first one is acceptable.


      1st solution:

      *** src/syntax.c (revision 1143)
      --- src/syntax.c (working copy)
      ***************
      *** 6461,6471 ****
      * With 8 colors brown is equal to yellow, need to use black for Search fg
      * to avoid Statement highlighted text disappears. */
      if (t_colors > 8)
      ! do_highlight((char_u *)(*p_bg == 'l' ? "Visual ctermbg=LightGrey"
      ! : "Visual ctermbg=DarkGrey"), FALSE, TRUE);
      else
      {
      ! do_highlight((char_u *)"Visual cterm=reverse", FALSE, TRUE);
      if (*p_bg == 'l')
      do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE);
      }
      --- 6461,6471 ----
      * With 8 colors brown is equal to yellow, need to use black for Search fg
      * to avoid Statement highlighted text disappears. */
      if (t_colors > 8)
      ! do_highlight((char_u *)(*p_bg == 'l' ? "Visual cterm=NONE ctermbg=LightGrey"
      ! : "Visual cterm=NONE ctermbg=DarkGrey"), FALSE, TRUE);
      else
      {
      ! do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE", FALSE, TRUE);
      if (*p_bg == 'l')
      do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE);
      }


      2nd solution:

      *** src/option.c (revision 1143)
      --- src/option.c (working copy)
      ***************
      *** 5985,5991 ****
      T_CCO = empty_option;
      }
      /* We now have a different color setup, initialize it again. */
      ! init_highlight(TRUE, FALSE);
      }
      ttest(FALSE);
      if (varp == &T_ME)
      --- 5985,5991 ----
      T_CCO = empty_option;
      }
      /* We now have a different color setup, initialize it again. */
      ! init_highlight(TRUE, TRUE);
      }
      ttest(FALSE);
      if (varp == &T_ME)


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Bram Moolenaar
      ... I think the first solution should work. Clearing all the settings is drastic, it might have unexpected side effects. I suppose that when switching from 16
      Message 2 of 3 , Aug 4, 2008
      • 0 Attachment
        Markus Heidelberg wrote:

        > In non-gui vim the color of the visual selection is reverse instead of grey,
        > if t_Co > 8. It should only be reversed if t_Co <= 8.
        >
        > ":hi Visual" still contains cterm=reverse after setting t_Co to >8, so I think
        > this is used instead of ctermbg=7 (grey). After ":hi clear" it's cleaned up
        > and the color is shown as intended.
        >
        > to reproduce it:
        > vim -u NONE
        >
        > :set t_Co?
        > t_Co=8 (for me)
        > :hi Visual
        > Visual xxx term=reverse cterm=reverse guibg=LightGrey
        > write some text and test visual mode, it's reversed (correct)
        >
        > :set t_Co=16
        > :hi Visual
        > Visual xxx term=reverse cterm=reverse ctermbg=7 guibg=LightGrey
        > test visual mode, it's still reversed (wrong)
        >
        > :hi clear
        > :hi Visual
        > Visual xxx term=reverse ctermbg=7 guibg=LightGrey
        > test visual mode, now it's grey (correct)
        >
        > :set t_Co=8
        > :hi Visual
        > Visual xxx term=reverse cterm=reverse ctermbg=7 guibg=LightGrey
        > test visual mode, it's already (in contrast to t_Co=16) reversed (correct)
        >
        > :hi clear
        > :hi Visual
        > Visual xxx term=reverse cterm=reverse guibg=LightGrey
        > test visual mode, it's still reversed (correct)
        >
        >
        > I have two solutions and think the first one is acceptable.

        I think the first solution should work. Clearing all the settings is
        drastic, it might have unexpected side effects.

        I suppose that when switching from 16 to 8 colors then ctermbg value
        should be cleared.


        *** ../vim-7.2b.026/src/syntax.c Wed Jun 25 00:17:00 2008
        --- src/syntax.c Mon Aug 4 23:07:11 2008
        ***************
        *** 6459,6471 ****
        /* Reverse looks ugly, but grey may not work for 8 colors. Thus let it
        * depend on the number of colors available.
        * With 8 colors brown is equal to yellow, need to use black for Search fg
        ! * to avoid Statement highlighted text disappears. */
        if (t_colors > 8)
        ! do_highlight((char_u *)(*p_bg == 'l' ? "Visual ctermbg=LightGrey"
        ! : "Visual ctermbg=DarkGrey"), FALSE, TRUE);
        else
        {
        ! do_highlight((char_u *)"Visual cterm=reverse", FALSE, TRUE);
        if (*p_bg == 'l')
        do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE);
        }
        --- 6459,6474 ----
        /* Reverse looks ugly, but grey may not work for 8 colors. Thus let it
        * depend on the number of colors available.
        * With 8 colors brown is equal to yellow, need to use black for Search fg
        ! * to avoid Statement highlighted text disappears.
        ! * Clear the attributes, needed when changing the t_Co value. */
        if (t_colors > 8)
        ! do_highlight((char_u *)(*p_bg == 'l'
        ! ? "Visual cterm=NONE ctermbg=LightGrey"
        ! : "Visual cterm=NONE ctermbg=DarkGrey"), FALSE, TRUE);
        else
        {
        ! do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE",
        ! FALSE, TRUE);
        if (*p_bg == 'l')
        do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE);
        }


        --
        TIM: To the north there lies a cave, the cave of Caerbannog, wherein, carved
        in mystic runes, upon the very living rock, the last words of Olfin
        Bedwere of Rheged make plain the last resting place of the most Holy
        Grail.
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Markus Heidelberg
        ... I included the second patch, only because it was my first solution (similar to ... Yes, I did so in my patch. Markus
        Message 3 of 3 , Aug 4, 2008
        • 0 Attachment
          Bram Moolenaar, 04.08.2008:
          >
          > Markus Heidelberg wrote:
          >
          > > In non-gui vim the color of the visual selection is reverse instead of grey,
          > > if t_Co > 8. It should only be reversed if t_Co <= 8.
          > >
          > >
          > > I have two solutions and think the first one is acceptable.
          >
          > I think the first solution should work. Clearing all the settings is
          > drastic, it might have unexpected side effects.

          I included the second patch, only because it was my first solution (similar to
          :hi clear).

          > I suppose that when switching from 16 to 8 colors then ctermbg value
          > should be cleared.

          Yes, I did so in my patch.

          Markus


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        Your message has been successfully submitted and would be delivered to recipients shortly.