mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-08 20:38:21 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ee963f6296 | ||
![]() |
b44b1086d3 | ||
![]() |
9978ea3b9c | ||
![]() |
710ea1c8d9 |
@@ -1,6 +1,6 @@
|
|||||||
.{
|
.{
|
||||||
.name = "ghostty",
|
.name = "ghostty",
|
||||||
.version = "1.1.1",
|
.version = "1.1.2",
|
||||||
.paths = .{""},
|
.paths = .{""},
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
// Zig libs
|
// Zig libs
|
||||||
|
@@ -48,7 +48,7 @@
|
|||||||
in
|
in
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "ghostty";
|
pname = "ghostty";
|
||||||
version = "1.1.1";
|
version = "1.1.2";
|
||||||
|
|
||||||
# We limit source like this to try and reduce the amount of rebuilds as possible
|
# We limit source like this to try and reduce the amount of rebuilds as possible
|
||||||
# thus we only provide the source that is needed for the build
|
# thus we only provide the source that is needed for the build
|
||||||
|
@@ -224,6 +224,7 @@ pub const App = struct {
|
|||||||
const result: input.Keymap.Translation = if (event_text) |text| .{
|
const result: input.Keymap.Translation = if (event_text) |text| .{
|
||||||
.text = text,
|
.text = text,
|
||||||
.composing = event.composing,
|
.composing = event.composing,
|
||||||
|
.mods = translate_mods,
|
||||||
} else try self.keymap.translate(
|
} else try self.keymap.translate(
|
||||||
&buf,
|
&buf,
|
||||||
switch (target) {
|
switch (target) {
|
||||||
@@ -231,14 +232,7 @@ pub const App = struct {
|
|||||||
.surface => |surface| &surface.keymap_state,
|
.surface => |surface| &surface.keymap_state,
|
||||||
},
|
},
|
||||||
@intCast(keycode),
|
@intCast(keycode),
|
||||||
if (comptime builtin.target.isDarwin()) mods: {
|
translate_mods,
|
||||||
// On macOS we strip ctrl because UCKeyTranslate
|
|
||||||
// converts to the masked values (i.e. ctrl+c becomes 3)
|
|
||||||
// and we don't want that behavior.
|
|
||||||
var v = translate_mods;
|
|
||||||
v.ctrl = false;
|
|
||||||
break :mods v;
|
|
||||||
} else translate_mods,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO(mitchellh): I think we can get rid of the above keymap
|
// TODO(mitchellh): I think we can get rid of the above keymap
|
||||||
@@ -275,16 +269,12 @@ pub const App = struct {
|
|||||||
// then we clear the text. We handle non-printables in the
|
// then we clear the text. We handle non-printables in the
|
||||||
// key encoder manual (such as tab, ctrl+c, etc.)
|
// key encoder manual (such as tab, ctrl+c, etc.)
|
||||||
if (result.text.len == 1 and result.text[0] < 0x20) {
|
if (result.text.len == 1 and result.text[0] < 0x20) {
|
||||||
break :translate .{ .composing = false, .text = "" };
|
break :translate .{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break :translate result;
|
break :translate result;
|
||||||
} else .{ .composing = false, .text = "" };
|
} else .{};
|
||||||
|
|
||||||
// UCKeyTranslate always consumes all mods, so if we have any output
|
|
||||||
// then we've consumed our translate mods.
|
|
||||||
const consumed_mods: input.Mods = if (result.text.len > 0) translate_mods else .{};
|
|
||||||
|
|
||||||
// We need to always do a translation with no modifiers at all in
|
// We need to always do a translation with no modifiers at all in
|
||||||
// order to get the "unshifted_codepoint" for the key event.
|
// order to get the "unshifted_codepoint" for the key event.
|
||||||
@@ -356,7 +346,7 @@ pub const App = struct {
|
|||||||
.key = key,
|
.key = key,
|
||||||
.physical_key = physical_key,
|
.physical_key = physical_key,
|
||||||
.mods = mods,
|
.mods = mods,
|
||||||
.consumed_mods = consumed_mods,
|
.consumed_mods = result.mods,
|
||||||
.composing = result.composing,
|
.composing = result.composing,
|
||||||
.utf8 = result.text,
|
.utf8 = result.text,
|
||||||
.unshifted_codepoint = unshifted_codepoint,
|
.unshifted_codepoint = unshifted_codepoint,
|
||||||
|
@@ -19,7 +19,7 @@ const GitVersion = @import("GitVersion.zig");
|
|||||||
/// TODO: When Zig 0.14 is released, derive this from build.zig.zon directly.
|
/// TODO: When Zig 0.14 is released, derive this from build.zig.zon directly.
|
||||||
/// Until then this MUST match build.zig.zon and should always be the
|
/// Until then this MUST match build.zig.zon and should always be the
|
||||||
/// _next_ version to release.
|
/// _next_ version to release.
|
||||||
const app_version: std.SemanticVersion = .{ .major = 1, .minor = 1, .patch = 1 };
|
const app_version: std.SemanticVersion = .{ .major = 1, .minor = 1, .patch = 2 };
|
||||||
|
|
||||||
/// Standard build configuration options.
|
/// Standard build configuration options.
|
||||||
optimize: std.builtin.OptimizeMode,
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
@@ -50,10 +50,13 @@ pub const State = struct {
|
|||||||
pub const Translation = struct {
|
pub const Translation = struct {
|
||||||
/// The translation result. If this is a dead key state, then this will
|
/// The translation result. If this is a dead key state, then this will
|
||||||
/// be pre-edit text that can be displayed but will ultimately be replaced.
|
/// be pre-edit text that can be displayed but will ultimately be replaced.
|
||||||
text: []const u8,
|
text: []const u8 = "",
|
||||||
|
|
||||||
/// Whether the text is still composing, i.e. this is a dead key state.
|
/// Whether the text is still composing, i.e. this is a dead key state.
|
||||||
composing: bool,
|
composing: bool = false,
|
||||||
|
|
||||||
|
/// The mods that were consumed to produce this translation
|
||||||
|
mods: Mods = .{},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init() !Keymap {
|
pub fn init() !Keymap {
|
||||||
@@ -122,8 +125,18 @@ pub fn translate(
|
|||||||
out: []u8,
|
out: []u8,
|
||||||
state: *State,
|
state: *State,
|
||||||
code: u16,
|
code: u16,
|
||||||
mods: Mods,
|
input_mods: Mods,
|
||||||
) !Translation {
|
) !Translation {
|
||||||
|
// On macOS we strip ctrl because UCKeyTranslate
|
||||||
|
// converts to the masked values (i.e. ctrl+c becomes 3)
|
||||||
|
// and we don't want that behavior in Ghostty ever. This makes
|
||||||
|
// this file not a general-purpose keymap implementation.
|
||||||
|
const mods: Mods = mods: {
|
||||||
|
var v = input_mods;
|
||||||
|
v.ctrl = false;
|
||||||
|
break :mods v;
|
||||||
|
};
|
||||||
|
|
||||||
// Get the keycode for the space key, using comptime.
|
// Get the keycode for the space key, using comptime.
|
||||||
const code_space: u16 = comptime space: for (codes) |entry| {
|
const code_space: u16 = comptime space: for (codes) |entry| {
|
||||||
if (std.mem.eql(u8, entry.code, "Space"))
|
if (std.mem.eql(u8, entry.code, "Space"))
|
||||||
@@ -183,7 +196,11 @@ pub fn translate(
|
|||||||
|
|
||||||
// Convert the utf16 to utf8
|
// Convert the utf16 to utf8
|
||||||
const len = try std.unicode.utf16leToUtf8(out, char[0..char_count]);
|
const len = try std.unicode.utf16leToUtf8(out, char[0..char_count]);
|
||||||
return .{ .text = out[0..len], .composing = composing };
|
return .{
|
||||||
|
.text = out[0..len],
|
||||||
|
.composing = composing,
|
||||||
|
.mods = mods,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Map to the modifiers format used by the UCKeyTranslate function.
|
/// Map to the modifiers format used by the UCKeyTranslate function.
|
||||||
|
@@ -6,8 +6,9 @@ const Mods = @import("key.zig").Mods;
|
|||||||
|
|
||||||
pub const State = struct {};
|
pub const State = struct {};
|
||||||
pub const Translation = struct {
|
pub const Translation = struct {
|
||||||
text: []const u8,
|
text: []const u8 = "",
|
||||||
composing: bool,
|
composing: bool = false,
|
||||||
|
mods: Mods = .{},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init() !KeymapNoop {
|
pub fn init() !KeymapNoop {
|
||||||
|
Reference in New Issue
Block a user