qwert

How to move forum code snippets?

20 posts in this topic

For the umpteenth time, I'm baffled in moving a code snippet from a forum post to my script in SciTE.  The attached screen capture shows a code segment posted by Yashied.  When I highlight and drag to SciTE, I end up with one long line:

$hForm = GUICreate('MyGUI', 400, 400) GUISetState() While 1  Switch GUIGetMsg()   Case -3   WinSetTrans($hForm, '', 0)   GUISetState(@SW_HIDE)    ExitLoop     EndSwitch WEnd Sleep(1000)

And it doesn't matter whether the target application is SciTE, NotePad, WordPad or another text processor.

Code segments with the Popup tab work properly ... with either drag/drop or cut/paste.

Are the CRs/LFs removed by the OS? ... my browser? ... unknown forces?  Is there an SciTE "receive code" setting?

Thanks for any help.

 

post-29172-0-86046500-1425564243_thumb.p

Share this post


Link to post
Share on other sites



Yeah ive observed the same behavior.. Its pretty annoying having to manually insert linebreaks

Share this post


Link to post
Share on other sites

I had the same issue with Firefox.

The only way I found was to select the whole code exept the last caracter (or the first), copy/paste and then enter the last caracter manually in Scite.

1 person likes this

Share this post


Link to post
Share on other sites

Thanks for all the suggestions.

I forgot to mention that Cut/Paste does not work ... not in its standard way.

But thanks to jguinch for the following ... which does let cut/paste work:

select the whole code except the last caracter

 

I also tried the extension, with has a Edit in SciTE menu entry.  It works as advertised, but it's a lot of extra baggage unless you're going to use all the other features.  Plus, to get the snippet into your script, you still have to cut/paste after it's in SciTE.

Regardless, this is an annoyance that should be able to be corrected in the mechanics of the forum.  I'd be interested in hearing if anything has been tried.  Surely, it's not by design.

In the mean time, the above method solves it for me.  Thanks, jguinch!

Share this post


Link to post
Share on other sites

It's a genuine FF problem!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Also forgot to mention:  I use Pale Moon ... originally a fork of FireFox ... now an independent development ... but compatible with many FF addons.

(for reference: http://www.palemoon.org/ )

Share this post


Link to post
Share on other sites

... it makes the necessary changes ...

 

... which begs the question: what's included with that last character?

 

Share this post


Link to post
Share on other sites

That might, indeed, work.

But can anyone explain why I can drag/drop or cut/paste a comment block from the forum, but not a code snippet?

They look essentially the same on the screen and behave the same in the drag operation.  It tells me that something extra (or less) is being put into the element.  Since SciTE is usually the source of code, is it involved? 

Maybe someone can (soon) try posting a snippet from a word processor.

post-29172-0-04762800-1425584357_thumb.p

Share this post


Link to post
Share on other sites

I just pasted verbatim into a WP and got the result shown below.  There's a lot involved behind the scenes with those few lines of displayed code.

Ideas, anyone?

post-29172-0-43858800-1425585741_thumb.p

Share this post


Link to post
Share on other sites

I had the same issue with Firefox.

The only way I found was to select the whole code exept the last caracter (or the first), copy/paste and then enter the last caracter manually in Scite.

Thanks, this was helpful. I also noticed that it works fine when you can get the code to a pop-up window.

Share this post


Link to post
Share on other sites

I found the "reasoning" over on the Pale Moon forum in a 2012 post:

 

There is only one way to paste with all formatting from Pale Moon or Firefox, i.e. through the Firefox/Pale Moon Add-On called “Fire IE”. “Fire IE” allows you to display Web pages in tabs using the IE rendering engine. When the page is displaying through the IE engine, you can copy/paste into most applications and keep the formatting.

There is a dual reason for this:

1. IE has an internal HTML to RTF converter. So it sends the copied contents both as HTML and RTF to the clipboard (plus a “pure text” version).

2. A number of applications, including some word processors, have no support for the HTML format of the Windows clipboard. If they cannot find a RTF version in the clipboard, they use the default “pure text” version. This is why formatting is lost: such applications don’t support the HTML clipboard contents, and they don’t get the RTF version from Pale Moon or Firefox. Catch-22.

You need the IE rendering engine.

Catch-22, indeed.  And it sounds like no "fix" is forthcoming.   But I'm no expert on HTML or browser engines ... so, who knows.

I'm just glad to have a convenient workaround.

 

 

Share this post


Link to post
Share on other sites

Just a quick footnote ...

In Win7, you can highlight snippet without the last character and drag/drop it into SciTE.  For me, that's easier than cut and paste.

I've tried a dozen other variations and this is the only one that works.  I'll bet a "snippet washer" could be fashioned to duplicate whatever omitting the last character does with the html.  Hmmm.  Maybe something for a spare-time task.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now