notepad2-mod icon indicating copy to clipboard operation
notepad2-mod copied to clipboard

Is it possible to add support for MATLAB

Open zhiboz opened this issue 11 years ago • 27 comments

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!

zhiboz avatar Nov 05 '12 19:11 zhiboz

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 avatar Dec 01 '12 00:12 XhmikosR

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

XhmikosR avatar Dec 02 '12 22:12 XhmikosR

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

zhiboz avatar Dec 03 '12 13:12 zhiboz

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 avatar Jan 28 '13 10:01 XhmikosR

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 avatar Jan 28 '13 13:01 XhmikosR

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 avatar Feb 04 '13 19:02 XhmikosR

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 avatar Mar 07 '13 09:03 XhmikosR

Block comments are properly detected now with the updated Scintilla.

XhmikosR avatar Apr 08 '13 10:04 XhmikosR

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

zhiboz avatar Apr 09 '13 14:04 zhiboz

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

XhmikosR avatar Apr 09 '13 15:04 XhmikosR

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.

XhmikosR avatar Apr 09 '13 16:04 XhmikosR

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

zhiboz avatar Apr 09 '13 17:04 zhiboz

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

XhmikosR avatar Apr 09 '13 17:04 XhmikosR

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.

zhiboz avatar Apr 09 '13 17:04 zhiboz

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.

XhmikosR avatar Apr 09 '13 17:04 XhmikosR

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

zhiboz avatar Apr 09 '13 18:04 zhiboz

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.

XhmikosR avatar Apr 09 '13 20:04 XhmikosR

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.

zhiboz avatar Apr 09 '13 22:04 zhiboz

I added the VS2010 scripts and stuff back.

XhmikosR avatar Apr 10 '13 06:04 XhmikosR

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 @)

Kongsea avatar Apr 16 '13 08:04 Kongsea

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

XhmikosR avatar Apr 16 '13 08:04 XhmikosR

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

amroamroamro avatar Oct 09 '14 07:10 amroamroamro

@amroamroamro: please don't distribute random builds.

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

XhmikosR avatar Oct 09 '14 07:10 XhmikosR

@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...

amroamroamro avatar Oct 09 '14 07:10 amroamroamro

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.

XhmikosR avatar Oct 09 '14 07:10 XhmikosR

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

zufuliu avatar Aug 04 '17 12:08 zufuliu

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

XhmikosR avatar Aug 04 '17 15:08 XhmikosR