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

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

  •  28-02-2021
  •  | 
  •  

문제

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

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top