How many characters should I update in the normal flow of a text editing program?

StackOverflow https://stackoverflow.com/questions/8114628

  •  28-02-2021
  •  | 
  •  

Question

So, I'm making this text editor from scratch using a custom edit control. As of now, I update the visible part of the current line in which the caret is contained. It works generally fine, but i tried to type really fast on it, and I notice that it flickers(only once or twice, and only for lines that are very long). But this little flicker is kinda not good.

  • So, I was wondering whether I should update only two characters at a time(the current character and the previous character). 2 characters because if I don't erase/update the previous character there would be an artifact from the cursor in the previous position.
  • I am also analyzing my code to check if there is a performance bottleneck or sloppy code out there. In this regard, I noticed that I pass a lot of `HANDLE's' to windows and stuff. I was wondering if it would make a difference if I pass them as references instead. I know that handles are 32-bit values as well, so I'm not sure if there would be any boost in performance.

Thanks!

Devjeet

Était-ce utile?

La solution

Draw the contents of your editor control using MemDC. This example uses MFC, but the idea is independent of it.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top