Syntax Highlighting (How To)

This is a discussion on Syntax Highlighting (How To) within the Windows Programming forums, part of the Platform Specific Boards category; i have a text editor all made and everything. but how do i make it so that when a user ...

  1. #1
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343

    Syntax Highlighting (How To)

    i have a text editor all made and everything. but how do i make it so that when a user types the full complete word of my choice itll turn to a different color and bold or something like that. like any editor for html, javascript, C++ compilers, and everything.

    like, while in the document, if someone types in the word
    print
    then i want it to go red and italic. but if they type in any other words, theyll still be blue.

    oh yeah, and default text is blue and syntax words of my choice will appear red and some sort of text decoration.

    how would i be able to do that.

    it has to be more than a "for-each" loop.

    if anyone needs more details then please, ask away:

    but i think i got all the details down.
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  2. #2
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    doesn;t anybody know how to do this! 14 views and not a single reply yet! jees!
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    272
    You could start a background thread to parse the inputted tokens. You could even use for-each in this if you wanted.
    Joe

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>>
    doesn;t anybody know how to do this! 14 views and not a single reply yet! jees!
    <<<

    Bumping your own threads is against the board rules, and may well result in your thread being deleted.

    As for your question, think about it, there could be a hundred ways of doing this depending on how you are doing what you are doing...

    >>> but i think i got all the details down.

    ... no. You have some vague idea of the outline of what you want to do, but...

    >>> i have a text editor all made and everything

    ... so how are you doing anything? You must learn, in Windows, there is never a simple, single way to do anything.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    I think I would use a for loop in a function - only this loop checks only the line you're currently working on - The loop would check through a list, array, hash table or whatever to see if the word currently being typed is a keyword. Then if the value checked out, I would throw some FLAGS that are attached to the way the text is displayed - I guess a hash table or map would be best.
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I would get it to scan the current word or expression or something each time it encounters a white-space... but then, that's just an idea off the top of my head, probably no good...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #7
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343

    Unhappy

    ok, maybe you guys didn;t understand my question good enough.

    a foreahc sopunds good. im vaguly askin, how would i be able to do this.

    like what would the function be and how do i set the font and stuff because none of the tutorials i have explain this.

    in java, its g.setFont, g.setColor, g.drawString, or something! it aint simple in C++ and was just asking.

    where would i put this for-each loop and how would i put the function to use (what the function in which i could change the fiont and color). and maybe how to do tect decorations like italic and bold.
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 09:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21