aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/syntax/syntaxedit.c16
-rw-r--r--ui/syntax/syntaxedit.go6
-rw-r--r--ui/syntax/syntaxedit.h1
3 files changed, 19 insertions, 4 deletions
diff --git a/ui/syntax/syntaxedit.c b/ui/syntax/syntaxedit.c
index cf2d1b33..0050af4c 100644
--- a/ui/syntax/syntaxedit.c
+++ b/ui/syntax/syntaxedit.c
@@ -22,6 +22,7 @@ struct syntaxedit_data {
IRichEditOle *irich;
ITextDocument *idoc;
enum block_state last_block_state;
+ LONG yheight;
bool highlight_guard;
};
@@ -118,6 +119,7 @@ done:
static void highlight_text(HWND hWnd)
{
+ struct syntaxedit_data *this = (struct syntaxedit_data *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
GETTEXTLENGTHEX gettextlengthex = {
.flags = GTL_NUMBYTES,
.codepage = CP_ACP /* Probably CP_UTF8 would be better, but (wine at least) returns utf32 sizes. */
@@ -130,10 +132,9 @@ static void highlight_text(HWND hWnd)
.cbSize = sizeof(CHARFORMAT2),
.dwMask = CFM_COLOR | CFM_CHARSET | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE,
.dwEffects = CFE_AUTOCOLOR,
- .yHeight = 20 * 10,
+ .yHeight = this->yheight ?: 20 * 10,
.bCharSet = ANSI_CHARSET
};
- struct syntaxedit_data *this = (struct syntaxedit_data *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
LRESULT msg_size;
char *msg = NULL;
struct highlight_span *spans = NULL;
@@ -318,9 +319,16 @@ static LRESULT CALLBACK child_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
SendMessage(hWnd, EM_EMPTYUNDOBUFFER, 0, 0);
return ret;
}
- case WM_DPICHANGED:
+ case SE_SET_PARENT_DPI: {
+ struct syntaxedit_data *this = (struct syntaxedit_data *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ HDC hdc = GetDC(hWnd);
+ if (this->yheight)
+ SendMessage(hWnd, EM_SETZOOM, GetDeviceCaps(hdc, LOGPIXELSY), wParam);
+ this->yheight = MulDiv(20 * 10, wParam, GetDeviceCaps(hdc, LOGPIXELSY));
+ ReleaseDC(hWnd, hdc);
highlight_text(hWnd);
- break;
+ return 0;
+ }
case WM_REFLECT + WM_COMMAND:
case WM_COMMAND:
case WM_REFLECT + WM_NOTIFY:
diff --git a/ui/syntax/syntaxedit.go b/ui/syntax/syntaxedit.go
index 67e132c4..62b4310b 100644
--- a/ui/syntax/syntaxedit.go
+++ b/ui/syntax/syntaxedit.go
@@ -15,6 +15,7 @@ import (
"github.com/lxn/win"
)
+// #cgo LDFLAGS: -lgdi32
// #include "syntaxedit.h"
import "C"
@@ -108,6 +109,7 @@ func NewSyntaxEdit(parent walk.Container) (*SyntaxEdit, error) {
if err != nil {
return nil, err
}
+ se.SendMessage(C.SE_SET_PARENT_DPI, uintptr(parent.DPI()), 0)
se.GraphicsEffects().Add(walk.InteractionEffect)
se.GraphicsEffects().Add(walk.FocusEffect)
@@ -126,3 +128,7 @@ func NewSyntaxEdit(parent walk.Container) (*SyntaxEdit, error) {
return se, nil
}
+
+func (se *SyntaxEdit) ApplyDPI(dpi int) {
+ se.SendMessage(C.SE_SET_PARENT_DPI, uintptr(dpi), 0)
+}
diff --git a/ui/syntax/syntaxedit.h b/ui/syntax/syntaxedit.h
index 7d158b29..048e7bc4 100644
--- a/ui/syntax/syntaxedit.h
+++ b/ui/syntax/syntaxedit.h
@@ -18,6 +18,7 @@
#define SE_PRIVATE_KEY (WM_USER + 0x3100)
#define SE_TRAFFIC_BLOCK (WM_USER + 0x3101)
+#define SE_SET_PARENT_DPI (WM_USER + 0x3102)
enum block_state {
InevaluableBlockingUntunneledTraffic,