pyscripter / SynEdit

SynEdit is a syntax highlighting edit control, not based on the Windows common controls.
26 stars 11 forks source link

TopLine and paintlock #17

Closed MShark67 closed 4 years ago

MShark67 commented 4 years ago

Anytime TopLine is changed it causes a full repaint regardless of paintlock. This may be as designed since paintlock is always > 0 during any caret movement/ecCommand handling. However it does mean that TSynEdit.BeginUpdate and TSynEdit.EndUpdate don't fully work. I was a bit surprised that PaintLock doesn't actually stop any paint handling (maybe it's just missing or more likely it's a complexity beyond my knowledge.) My workaround to these problems is to just use SendMessage(Handle, WM_SETREDRAW, 0, 0); and SendMessage(Handle, WM_SETREDRAW, 1, 0); (followed by an invalidate)

In my own TSynEdit helper class..

Note that there's also a minor issue with SetTopLine. When eoScrollPastEof is not set, it uses fLinesInWindow to calculate the max top line allowed, but that value appears to not be accurate and so some commands (like ecUpperCase) when scrolled to the bottom will shift the TopLine even though it's not needed.

Thanks as always!

MShark67 commented 4 years ago

Update: My guess about fLinesInWindow being the issue regarding the "changing case of selection" commands is wrong. The issue is that selecting a multi-line block and performing any of the case change commands deletes the text and then replaces it, causing a TopLine change (only if eoScrollPastEof is false.) Again, this is a minor issue, which I work around by just storing topline and then restoring it after the case change (which is why I needed BegingUpdate/EndUpdate to work so it works without extra full redraws.)

pyscripter commented 4 years ago

Fixed at https://github.com/TurboPack/ I removed the UpdateWindow call from SetTopLine. So no immediate painting should occur within BeginUpdate/EndUpdate. Please confirm.

Regarding the issue with the "changing case of selection" commands it only have any impact if the selection spans page breaks. (not very common case) and you can always store/restore the topline. So I will leave it for now.

When eoScrollPastEof is not set, it uses fLinesInWindow to calculate the max top line allowed, but that value appears to not be accurate Can we deal with this as a separate issue (please open at https://github.com/TurboPack/)? Would it possible to provide some instructions to replicate this error?