feat(win32 gui): add reset_fontsize and rest_fontface commands
This commit is contained in:
parent
a5622af68d
commit
6530a7a51c
5 changed files with 61 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"project": {
|
"project": {
|
||||||
"press": [
|
"press": [
|
||||||
|
["ctrl+0", "reset_fontsize"],
|
||||||
["ctrl+=", "adjust_fontsize", 1.0],
|
["ctrl+=", "adjust_fontsize", 1.0],
|
||||||
["ctrl+-", "adjust_fontsize", -1.0]
|
["ctrl+-", "adjust_fontsize", -1.0]
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"project": {
|
"project": {
|
||||||
"press": [
|
"press": [
|
||||||
|
["ctrl+0", "reset_fontsize"],
|
||||||
["ctrl+plus", "adjust_fontsize", 1.0],
|
["ctrl+plus", "adjust_fontsize", 1.0],
|
||||||
["ctrl+minus", "adjust_fontsize", -1.0],
|
["ctrl+minus", "adjust_fontsize", -1.0],
|
||||||
["f5", ["create_scratch_buffer", "*test*"], ["shell_execute_insert", "zig", "build", "test"]],
|
["f5", ["create_scratch_buffer", "*test*"], ["shell_execute_insert", "zig", "build", "test"]],
|
||||||
|
|
|
@ -381,11 +381,21 @@ pub fn set_fontsize(self: *Self, fontsize: f32) void {
|
||||||
gui.set_fontsize(hwnd, fontsize);
|
gui.set_fontsize(hwnd, fontsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset_fontsize(self: *Self) void {
|
||||||
|
const hwnd = self.hwnd orelse return;
|
||||||
|
gui.reset_fontsize(hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_fontface(self: *Self, fontface: []const u8) void {
|
pub fn set_fontface(self: *Self, fontface: []const u8) void {
|
||||||
const hwnd = self.hwnd orelse return;
|
const hwnd = self.hwnd orelse return;
|
||||||
gui.set_fontface(hwnd, fontface);
|
gui.set_fontface(hwnd, fontface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset_fontface(self: *Self) void {
|
||||||
|
const hwnd = self.hwnd orelse return;
|
||||||
|
gui.reset_fontface(hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_terminal_cursor_color(self: *Self, color: Color) void {
|
pub fn set_terminal_cursor_color(self: *Self, color: Color) void {
|
||||||
_ = self;
|
_ = self;
|
||||||
_ = color;
|
_ = color;
|
||||||
|
|
|
@ -653,6 +653,12 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
pub const set_fontsize_meta = .{ .arguments = &.{.float} };
|
pub const set_fontsize_meta = .{ .arguments = &.{.float} };
|
||||||
|
|
||||||
|
pub fn reset_fontsize(_: *Self, _: Ctx) Result {
|
||||||
|
if (build_options.gui)
|
||||||
|
tui.current().rdr.reset_fontsize();
|
||||||
|
}
|
||||||
|
pub const reset_fontsize_meta = .{ .description = "Reset font to configured size" };
|
||||||
|
|
||||||
pub fn set_fontface(_: *Self, ctx: Ctx) Result {
|
pub fn set_fontface(_: *Self, ctx: Ctx) Result {
|
||||||
var fontface: []const u8 = undefined;
|
var fontface: []const u8 = undefined;
|
||||||
if (!try ctx.args.match(.{tp.extract(&fontface)}))
|
if (!try ctx.args.match(.{tp.extract(&fontface)}))
|
||||||
|
@ -661,6 +667,12 @@ const cmds = struct {
|
||||||
tui.current().rdr.set_fontface(fontface);
|
tui.current().rdr.set_fontface(fontface);
|
||||||
}
|
}
|
||||||
pub const set_fontface_meta = .{ .arguments = &.{.float} };
|
pub const set_fontface_meta = .{ .arguments = &.{.float} };
|
||||||
|
|
||||||
|
pub fn reset_fontface(_: *Self, _: Ctx) Result {
|
||||||
|
if (build_options.gui)
|
||||||
|
tui.current().rdr.reset_fontface();
|
||||||
|
}
|
||||||
|
pub const reset_fontface_meta = .{ .description = "Reset font to configured face" };
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn handle_editor_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {
|
pub fn handle_editor_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {
|
||||||
|
|
|
@ -28,13 +28,17 @@ const WM_APP_SET_BACKGROUND = win32.WM_APP + 2;
|
||||||
const WM_APP_ADJUST_FONTSIZE = win32.WM_APP + 3;
|
const WM_APP_ADJUST_FONTSIZE = win32.WM_APP + 3;
|
||||||
const WM_APP_SET_FONTSIZE = win32.WM_APP + 4;
|
const WM_APP_SET_FONTSIZE = win32.WM_APP + 4;
|
||||||
const WM_APP_SET_FONTFACE = win32.WM_APP + 5;
|
const WM_APP_SET_FONTFACE = win32.WM_APP + 5;
|
||||||
const WM_APP_UPDATE_SCREEN = win32.WM_APP + 6;
|
const WM_APP_RESET_FONTSIZE = win32.WM_APP + 6;
|
||||||
|
const WM_APP_RESET_FONTFACE = win32.WM_APP + 7;
|
||||||
|
const WM_APP_UPDATE_SCREEN = win32.WM_APP + 8;
|
||||||
|
|
||||||
const WM_APP_EXIT_RESULT = 0x45feaa11;
|
const WM_APP_EXIT_RESULT = 0x45feaa11;
|
||||||
const WM_APP_SET_BACKGROUND_RESULT = 0x369a26cd;
|
const WM_APP_SET_BACKGROUND_RESULT = 0x369a26cd;
|
||||||
const WM_APP_ADJUST_FONTSIZE_RESULT = 0x79aba9ef;
|
const WM_APP_ADJUST_FONTSIZE_RESULT = 0x79aba9ef;
|
||||||
const WM_APP_SET_FONTSIZE_RESULT = 0x72fa44bc;
|
const WM_APP_SET_FONTSIZE_RESULT = 0x72fa44bc;
|
||||||
const WM_APP_SET_FONTFACE_RESULT = 0x1a49ffa8;
|
const WM_APP_SET_FONTFACE_RESULT = 0x1a49ffa8;
|
||||||
|
const WM_APP_RESET_FONTSIZE_RESULT = 0x082c4c0c;
|
||||||
|
const WM_APP_RESET_FONTFACE_RESULT = 0x0101f996;
|
||||||
const WM_APP_UPDATE_SCREEN_RESULT = 0x3add213b;
|
const WM_APP_UPDATE_SCREEN_RESULT = 0x3add213b;
|
||||||
|
|
||||||
pub const DropWriter = struct {
|
pub const DropWriter = struct {
|
||||||
|
@ -453,6 +457,15 @@ pub fn set_fontsize(hwnd: win32.HWND, fontsize: f32) void {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset_fontsize(hwnd: win32.HWND) void {
|
||||||
|
std.debug.assert(WM_APP_RESET_FONTSIZE_RESULT == win32.SendMessageW(
|
||||||
|
hwnd,
|
||||||
|
WM_APP_RESET_FONTSIZE,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_fontface(hwnd: win32.HWND, fontface_utf8: []const u8) void {
|
pub fn set_fontface(hwnd: win32.HWND, fontface_utf8: []const u8) void {
|
||||||
const fontface = FontFace.initUtf8(fontface_utf8) catch |e| {
|
const fontface = FontFace.initUtf8(fontface_utf8) catch |e| {
|
||||||
std.log.err("failed to set fontface '{s}' with {s}", .{ fontface_utf8, @errorName(e) });
|
std.log.err("failed to set fontface '{s}' with {s}", .{ fontface_utf8, @errorName(e) });
|
||||||
|
@ -466,6 +479,15 @@ pub fn set_fontface(hwnd: win32.HWND, fontface_utf8: []const u8) void {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset_fontface(hwnd: win32.HWND) void {
|
||||||
|
std.debug.assert(WM_APP_RESET_FONTFACE_RESULT == win32.SendMessageW(
|
||||||
|
hwnd,
|
||||||
|
WM_APP_RESET_FONTFACE,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn updateScreen(hwnd: win32.HWND, screen: *const vaxis.Screen) void {
|
pub fn updateScreen(hwnd: win32.HWND, screen: *const vaxis.Screen) void {
|
||||||
std.debug.assert(WM_APP_UPDATE_SCREEN_RESULT == win32.SendMessageW(
|
std.debug.assert(WM_APP_UPDATE_SCREEN_RESULT == win32.SendMessageW(
|
||||||
hwnd,
|
hwnd,
|
||||||
|
@ -1085,6 +1107,13 @@ fn WndProc(
|
||||||
win32.invalidateHwnd(hwnd);
|
win32.invalidateHwnd(hwnd);
|
||||||
return WM_APP_SET_FONTSIZE_RESULT;
|
return WM_APP_SET_FONTSIZE_RESULT;
|
||||||
},
|
},
|
||||||
|
WM_APP_RESET_FONTSIZE => {
|
||||||
|
const state = stateFromHwnd(hwnd);
|
||||||
|
global.fontsize = null;
|
||||||
|
updateWindowSize(hwnd, win32.WMSZ_BOTTOMRIGHT, &state.bounds);
|
||||||
|
win32.invalidateHwnd(hwnd);
|
||||||
|
return WM_APP_SET_FONTSIZE_RESULT;
|
||||||
|
},
|
||||||
WM_APP_SET_FONTFACE => {
|
WM_APP_SET_FONTFACE => {
|
||||||
const state = stateFromHwnd(hwnd);
|
const state = stateFromHwnd(hwnd);
|
||||||
const fontface: *FontFace = @ptrFromInt(wparam);
|
const fontface: *FontFace = @ptrFromInt(wparam);
|
||||||
|
@ -1093,6 +1122,13 @@ fn WndProc(
|
||||||
win32.invalidateHwnd(hwnd);
|
win32.invalidateHwnd(hwnd);
|
||||||
return WM_APP_SET_FONTFACE_RESULT;
|
return WM_APP_SET_FONTFACE_RESULT;
|
||||||
},
|
},
|
||||||
|
WM_APP_RESET_FONTFACE => {
|
||||||
|
const state = stateFromHwnd(hwnd);
|
||||||
|
global.fontface = null;
|
||||||
|
updateWindowSize(hwnd, win32.WMSZ_BOTTOMRIGHT, &state.bounds);
|
||||||
|
win32.invalidateHwnd(hwnd);
|
||||||
|
return WM_APP_SET_FONTFACE_RESULT;
|
||||||
|
},
|
||||||
WM_APP_UPDATE_SCREEN => {
|
WM_APP_UPDATE_SCREEN => {
|
||||||
const screen: *const vaxis.Screen = @ptrFromInt(wparam);
|
const screen: *const vaxis.Screen = @ptrFromInt(wparam);
|
||||||
_ = global.screen_arena.reset(.retain_capacity);
|
_ = global.screen_arena.reset(.retain_capacity);
|
||||||
|
|
Loading…
Add table
Reference in a new issue