943,771 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Feb 6th, 2007
0

Code line numbers - causing paste problems

Expand Post »
The new line numbers inserted when using syntax coloring code tags is causing me problems when copying and pasting code. Here are some examples:

http://www.daniweb.com/techtalkforum...311344-32.html

I copy and paste the code to my editor. This is how it looks when it's selected in my browser:
http://img522.imageshack.us/img522/7406/picture1ji6.png
And this is how my code looks when it's in the editor:
1.
#include <stdio.h>
2.
#include <string.h>
3.

4.
int main(void) {
    5.
    6.
    char mystring[] = "this is a test.\n";
    7.
        char *p = strchr(mystring, '\n');
    8.
        if (p != NULL) *p = '\0';
    9.
        printf("%s no newlines should occur.\n", mystring);
    10.
        11.
}
Sometimes, instead of line numbers I get pound symbols (#) instead. I'm using Firefox 2.0.
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

I don't have this problem at all. I tried copying/pasting from both Firefox and IE into Windows Notepad. Perhaps it's a problem with your editor?

In the meantime, a workaround would be to click the Reply w/ Quote button and then copy the post contents from the editor window.

Since the majority of the code posted within the forums is just for discussion purposes, I thought the line numbers would be a great aid towards talking about a particular piece of code. ie. "You have an error on line #5"
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

Click to Expand / Collapse  Quote originally posted by cscgal ...
Perhaps it's a problem with your editor?
Nah, before I was using Xcode, but using TextEdit didn't seem to make a difference. To me, it seems to be somewhat on the browser end of things.

Just tried Safari now - no difference.

I'll let you know how things are on Linux when I next boot onto Debian.

Quote ...
In the meantime, a workaround would be to click the Reply w/ Quote button and then copy the post contents from the editor window.
Thanks; it seems like I'll be needing to do this whenever I need to try out code in my compiler from now on.
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

I have a mac as well so I am going to see if it works for me.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

Click to Expand / Collapse  Quote originally posted by cscgal ...
Perhaps it's a problem with your editor?
Same issue with my editor. DevShed had a similar issue and a better workaround.

[imo]Even though the better solution was to leave it as it was.[/imo]
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

Dave, are you in Linux?
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

Click to Expand / Collapse  Quote originally posted by cscgal ...
Dave, are you in Linux?
Nope.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

Although it may first seem like a great idea...
Click to Expand / Collapse  Quote originally posted by cscgal ...
Since the majority of the code posted within the forums is just for discussion purposes, I thought the line numbers would be a great aid towards talking about a particular piece of code. ie. "You have an error on line #5"
That actually happens about 0.5% of the time. IMO it's not worthwhile to inconvenience 99.5% of the rest.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

0.5% of the time you discuss the code snippets and 99.5% of the time you copy them into your editor and compile them? I suspect that's not the case with the vast majority of traffic to the programming forums.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Feb 6th, 2007
0

Re: Code line numbers - causing paste problems

Click to Expand / Collapse  Quote originally posted by cscgal ...
0.5% of the time you discuss the code snippets and 99.5% of the time you copy them into your editor and compile them? I suspect that's not the case with the vast majority of traffic to the programming forums.
I use colors and other tools available [when available] because that is far more effective than looking at a printout from 1972. So yes, that is the case.

BTW, I found this, FWIW.
Last edited by Dave Sinkula; Feb 6th, 2007 at 1:59 am.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in DaniWeb Community Feedback Forum Timeline: User Control Panel not working
Next Thread in DaniWeb Community Feedback Forum Timeline: formatting playing up





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC