Thread: Looking for a few people willing to test!

  1. #16
    *this
    Join Date
    Mar 2005
    Posts
    498
    I think ill try and contribute some code to this... I have an idea for one and maybe ill try it out and post it. My Idea is for one, it can be vB code or HTML. Then maybe ill create a windows app to have a text box that does it right before your eyes so you can paste or type the code and click a button.

    This is a great Idea for a project that everyone could use to make code easier to read on the boards.

  2. #17
    *this
    Join Date
    Mar 2005
    Posts
    498
    Here is a preview of the c-style comments part, the NoColor is a vector that contains zones that are already in use by a comment or something else so that no other colors are added to it:
    Code:
    	///////////////////////////////////////////////
    	// C-Style Comments ///////////////////////////
    	
    	/* Comment setup ------------------- */
    	const int CommentCSize = Colors[ColorChoices[3]].size();
            /* End setup ----------------------- */
    	do
    	{
    		current = code.find("/*", end);
    		if (current != string::npos)
    		{   
    			// Insert the color for comments
    			code.insert(current, Colors[ColorChoices[3]]);
    			nz.begin = current;
    			
    			// Now lets search for the matching pair
    		        end = code.find("*/", current + CommentCSize + 3);
    		        if (end != string::npos)
    			{
    				// Insert the closing color tag
    				code.insert(end + 2, ColorEnd);
    				nz.end = end + ColorEnd.size() + 1;
    			}		
    			// If there is no end, erase what we have
    			// inserted and report a syntax error
    			else
    			{
    				code.erase(current, current + CommentCSize);
    				return SYNTAXERROR;
    			}
    			// If everything works add the current
    			// comment zone to the no more color vector
                            NoColor.push_back(nz);   	
    		}
    	}
    	while (current != string::npos);
    	
    	// End C-Style Comments ///////////////////////
           ////////////////////////////////////////////////
    Last edited by JoshR; 08-19-2005 at 06:07 PM.

  3. #18
    Banned
    Join Date
    Jun 2005
    Posts
    594
    here is a update i made, so far i could onyl find one bug and
    its werid as hell bug i gotta work on it, it wont highlight using
    or namespace when there is a midline comment,
    but it will high light everything else correctly even with
    a midline comment. i suppose you can live with this bug
    and prolly never know it was there, because not many people
    are likly to put a midline comment withing using namespace :/

    the following is source colored with the program, then the source
    is an attachment.

    Code:
    #pragma once
    
    #include<iostream>
    #include<string>
    
    /* Multi-line comment begins here
       And ends here*/
    
    //bool and char
    
    #ifdef __BORLANDC__
      #error "Borland"
    #else if defined(_MSC_VER)
      #error "Microsoft"
    #endif
    
    using namespace std;
    
    int main()
    {
    	char ch;
    	int num;
    	double dnum;
    	string mysentence = "hello /*midline true comment*/ bool world"; //a string
    	cout << mysentence << endl;
    	cout << "welcome to my world" << end;
    	return 0;
    }
    i suppose once i finish and get the bugs out i will
    comment the code.

    for less then 3k of code, and just under 115 lines of code
    id say its pretty impressive.
    Last edited by ILoveVectors; 08-19-2005 at 08:40 PM.

  4. #19
    Banned
    Join Date
    Jun 2005
    Posts
    594
    JoshR, did you highlight your code taht you posted by hand,
    with your program? with mine? with lucky's? something else?

  5. #20
    *this
    Join Date
    Mar 2005
    Posts
    498
    Lol by hand... but the zone idea I have essentially double checks and makes sure that things arent overlapped with wrong colors. All my code can do now is correctly color c-style comments and double dash comments.. some that i couldnt get with your program like this:

    Code:
    /*/* */
    and
    Code:
    /*//*/
    Sorry didnt check your updates maybe you fixed it...
    but midline comments i have working
    for example
    Code:
    int test /*test comment*/;

  6. #21
    *this
    Join Date
    Mar 2005
    Posts
    498
    In my IDE's this midline comment:
    Code:
     "hello /*midline true comment*/ bool world"; //a
    would be part of the string because it takes priority i guess.
    tried it out and it is part of the string, maybe its not on your compiler?

  7. #22
    Banned
    Join Date
    Jun 2005
    Posts
    594
    yea i just checked that it does, i never put that in my compiler
    i just wrote it in the my test text file.

  8. #23
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Well, in my IDE, a single line comment with a backslash at the end doesn't turn the comment's colour.

    Code:
    // comment . . . \
    int i;
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #24
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    How about this? How does your highlighter fare with it?

    Code:
    puts("printf(\"Hello, World!\n\");");
    [edit]
    Or this . . .
    Code:
    puts("\\\"\\");

    [/edit]
    Last edited by dwks; 08-20-2005 at 01:38 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  10. #25
    Banned
    Join Date
    Jun 2005
    Posts
    594
    here is a new update, should accomedate the changes
    dwks mention. p.s. that C, this was written for c++.
    im sure it doesnt make much of a different in either case but
    i wanted to point that out.

    im unloading the application, config, and source
    file so those who have bene keeping up can make
    sure they are gettign the full of the program
    and not commenting on old problems. thansk again.

    and as always here what that one program looks like
    colorized with the program.

    Code:
    #pragma once
    
    #include<iostream>
    #include<string>
    
    /* Multi-line comment begins here
       And ends here*/
    
    //bool and char
    
    #ifdef __BORLANDC__
      #error "Borland"
    #else if defined(_MSC_VER)
      #error "Microsoft"
    #endif
    
    using namespace std;
    
    int main()
    {
    	char ch;
    	int num;
    	double dnum;
    	string mysentence = "hello /*midline true comment*/ bool world"; //a string
    	cout << mysentence << endl;
    	cout << "welcome to my world" << end;
    	return 0;
    }
    there are a still a few bugs in this, more then there was
    in the last one, but hey, i onyl get 10 minut eor so a day to
    work on this.
    Last edited by ILoveVectors; 08-20-2005 at 08:13 PM.

  11. #26
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Sorry, I'm mainly a C programmer.

    (Finally, someone else who uses .RAR instead of .ZIP.)

    How about this?

    Code:
    /* comment \*/
    int i;
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  12. #27
    Banned
    Join Date
    Jun 2005
    Posts
    594
    yea i mainly use rar, but i posted most of then in zip
    because alot of people dont have the ability to
    decompress winrar.

  13. #28
    Banned
    Join Date
    Jun 2005
    Posts
    594
    im not sure what you mean about this
    Code:
    /* comment \*/
    int i;

    this is what i get when i put it thourgh the program

    Code:
    /* comment \*/
    int i;

  14. #29
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    I haven't tried the latest app, but just wanted to point out a couple of things you'll want to be sure to properly colorize. Here's how yours colorizes:
    Code:
    // multi-line single-line comment \
       this is a continuation of the comment
    
    char ch = '\\';
    const char *str = "\" \
                       blah";
    const char *str2 = "\"", str3 = "\"";
    /*/ /*/
    But here's how it should:
    Code:
    // multi-line single-line comment \
       this is a continuation of the comment
    
    char ch = '\\';
    const char *str = "\" \
                       blah";
    const char *str2 = "\"", str3 = "\"";
    /*/ /*/
    A single-line comment ending with a backslash makes the next line a comment. You aren't colorizing any single-quote (aka. apostrophe) encapsulated data, and when you do you'll want to be sure you account for escaped quotes and backslashes. When it comes to strings, you are apparently making everything from the first quote to the last quote on the line a string. First, there may be multiple strings on a line, and second, a string literal may span multiple lines. Finally, multi-line comments must start with /* and end with */ but they cannot share the asterisk, so /*/ should not start and end a comment. Even if it did, for some reason the second /*/ on a line doesn't get colorized.

    Way to make good progress.

  15. #30
    Banned
    Join Date
    Jun 2005
    Posts
    594
    wow when i started this project, i had no idea of ther werid
    stuff people would do to there code. my first version was
    almost perfect for my style, without the pointing out of
    these things i could of went an eternity with it never producing
    a problem for me. oh well it still hastn discouraged me i will
    keep it up this project interests me alot anyways.

    about the comment thing were it highlight the next line i
    never new about that, that interesting..


    as for /*/ /*/ the way i was handling comments was something
    i was thinking about changing.

    to deal with some of that other stuff i have a feeling im going to
    have to change the way i choose to do my setup. the way
    i am thinking about doing it now, may actually be faster,
    and i dont think it will take to much time to convert.

    thanks for all the input, it really helps knowing the werid stuff
    people do.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Katrina Aftermath: Woeful Incompetence (rant).
    By anonytmouse in forum A Brief History of Cprogramming.com
    Replies: 61
    Last Post: 09-05-2005, 07:39 AM
  2. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  3. February 1, 2019...
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 98
    Last Post: 08-03-2002, 07:24 AM
  4. Religious Bull****
    By Witch_King in forum A Brief History of Cprogramming.com
    Replies: 119
    Last Post: 10-23-2001, 07:14 AM
  5. IT people - weird genius or simply narrow-minded, antisocial, lazy people
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 10-11-2001, 05:00 AM