Jump to content

How to move forum code snippets?


Recommended Posts

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

Link to comment
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.

Link to comment
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!

Link to comment
Share on other sites

It's a genuine FF problem!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
Share on other sites

Actually that does not work.

When the whole thing is copied as opposed to leaving out the last character.

@CR and @LF are replaced with a single SPACE.  

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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.

Link to comment
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.

 

 

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...