Yay

Published September 12, 2008
Advertisement
Haven't done a whole lot, but I managed to fix some things in the past day or so. Most of it had to do with my ignorance of things. Imagine that.

The backspace key now works. Apparently Control.IsInputChar states that the backspace should count as a char. I didn't notice this until I started playing around with using TextRenderer.DrawText to draw the text instead of Graphics's lovely-yet-flawed DrawString method(see following paragraph). DrawText was displaying what I presume was the 0x08(backspace) ASCII char. My fix at the moment is just to call my class's override of the IsInputChar method when handling keyboard events. Backspacing works quite fine, now.

In regards to the problem I mentioned in my previous(and previous previous, I'm sure) post about the caret going off to the left and not being where it is supposed to in the line, I've solved that. Graphics's differences between MeasureString and DrawString have apparently existed since .NET 1.1, but Microsoft is refusing to fix it on the grounds that it would break already deployed applications[Clicky]. They came up with TextRenderer to solve the problem. I found this out by reading various forum posts. That still didn't work for me, following what was stated in the forums. Turns out that both MeasureText and DrawText need to be passed TextFormatFlags.NoPadding, or else spaces are thrown on the sides. I swear I didn't see this when I was researching it. :/

Also, when I was playing around with the actual control in a form the other day, testing and debugging, etc., I found out that when the control's width was increased(the height didn't seem to factor in; at least not noticeably), there was an extremely obvious slow down in the drawing. At least a second or two would go between the keypress and the char showing when it was fullscreen. Definately not good for a text editor. I changed the OnPaint method to draw straight to the double-buffered e.Graphics provided as an argument. I had been drawing to a Bitmap and then drawing that to the screen when done. Turns out that considerably speeded things up, and there is no delay that I can see now. Also turns out that as soon as you start typing, the line underneath doesn't draw. All the other lines do, but not that one. Just gotta figure that out, now.

Still have to implement highlight selection, scrollbars, and proper virtual space, and undo/redo. I'll be focusing solely on the text editing bit until it is 'standard' with the TextBox control. Then I'll focus on the code editing bits, most of which is implemented already. Shouldn't be too difficult, as the 'worst' bit will be implementing clicking of the line icons. After that, since things should be pretty much done, I'll clean it up and write up a basic Lexer and Library that should work for most syntax highlighting and intellisense operations.
Previous Entry Almost a month...
Next Entry Updates all around!
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement