Omnimaga

General Discussion => Technology and Development => Computer Projects and Ideas => Topic started by: Deep Toaster on May 25, 2012, 05:56:22 pm

Title: Syntax-highlighting TI-BASIC editor
Post by: Deep Toaster on May 25, 2012, 05:56:22 pm
Yeah, I know we have a lot of computer-based TI-BASIC editors already, but in my defense, I had an assignment to make something in C# and I decided to make an editor with a themable, extensible, and more efficient syntax highlighting.

It currently doesn't do any converting to or from 8XPs yet (so the Open and Save buttons don't actually work), but it does have a complete highlighting engine that I can easily add more themes (color schemes) and modes (language syntaxes) to. The TI-BASIC rulesheet is also automatically updated when the editor starts up (it's that UTR thing I'd been working on), so it always keeps up-to-date in case there are new additions or bugfixes.
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: stevon8ter on May 25, 2012, 06:00:52 pm
Cool

If the conversion systems work, could you pm me the code? It would be handy if i could convert 8xp files to text files on my ipod, i know there would still be some things to adjust but it could be nice
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Sorunome on May 25, 2012, 06:10:53 pm
Nice! You could make that it detects if it is a Axe program/Grammer program and change the highlighter. :)
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: stevon8ter on May 25, 2012, 06:13:30 pm
Yeah that would be nice, then you don't need 3 different convertors
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Sorunome on May 25, 2012, 06:15:18 pm
Maybe a option to turn auto-detect on. When tokenizing be also sure that Axe and grammer have token hooks :)
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: piexil on May 26, 2012, 12:22:36 am
Holy sheet, looks amazing dude.

I always hated how none of the IDEs had syntax highlighting
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Deep Toaster on May 26, 2012, 12:25:07 am
Thanks :D

And what I'm personally proud of is that it only updates the text that actually got changed, so the editor won't slow down at all no matter how long your program is.
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Sorunome on May 26, 2012, 04:49:23 am
That's good. But loading times could take a while >:D
BTW, could you make then files that are to large to fit into the RAM of that calc? xD
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Deep Toaster on May 26, 2012, 01:25:38 pm
That's good. But loading times could take a while >:D
About two seconds for a 20 KB program, which is about as large as possible in practical terms. (That's nothing compared to, say, gedit :P)
BTW, could you make then files that are to large to fit into the RAM of that calc? xD
Of course—you can do that with any editor. Theoretically the largest program that can fit in an 8XP file is 65,518 bytes long
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Sorunome on May 26, 2012, 01:27:48 pm
O.o two seconds! That's pretty fast! Cool!
Be sure that it'll be linux compatible :P
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Deep Toaster on May 26, 2012, 01:37:53 pm
Oh wait, I got two seconds after disabling the highlighter :P

It's actually more like five minutes ... so yeah, it is slow. Whoops.
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Sorunome on May 26, 2012, 01:39:11 pm
D: You need optimization :P
And don't, please don't forget to make it linux compatible :D
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: stevon8ter on May 26, 2012, 02:14:29 pm
@ Deep Thought: do you have the nescessary skills to make this (not nescecerally (spelled weong) with the highlighter but it can be if you want) for ipod touch? (has to be cydia) i'll pay the costs, and should it then be possible to have a compiler and decompiler for the .8xp files?
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: ben_g on May 26, 2012, 02:16:20 pm
Oh wait, I got two seconds after disabling the highlighter :P

It's actually more like five minutes ... so yeah, it is slow. Whoops.
You can always only highlight the visible lines, then make the editor usable while the rest of the lines are highlighted in a separate process. When the user scrolls, then continue to highlight from the new position, if that hasn't been highlighted yet.
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Sorunome on May 26, 2012, 02:19:06 pm
Or maybe it first highlits the visible lines and then continues highlight in some other routine where you can also edit while it does all the other lines.
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Nick on May 26, 2012, 02:23:49 pm
well, if i might recommend something (i know you probably did dpend a lot of time to the syntax highlighting) but here's a textbox that does all you want, and it does it fast:

http://www.codeproject.com/Articles/161871/Fast-Colored-TextBox-for-syntax-highlighting

although it is for visual basic and visual c#, so i don't know if you're using that..
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Deep Toaster on May 26, 2012, 02:29:48 pm
Yeah, I'm thinking of putting the highlighting in a separate thread, so the user can keep typing while the editor slowly finishes highlighting the rest of the lines.
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: shmibs on May 31, 2012, 11:16:10 pm
couldn't you just hilight only the lines that are to be displayed, and then do it as you go?
would that take too long on tall screens?
Title: Re: Syntax-highlighting TI-BASIC editor
Post by: Deep Toaster on June 05, 2012, 08:22:29 pm
couldn't you just hilight only the lines that are to be displayed, and then do it as you go?
would that take too long on tall screens?
Then it would have to update the highlighting at every incremental change of the scroll position, and wouldn't update when the text changes (until it gets scrolled).

The editor is fine at updating while you type—I don't notice any lag at all when I'm typing a TI-BASIC program. The lag starts to get noticeable only when you open or paste a program that's somewhat long (more than a few dozen lines). The most reasonable solution is to put the highlighter in a separate thread so it can do its work without interfering in the user's typing, but that would involve restructuring the whole thing and will take a while for me to do.

Update

New:
The name of the program generated goes in the text box between Open and Save, and you can toggle the checkbox at the bottom-right corner to set whether the program should be edit-locked or not (on the calculator).

The download is still in the first post.