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

Re: Feature Request: copy from vim, paste to Cocoa app: Would like menu option to 'Copy with Attributes'

Expand Messages
  • Jjgod Jiang
    Hi,On Sun, Jul 27, 2008 at 8:54 PM, björn wrote: From the Cocoa perspective this feature is simple to implement: when copying
    Message 1 of 6 , Jul 27, 2008
    • 0 Attachment
      Hi,

      On Sun, Jul 27, 2008 at 8:54 PM, björn <bjorn.winckler@...> wrote:
      > From the Cocoa perspective this feature is simple to implement: when
      > copying you can put multiple representations of the text on the
      > pasteboard. What you're asking for could be achieved by putting the
      > selection in "rich text" format on the pasteboard. However, (as far
      > as I know) Vim has no way of giving you the selected text complete
      > with attributes (such as font, bold, etc.) which makes this feature
      > hard to implement. In fact, hard enough for me not to want to attempt
      > it. :-/

      Well, since we use NSTextStorage (which inherits from NSAttributedString)
      to store the text for (at least MMTextView), it might be possible to bypass
      the vim process, simply give the text stored in that TextStorage. However,
      I do agree there might be some limitations.

      - Jiang

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Ben Schmidt
      ... Like only being able to copy what s currently in view perhaps? Particularly for the OP: Have you investigated the :TOhtml command? Its purpose is to
      Message 2 of 6 , Jul 27, 2008
      • 0 Attachment
        Jjgod Jiang wrote:
        > Hi,
        >
        > On Sun, Jul 27, 2008 at 8:54 PM, björn <bjorn.winckler@...> wrote:
        >> From the Cocoa perspective this feature is simple to implement: when
        >> copying you can put multiple representations of the text on the
        >> pasteboard. What you're asking for could be achieved by putting the
        >> selection in "rich text" format on the pasteboard. However, (as far
        >> as I know) Vim has no way of giving you the selected text complete
        >> with attributes (such as font, bold, etc.) which makes this feature
        >> hard to implement. In fact, hard enough for me not to want to attempt
        >> it. :-/
        >
        > Well, since we use NSTextStorage (which inherits from NSAttributedString)
        > to store the text for (at least MMTextView), it might be possible to bypass
        > the vim process, simply give the text stored in that TextStorage. However,
        > I do agree there might be some limitations.

        Like only being able to copy what's currently in view perhaps?

        Particularly for the OP: Have you investigated the :TOhtml command? Its
        purpose is to convert a file into HTML using syntax highlighting.

        Perhaps also hijacking its functionality could be a way of implementing
        this kind of clipboard support. I don't suppose HTML is a flavour you
        can put on the pasteboard that other apps will readily recognise is it?
        I'd suggest if anything just implementing a Vim command to place
        something on the pasteboard with a user-defined flavour and then leave
        the rest to Vimscript. Something like

        :[range]macyank[!] flavour

        to yank text in range (default current line--bang to omit final newline)
        into the clipboard with given flavour. Could be quite handy, e.g. you
        could possibly even yank bits of binary files as images if desired, etc..

        Ben.



        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_mac" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • E. Wing
        ... That reminds me, I have a lot of problems mouse-selecting a large body of text. First, I seem to have inconsistent problems with the scroll speed as I try
        Message 3 of 6 , Jul 28, 2008
        • 0 Attachment
          > Like only being able to copy what's currently in view perhaps?

          That reminds me, I have a lot of problems mouse-selecting a large body
          of text. First, I seem to have inconsistent problems with the scroll
          speed as I try to drag-select off the top or bottom edge to get more
          text. Sometimes it's really slow.

          Second, I notice that the cursor position in the editor seems to alter
          my selection if I scroll forward or back using the scrollbar or
          scrollwheel. For example, if I drag-select text downward so a full
          page is highlighted and then I let go of the mouse-button. The cursor
          is at the very bottom of the text. Then while the text is still
          highlighted, if I scroll up with the scrollbar or scrollwheel, the
          cursor moves upward as to not fall off the page. As it does so, it
          starts un-highlighting all the text that fell off the bottom of the
          page. Conversely, if I scroll down several pages, the cursor gets
          stuck at the top of the page and gets pushed down to not fall off the
          screen and increases the highlight.

          Is there a way to avoid this change in selection? (Maybe the question
          needs to be, how do I prevent the cursor from moving on scroll if the
          two events aren't separable.)

          Thanks,
          Eric
          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_mac" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Ben Schmidt
          ... This is unavoidable in Vim within its design, as I think you suspected. Vim always must have the cursor on the screen, and the cursor must always be either
          Message 4 of 6 , Jul 28, 2008
          • 0 Attachment
            > Second, I notice that the cursor position in the editor seems to alter
            > my selection if I scroll forward or back using the scrollbar or
            > scrollwheel.

            This is unavoidable in Vim within its design, as I think you suspected.
            Vim always must have the cursor on the screen, and the cursor must
            always be either at the beginning or the end of the visual area. So if
            the visual area is larger than a page, you must be looking at one end of
            it, and since scrolling must move the cursor to keep it on the screen,
            this alters the visual area.

            If you didn't know already, you may find it handy to learn that you can
            use the o key to move the cursor to the other end of the visual area.

            I guess one thing that could be considered would be automatically doing
            o if scrolling would move the cursor off the screen without doing so,
            but not with doing so, i.e. if by simulating o the cursor would stay on
            the screen while scrolling. I don't know if this is a very good idea,
            though, or whether it would really help that much anyway.

            Ben.



            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_mac" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • dacresni
            sounds like a bad idea to me, I think the selection movement is the result of the selection being directly related to the portion marked in visual mode. if we
            Message 5 of 6 , Jul 29, 2008
            • 0 Attachment
              sounds like a bad idea to me, I think the selection movement is the
              result of the selection being directly related to the portion marked
              in visual mode. if we could make a meta key (like shift clikc) option

              On Jul 28, 8:01 am, Ben Schmidt <mail_ben_schm...@...> wrote:
              > > Second, I notice that the cursor position in the editor seems to alter
              > > my selection if I scroll forward or back using the scrollbar or
              > > scrollwheel.
              >
              > This is unavoidable in Vim within its design, as I think you suspected.
              > Vim always must have the cursor on the screen, and the cursor must
              > always be either at the beginning or the end of the visual area. So if
              > the visual area is larger than a page, you must be looking at one end of
              > it, and since scrolling must move the cursor to keep it on the screen,
              > this alters the visual area.
              >
              > If you didn't know already, you may find it handy to learn that you can
              > use the o key to move the cursor to the other end of the visual area.
              >
              > I guess one thing that could be considered would be automatically doing
              > o if scrolling would move the cursor off the screen without doing so,
              > but not with doing so, i.e. if by simulating o the cursor would stay on
              > the screen while scrolling. I don't know if this is a very good idea,
              > though, or whether it would really help that much anyway.
              >
              > Ben.
              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_mac" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Nico Weber
              Hi, ... in addition to what Ben said, you can click on where you want the selection to start, hit `ma`, scroll, click at the end, and hit `v a` to select the
              Message 6 of 6 , Jul 30, 2008
              • 0 Attachment
                Hi,

                > That reminds me, I have a lot of problems mouse-selecting a large body
                > of text. First, I seem to have inconsistent problems with the scroll
                > speed as I try to drag-select off the top or bottom edge to get more
                > text. Sometimes it's really slow.

                in addition to what Ben said, you can click on where you want the
                selection to start, hit `ma`, scroll, click at the end, and hit `v'a`
                to select the text between the two clicks.

                Nico

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