Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Hiroshi Shirosaki <h.shirosaki@gmail.com>
To: wireguard@lists.zx2c4.com
Subject: Wireguard Windows tunnel editing does not draw correctly with vertical scroll down
Date: Mon, 6 Sep 2021 20:49:37 +0900	[thread overview]
Message-ID: <CAOWZXk1LsG_kr3JD8kTkY1U1pp4uq5Vc3DR29hX_Af+XD=QDBA@mail.gmail.com> (raw)

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

                 reply	other threads:[~2021-09-06 11:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOWZXk1LsG_kr3JD8kTkY1U1pp4uq5Vc3DR29hX_Af+XD=QDBA@mail.gmail.com' \
    --to=h.shirosaki@gmail.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).