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

[60am,mb] visual selection is not drawn correctly

Expand Messages
  • Yasuhiro Matsumoto
    Hello vim-multibyte, in below s case, the second line does not draw shadow of selection. the cause of this problem is skipping boundary of selection area by
    Message 1 of 9 , Jul 2, 2001
    View Source
    • 0 Attachment
      Hello vim-multibyte,

      in below's case, the second line does not draw shadow of selection.
      the cause of this problem is skipping boundary of selection area
      by multibyte which defined fromcol and tocol in screen.c(2908).
      (please compare like multibyte to [])

      ex)
      [][][]
      [][][]

      I made a patch.
      Please check this.

      --
      Yasuhiro Matsumoto
    • Yasuhiro Matsumoto
      ... Sorry. I have mistake. please check this (ptr2len - ptr2cells) -- Yasuhiro Matsumoto
      Message 2 of 9 , Jul 2, 2001
      View Source
      • 0 Attachment
        Yasuhiro Matsumoto wrote:
        >
        >Hello vim-multibyte,
        >
        >in below's case, the second line does not draw shadow of selection.
        >the cause of this problem is skipping boundary of selection area
        > by multibyte which defined fromcol and tocol in screen.c(2908).
        >(please compare like multibyte to [])
        >
        >ex)
        >[][][]
        > [][][]
        >
        >I made a patch.
        >Please check this.

        Sorry.
        I have mistake.
        please check this (ptr2len -> ptr2cells)

        --
        Yasuhiro Matsumoto
      • Bram Moolenaar
        ... [and then:] ... Thanks for fixing this. This code to check for the start/end of a highlighting region is executed for every character. It starts to look
        Message 3 of 9 , Jul 3, 2001
        View Source
        • 0 Attachment
          Yasuhiro Matsumoto wrote:

          >in below's case, the second line does not draw shadow of selection.
          >the cause of this problem is skipping boundary of selection area
          > by multibyte which defined fromcol and tocol in screen.c(2908).
          >(please compare like multibyte to [])
          >
          >ex)
          >[][][]
          > [][][]
          >
          >I made a patch.
          >Please check this.
          [and then:]
          > Sorry.
          > I have mistake.
          > please check this (ptr2len -> ptr2cells)

          Thanks for fixing this.

          This code to check for the start/end of a highlighting region is executed for
          every character. It starts to look complicated now. I'll try to simplify it
          a bit.

          Please verify that the patch below works properly. It's simpler than your
          patch, perhaps I missed something. I verified it works correclty in UTF-8
          text. The characters that are highlighted are the ones deleted with "d".

          *** ../dist/vim60am/src/screen.c Wed Jun 20 22:05:08 2001
          --- screen.c Tue Jul 3 11:41:01 2001
          ***************
          *** 2316,2321 ****
          --- 2316,2322 ----
          int n_skip = 0; /* nr of chars to skip for 'nowrap' */

          int fromcol, tocol; /* start/end of inverting */
          + int fromcol_prev = -2; /* start of inverting after cursor */
          int noinvcur = FALSE; /* don't invert the cursor */
          #ifdef FEAT_VISUAL
          pos_T *top, *bot;
          ***************
          *** 2640,2645 ****
          --- 2641,2669 ----
          #endif
          }

          + /*
          + * Correct highlighting for cursor that can't be disabled.
          + * Avoids having to check this for each character.
          + */
          + if (fromcol >= 0)
          + {
          + if (noinvcur)
          + {
          + if ((colnr_T)fromcol == wp->w_virtcol)
          + {
          + /* highlighting starts at cursor, let it start just after the
          + * cursor */
          + fromcol_prev = fromcol;
          + fromcol = -1;
          + }
          + else if ((colnr_T)fromcol < wp->w_virtcol)
          + /* restart highlighting after the cursor */
          + fromcol_prev = wp->w_virtcol;
          + }
          + if (fromcol >= tocol)
          + fromcol = -1;
          + }
          +
          #ifdef FEAT_SEARCH_EXTRA
          /*
          * Handle highlighting the last used search pattern.
          ***************
          *** 2905,2924 ****
          if (draw_state == WL_LINE && area_highlighting)
          {
          /* handle Visual or match highlighting in this line */
          ! if (((vcol == fromcol
          ! && !(noinvcur
          ! && (colnr_T)vcol == wp->w_virtcol
          ! ))
          ! || (noinvcur
          ! && (colnr_T)vcol_prev == wp->w_virtcol
          ! && vcol >= fromcol))
          ! && vcol < tocol)
          area_attr = attr; /* start highlighting */
          ! else if (area_attr
          && (vcol == tocol
          ! || (noinvcur
          ! && (colnr_T)vcol == wp->w_virtcol
          ! )))
          #ifdef LINE_ATTR
          area_attr = line_attr; /* stop highlighting */
          else if (line_attr && ((fromcol == -10 && tocol == MAXCOL)
          --- 2929,2945 ----
          if (draw_state == WL_LINE && area_highlighting)
          {
          /* handle Visual or match highlighting in this line */
          ! if (vcol == fromcol
          ! #ifdef FEAT_MBYTE
          ! || (has_mbyte && vcol + 1 == fromcol && n_extra == 0
          ! && (*mb_ptr2cells)(ptr) > 1)
          ! #endif
          ! || ((colnr_T)vcol_prev == fromcol_prev
          ! && vcol < tocol))
          area_attr = attr; /* start highlighting */
          ! else if (area_attr != 0
          && (vcol == tocol
          ! || (noinvcur && (colnr_T)vcol == wp->w_virtcol)))
          #ifdef LINE_ATTR
          area_attr = line_attr; /* stop highlighting */
          else if (line_attr && ((fromcol == -10 && tocol == MAXCOL)
          --
          hundred-and-one symptoms of being an internet addict:
          89. In addition to your e-mail address being on your business cards
          you even have your own domain.

          /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
          ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
          \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
        • Yasuhiro Matsumoto
          ... No, your patch does not have the same function as my patch. if comparing like multibyte to [], and comparing like selected multibyte to (), below s
          Message 4 of 9 , Jul 3, 2001
          View Source
          • 0 Attachment
            Bram Moolenaar wrote:
            >This code to check for the start/end of a highlighting region is executed for
            >every character. It starts to look complicated now. I'll try to simplify it
            >a bit.
            >
            >Please verify that the patch below works properly. It's simpler than your
            >patch, perhaps I missed something. I verified it works correclty in UTF-8
            >text. The characters that are highlighted are the ones deleted with "d".

            No, your patch does not have the same function as my patch.

            if comparing like multibyte to [], and comparing like
            selected multibyte to (),
            below's operation is correctly.

            1. one line vertical selection.

            start point
            |
            v
            []()[][]
            [][][]
            []()[][]
            ^
            |
            end point

            2. two line vertical selection.

            start point
            |
            v
            []()()[]
            []()[]
            []()()[]
            ^
            |
            end point

            but your patch's selection is below.

            1. one line vertical selection.

            []()[][]
            ()()[]
            []()[][]

            2. two line vertical selection.

            []()()[]
            ()()()
            []()()[]
          • Yasuhiro Matsumoto
            ... Hmm? it is difference that area of yank and area of delete. which is correctly?
            Message 5 of 9 , Jul 3, 2001
            View Source
            • 0 Attachment
              Bram Moolenaar wrote:
              >This code to check for the start/end of a highlighting region is executed for
              >every character. It starts to look complicated now. I'll try to simplify it
              >a bit.
              >
              >Please verify that the patch below works properly. It's simpler than your
              >patch, perhaps I missed something. I verified it works correclty in UTF-8
              >text. The characters that are highlighted are the ones deleted with "d".

              Hmm?
              it is difference that area of yank and area of delete.
              which is correctly?
            • Bram Moolenaar
              ... That is the same as what I see. However, suppose one line is selected, as in 1., then press d to delete the selected text. The two characters in between
              Message 6 of 9 , Jul 3, 2001
              View Source
              • 0 Attachment
                Yasuhiro Matsumoto wrote:

                > >Please verify that the patch below works properly. It's simpler than your
                > >patch, perhaps I missed something. I verified it works correclty in UTF-8
                > >text. The characters that are highlighted are the ones deleted with "d".
                >
                > No, your patch does not have the same function as my patch.
                >
                > if comparing like multibyte to [], and comparing like
                > selected multibyte to (),
                > below's operation is correctly.
                >
                > 1. one line vertical selection.
                >
                > start point
                > |
                > v
                > []()[][]
                > [][][]
                > []()[][]
                > ^
                > |
                > end point
                >
                > 2. two line vertical selection.
                >
                > start point
                > |
                > v
                > []()()[]
                > []()[]
                > []()()[]
                > ^
                > |
                > end point
                >
                > but your patch's selection is below.
                >
                > 1. one line vertical selection.
                >
                > []()[][]
                > ()()[]
                > []()[][]
                >
                > 2. two line vertical selection.
                >
                > []()()[]
                > ()()()
                > []()()[]

                That is the same as what I see.

                However, suppose one line is selected, as in 1., then press "d" to delete the
                selected text. The two characters in between are also deleted (two spaces
                inserted to align the text). Do you get this as well? Or is there some
                situation where this is different?

                start point
                | after deleting
                v
                []()[][] [][][]
                [][][] []
                []()[][] [][][]
                ^
                |
                end point

                Since the characters are affected, I think they should be highlighted.

                Unfortunately, when using "y" on the same text, pasting it somewhere else
                results in spaces to be inserted, thus you might argue that the two characters
                in between were not included.

                I would argue that deleting is more important here, since you need to be
                warned that "d" deletes more than what you might expect.

                --
                >From "know your smileys":
                :-H Is missing teeth

                /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
                ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
                \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
              • Yasuhiro Matsumoto
                ... * this is case of delete. start point ... v []()[][] _()()[]_ []()[][] ^ ... end point deleted text is ... start point ... v __()____ _()()___ __()____ ^
                Message 7 of 9 , Jul 3, 2001
                View Source
                • 0 Attachment
                  Bram Moolenaar wrote:
                  >That is the same as what I see.
                  >
                  >However, suppose one line is selected, as in 1., then press "d" to delete the
                  >selected text. The two characters in between are also deleted (two spaces
                  >inserted to align the text). Do you get this as well? Or is there some
                  >situation where this is different?
                  >
                  >
                  >Since the characters are affected, I think they should be highlighted.
                  >
                  >Unfortunately, when using "y" on the same text, pasting it somewhere else
                  >results in spaces to be inserted, thus you might argue that the two characters

                  >in between were not included.
                  >
                  >I would argue that deleting is more important here, since you need to be
                  >warned that "d" deletes more than what you might expect.

                  -----------------------------------
                  * this is case of delete.

                  start point
                  |
                  v
                  []()[][]
                  _()()[]_
                  []()[][]
                  ^
                  |
                  end point

                  deleted text is ...

                  start point
                  |
                  v
                  __()____
                  _()()___
                  __()____
                  ^
                  |
                  end point

                  -----------------------------------
                  * this is case of yank.

                  start point
                  |
                  v
                  []()[][]
                  _()()[]_
                  []()[][]
                  ^
                  |
                  end point

                  yanked text is ...

                  start point
                  |
                  v
                  __()____
                  __ ____
                  __()____
                  ^
                  |
                  end point

                  -----------------------------------

                  Hmm,
                  Is this not actual area but the area which may influence?
                  That is right if this is right.

                  but do_put doesn't work correctly. X-(
                  if it need inserting visual selected area and
                  it located between two multibyte string,
                  pasted text need shifting left.

                  this is a patch.

                  please check this.

                  thanks.

                  --
                  Yasuhiro Matsumoto
                • Bram Moolenaar
                  ... I think that s the best thing to do here. It s not possible to highlight half a character. It s not possible to delete or yank half a character either.
                  Message 8 of 9 , Jul 4, 2001
                  View Source
                  • 0 Attachment
                    Yasuhiro Matsumoto wrote:

                    > Hmm,
                    > Is this not actual area but the area which may influence?
                    > That is right if this is right.

                    I think that's the best thing to do here. It's not possible to highlight half
                    a character. It's not possible to delete or yank half a character either.

                    > but do_put doesn't work correctly. X-(
                    > if it need inserting visual selected area and
                    > it located between two multibyte string,
                    > pasted text need shifting left.
                    >
                    > this is a patch.
                    >
                    > please check this.

                    I can see the problem with UTF-8 as well.

                    I think there is some confusion of screen cells and bytes here. I'll look
                    into it.

                    --
                    >From "know your smileys":
                    @:-() Elvis Presley

                    /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
                    ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
                    \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
                  • Bram Moolenaar
                    ... On further investigation I discovered this was wrong for control characters as well. When pasting halfway a ^V (or , when display is uhex ), the
                    Message 9 of 9 , Jul 4, 2001
                    View Source
                    • 0 Attachment
                      Yasuhiro Matsumoto wrote:

                      > but do_put doesn't work correctly. X-(
                      > if it need inserting visual selected area and
                      > it located between two multibyte string,
                      > pasted text need shifting left.
                      >
                      > this is a patch.
                      >
                      > please check this.

                      On further investigation I discovered this was wrong for control characters as
                      well. When pasting halfway a ^V (or <16>, when 'display' is "uhex"), the
                      character would be deleted.

                      The patch below fixes this by only deleting the character if it is a tab. I
                      think a put operation is allowed to replace a tab by spaces, to make the text
                      aligned. But deleting another character is not what a user expects. The
                      result is that the text after the put block is misaligned. I don't see a
                      simple way to avoid that.

                      *** ../dist/vim60am/src/ops.c Wed Jun 27 13:41:37 2001
                      --- ops.c Wed Jul 4 15:03:55 2001
                      ***************
                      *** 3023,3028 ****
                      --- 3023,3040 ----
                      bd.startspaces = incr - bd.endspaces;
                      --bd.textcol;
                      delcount = 1;
                      + #ifdef FEAT_MBYTE
                      + if (has_mbyte)
                      + bd.textcol -= (*mb_head_off)(oldp, oldp + bd.textcol);
                      + #endif
                      + if (oldp[bd.textcol] != TAB)
                      + {
                      + /* Only a Tab can be split into spaces. Other
                      + * characters will have to be moved to after the
                      + * block, causing misalignment. */
                      + delcount = 0;
                      + bd.endspaces = 0;
                      + }
                      }

                      yanklen = (int)STRLEN(y_array[i]);

                      --
                      >From "know your smileys":
                      :.-( Crying

                      /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
                      ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
                      \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
                    Your message has been successfully submitted and would be delivered to recipients shortly.