Author Topic: Syntax Highlight for MY file extensions/languages  (Read 8538 times)

Offline mark4

  • Single posting newcomer
  • *
  • Posts: 4
Syntax Highlight for MY file extensions/languages
« on: January 26, 2010, 11:59:19 pm »
This is kind of a feature request but I placed it here because I cant see a dedicated forum for such.  I have a few requests  :)

[1]  I noticed that under settings/environment there is a file extention handling item which will allow me to add a new file extension.  I have done this yet when I go to settings/editor/syntax highlighting there is no way for me to create new rules for this file type.  There needs to be a "Syntax highight for"  [NEW] button added so that I can create highlight rules for languages other than C++.  I should be able to associate my new file extension to the new language.

[2] Please stop refering to the cursor as the caret.  The mouse pointer is the mouse pointer, it is not a cursor.  This is moved about the display with a mouse which is known as a pointing  device.  The cursor keys do not normally move the pointer around the display (they can but thats not the primary means of moving it).

The cursor is the cursor it is not a  caret.  For example, the keys on the keyboard are knows as the 'cursor' keys because they move the cursor, they are not called the caret keys.  </ rant > :)

[3] Please allow me to move the cursor up or down the display without it bouncing around all over the map simply because the line I moved into is shorter than the line I moved out of.  I believe some editors refer to this as "virtual spaces".

I find the use of these virtual spaces to be far far more intuative when moving the cursor around the display.  When I hit cursor down it is far easier on the eye for the cursor to 'only' move down.  If it jumps left or right of where I am currently looking then my eyes have to re-focus on where it jumped to. 

This lefty/righty jumping is just too schitzoid for me, I cant tell where the cursor is going to end up argh!

[4] Please add an underline mode to the cursor.  This is more visually pleasing to me than a thin vertical bar between the characters.  I have seen that I can change the width of this bar but I would still prefer a horizontal cursor under the character being edited.  I guess this preference is derived from all those wasted years I spent coding for DOS :)




Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Syntax Highlight for MY file extensions/languages
« Reply #1 on: January 27, 2010, 12:16:58 am »
[1]
For syntax-highlighting you need to create a lexer, see the wiki for details: http://wiki.codeblocks.org/index.php?title=Creating_a_custom_lexer_for_Code::Blocks_editor


[2]
Why ?
It's the name used by scintilla and scintilla is the base for our editor.

And it's not only used by scintilla (and C::B):

Quote from: http://en.wikipedia.org/wiki/Caret_%28disambiguation%29
Caret may refer to:

Language

    * Caret, the symbol, ^
    * Circumflex, the ^ in â, ê, î, ô, û.

Other

    * CARET Brain Mapping Software
    * Robert L. Caret, the president of Towson University
    * Cursor (computers), a blinking vertical bar


[3]
Virtual space will come with the next nightly and with the next release (of course).
THe actual trunk of C::B has it included (configurable).


[4]
That's really a matter of taste, I prefer a vertical bar at the place the next character will appear, not a horizontal line below the character that will be moved backwards by inserting a new character.
I com from coding under DOS too (mostly assembler), but I do not miss such a "feature".
I personally think the vertical caret/cursor is more intuitive.

Offline mark4

  • Single posting newcomer
  • *
  • Posts: 4
Re: Syntax Highlight for MY file extensions/languages
« Reply #2 on: January 27, 2010, 02:12:59 am »
ok. i looked at the page related to creating lexer xml files and the scintilla header file.  It seems that scintilla does support the language I would like to have syntax highlighting for but code::blocks does not have an associated XML file for this language. 

It does have about 50 or so other xml files for various languages but code:blocks itself is obviously not loading them because the only languages that have highlighting are c/c++ squirrel (wtf is squirrel???), windows resource and xml. 

How do i make this editor load the highlightng rules for ALL the languages it supports?

Also, can someone with more of a clue about creating one of these xml files please create one for the forth programming language because after about an hour inside the various xml files and the suggested page my head is spinning. 

Or... better yet, can we add a plugin to the editor that would allow me to create a highlighting xml template for any language from WITHIN the editor where I wouldnt have to tie myself into a grodian knot wading throu 50 other languages xml files, various header files and web pages that do a great job of explaining the process to someone who already knows it.

would really appreciate it ty :)

Oh... could we also create a default color scheme for unsupported languages so that I can get rid of the blinding wall of white background that cannot seem to be changed for files that dont currently have a supported language xml file.  This is actually one of my biggest gripes with editors today.  They all insist on using a blinding white background with a dark foreground.  This is very harsh on the eyes and i much prefer a dark background with a light foreground.  Ive been looking for a way to make this a default but if it exists it escapes me.


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Syntax Highlight for MY file extensions/languages
« Reply #3 on: January 27, 2010, 07:29:32 am »
What OS dou you use and which version of C::B ?

I attach a screenshot of the "Edit -> Highlight mode" submenu, there are much more than four supported languages.

Squirrel is a scripting language.

[..]
It seems that scintilla does support the language I would like to have syntax highlighting for but code::blocks does not have an associated XML file for this language. 

[...]
Also, can someone with more of a clue about creating one of these xml files please create one for the forth programming language because after about an hour inside the various xml files and the suggested page my head is spinning. 

Or... better yet, can we add a plugin to the editor that would allow me to create a highlighting xml template for any language from WITHIN the editor where I wouldnt have to tie myself into a grodian knot wading throu 50 other languages xml files, various header files and web pages that do a great job of explaining the process to someone who already knows it.
[...]

If there is a language supported by scintilla, that is not supported by C::B (at least for synatx highlighting), please post which language it is, and where to get the needed lexer-files and it might get included.

I never used forth, so I don't know how easy it is to create a lexer for it.
There exists a syntax-highlighting file for vi(m), so it might be able to use it as base for scintilla lexer, but I don't know whether I find the time to try it.

I don't know whether a plugin to create a plugin that creates a lexer-xml interactively makes sense.
It takes sometime to get it reliable and ergonomically, but will most likely not be needed very often and it might be more effective to create the lexer-files manually.

But if anyone wants to do the job, patches and plugins ared always welcome.

[attachment deleted by admin]

Offline mark4

  • Single posting newcomer
  • *
  • Posts: 4
Re: Syntax Highlight for MY file extensions/languages
« Reply #4 on: January 27, 2010, 08:08:33 am »
1: Ill take a look at the VI lexer and see if i can figure out how to port it here.  Im not totally clueless, just lost in a sea of complexity i really dont want to have to deal with myself if i dont have to.  I will give it a shot though.  forth does not follow the same rules as other languages though so it would be difficult for you to do this unless you understood the language methinks.

as for the plugin thing.  in codewright you can create a new language from within a configuration menu/window.  you can then define all the various components of that language within the same configuration menu/window.  I have no idea what the syntax of the files it creates is but adding a new lexer for an unsupported language used to take me about 10 minutes.  Pity borland murdered this awesome editor and refused to create a linux version :/

Ill RTFM some more tomorrow and see if i cant get my head round the xml files some more.  im sure its real easy once you understand them :)


Oh.  I use arch/gentoo Linux and have windows XP and vista (ick) in virtual machines here.  The one that only has a few language files loaded is in XP and its version 8.02 of C::B.

p.s. ive noticed i cannot drag and drop more than one file into this editor unless i do them all at the same time.  Not easy when you have multiple files in multiple sub dirs.  Is there a reason why you can only perform one d+d operation into C::B?  I tried to use the forum search but errr the output of this search is very fragmented and somewhat difficult to parse.  Ive seen a few postings related to drag and drop but nothign related to this specifically. \

p.p.s btw have you compared the C::B icon to the AVG anti virus icon? I keep launching AVG when i mean C::B !!! zomg lol
« Last Edit: January 27, 2010, 08:16:34 am by mark4 »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7592
    • My Best Post
Re: Syntax Highlight for MY file extensions/languages
« Reply #5 on: January 27, 2010, 09:00:55 am »
Is the already existing LexForth.cxx the right file?

http://svn.berlios.de/viewvc/codeblocks/trunk/src/sdk/wxscintilla/src/scintilla/src/LexForth.cxx?view=log

Oops, your are looking for an file with a format like this lexer_*.xml

Tim S.
« Last Edit: January 27, 2010, 09:06:08 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Syntax Highlight for MY file extensions/languages
« Reply #6 on: January 27, 2010, 09:05:41 am »
Is the already existing LexForth.cxx the right file?
Yes, but you'll need to implement the C::B's XML configuration file as described here:
http://wiki.codeblocks.org/index.php?title=Creating_a_custom_lexer_for_Code::Blocks_editor
BTW: My first contributions to C::B were some lexers, because it was easy after all... hence I had to digg through this, too.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Syntax Highlight for MY file extensions/languages
« Reply #7 on: January 27, 2010, 09:08:21 am »
Is the already existing LexForth.cxx the right file?

http://svn.berlios.de/viewvc/codeblocks/trunk/src/sdk/wxscintilla/src/scintilla/src/LexForth.cxx?view=log

Tim S.

Yes.

I started working on a forth xml-file, should not be so hard.
To create a whole new lexer is not that easy, because it might need recompilation of scintilla (a source-file is needed in most cases).

It would be nice, if you can provide a sample source-file in forth for the syntax-highlighting.
You can have a look at the other samples to see how it's done there.

The one that only has a few language files loaded is in XP and its version 8.02 of C::B.

You should rerun the C::B-installer and chose the lexers you need, because only a basic set of lexers is installed by default.

p.s. ive noticed i cannot drag and drop more than one file into this editor unless i do them all at the same time.  Not easy when you have multiple files in multiple sub dirs.  Is there a reason why you can only perform one d+d operation into C::B?  I tried to use the forum search but errr the output of this search is very fragmented and somewhat difficult to parse.  Ive seen a few postings related to drag and drop but nothign related to this specifically. \

Might be related to this: http://forums.codeblocks.org/index.php/topic,11933.msg81134/topicseen.html#msg81134.
I'm not sure if it was implemented in the 8.02 release. If not you should use more recent nightly-build.

Offline filofel

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Syntax Highlight for MY file extensions/languages
« Reply #8 on: February 02, 2010, 11:50:23 am »
Virtual space will come with the next nightly and with the next release (of course).

Great news!  :D
Thank you!

Offline filofel

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Syntax Highlight for MY file extensions/languages
« Reply #9 on: February 03, 2010, 12:20:13 pm »
Virtual space will come with the next nightly and with the next release (of course).

Geee!
Just installed the stealth SVN 6130 nightly deb that popped up on your site, and sure, virtual spaces are there and working. That's going to make my C::B editing life more comfortable, and by a very significant margin.

I was a bit puzzled for a second or two to find the option under "Selections" (in Editor / Margins and caret), but checking the box and trying showed that it was definitly what I was hoping for.

Thanks to the Code::Blocks crew!

Offline Orgulas

  • Single posting newcomer
  • *
  • Posts: 4
Re: Syntax Highlight for MY file extensions/languages
« Reply #10 on: February 08, 2010, 08:51:14 pm »
p.s. ive noticed i cannot drag and drop more than one file into this editor unless i do them all at the same time.  Not easy when you have multiple files in multiple sub dirs.  Is there a reason why you can only perform one d+d operation into C::B?
Ever tried to drop them on the toolbar? Does work at least on Windows.
The 'reason' is quite simple: The first operation will end on the html welcome page which obviously seems to handle it (or rather pass it to c::b) and subsequent ones on the scintilla editor control which doen't.

Code
main(int f,int*v){for(f=fopen(*++v,"r");*v=~getc(f);)putchar(~*v);}