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

20596Re: [Clip] Re: Clipboard boilerplate for cn_le

Expand Messages
  • loro
    Apr 22, 2010
    • 0 Attachment
      diodeom wrote:
      >lotta wrote
      > > Yesterday I realized that my OnClipBoardChange clip sometimes
      > > screws up when the copied text contains quotes (but only
      > > sometimes) and you end up with a broken heading like so
      > > H="heading
      > > "
      > > which messes up the following snips. A little odd. Maybe it
      > > was something else than quotes that made it happened even if
      > > I blamed the quotes at the time. Haven't looked into it yet.
      > >
      > > Lotta
      > >
      >Please do share if you find out more. I'm still somewhat timid when
      >it comes to playing with an active library, but your (new to me)
      >idea has opened some very interesting possibilities, as I was able
      >to put it into some immediate "useful use" with no unresolvable
      >glitches so far.

      If someone is still interested, we've figured it out. At long last I
      realized it was line breaks in the copied text that screwed things
      up. Since I'm feebleminded and it only happened when I copied certain
      comments at a certain blog I set off on a wild goose chase, looking
      at different kinds of line endings and contemplating the possibility
      of corrupt characters. Diodeom immediately realized that the problem
      was caused by the clip cutting the string exactly between CR and LF
      and that it could be fixed with ^$StrFixLines()$. :-P

      I've compiled our efforts if someone wants it.

      __________[ ClipboardCollect ]__________

      H="Status On/Off"

      ^!Set %watch_clipboard%=^?{Watch clipboard==ON^=1|OFF^=0}

      H="Paste All"

      ^!Set %ww%=^$IsWordWrap$
      ^!Set %snips%=^%empty%
      ^!SetWordWrap off
      ^!SetScreenUpdate off

      ; Long line follows
      ^!Open "^$GetLibraryPath(^$GetLibraryName$)$^$GetLibraryName$.clb"
      ; End long line
      ^!Jump text_start
      ^!Find "^%sc%Text collected from clipboard""

      ^!Jump select_end
      ^!Find "h="" SI
      ^!IfError do
      ^!Jump select_end
      ^!Set %start_pos%=^$GetRow$:^$GetCol$
      ^!Find """
      ^!Jump select_start
      ^!SelectTo ^%start_pos%
      ^!Set %this%=^$GetSelection$¤
      ^!Append %snips%=^%this%
      ^!Goto loop

      ^!Set %cntr%=0
      ^!SetListDelimiter ¤
      ; Long line follows
      ^!SetArray %snips%=^$StrDelete("^%snips%";^$StrSize("^%snips%")$;1)$
      ; End long line
      ^!Menu File/new
      ^!Inc %cntr%
      ^!Clip "^%snips^%cntr%%"
      ; Long line follows
      ^!InsertText --------------------------------------^p
      ; End long line
      ^!If ^%cntr%=^%snips0% fini
      ^!Goto paste-loop

      ^!If ^%ww%=1 next else end
      ^!SetWordWrap on

      H="Remove selected clips"

      ; ^!Open "^$GetLibraryFileName$" /J=-1
      ; Changed to work in 4.8 /loro
      ^!Open "^$GetLibraryPath(^$GetLibraryName$)$^$GetLibraryName$.clb"
      ^!Set %bot%=^$GetRow$:^$GetCol$
      ^!Find "^H\=";Text.++\R\K" WRS
      ^!SelectTo ^%bot%
      ^!SetListDelimiter |
      ^!Set %del%=^$GetDocMatchAll("^H\=\"\K(.+?)(?=\"$)")$
      ^!SetArray %del%=^?{(T=A;H=50)=^%del%}
      ^!Set %n%=0
      ^!Inc %n%
      ^!If ^%n%>^%del0% Done
      ;Long line follows
      ^!Replace "\R\R\K\R*^H\=\"\Q^%del^%n%%\E\"$(?s).+?(?=(^H\=\"|\R*\Z))" >> "" WRS
      ;Long line end
      ^!Goto Del
      ^!Replace "\R+\Z" >> "\r\n" WRS
      ^!Close Save
      ^!ClearVariable %bot%
      ^!ClearVariable %del%
      ^!ClearVariable %n%

      H="Clear collected text"

      ^!Set %ww%=^$IsWordWrap$
      ^!Set %curr_doc%=^$GetDocIndex$
      ^!SetWordWrap off
      ^!SetScreenUpdate off

      ^!Open "^$GetLibraryPath(^$GetLibraryName$)$^$GetLibraryName$.clb"
      ^!Jump text_start
      ^!Find "^%sc%Text collected from clipboard""
      ^!Jump select_end
      ^!Set %deltxt%=^$GetRow$:^$GetCol$
      ^!Jump text_end
      ^!SelectTo ^%deltxt%
      ^!Menu Edit/Delete
      ^!Export "^##" ANSI

      ^!SetDocIndex ^%curr_doc%
      ^!If ^%ww%=1 next else end
      ^!SetWordWrap on


      ^!IfFalse ^%watch_clipboard% end else next

      ; Long line follows
      ; end long line
      ^!Sound ^$GetSoundPath$Click-9.wav

      H=";Text collected from clipboard"

    • Show all 24 messages in this topic