Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / "Fix" Code Snippets Request

Author
Message
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Jun 2013 20:50
There used to be a trick to copy the entire contents of a code snippet by copying the tab when it was closed. This doesn't work any more, so copying long snippets is a bit of a pain. Would it be possible to bring back that "glitch" or add a button to copy the contents of the snippet to the clipboard? If someone wants to get really involved then it would be nice to have a scrollbar in code snippets thus allowing for a height limit so the snippet doesn't hijack the page.

The difficulty in learning is not acquiring new knowledge but relinquishing the old.
RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 14th Jun 2013 22:24 Edited at: 14th Jun 2013 22:32
Just hacked together a Greasemonkey script that will add a button to select the content of a Code Snippet. Works in firefox with Greasemonkey, not tested in Chrome ( I think chrome has 'tampermonkey', right? ) or anywhere else.

http://dl.dropbox.com/u/69014538/TGC_CodeSnippets.user.js

I'll reproduce the code here, so you can test its functionality here within this thread:


And another snippet just to make sure everything works (atleast it does for me, dunno about anyone else. )


Let me know if that helps/works and maybe someone more skilled in javascript can make a nicer script for this stuff

Edit: And attached a screenshot of what it should look like.

Attachments

Login to view attachments
Virtual Nomad
Moderator
19
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Jun 2013 22:38
i always triple-click the first character in a snippet to "select all".

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Jun 2013 22:42 Edited at: 14th Jun 2013 22:43
Press shift / click at the beginning

shift / click at the end

RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 14th Jun 2013 22:42 Edited at: 14th Jun 2013 22:43
No matter how often I double-, triple- or quadruple-click in Firefox, it only selects the first line for me. :I

Edit: Well, yes, the shift clicking should work, but if it's a veeery long snippet you'd have to scroll a lot which OBese wanted to avoid, I think
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Jun 2013 22:56
@Redflames - Nice work, thanks.

The difficulty in learning is not acquiring new knowledge but relinquishing the old.
Virtual Nomad
Moderator
19
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Jun 2013 23:00 Edited at: 14th Jun 2013 23:03
Quote: "i always triple-click the first character in a snippet to "select all"."


should have mentioned that i use vista/ie.

there's probably similar functionality in other browsers?

mozilla short-cuts: http://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly#w_editing (bah, not helpful )

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Jun 2013 23:02
In firefox Ctrl+A will select everything on the page, not just in the snippet box.

The difficulty in learning is not acquiring new knowledge but relinquishing the old.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jun 2013 23:10
Quote: "i always triple-click the first character in a snippet to "select all"."


Works nicely. Thanks.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Jun 2013 23:55
Quote: "i always triple-click the first character in a snippet to "select all"."

Doesn't work for me in chrome

swissolo
15
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 15th Jun 2013 02:47
I always used to use the trick OBese mentioned You had to remove the + Code Snippet text, but it was very useful.

swis
Joined: Tue Dec 16th 2008
Interstellar
RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 15th Jun 2013 02:53 Edited at: 15th Jun 2013 02:56
Normally in Firefox you can select paragraphs of text by triple-clicking just fine, but it seems they made the decision that you'll always just highlight a single line inside "pre" tags or tags with the CSS attribute "white-space: pre"... atleast that's what it looks like after replacing the pres with divs. No triple-click success so far unless you make the code unpreformatted (is that a even word?) - which in turn would collapse all whitespace and linebreaks. The code with syntax highlighting doesn't change much for me, whatever I try.

Anyways, updated the script (link still in my original post) so that a double-click highlights everything to circumvent this "handicap" in firefox.

Edit:
Quote: " I always used to use the trick OBese mentioned You had to remove the + Code Snippet text, but it was very useful."

Doesn't that still work though? If I select the closed Code Snippet and open it while it's selected I can copy the whole content with the "+ Code Snippet" in front of it.
swissolo
15
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 15th Jun 2013 03:16
Quote: "Doesn't that still work though? If I select the closed Code Snippet and open it while it's selected I can copy the whole content with the "+ Code Snippet" in front of it."

Attempting to open it deselects it for me, but there was never a need to open it in the past.

swis
Joined: Tue Dec 16th 2008
Interstellar

Login to post a reply

Server time is: 2025-05-16 04:41:10
Your offset time is: 2025-05-16 04:41:10