Auto Complete changes |
Post Reply |
Author | ||
bfahle
Newbie Joined: 01 April 2011 Status: Offline Points: 3 |
Post Options
Thanks(0)
Posted: 27 July 2012 at 3:30pm |
|
I just wanted to share with the forum some changes I made to the XTPSyntaxEditAutoCompleteWnd. I added these changes by overriding the existing class with my own MyAutoCorrect and implemented OnChar, which is where I addressed a couple of issues. I inserted my class by overriding the edit control class and replacing the autownd in the constructor, freeing theirs and replacing it with my override class. Then mine gets freed at destruction, when theirs would have.
1) I was making a dynamic autocomplete which is aware of class structure, so that at each . in java.lang.String, it would bring up a list of possible classes or packages that it was aware of. I did this by overriding the lex parser in a similar fashion to the above, and making my own GetTokensForAutoCompleate which updates the list on the fly based on class context. 2) The issue I ran into was that when I would reach a (, I had that set as a CloseTag. However, it would add the close tag ( into the stream twice, so that it would read: String.valueOf(( when I typed the parenthesis. To fix this, I wrote my own MyReturnSelected to replace the ReturnSelected which gets called by OnChar. Specifically, I commented out the line which added the CloseTag. 3) The second issue I ran into was if I typed a misspelling intentionally; say I was in the process of adding a new function to String called Load but I wasn't done with it yet so it was not in the edit list for whatever reason. What I did was, if you type String.Load, and hit comma or whatever to end the autocorrect (a close tag), it would check the string Load against its list. If it disagreed in any way other than case or length, it would just accept what the user types. So if I type java.lang.m and hit space or enter or whatever, it will accept that as java.lang.Math. But if I type java.lang.mosquito and hit enter, it just accepts it as is. This seems like a friendlier way to accept user input instead of overwriting it. The user knows when they have gone "off script" because the selection "mosquito" doesn't exist. But it doesn't undo all that typing unless they specifically pick "Math" from the list. 4) The final issue I changed was that the SetCloseTag option required me to specifically put a tag which was at the end. But what I wanted was when any character other than alpha and _ was typed, to have it end. So I could put java.lang.Math.PI+ and it would end on the +. This may not be for everyone, but as an option I think it is pretty good. Anyway here is the code in case anyone else wants it.
and
|
||
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |