Code line numbers - causing paste problems

Reply

Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Code line numbers - causing paste problems

 
0
  #1
Feb 6th, 2007
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.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,040
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Code line numbers - causing paste problems

 
0
  #2
Feb 6th, 2007
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"
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Code line numbers - causing paste problems

 
0
  #3
Feb 6th, 2007
Originally Posted by cscgal View Post
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.

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.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,040
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Code line numbers - causing paste problems

 
0
  #4
Feb 6th, 2007
I have a mac as well so I am going to see if it works for me.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Code line numbers - causing paste problems

 
0
  #5
Feb 6th, 2007
Originally Posted by cscgal View Post
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]
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,040
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Code line numbers - causing paste problems

 
0
  #6
Feb 6th, 2007
Dave, are you in Linux?
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Code line numbers - causing paste problems

 
0
  #7
Feb 6th, 2007
Originally Posted by cscgal View Post
Dave, are you in Linux?
Nope.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Code line numbers - causing paste problems

 
0
  #8
Feb 6th, 2007
Although it may first seem like a great idea...
Originally Posted by cscgal View Post
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.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,040
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Code line numbers - causing paste problems

 
0
  #9
Feb 6th, 2007
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.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Code line numbers - causing paste problems

 
0
  #10
Feb 6th, 2007
Originally Posted by cscgal View Post
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.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the DaniWeb Community Feedback Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC