Jump to content


Photo

Scintilla Aka Gmscint - [unsupported]


  • Please log in to reply
102 replies to this topic

#1 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 16 March 2007 - 05:18 AM

Intro on colour coding and Scintilla
Many of us GM users have always wanted to create syntax highlighters/colour coders for GM, HERE IS THE CHANCE.
Scintilla (scintilla.org) is a "free source code editing component" including features like "support for syntax styling, error indicators, code completion and call tips".

Colour coding example
An example of syntax highlighting is GM's code/script editor which looks like:
global.test=room_width //just a test

Intro on the GM interfacer
Using 7 GML scripts you may control this great component. The current zip file contains a gm6 file, an exe file and 2 dll files. The gm6 file, apart from explaining how this system works, it is a complete dll tester with features like:
clear document, undo, redo, selection highlight colour, selection text colour, caret colour, cut, copy, paste, zoom in, zoom out, wrap words, set lexer, use markers aka "breakpoints", disable right-mouse-click edit popup, destroy window, set margin width, save/load text to/from file.

Some words of warning:
-Right now you need 2 dlls for this to work, we will in the future complete wrap the code in one dll.
-The GML lexer does not exist, we will be creating one in the future.

Creator: Christian Sciberras
Version: v4.5
ZIP file size: 1.27 Mb
Includes: tester.exe | tester.gm6 | GMScintilla.dll | SciLexer.dll
Link: Download Now: GMSCINT.zip

Edited by uuf6429, 26 December 2008 - 02:51 PM.

  • 0

#2 t6q4

t6q4

    GMC Member

  • New Member
  • 104 posts

Posted 17 March 2007 - 12:01 PM

This has some potential. Looks good, but there aren't many things working. I was making my own syntax parser, but hey, you've made one too :P and with a lexer!

Only thing is, it is pretty useless, apart from the richtextbox control. All you can do is undo redo(nice addition) and use clipboard(already can do with gm.)

Zooming in just changes the text size.

Edited by t6q4, 17 March 2007 - 12:06 PM.

  • 0

#3 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 17 March 2007 - 02:04 PM

Zooming in does not change the text size. It is really zooming in!! At first I thought as you said but the Scintilla documentation saus otherwise.

There are a lot of other things you could do; just check the constants script.

The dll comes complete with MANY lexers such as:
Ada, assembler, batch, c/c++, c#, css, D, fortran, HTML, Java, JavaScript, Lua, Pascal, Perl, PHP, Python, Ruby, SQL, VB, VBScript, XML, YAML...

The only problem with the lexers is I can't seem to communicate to them for some reason. :P

Anyway this dll also supports folding (ie: lines between {} could be hidden or shown in a way similar how a GM's resource tree view works).

Regards,

Edited by uuf6429, 17 March 2007 - 02:10 PM.

  • 0

#4 t6q4

t6q4

    GMC Member

  • New Member
  • 104 posts

Posted 17 March 2007 - 06:26 PM

K, but i really think if the constants are not being modified, put them inside the constants tab in global game settings. It also helps when youre typing in the code. I might use this with my parser.

About the zooming in - How come the grey bar does not change size. That was the doubt that made me think it was just changing text size.

You should also add showing what line your on, etc

How can I add an object to the grey panel to show there is an error in the code?

Edited by t6q4, 17 March 2007 - 06:37 PM.

  • 0

#5 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 17 March 2007 - 07:18 PM

Wow you're using it alright!! Most functions i don't know how to use but here's a link to the complete documentation: http://scintilla.sou...intillaDoc.html
Note that most functions are readily available through my scripts but for some reason some doesn't work correctly.
  • 0

#6 CyberTwister

CyberTwister

    GMC Member

  • New Member
  • 243 posts

Posted 26 March 2007 - 09:23 PM

Great one ;)

Is this dll still under developpement ?
  • 0

#7 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 27 March 2007 - 05:38 AM

Yes it is. I'm still mastering it's calls and functions.
I found a small fix for colours. I used hex rgb that is ie: FFFFFF. But i should have used red|green|blue ie: 255|0|0 the value returned is the colour.
To change the lexer, I need to use the CREATEDOCUMENT call once. Not sure about this.
  • 0

#8 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 28 March 2007 - 06:38 PM

This needs a lot of work, but if I can highlight my own language I will definately use it in my Robot Simulator!

Edited by Murfy_the_game, 28 March 2007 - 06:39 PM.

  • 0

#9 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 30 March 2007 - 07:24 AM

Glad you liked it!! Scintilla supports external lexers saved as dll files. I'll write a tutorial when i get some time.

EDIT:
The lexers ARE working, I'll continue the project and edit this post.

Edited by uuf6429, 30 March 2007 - 08:33 AM.

  • 0

#10 callum

callum

    GMC Member

  • New Member
  • 176 posts

Posted 30 March 2007 - 11:02 AM

has any one figured out how to use it so u can set the colour of the text cause i have searched everywhere to figure out how to do it.
  • 0

#11 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 30 March 2007 - 04:35 PM

The Lexers are now working and colourising the text successfully!! Thanks for everyone's patience and comments.

Now for the next trick, building a GML lexer!!

Regards,
Christian

Edited by uuf6429, 30 March 2007 - 04:36 PM.

  • 0

#12 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 31 March 2007 - 01:33 PM

There isn't a function to remove it yet.
When going to an other room, it stays on top of everything.
  • 0

#13 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 31 March 2007 - 04:40 PM

Nah i forgot that! There is an Api function but i can't rewrite the dll source yet! But I believe there is a message call for that, i'll look into it.
If you use cv_sa_sendI(global.sc,2,0,0) this should be the equivalent of sending a WM_DESTROY message, which in windows api, tells the control to destroy itself, i'm not sure this is the same for scintilla so i'll check it now...

Edited by uuf6429, 01 April 2007 - 11:10 AM.

  • 0

#14 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 02 April 2007 - 08:24 PM

This is getting better and better!

I would like to see a manual (not between the GML) that shows how to:
- set the text (not the clipboard way from example)
- get the text

Edited by Murfy_the_game, 02 April 2007 - 08:25 PM.

  • 0

#15 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 03 April 2007 - 07:00 AM

The problem with get/set text in scintilla is that it uses constant string, that is LPCSTR in c++. Now the sendS uses LPSTR so the casts are inncompatible. I guess this is the same for getting text.
But don't despair, Scintilla has automatic file saving/loading functions so you could tell scintilla to save to a file and make your gm program read from the file.
By the way, did cv_sa_sendI(global.sc,2,0,0) work?

Edit:
When most issues will be solved i'll do the manual (unless someone would want to help?). If someone wants to help in the manual then pm me. We could work by recieving text excerpts and i'll compile them into chm format.

Regards,
Christian

Edited by uuf6429, 03 April 2007 - 07:02 AM.

  • 0

#16 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 03 April 2007 - 09:21 AM

The problem with get/set text in scintilla is that it uses constant string, that is LPCSTR in c++. Now the sendS uses LPSTR so the casts are inncompatible. I guess this is the same for getting text.
But don't despair, Scintilla has automatic file saving/loading functions so you could tell scintilla to save to a file and make your gm program read from the file.
By the way, did cv_sa_sendI(global.sc,2,0,0) work?

Edit:
When most issues will be solved i'll do the manual (unless someone would want to help?). If someone wants to help in the manual then pm me. We could work by recieving text excerpts and i'll compile them into chm format.

Regards,
Christian

<{POST_SNAPBACK}>

I would like to help, I will test cv_sa_sendI(global.sc,2,0,0) right now.
Automatic saving and loading is great, do you have a call for that yet?

Edit:
cv_sa_sendI(global.sc,2,0,0) doesn't work...

Edited by Murfy_the_game, 03 April 2007 - 12:09 PM.

  • 0

#17 t6q4

t6q4

    GMC Member

  • New Member
  • 104 posts

Posted 03 April 2007 - 11:13 AM

This is getting better, and when you've added a remove function, I'll use it for sure. If you have finished the GML lexer, then it might be an alternative to the standard code editor for GM! Can you make your own lexer, like give it a set of code and then what colour to give it?

btw, the MAKEFILE lexer is 0 and the ones after that are jumbled up, like BAAN thinking its VBSCRIPT and NSIS thinking its PS.

Edited by t6q4, 03 April 2007 - 01:45 PM.

  • 0

#18 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 03 April 2007 - 03:43 PM

There are two ways of making your own lexers:
- Putting lexers in a dll and then loading theminto scintilla [recomended]
- or sending messages to scintilla on how to create the new lexer [not recommended] very difficult.
So, cv_sa_sendI(global.sc,2,0,0) didn't work, anyone knows how to translate 0x0008 to decimal? I tried and got 2. Well I guess i'll have to add the usual DestroyWindow function. Untill that time, people might be interested to know that the handle returned by scintilla is a valid control handle a maybe controlled nearly like other controls (there are some deprecated and unused api calls that does not work with scintilla). Yet i guess the c++ api call DestroyWindow() should work, so people could use other dlls like h0bbel's and roach's common controls or our own listbox dll, which include that api call.

btw, the MAKEFILE lexer is 0 and the ones after that are jumbled up, like BAAN thinking its VBSCRIPT and NSIS thinking its PS.

Strange, how did you find that? I thought 0 was for none, very well i'll check it again and if possible i'll fix it for next release.
Edit: Oh, i forgot, thanks for all comments guys! :)

Edited by uuf6429, 03 April 2007 - 03:47 PM.

  • 0

#19 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 03 April 2007 - 05:23 PM

Converters on the internet say:
1
8
8
So I think it's 8, that doesn't work... (1 also not)

Edited by Murfy_the_game, 03 April 2007 - 05:27 PM.

  • 0

#20 t6q4

t6q4

    GMC Member

  • New Member
  • 104 posts

Posted 04 April 2007 - 10:55 AM

btw, the MAKEFILE lexer is 0 and the ones after that are jumbled up, like BAAN thinking its VBSCRIPT and NSIS thinking its PS.

Strange, how did you find that? I thought 0 was for none, very well i'll check it again and if possible i'll fix it for next release.

<{POST_SNAPBACK}>

Try checking the lexers list after MAKEFILE. 0 is for none, but all the list is like=
MAKEFILE
...
VBSCRIPT
BAAN
...
PS
NSIS
...
And the Current Lexer says BAAN is VBSCRIPT and so on. MAKEFILE is 0, which is also meaning nothing OR false :skull:
Get the error in it?

Converters say 8, but I say that doesnt work.

Edited by t6q4, 04 April 2007 - 11:03 AM.

  • 0

#21 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 05 April 2007 - 06:22 PM

Ok, thanks to all i'll do the necessary fixes.
About the 8 thing, well I'll just add the DestroyWindow() function.
Strange in windows.h WM_DESTROY is defined as 0x0008, but anyway...
  • 0

#22 celebraces

celebraces

    GMC Member

  • GMC Member
  • 956 posts

Posted 06 April 2007 - 05:28 AM

Can't you do something like this? (this is off the top of my head)

export double SetText(double wHwnd, const char* text) {
  return (double)SetWindowText((HWND)(DWORD)wHwnd,(LPCTSTR)text);
}

EDIT: Yep, you can. It works perfectly.

Edited by celebraces, 06 April 2007 - 05:49 AM.

  • 0

#23 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 06 April 2007 - 11:45 AM

I am aware that that works but most arguments aren't LPCSTR so the dll function does not use LPCSTR.
I'll think on how to work arround it but i think i will use one function for both, this is an example of what i mean:
"Csomething" is an LPCSTR
"Ssomething" is an LPSTR
then i will add 2 gml scripts, the first one adds an 's' and the second a 'c', and call the same dll function.
By the way, using SetWindowText() on scintilla is for compatibility, there are other (better) ways to set/get the text.
NB: Thanks for using Scintilla!!
If anyone get any further problems not covered here, i would love to know them.
  • 0

#24 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 13 April 2007 - 07:29 AM

Here is a new update.
It includes:
- save/load text to/from file
- explains the use of line markers/"breakpoints"
- enable/disable RMC popup
- remove window
- fixed lexer list (thanks t6g4)
To murfy: yes i used the therminal but i wasn't supposed to so :D .

Edited by uuf6429, 13 April 2007 - 07:29 AM.

  • 0

#25 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 13 April 2007 - 03:40 PM

When opening a large file, more than 100 lines, the linenumbers start at 00 again...

Breakpoints are cool, but I only get empty rounds. Am I using the example wrong?

Edit:The example text says V3, topic says V4.
Let's make a V5 to change this ^_^

Edited by Murfy_the_game, 13 April 2007 - 03:59 PM.

  • 0

#26 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 13 April 2007 - 05:02 PM

Edit:The example text says V3, topic says V4.
Let's make a V5 to change this

Haha, maybe v4.5...

Too use the breakpoints first define one, then select were you want to put it. An empty circle is when you selected a standard symbol with 0 and black and white colour.
  • 0

#27 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 13 April 2007 - 05:02 PM

Edit:The example text says V3, topic says V4.
Let's make a V5 to change this

Haha, maybe v4.5...

To use the breakpoints first define one, then select were you want to put it. An empty circle is when you selected a standard symbol with 0 and black and white colour.

Edit: (sorry for double post, didn't mean it.)
About the 100 to 00 lines hahahaha that is because the margin 0 is able to display up to 99. There is a button in the bottom pane (the small windows-like buttons) which sets a margin's width. Click it, then set the first number to 0, the second one to 30. This means for every 10 pixels a digit is shown, so 20 shows two digits (example's default) and 30 for 3 digits (to solve 00 'problem')

I will add a gml script that people should put in step event so the margin is trimmed accordingly.

EDIT:
Tomorrow, or maybe the day after, I'll do an enourmous update.
This includes:
A new dll call which is cv_sa_sendD(). It returns integers, and with this we fixed several issues, ie:
Getting margin width
Getting text wrap mode
...
After the update I'll start working on the GML lexer and a better help document.
Afterwords I'll work on NQC lexer with murfy (yay!)

Edited by uuf6429, 15 April 2007 - 06:33 PM.

  • 0

#28 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 16 April 2007 - 07:16 PM

Is is possible to add a set of keywords, and let scintilla make them bold, by changing the "ReDraw" script?

Thanks!
  • 0

#29 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts

Posted 17 April 2007 - 08:11 AM

You need to change the script. First create a keywords gml variable and put the keywords seperated with a space. Then use the commands found in the script to set the keywords.
  • 0

#30 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 17 April 2007 - 11:07 AM

When I use the following code (create event):
cv_sa_marker_add(global.sc,1,1);
cv_sa_marker_set(global.sc,1,2);
Gamemaker says "an unexpected error occured".
What's wrong with this?

Edited by Murfy_the_game, 17 April 2007 - 11:07 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users