wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
* Wireguard Windows tunnel editing does not draw correctly with vertical scroll down
@ 2021-09-06 11:49 Hiroshi Shirosaki
  0 siblings, 0 replies; only message in thread
From: Hiroshi Shirosaki @ 2021-09-06 11:49 UTC (permalink / raw)
  To: wireguard

Hi,

When I edit my tunnel setting that has multiple peers and input keys
with vertical scroll down,
the inputted characters are not shown correctly.
It looks like the old contents remain.

Without vertical scroll down the inputted characters are shown correctly.

It seems EM_SETCHARFORMAT and RedrawWindow don't play nicely together.

I use Wireguard-windows amd64 0.4.5.

I've found that adding window hide/show around EM_SETCHARFORMAT seems
to fix the redraw issue.
Here is a patch.

diff --git a/ui/syntax/syntaxedit.go b/ui/syntax/syntaxedit.go
index 42f6e7b7..7b88271a 100644
--- a/ui/syntax/syntaxedit.go
+++ b/ui/syntax/syntaxedit.go
@@ -247,6 +247,8 @@ func (se *SyntaxEdit) highlightText() error {
  win.SendMessage(hWnd, win.EM_SETBKGNDCOLOR, 0, uintptr(bgColor))
  numSpans := len(spans)
  foundPrivateKey := false
+ // Workaround to redraw correctly with vertical scroll down
+ win.ShowWindow(hWnd, win.SW_HIDE)
  for i := range spans {
  span := &spans[i]
  if numSpans <= 2048 {
@@ -262,6 +264,7 @@ func (se *SyntaxEdit) highlightText() error {
  foundPrivateKey = true
  }
  }
+ win.ShowWindow(hWnd, win.SW_SHOW)
  win.SendMessage(hWnd, win.EM_SETSCROLLPOS, 0,
uintptr(unsafe.Pointer(&origScroll)))
  win.SendMessage(hWnd, win.EM_EXSETSEL, 0,
uintptr(unsafe.Pointer(&origSelection)))
  win.SendMessage(hWnd, win.EM_HIDESELECTION, win.FALSE, 0)

-- 
Hiroshi Shirosaki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-06 11:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 11:49 Wireguard Windows tunnel editing does not draw correctly with vertical scroll down Hiroshi Shirosaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).