Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / syntax highlighter

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Jan 2009 19:59 Edited at: 29th Jan 2009 19:59
I started this before Rudolpho mentioned he had a similar project in the works, it's just all coincidence.

Highlighting is basically finished, that includes: keywords, quoted strings, rem and `, and multi-line remarks.

I have not used any plugins, it's 100% native DBP. So the scrolling window was a bit tricky.

Syntax highlighting
Text editing (typing, backspace, tab, enter)
text selection using mouse and holding shift

support delete key
support other methods of text selection
copy/paste (scancode and entry$() do not pick up other keys while Control is being pressed)

Using the source code as default text (1200 lines), I get around 500fps. The majority of the slowdown is the text rendering. Another bewildering issue is the binary search I put in place to speed up keyword searching. Turns out its actually slower than a sequential search, regardless of it taking only a max of 10 iterations as compared to a few hundred. (Im making a post about that on the DBP board)

I'll release a demo once I have menus implemented.



Your signature has been erased by a mod because it's larger than 600x120

Attachments

Login to view attachments
Oolite
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Middle of the West
Posted: 29th Jan 2009 21:21
This is awesome, i've been after something like this for BlueGUI for a while but this means i'll probably be able to have a little more control over what i can do with it.
Looking forward to it.
Are you releasing the full source then?

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 30th Jan 2009 23:16
Good work
But isn't the standard ink command way too slow for large editing area?
Anyways, keep it up

"We know some things about poodles, for example that they are alive, they can bark, they eat meat..."
- Extract from Objects first with Java.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Feb 2009 19:25
Do you know another way of coloring text?

I have an issue with multi-line remstart/remend. Detecting it when the document is loaded works fine, but I'm not sure how to work it out when the user is typing, mainly when a user deletes a remstart statement.

I managed to squeeze an extra 200-300 FPS by using Cloggy's D3D library for the text rendering. Using those commands to also draw the GUI (boxes/lines) actually slowed it down a little. I won't be using the library because I want this to be 100% native DBP code.

Your signature has been erased by a mod because it's larger than 600x120
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Feb 2009 00:10 Edited at: 3rd Feb 2009 00:11
Quote: "I have an issue with multi-line remstart/remend. Detecting it when the document is loaded works fine, but I'm not sure how to work it out when the user is typing, mainly when a user deletes a remstart statement."


Well, perhaps add code that handles the syntax highlighting when deleting characters. In most editors, a normal command also quits being highlighted when the command becomes incomplete.
I think this is also what happens if the user removes remstart. But instead, it un-highlights the whole area. When removing remend, the "comment" highlight is being drawn until the next remend. And so on...

It's just a guess. I haven't got any experience writing syntax highlighting.

[EDIT] Will you also release the code? It might serve as a good example to learn from.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Feb 2009 00:53
Anytime a line has changed it checks the entire line over again. When remstart is detected, it'll continue scanning until remend is found. However, if someone deletes remstart, the line is rescanned and doesn't find it but it doesn't know if it was there before or not, so it won't know to continue on and recheck all following lines. Only way I see around it is to keep track of any line that has remstart on it and see if the command is still present when its edited.

I'll likely release the code after I clean it up a bit, plus I don't have it on me right now anyway.

Your signature has been erased by a mod because it's larger than 600x120
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 3rd Feb 2009 14:41
@Phaelex
Store a separate list of remstarts/remends that you update as the user edits. To highlight you just check if the current line is between two remstarts/remends in the list. That way you still only need to parse the current line.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Mar 2009 01:19 Edited at: 3rd Mar 2009 01:20
I haven't been able to work on this lately because every time I try to run the program I get this error:
Failed to 'CreateASMFooter::FindLabel'
I may just need to reboot or something.

So I'm posting the code that I have available now because it sounds like a few people were interested.

The frame rates could probably be improved by moving several of the variables out of the loop so they're not constantly being recalculated. The biggest slowdown really is the text drawing, but you should still be pulling over 100fps regardless.




[url="http://dbcc.zimnox.com"][/url]
Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 3rd Mar 2009 01:37
Quote: "Failed to 'CreateASMFooter::FindLabel"


Got that too, no coincidence I'm assuming. I'll see if i can find it.

~QJ
tiresius
22
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 3rd Mar 2009 02:01
You're missing a "book:" data label. The line

is causing the parser error.

I'm not a real programmer but I play one with DBPro!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Mar 2009 17:42
weird, not sure how i saved an incomplete file. The 'book' references can be removed, loadFile() took its place.

[url="http://dbcc.zimnox.com"][/url]
zzz
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: Sweden
Posted: 3rd Mar 2009 22:24 Edited at: 3rd Mar 2009 22:25
This looks cool!
But Phaelax, your signature...

Login to post a reply

Server time is: 2024-11-24 08:35:10
Your offset time is: 2024-11-24 08:35:10