Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


How knackered is your code paste


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
29 replies to this topic

Poll: How knackered is your code paste (35 member(s) have cast votes)

Does the source/code box on gamedev.net annoy you?

  1. Yes (2 votes [5.71%])

    Percentage of vote: 5.71%

  2. Yes! (10 votes [28.57%])

    Percentage of vote: 28.57%

  3. Wait, you can paste source? (4 votes [11.43%])

    Percentage of vote: 11.43%

  4. I tried to paste some source, but then I took an arrow to the knee. (16 votes [45.71%])

    Percentage of vote: 45.71%

  5. No. (3 votes [8.57%])

    Percentage of vote: 8.57%

Vote Guests cannot vote

#1 Washu   Senior Moderators   -  Reputation: 6492

Posted 16 February 2012 - 10:55 PM

So, I was posting a reply to a journal when it produced this:

Lexing took:  66ms
Parsing took: 0ms
Grammar
	MetaEntities
		Vector
			Members
				Member
					real
						X
				Member
					real
						Y
				Member
					real
						Z
				Member
					dot
						ParamTypeSpec
							Vector
							Vector
						float
		entrypoint
			Parameters

Now, here's the thing: If you go to edit you'll see that this actually only has FOUR space indents. Yet somehow that indent became EIGHT spaces...CONDITIONALLY. The actual reply is here, and the first indent WAS originally only four spaces, but after I edited it for quoting in this thread (without saving changes) it changed it to EIGHT spaces as well.

Now, we're a software development (with a focus on game development) website. So how hard is it for us to come up with a decent CODE/SOURCE box that actually, you know, works. By works I mean: When you paste code into it doesn't randomly remove or insert new spaces, newlines, and the color coding doesn't magically stay when you go to raw mode. Oh... and half your source doesn't magically vanish every time you click the "Raw" toggle switch on the WYSIWYG editor for posts.

Thoughts?

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6995

Posted 16 February 2012 - 11:42 PM

I've already posted a gripe of mine with the editor. It also drives me nuts when someone copies and pastes some code, but the editor tries to preserve its rich text formatting, and then you end up with a post like this.
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#3 Washu   Senior Moderators   -  Reputation: 6492

Posted 16 February 2012 - 11:53 PM

Oh yes, I've taken to pasting in notepad, then copying from there, THEN pasting to the forums to make sure visual studio formatting doesn't end up getting pasted. Interestingly though, it only happens SOME of the time.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#4 swiftcoder   Senior Moderators   -  Reputation: 12446

Posted 17 February 2012 - 12:10 AM

Oh yes, I've taken to pasting in notepad, then copying from there, THEN pasting to the forums to make sure visual studio formatting doesn't end up getting pasted. Interestingly though, it only happens SOME of the time.

It happens enough that I just instinctively toggle to 'raw' mode when pasting source. Mind you, I have to do the same for WordPress' syntax colouring plugin, so I guess it doesn't bother me all that much.

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#5 Sirisian   Crossbones+   -  Reputation: 1868

Posted 17 February 2012 - 12:17 AM

yeah it's a pain. Same here. Pasted some code earlier and it garbled it so I pasted in notepad then into their editor. Also having both [ code] and [ source] tags is fun.

#6 rip-off   Moderators   -  Reputation: 9455

Posted 17 February 2012 - 06:29 AM

I find Chrome's "paste as plain text" alleviates this to some degree. It is still annoying if you forget, and up to recently my Linux install of Chrome didn't have this feature.

I also find it annoying that copying and pasting text from someone else's post is in a different font to the message builder.

#7 SteveDeFacto   Banned   -  Reputation: 109

Posted 18 February 2012 - 03:31 AM

I agree completely, Washu. Recently the up time for GDNet has been pretty good and everything seems pretty solid except the text editor and source tags. These two things are the only gripes I've had recently but it's still pretty annoying.

#8 Cornstalks   Crossbones+   -  Reputation: 6995

Posted 18 February 2012 - 09:53 AM

Yeah, what's up with source tags? I can't figure out how to specify a language so that there's syntax highlighting.

And yes to what SteveDeFacto said about uptime: it's been a lot better lately!
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#9 Cornstalks   Crossbones+   -  Reputation: 6995

Posted 18 February 2012 - 07:21 PM

Just saw a fun one. Washu's post. Notice fastcall22's '&' got turned into &
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#10 Matt328   Members   -  Reputation: 258

Posted 18 February 2012 - 07:52 PM

I had a hell of a time with it with a post the other day, if I put the lang="cpp" part in the source tag, it would chew it all up. Trying to edit the post to fix it just seemed to make it even worse. Finally I discovered that without lang="cpp" it at least put it in a code box with line numbers. I tried with both Chrome and Firefox, and had varying degrees of problems with each. Given that posting code is pretty common on this site, I hope they get it fixed ASAP.

#11 Washu   Senior Moderators   -  Reputation: 6492

Posted 19 February 2012 - 04:20 PM

That code paste is really ticking me off.
eve.png

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#12 Gaiiden   Senior Staff   -  Reputation: 5338

Posted 19 February 2012 - 04:26 PM

Okay, been following along and I have a question that has to do with the issue Washu raised. There are a lot of old but still often-referenced articles with source that is supposed to look like this:

long arr[10] = { 3,6,1,2,3,8,4,1,7,2};
char arr2[5][20] = {  "Mickey Mouse",
                      "Donald Duck",
                      "Minnie Mouse",
                      "Goofy",
                      "Ted Jensen" };

void bubble(void *p, int width, int N,
            int(*fptr)(const void *, const void *));
int compare_string(const void *m, const void *n);
int compare_long(const void *m, const void *n);

int main(void)
{
    int i;
    puts("\nBefore Sorting:\n");

    for (i = 0; i < 10; i++)               /* show the long ints */
    {
        printf("%ld ",arr[i]);
    }
    puts("\n");

    for (i = 0; i < 5; i++)                  /* show the strings */
    {
        printf("%s\n", arr2[i]);
    }
    bubble(arr, 4, 10, compare_long);          /* sort the longs */
    bubble(arr2, 20, 5, compare_string);     /* sort the strings */
    puts("\n\nAfter Sorting:\n");

    for (i = 0; i < 10; i++)             /* show the sorted longs */
    {
        printf("%d ",arr[i]);
    }
    puts("\n");

    for (i = 0; i < 5; i++)            /* show the sorted strings */
    {
        printf("%s\n", arr2[i]);
    }
    return 0;
}


But instead when you plain text paste it into the editor and wrap it in code tags it looks like this:

long arr[10] = { 3,6,1,2,3,8,4,1,7,2};
char arr2[5][20] = {  "Mickey Mouse",
					  "Donald Duck",
					  "Minnie Mouse",
					  "Goofy",
					  "Ted Jensen" };

void bubble(void *p, int width, int N,
			int(*fptr)(const void *, const void *));
int compare_string(const void *m, const void *n);
int compare_long(const void *m, const void *n);

int main(void)
{
	int i;
	puts("\nBefore Sorting:\n");

	for (i = 0; i < 10; i++)			   /* show the long ints */
	{
		printf("%ld ",arr[i]);
	}
	puts("\n");

	for (i = 0; i < 5; i++)				  /* show the strings */
	{
		printf("%s\n", arr2[i]);
	}
	bubble(arr, 4, 10, compare_long);		  /* sort the longs */
	bubble(arr2, 20, 5, compare_string);	 /* sort the strings */
	puts("\n\nAfter Sorting:\n");

	for (i = 0; i < 10; i++)			 /* show the sorted longs */
	{
		printf("%d ",arr[i]);
	}
	puts("\n");

	for (i = 0; i < 5; i++)			/* show the sorted strings */
	{
		printf("%s\n", arr2[i]);
	}
	return 0;
}

Does that bother anyone else as much as it does me? I think I might just be a bit of a stickler for neatly-formatted code.

Also I don't use code boxes on the forums ever, mainly deal with them in articles where there is no source coloring for them. Does anyone else see a lot of comments in the above example that aren't really comments? I realize coloring is another personal preference but I've always thought green for comments was pretty universal as a default color

Drew Sikora
Executive Producer
GameDev.net


#13 swiftcoder   Senior Moderators   -  Reputation: 12446

Posted 19 February 2012 - 04:27 PM

That code paste is really ticking me off.
eve.png

I'm so confused...

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#14 fastcall22   Crossbones+   -  Reputation: 4867

Posted 19 February 2012 - 04:30 PM

Here's a fun one, hold on to your seats:

Original code
#include <sfml/graphics.hpp>

template<class type>
class why_does_it_think_theres_html {
    template<class i_dunno>
    void foobar() {
        /* ??? */
    }
};

After pressing the edit button, my post looks like:

Here's a fun one, hold on to your seats:

Original code

#include <sfml graphics.hpp="">

template<class type="">
class why_does_it_think_theres_html {
    template<class i_dunno="">
    void foobar() {
        /* ??? */
    }
};

After pressing the edit button, my post looks like:</class></class></sfml>


QWxsIHRvYXN0LXRvYXN0aW5nIHRvYXN0ZXJzIGNhbiB0b2FzdCB0b2FzdGVkIHRvYXN0LCBhbHRob3Vn aCByZS10b2FzdGluZyB0b2FzdGVkIHRvYXN0IGlzIGdlbmVyYWxseSBub3QgcmVjb21tZW5kZWQgYnkg dGhlIG1hbnVmYWN0dXJlcnMgb2YgdG9hc3QtdG9hc3RpbmcgdG9hc3RlcnMuLi4=

#15 Washu   Senior Moderators   -  Reputation: 6492

Posted 19 February 2012 - 04:36 PM

Okay, been following along and I have a question that has to do with the issue Washu raised. There are a lot of old but still often-referenced articles with source that is supposed to look like this:

Does that bother anyone else as much as it does me? I think I might just be a bit of a stickler for neatly-formatted code.

Also I don't use code boxes on the forums ever, mainly deal with them in articles where there is no source coloring for them. Does anyone else see a lot of comments in the above example that aren't really comments? I realize coloring is another personal preference but I've always thought green for comments was pretty universal as a default color

I think you're a stickler for neatly formatted code. That being said, I think its probably the same issue at the core of the problem with the "code" block, which is that the forum post formatter isn't treating the code blocks as "raw stuff that I should escape but otherwise ignore."

Here's a fun one, hold on to your seats:

Original code

#include <sfml/graphics.hpp>

template<class type>
class why_does_it_think_theres_html {
	template<class i_dunno>
	void foobar() {
		/* ??? */
	}
};

After pressing the edit button, my post looks like:


Here's a fun one, hold on to your seats:

Original code

#include <sfml graphics.hpp="">

template<class type="">
class why_does_it_think_theres_html {
	template<class i_dunno="">
	void foobar() {
		/* ??? */
	}
};

After pressing the edit button, my post looks like:</class></class></sfml>

Yup yup, I get that A LOT.


That code paste is really ticking me off.
eve.png

I'm so confused...

What, its gamedev.net... from eve.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#16 Gaiiden   Senior Staff   -  Reputation: 5338

Posted 19 February 2012 - 04:37 PM

Yeah, what's up with source tags? I can't figure out how to specify a language so that there's syntax highlighting.


See this Staff Journal post.

Drew Sikora
Executive Producer
GameDev.net


#17 Cornstalks   Crossbones+   -  Reputation: 6995

Posted 19 February 2012 - 04:39 PM



That code paste is really ticking me off.
eve.png

I'm so confused...

What, its gamedev.net... from eve.

Well... one gets the idea that the picture further explains/gives example of the code paste that's really ticking you off... but it doesn't.

[edit]

@Drew: Hmmm... I swore it wasn't working for me at one point. Anyway, the preview is kinda messed up. Here's the code I entered to test, and I took a screenshot of what I got for the preview.

[source lang="cpp"]#include <iostream>// Empty classclass X{};int main(){ std::cout << "Hello world!";}[/source]

[edit]
The code above is NOT what I typed.

Attached Thumbnails

  • Screen shot 2012-02-19 at 3.41.46 PM.png

[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#18 Washu   Senior Moderators   -  Reputation: 6492

Posted 19 February 2012 - 04:48 PM

Yes, anything that uses the greater or lesser signs tend to break the code pad triviallly. As an example ANY C++ code using std::cout, std::cin, or templates.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#19 fastcall22   Crossbones+   -  Reputation: 4867

Posted 19 February 2012 - 05:55 PM

Here's the code I entered to test, and I took a screenshot of what I got for the preview.

[source lang="cpp"]#include <iostream>// Empty classclass X{};int main(){ std::cout << "Hello world!";}[/source]

[edit]
The code above is NOT what I typed.


My other beef with the source tag is you can (pseduo-)edit its contents when you double click it:
Posted Image

So if you would like to copy a word from the source in order to look up the documentation for it or something, instead of highlighting the whole word when you double click the word, it'll enter "edit" mode and highlight the entire code for you. Awesome.

</iostream>
QWxsIHRvYXN0LXRvYXN0aW5nIHRvYXN0ZXJzIGNhbiB0b2FzdCB0b2FzdGVkIHRvYXN0LCBhbHRob3Vn aCByZS10b2FzdGluZyB0b2FzdGVkIHRvYXN0IGlzIGdlbmVyYWxseSBub3QgcmVjb21tZW5kZWQgYnkg dGhlIG1hbnVmYWN0dXJlcnMgb2YgdG9hc3QtdG9hc3RpbmcgdG9hc3RlcnMuLi4=

#20 Gaiiden   Senior Staff   -  Reputation: 5338

Posted 19 February 2012 - 07:07 PM

Oh right, the source box parses HTML, which I personally find a bit shocking since as Washu just pointed out the < character is used often, especially in C.

The source box also parses BBCode, so something like an array index with the value i will turn all text after it into italics.

My other beef with the source tag is you can (pseduo-)edit its contents when you double click it:


Woah, never knew that...

Drew Sikora
Executive Producer
GameDev.net





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS