XhmikosR / notepad2-mod

LOOKING FOR DEVELOPERS - Notepad2-mod, a Notepad2 fork, a fast and light-weight Notepad-like text editor with syntax highlighting
https://xhmikosr.github.io/notepad2-mod/
Other
1.45k stars 270 forks source link

Is it possible to add support for MATLAB #28

Open zhiboz opened 12 years ago

zhiboz commented 12 years ago

MATLAB is gaining its popularity among engineering professionals and students; Its creator, MathWorks, claims that it has over 2 million users worldwide. Is it possible for you to add support for MATLAB please? Thanks very much!

XhmikosR commented 11 years ago

Sorry for the late reply, I totally missed the notification.

If Scintilla supports it and someone provides the keywords I could add it I guess. Although I don't use MATLAB at all so I need some good code samples to check if everything works.

XhmikosR commented 11 years ago

You can't attach anything on GitHub. So use the webform and upload the files somewhere easily accessible.

zhiboz commented 11 years ago

You may get a copy from http://www.mathworks.com/matlabcentral/fileexchange/8550 . Thanks!

XhmikosR commented 11 years ago

Please try this build and let me know.

Keep in mind that I don't use Matlab myself so there might be things that should be different. The code changes are in the Matlab branch here.

Also the lexer itself which comes from Scintilla seem a little limited, for example it doesn't highlight block comments properly when I use %{...%}, but from what I read this should be supported.

XhmikosR commented 11 years ago

I cannot do that because .m files are associated to open with the C/C++ lexer. I'm pretty sure there is another way to solve this apart from removing .m files from the C/C++ filelist, but unfortunately I have no idea how to do this at this point.

XhmikosR commented 11 years ago

I didn't mean supported in Scintilla, since I know it's not... I mean that in general %{...%} is a block comment in Matlab.

Anyway, not sure what I'm going to do with this patch since like I said above m files are associated with the C/C++ lexer.

XhmikosR commented 11 years ago

The matlab branch is up to date, but I still don't know if I should merge this.

If anyone is interested to work on this, they are more than welcome to do so.

XhmikosR commented 11 years ago

Block comments are properly detected now with the updated Scintilla.

zhiboz commented 11 years ago

Great news, very much appreciated! Any plan to merge this into the master branch?

XhmikosR commented 11 years ago

I cannot solve the issue with .m files. Please leave this ticket open until the patch is merged.

XhmikosR commented 11 years ago

Another thing I noticed.

M = regexp(str, {'(?-i)\w{5}(?=CASE)', ...
                 '(?i)\w{5}(?=CASE)'}, 'match');

M{:}
ans =
    'UPPER'
ans =
    'UPPER'    'lower'
    break

If I comment out

M = regexp(str, {'(?-i)\w{5}(?=CASE)', ...
                 '(?i)\w{5}(?=CASE)'}, 'match');

M{:}
%{ans =
    'UPPER'%}
ans =
    'UPPER'    'lower'
    break

It shows as if it's commented out until the end. But this is a Scintilla issue.

zhiboz commented 11 years ago

MATLAB editor handles it this way too. It works if you put %} into a separate line as below.

M{:} %{ ans = 'UPPER' %} ans = 'UPPER' 'lower' break

XhmikosR commented 11 years ago

So does this mean that the code isn't commented out unless %} is in a new line?

zhiboz commented 11 years ago

M{:} %{ans = 'UPPER'%} ans = 'UPPER' 'lower' break

I meant at least that the MATLAB editor shows the above code as if it's commented out until the end.

XhmikosR commented 11 years ago

Yes I got that, but does it work as expected? If yes then their editor has the same issue or the specs must say that the it must be in a new line.

zhiboz commented 11 years ago

Yes, I believe the document says the opening and closing of the comment blocks have to be in their own lines.

XhmikosR commented 11 years ago

That's too bad cause I can't fix it properly at this point. I mean I can easily add a new line, but I need to take account for the document's line endings.

I'll add this in the PR's todo.

zhiboz commented 11 years ago

Thanks very much for your extra efforts! Any chance you could put a x64 build somewhere? I only have VS2010 Express and can not compile np2-mod with it any more.

XhmikosR commented 11 years ago

I added the VS2010 scripts and stuff back.

Kongsea commented 11 years ago

I want a x86 Notepad2 copy supported MATLAB too. Can you send me a copy please? my email is konguo#gmail.com (please replace # with @)

XhmikosR commented 11 years ago

No, sorry. You can see #36 and help me fix the TODO issues; then it will be merged in the master branch.

amroamroamro commented 10 years ago

Your previous link is dead. Here is my personal build with MATLAB support (link removed per XhmikosR request)

Basically I rebased the matlab branch on top of master, and merged it. Then I built the solution using VS2013 Update 3 (both x86/x64).

I had to fix a minor bug in src/Styles.h, your forgot to increment the number of lexers in a macro: s/#define NUMLEXERS 37/#define NUMLEXERS 38/

The stream comment bug discussed is obviously still there (someone ought to fix the MATLAB lexer in upstream Scintilla). I think it's a minor thing and I can live with it for the moment... Better than having no MATLAB support at all :)

If anyone is interested in working on fixing the bug, here are the doc pages for the "block comment" construct: http://www.mathworks.com/help/matlab/matlab_prog/comments.html http://www.mathworks.com/help/matlab/ref/specialcharacters.html#bqwxykj-1

XhmikosR commented 10 years ago

@amroamroamro: please don't distribute random builds.

If you want to help, you can help by fixing the TODOs from #36.

amroamroamro commented 10 years ago

@XhmikosR: Fair enough. Do you want me to remove the link?

I was just trying to give a quick solution for those who dont have the necessary dev tools installed...

XhmikosR commented 10 years ago

That is not a quick solution. The patch isn't ready; if it was, it would have been merged. So, yeah, please remove any links.

zufuliu commented 7 years ago

can someone try the build from https://github.com/zufuliu/notepad2/releases?

XhmikosR commented 7 years ago

@zufuliu: you could rebase my branch and make any changes there and submit a PR where you CC me.