14 Replies - 768 Views - Last Post: 22 May 2011 - 11:48 AM

#1 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Syntax Highlighting?

Posted 17 May 2011 - 01:20 AM

Hello everybody,

I've built a simple Text Editor program and I've been kicking around the idea of adding Syntax Highlighting to it. I've looked at a few different open source editors, Notepad++, scintilla, Notepad2, Sharpdevelop, and what is bugging me is how to actually get the words. From what I've noticed everyone seems to just use a list of key words. This seems like a lot of Googleing and tedious typing, and well I program to make my life easier, in other words I be lazy. Does anyone know of a way to use maybe the Assembly method in .NET or any other short cuts to get all these words instead of typing out a list?

Any help would be greatly appreciated.

Thank You.

Is This A Good Question/Topic? 0
  • +

Replies To: Syntax Highlighting?

#2 RevTorA  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 76
  • View blog
  • Posts: 251
  • Joined: 22-April 11

Re: Syntax Highlighting?

Posted 17 May 2011 - 04:00 PM

The lists of keywords are the combined work of numerous individuals. Nobody single-handedly types them all in. If you come up with a simple file format for describing a language's syntax and release it, you might get some others to help out.
Was This Post Helpful? 0
  • +
  • -

#3 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Re: Syntax Highlighting?

Posted 18 May 2011 - 12:01 AM

Yeah I was thinking that too. Sounds like a much better idea than me bashing my head against googles home page for hours on end.
Was This Post Helpful? 0
  • +
  • -

#4 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,363
  • Joined: 14-January 10

Re: Syntax Highlighting?

Posted 20 May 2011 - 04:10 PM

Here's you a start. :D

EDIT: Here's another one and another.

This post has been edited by RandomlyKnighted: 20 May 2011 - 04:14 PM

Was This Post Helpful? 0
  • +
  • -

#5 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Re: Syntax Highlighting?

Posted 21 May 2011 - 08:20 AM

Hey that was usful RandomlyKnighted, now i just need a C and Python one and I'll be good.
Was This Post Helpful? 0
  • +
  • -

#6 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,363
  • Joined: 14-January 10

Re: Syntax Highlighting?

Posted 21 May 2011 - 02:39 PM

Here are the keywords for C.

and here are the keywords for Python. The link for the Python keywords comes directly from the Python documentation website and I made sure I got the keywords for Python 3.2 which the most recent version that is stable.

This post has been edited by RandomlyKnighted: 21 May 2011 - 02:39 PM

Was This Post Helpful? 0
  • +
  • -

#7 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,025
  • Joined: 15-July 08

Re: Syntax Highlighting?

Posted 21 May 2011 - 02:42 PM

Remember that syntax highlighting is more than just a list of keywords. It also includes comments for each language, different String notations and common idioms. What I would do is make a configuration file for each language tha includes all of this information and have it load the appropriate one based on the file type.
Was This Post Helpful? 1
  • +
  • -

#8 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2251
  • View blog
  • Posts: 9,435
  • Joined: 29-May 08

Re: Syntax Highlighting?

Posted 21 May 2011 - 02:50 PM

Take vb.net for example, you can literal embed XML inside your sourecode, and inside then you can escape the XML to embed vb.net expressions. So Keyword highlighting is only get you so far, the best highlighters understand the grammar of the language.
Was This Post Helpful? 0
  • +
  • -

#9 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Re: Syntax Highlighting?

Posted 21 May 2011 - 02:53 PM

Yeah I'll end up using XML. I just figured out a lot of XML from the current project I'm working on. But I figured I'd start slow just get the keywords and the comments working first before I started getting into anything deeper.
Was This Post Helpful? 1
  • +
  • -

#10 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,363
  • Joined: 14-January 10

Re: Syntax Highlighting?

Posted 21 May 2011 - 08:49 PM

Good thinking and if you need anything else just let me know. I'll be glad to help with what I can.

This post has been edited by RandomlyKnighted: 21 May 2011 - 08:49 PM

Was This Post Helpful? 0
  • +
  • -

#11 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Re: Syntax Highlighting?

Posted 22 May 2011 - 01:10 AM

Thanks RandomlyKnighted.

And Adam I'm guessing your talking about
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>



And that wouldn't be to difficult, XML highlighting would probably have to be its own module just due to the way the syntax is. But if I was to just pull something together right now. I'd probably TrimLeadingSpaces and see if the string startswith ''' then just pass the comments to the XML module.

If thats not what you meant please let me know.

And since we on the topic of syntax. I'm guessing autocomplete is done in a similar way but you'd have to, at least in Microsofts CLR, use the assembly class to get all the other things.

Don't mind me as I ramble my mind is about ten steps ahead of my knowledge, so its constantly try to figure things out.
Was This Post Helpful? 0
  • +
  • -

#12 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,363
  • Joined: 14-January 10

Re: Syntax Highlighting?

Posted 22 May 2011 - 10:59 AM

You said something in your original post about .NET are you using VB or C# to build this text editor?
Was This Post Helpful? 0
  • +
  • -

#13 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Re: Syntax Highlighting?

Posted 22 May 2011 - 11:07 AM

VB.NET and VS 2010, It's the only language I know well enough to do anything large in.
Was This Post Helpful? 0
  • +
  • -

#14 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,363
  • Joined: 14-January 10

Re: Syntax Highlighting?

Posted 22 May 2011 - 11:39 AM

Oh ok. I don't know VB myself never really got into it. I personally like C# and Java. Keep me updated on how this project goes. I might need to do a little bit of syntax highlighting in Java later on.
Was This Post Helpful? 0
  • +
  • -

#15 zedth2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 14-September 09

Re: Syntax Highlighting?

Posted 22 May 2011 - 11:48 AM

There are a lot of code converters out there. Especially for VB to C# and vis versa. Because from what I've read the only real difference between C# and VB is just the syntax.
I use this one all the time because I always find more C# code than VB.
http://www.developer...t/csharp-to-vb/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1