0

Damn I thought there was a single click deployement for nested quotes.. this much effort *phew*.

Kudos to those who multiquote :D

0

But that takes effort!

Ummm, yeah...

Damn I thought there was a single click deployement for nested quotes.. this much effort *phew*.

Kudos to those who multiquote :D

Kids! What a bunch of lazy.... :rolleyes: Back when I was young, I use to --- Oh my GOSH! I sound like my dad!! :eek:

0

Kids! What a bunch of lazy.... :rolleyes: Back when I was young, I use to --- Oh my GOSH! I sound like my dad!! :eek:

You know I am not as young as I sound...;)

But still its a good thing people around here consider me as kid...

0

I have edited the highlighting for *all* syntax languages. Please test accordingly.

0

Looks good from what little I have seen.

All the imporatant features of the program like keywords, curly and round braces have been emphasized.

0

C/C++ functions don't need to be colored, but if they are, use a dark color like maybe red

Yeah even I think that the functions should be easily distinguished from the normal statements and constructs.

0

The problem is that I can't use red because I didn't like having numbers, strings, and characters all in one color as in WaltP's example, so I made numbers red.

0

Firstly ... everyone keeps giving me different suggestions to color everything and confuses me!! Secondly ... that example doesn't highlight functions which would be the purpose of changing color to begin with.

0

The problem is that I can't use red because I didn't like having numbers, strings, and characters all in one color as in WaltP's example, so I made numbers red.

Firstly ... everyone keeps giving me different suggestions to color everything and confuses me!! Secondly ... that example doesn't highlight functions which would be the purpose of changing color to begin with.

The example which I quoted was to do away with the confusion regarding numbers, strings, characters and other literals so that the color red would then be free to be used for functions...

Its bad that Mr. WaltP is offline right now , since you seem to be making the color scheme based on his base scheme. But still it wont hurt to let this discussion for a while, while each and everyone posts his choices.

After all it wouldnt hurt to take ideas from different places and see which works better for our site. There is no hurry as such( methinks ).

0

Ahh, I see ... It is nearly 4 am right now and I need sleep so I am going to get to bed. So let's definitely get some feedback and see if anyone has suggestions. I do want to use the same color scheme for all languages so it's also important to make sure things look good for all languages.

0

Ditto, maybe when it is morning at your place the other mods (especially Mr. WaltP) will take a look at this thread and give some valuable feedback.

Good night Miss Dani.

0

Firstly ... everyone keeps giving me different suggestions to color everything and confuses me!! Secondly ... that example doesn't highlight functions which would be the purpose of changing color to begin with.

Could you list the colors currently in use and for what? That might help come up with ideas. Are they defined as words or hex values?

0

keywords = bold purple
comments = green
multi-line comments = italic green
characters and strings = blue
numbers = red
escape character (ie '\') = bold blue
brackets and parentheses = bold gray
everything else = black

0

keywords = bold purple
comments = green
multi-line comments = italic green
characters and strings = blue
numbers = red
escape character (ie '\') = bold blue
brackets and parentheses = bold gray
everything else = black

I feel comments can be wrapped into one color/style.
escape chars are just chars, drop the bold. I don't feel bold is needed.

Possibilities:
Since strings/chars and numbers are essentially constants, make them both blue but different shades. Numbers in NavyBlue (#000080) so they stand out, chars in MediumBlue (#0000cd).
For "Everything Else", try Brown4 (#8b2323)

0

Bugs. Problems with quotes and escape characters. "\"" Where that is specifically. See below.

Actually this may just be the tip of the iceberg. Who knows what other inconsistencies there might be for other languages.

Normally I don't do this but I don't have time to explain.


Code:
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

string quoteExtract( string );
string extractFirstWord( string );

int main()
{
  string line;

  
  ifstream open ( "c:\\yourfile.txt" );
  
  while (getline(open,line,'\n')) //read in each line from the file
  {
        
    if (extractFirstWord(line)== "servername")
    {
       cout << quoteExtract (line);
    }
    
                                             
  } 
  open.close(); //close file
  cin.get(); //pause program
}

/*
 * Input: std::string
 * Returns: std::string
 * Purpose: To extract the characters between only ONE pair of quotes
 */
string quoteExtract (string line)
{
    
    int start,len; //Declare variables
    
    //string line = "description \"NightIRC service an rare constellation of stars\";";
    
    start =  line.find_first_of( "\"" ); //
    len   =  line.rfind( "\"" );  //stores position of last quote
    
    //cout << "Found first quote at:";
    //cout << start;
    //cout << "\nFound second quote at:";
    //cout << len << "\n";
    
    string extract;
    extract =  line.substr( start + 1, ( len -( start + 1 ) ) ); 
    //extracts the characters between quotes
    return extract;
    
    //cin.get();
}

/* Extracts the first word in a file
 * Assumes no preceding whitespace before the
 * first word
 */
string extractFirstWord( string line )
{
   int start;
   start =  line.find_first_of( " " ); //stores position of first space
   string extract;
   extract =  line.substr( 0, start ); //extracts the first word
   
   return extract;
}
Code:
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

string quoteExtract( string );
string extractFirstWord( string );

int main()
{
  string line;

  
  ifstream open ( "c:\\yourfile.txt" );
  
  while (getline(open,line,'\n')) //read in each line from the file
  {
        
    if (extractFirstWord(line)== "servername")
    {
       cout << quoteExtract (line);
    }
    
                                             
  } 
  open.close(); //close file
  cin.get(); //pause program
}

/*
 * Input: std::string
 * Returns: std::string
 * Purpose: To extract the characters between only ONE pair of quotes
 */
string quoteExtract (string line)
{
    
    int start,len; //Declare variables
    
    //string line = "description \"NightIRC service an rare constellation of stars\";";
    
    start =  line.find_first_of( "\"" ); //stores position of first quote
    len   =  line.rfind( "\"" );  //stores position of last quote
    
    //cout << "Found first quote at:";
    //cout << start;
    //cout << "\nFound second quote at:";
    //cout << len << "\n";
    
    string extract;
    extract =  line.substr( start + 1, ( len -( start + 1 ) ) ); 
    //extracts the characters between quotes
    return extract;
    
    //cin.get();
}

/* Extracts the first word in a file
 * Assumes no preceding whitespace before the
 * first word
 */
string extractFirstWord( string line )
{
   int start;
   start =  line.find_first_of( " " ); //stores position of first space
   string extract;
   extract =  line.substr( 0, start ); //extracts the first word
   
   return extract;
}
0

Eek that's terrible! I had no idea. All languages are handled the same way so once the bug is squished all languages will be affected, but I will see if I could get to the bottom of this before the end of the day (I'm having a very busy day).

0

That wasn't so hard. :) Can you confirm?

First time a girl has ever said that to me ;) Being the stallion that I am.

But yeah let's try. btw I remember writing a code syntaxer in c++/c before. There were a lot of things I had to fix. Who knows what other problems lie with other languages?

0

Well it's the same parser that has been used in the code snippets library for a good amount of time. The problem you pointed out turned out to just be something small in preparing the code before it is sent to the parser that HAS survived the test of time.

0

Well it's the same parser that has been used in the code snippets library for a good amount of time. The problem you pointed out turned out to just be something small in preparing the code before it is sent to the parser that HAS survived the test of time.

Oh I thought you had written the actual parser. Silly me. I'll let you know if I spot any unusual behaviour.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.