Author Topic: How to color code a whole line starting with '~@'  (Read 10036 times)

Bamsen

  • Community Member
  • Posts: 66
  • Hero Points: 8
How to color code a whole line starting with '~@'
« on: June 15, 2012, 07:12:39 PM »
I am a newbie using SlickEdit 2012 (v17.0.0.8 64-bit)

I have a file type mn and have added a language called MNotes.
I need to color code and bold (maybe even make the font larger) for all lines starting with ~@

example:
line 1
line 2
~@Heading of new note
line 3
line ...

Is this possible?
How to do it?

Any help will be greatly appreciated.

---
Morten A. Steien

Dennis

  • Senior Community Member
  • Posts: 3999
  • Hero Points: 522
Re: How to color code a whole line starting with '~@'
« Reply #1 on: June 15, 2012, 07:40:23 PM »
Your best bet would be to color code those lines as line comments.  That may not be technically correct, but if your language doesn't already have line comments, this is one way to highlight these specific lines.

Document > MNotes Options... > Color Coding > Comments

Click "New Line Comment" and make the start chars ~@

There is no way to change the font size for a particular color element, but you can make a color coding element, such as Line Comments, use a different background color or bold in order to make it stand out more.

Tools > Options > Appearance > Color Coding

Bamsen

  • Community Member
  • Posts: 66
  • Hero Points: 8
Re: How to color code a whole line starting with '~@'
« Reply #2 on: June 15, 2012, 08:09:25 PM »
Yes, I already tried that and it works, but with a BIG problem.
If I want to change the color of comments or make the bold to stand out, this also effects comments in all other languages, and that is not really an option.  :)
Can a language have different color coding settings for comments than all other languages?

I may have to write a macro for this......
Can a macro or Slick-C function be set to execute automatically when a file MNotes language is opened?
Can a macro or Slick-C function be set to execute automatically when I edit the file?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 7141
  • Hero Points: 545
Re: How to color code a whole line starting with '~@'
« Reply #3 on: June 16, 2012, 01:40:40 AM »
The color coding engine doesn't support regex yet. We need to rewrite our color coding engine to handle things like this. Sorry, this will be a while. Our todo list is pretty long. The good news is that this is MUCH easier than the GUI rewrite!

Graeme

  • Senior Community Member
  • Posts: 2837
  • Hero Points: 348
Re: How to color code a whole line starting with '~@'
« Reply #4 on: June 16, 2012, 08:22:21 AM »
The code below seems to work.  Look up _default_color in the help.  You can select bold or underscore if you want.
Any function that starts with _switchbuf_ gets called when you switch to a new buffer and any function that starts with _buffer_add_ gets called when you open a file.
Another possibility is the _SetTextColor function but I don't know how well that would work.

Also, you can probably use SlickEdit's selective display to hide everything except note headings or hide all notes of a certain type or something.
If you're interested in macro programming, have a look at SlickCMacroBestPractices.pdf in the slick installation docs folder.

Code: [Select]
#include "slick.sh"

static void _select_my_line_comment_color()
{
   //if (_get_extension(p_buf_name) == 'cpp') {
   if (p_lexer_name == 'cpp')
      _default_color(CFG_LINE_COMMENT,0x8000,0xFFFFFF,F_ITALIC|F_INHERIT_BG_COLOR);
   else
      _default_color(CFG_LINE_COMMENT,0x808000,0xFFFFFF,F_INHERIT_BG_COLOR);
}

void _buffer_add_my_color()
{
   _select_my_line_comment_color();
}

void _switchbuf_my_color()
{
   _select_my_line_comment_color();
}

_command void my_date() name_info(','VSARG2_REQUIRES_EDITORCTL)
{
   insert_line('Date: ' :+ _date() '  ' _time());
}

« Last Edit: June 16, 2012, 08:24:01 AM by Graeme »

Bamsen

  • Community Member
  • Posts: 66
  • Hero Points: 8
Re: How to color code a whole line starting with '~@'
« Reply #5 on: June 16, 2012, 11:27:29 AM »
The SlickC language and it's new (at least it was not there last time I checked) ability to arbitrarily color text, is why I will switch from CodeWright which is no longer supported. Until version 17 of SE I have not been able to find an editor with this capability.

I need this to create color coding for Forth, which is not supported native in any editor.
The problem with forth is that the definition of words and therefore their coloring is dynamical and changes through the code.

Are there any Forth users here?
I will ask that question in a new thread when I get around to start programming. :)

Graeme

  • Senior Community Member
  • Posts: 2837
  • Hero Points: 348
Re: How to color code a whole line starting with '~@'
« Reply #6 on: June 16, 2012, 12:34:06 PM »
Have you heard of Factor?

Bamsen

  • Community Member
  • Posts: 66
  • Hero Points: 8
Re: How to color code a whole line starting with '~@'
« Reply #7 on: June 17, 2012, 09:12:58 AM »
No. I don't know about Factor.

Graeme

  • Senior Community Member
  • Posts: 2837
  • Hero Points: 348
Re: How to color code a whole line starting with '~@'
« Reply #8 on: June 17, 2012, 10:24:01 AM »
oh, ok. 
http://factorcode.org/
http://planet.factorcode.org/
http://concatenative.org/wiki/view/Factor

The next link has a comparison of Factor and Forth
http://concatenative.org/wiki/view/Factor/FAQ/Why%3F
I guess you won't be able to use the Factor platform to develop Forth but who knows.

A long time ago I used to use an in-house language for embedded development that was a derivative of Forth but we don't use it any more.  I don't have any idea what Forth is like now but what we had was fairly primitive.  Factor is similar to Forth as far as I can tell but quite a bit more sophisticated.  The guy that created it, Slava Pestov, stopped blogging about it after he went to work for google so I don't know how much development it's getting.

If you want to add support for Forth, there's an article here that might help.
http://blog.slickedit.com/2008/05/tutorial-adding-language-support-to-slickedit/


Bamsen

  • Community Member
  • Posts: 66
  • Hero Points: 8
Re: How to color code a whole line starting with '~@'
« Reply #9 on: June 17, 2012, 04:18:40 PM »
I am using SwiftForth from Forth INC. (http://forth.com/index.html) This is very sophisticated and has full support for all window functions.
The ability to interactively test every part of a windows system makes it a unique way of creating windows applications.

Only the most basic coloring is possible using keywords and standard language support in SlickEdit.
The main difference is that new keywords are created all the time, and need to be recognized and correctly colored from their definition in the source code until the end.

I have done this in a Perl macro in CodeWright but since that editor is no longer being supported, it is getting more and more out of date...

Converting the code to SlickC should be fairly easy. :)

hs2

  • Senior Community Member
  • Posts: 2764
  • Hero Points: 292
Re: How to color code a whole line starting with '~@'
« Reply #10 on: June 17, 2012, 05:44:14 PM »
I think you could process <SE config dir>\17.0.0\user.vlx with either perl, Slick-C, etc.. It contains the (static) colorizer config.
See 'Help>About' for your config dir and maybe the Help for VSLICKCONFIG variable.
HS2