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

Functions needed to access conceal information in scripts

Expand Messages
  • Benjamin Fritz
    I have been looking into adding support for concealed text in TOhtml.vim, and have found that I will need to patch the C code to make conceal information
    Message 1 of 2 , Jul 1, 2010
    • 0 Attachment
      I have been looking into adding support for concealed text in
      TOhtml.vim, and have found that I will need to patch the C code to
      make conceal information accessible in Vim script. If I am mistaken,
      please enlighten me, but I propose the addition of three functions:

      concealed({lnum}, {col})
      Will return the column number on the given line of the start of the
      concealable area on that line containing the given column, or -1 if
      the given position is not in a concealable area.

      concealedend({lnum}, {col})
      Will return the column number on the given line of the end of the
      concealable area on that line containing the given column, or -1 if
      the given position is not in a concealable area.

      concealtextresult({lnum}, {col})
      Will return whatever text is displayed in place of the concealable
      area containing the line and column given, based on the cchar given in
      the syntax definition, the current 'listchars' setting, and the
      current 'conceallevel' setting.

      These three functions would be similar to foldclosed(),
      foldclosedend(), and foldtextresult(). I propose using
      concealtextresult()instead of just concealtext() for symmetry, and in
      case something similar to 'foldtext' is ever added for conceal
      functionality.

      Any comments? I do plan to try my hand at a patch to add these, but if
      somebody beats me to it, I will not be that upset. It will probably be
      a couple weeks before I have anything, because I'm pretty busy, and I
      haven't touched Vim's C code as of yet, so it will take a while to get
      my bearings.

      --
      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
    • Bram Moolenaar
      ... Why not join these two functions and have it return a list with two values? ... It could even be just one function that returns a list with three values,
      Message 2 of 2 , Jul 2, 2010
      • 0 Attachment
        Benjamin Fritz wrote:

        > I have been looking into adding support for concealed text in
        > TOhtml.vim, and have found that I will need to patch the C code to
        > make conceal information accessible in Vim script. If I am mistaken,
        > please enlighten me, but I propose the addition of three functions:
        >
        > concealed({lnum}, {col})
        > Will return the column number on the given line of the start of the
        > concealable area on that line containing the given column, or -1 if
        > the given position is not in a concealable area.
        >
        > concealedend({lnum}, {col})
        > Will return the column number on the given line of the end of the
        > concealable area on that line containing the given column, or -1 if
        > the given position is not in a concealable area.

        Why not join these two functions and have it return a list with two
        values?

        > concealtextresult({lnum}, {col})
        > Will return whatever text is displayed in place of the concealable
        > area containing the line and column given, based on the cchar given in
        > the syntax definition, the current 'listchars' setting, and the
        > current 'conceallevel' setting.

        It could even be just one function that returns a list with three
        values, the start and end column and the text.

        > These three functions would be similar to foldclosed(),
        > foldclosedend(), and foldtextresult(). I propose using
        > concealtextresult()instead of just concealtext() for symmetry, and in
        > case something similar to 'foldtext' is ever added for conceal
        > functionality.

        I not sure if it is an advantage to follow the way it's done for
        folding. For folding it's more often useful to just check if a line is
        folded or not, without needing the other information. For the conceal
        feature I think one would nearly always want to also know the end
        column, because there can be another concealed text item further down in
        the line.

        Note: make sure to document what {col} means. Whether the first column
        is zero or one and that it's the column before concealing. And the byte
        number, not the character number.

        > Any comments? I do plan to try my hand at a patch to add these, but if
        > somebody beats me to it, I will not be that upset. It will probably be
        > a couple weeks before I have anything, because I'm pretty busy, and I
        > haven't touched Vim's C code as of yet, so it will take a while to get
        > my bearings.

        --
        hundred-and-one symptoms of being an internet addict:
        257. Your "hundred-and-one" lists include well over 101 items, since you
        automatically interpret all numbers in hexadecimal notation.
        (hex 101 = decimal 257)

        /// 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.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      Your message has been successfully submitted and would be delivered to recipients shortly.