Flawless TextArea Undo

BlitzMax Forums/MaxGUI Module/Flawless TextArea Undo

JoshK(Posted 2011) [#1]
Please give this a good thrashing. If you find any incorrect behavior, please report it in VERY precise terms. Tell me exactly what keystrokes I need to produce a problem.

Even the MaxIDE text editor occasionally gets its undo stack garbled up. I took a different approach by recording each event that modifies the textarea in an "Action" class. And for every Action, there is an equal an opposite reaction: The Action class records the change, and can progress either way for undo/redo functionality. I think this approach will give perfectly accurate results, but please test it.

Next up with be code formatting. I'll try to make the lexer abstracted so that you can easily switch out code for your own languages.



Last edited 2011


JoshK(Posted 2011) [#2]
Here's an updated version that includes syntax highlighting. The only thing it doesn't handle is multi-line comments:

CodeArea.bmx:


Lexer.bmx:



shinkiro1(Posted 2011) [#3]
Good one.
Tested it on Linux with FLTK and GTK and works without any problems.

I had to smile when you explained your approach, because I have made a similar undo interface in my game editor (I even have a TAction Type ^^)


JoshK(Posted 2011) [#4]
Here's a new version with everything in one file. Still no multi-line comments, but I'm getting there:


Last edited 2011


beanage(Posted 2011) [#5]
Thanks for sharing this!

Some small glitches I noticed: Del, Home, Ins and End aint working. Also, when you hit Escape, some weird character is inserted.

(I also love you picked the Pledge of Allegiance as your example content, you know, as opposed to the Lord's Prayer everybody else normally chooses. Nevermind me.)

Last edited 2011


JoshK(Posted 2011) [#6]
Thanks. I fixed the problem. The CodeArea gadget now supports multi-line comments. You can set the language to C, Lua, or BlitzMax. I uploaded the final version here:
http://blitzmax.com/codearcs/codearcs.php?code=2816

Please report on that thread if you find anything else wrong.


beanage(Posted 2011) [#7]
Home, Del, Ins And End still dont work!


JoshK(Posted 2011) [#8]
Delete is easy to add, but what do you expect those other keys to do?

Last edited 2011


JoshK(Posted 2011) [#9]
I added support for all those keys:
http://blitzmax.com/codearcs/codearcs.php?code=2816#comments

If you find any other problems post in the code archive entry please.


JoshK(Posted 2011) [#10]
I got multi-line comments working properly, and made some changes so it will work right on OSX:
http://blitzmax.com/codearcs/codearcs.php?code=2816

The Mac textarea is slightly more picky about errors, and this will fix it.

It should be ready for production use now, but let me know if you find any errors by replying to the post in the code archive or emailing me. Thanks.


ziggy(Posted 2011) [#11]
That's interesting... it does not support non english keyboards properly. I can't write Ñ or Ç ç or [ ], etc. Other than that, seems to work pretty well.


JoshK(Posted 2011) [#12]
The code filters out unrecognized keys. These can be added in.


ziggy(Posted 2011) [#13]
The code filters out unrecognized keys.
Why? Are you going to make it unsuport all the UTF-8 charset? Wouldn't it be safer to make it filter the known undesired chars, wich are usually 8 bits chars from 00 to $1F


JoshK(Posted 2011) [#14]
Because they're un-American.

No, I had to to get the undo/redo working right.


Wiebo(Posted 2011) [#15]
Anything un-American should be filtered... I agree... not...





^this is sarcasm. :)


ziggy(Posted 2011) [#16]
this is sarcasm
I thought sarcams was much more British than American... weird world we live in...