mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Add adjust-cursor-height metric
This commit is contained in:
@ -247,7 +247,8 @@ const c = @cImport({
|
|||||||
///
|
///
|
||||||
/// * The font will be centered vertically in the cell.
|
/// * The font will be centered vertically in the cell.
|
||||||
///
|
///
|
||||||
/// * The cursor will remain the same size as the font.
|
/// * The cursor will remain the same size as the font, unless adjusted with
|
||||||
|
/// `adjust-cursor-height`.
|
||||||
///
|
///
|
||||||
/// * Powerline glyphs will be adjusted along with the cell height so
|
/// * Powerline glyphs will be adjusted along with the cell height so
|
||||||
/// that things like status lines continue to look aligned.
|
/// that things like status lines continue to look aligned.
|
||||||
@ -259,6 +260,7 @@ const c = @cImport({
|
|||||||
@"adjust-strikethrough-position": ?MetricModifier = null,
|
@"adjust-strikethrough-position": ?MetricModifier = null,
|
||||||
@"adjust-strikethrough-thickness": ?MetricModifier = null,
|
@"adjust-strikethrough-thickness": ?MetricModifier = null,
|
||||||
@"adjust-cursor-thickness": ?MetricModifier = null,
|
@"adjust-cursor-thickness": ?MetricModifier = null,
|
||||||
|
@"adjust-cursor-height": ?MetricModifier = null,
|
||||||
|
|
||||||
/// The method to use for calculating the cell width of a grapheme cluster.
|
/// The method to use for calculating the cell width of a grapheme cluster.
|
||||||
/// The default value is `unicode` which uses the Unicode standard to determine
|
/// The default value is `unicode` which uses the Unicode standard to determine
|
||||||
|
@ -427,6 +427,7 @@ pub const DerivedConfig = struct {
|
|||||||
@"adjust-strikethrough-position": ?Metrics.Modifier,
|
@"adjust-strikethrough-position": ?Metrics.Modifier,
|
||||||
@"adjust-strikethrough-thickness": ?Metrics.Modifier,
|
@"adjust-strikethrough-thickness": ?Metrics.Modifier,
|
||||||
@"adjust-cursor-thickness": ?Metrics.Modifier,
|
@"adjust-cursor-thickness": ?Metrics.Modifier,
|
||||||
|
@"adjust-cursor-height": ?Metrics.Modifier,
|
||||||
|
|
||||||
/// Initialize a DerivedConfig. The config should be either a
|
/// Initialize a DerivedConfig. The config should be either a
|
||||||
/// config.Config or another DerivedConfig to clone from.
|
/// config.Config or another DerivedConfig to clone from.
|
||||||
@ -461,6 +462,7 @@ pub const DerivedConfig = struct {
|
|||||||
.@"adjust-strikethrough-position" = config.@"adjust-strikethrough-position",
|
.@"adjust-strikethrough-position" = config.@"adjust-strikethrough-position",
|
||||||
.@"adjust-strikethrough-thickness" = config.@"adjust-strikethrough-thickness",
|
.@"adjust-strikethrough-thickness" = config.@"adjust-strikethrough-thickness",
|
||||||
.@"adjust-cursor-thickness" = config.@"adjust-cursor-thickness",
|
.@"adjust-cursor-thickness" = config.@"adjust-cursor-thickness",
|
||||||
|
.@"adjust-cursor-height" = config.@"adjust-cursor-height",
|
||||||
|
|
||||||
// This must be last so the arena contains all our allocations
|
// This must be last so the arena contains all our allocations
|
||||||
// from above since Zig does assignment in order.
|
// from above since Zig does assignment in order.
|
||||||
@ -598,6 +600,7 @@ pub const Key = struct {
|
|||||||
if (config.@"adjust-strikethrough-position") |m| try set.put(alloc, .strikethrough_position, m);
|
if (config.@"adjust-strikethrough-position") |m| try set.put(alloc, .strikethrough_position, m);
|
||||||
if (config.@"adjust-strikethrough-thickness") |m| try set.put(alloc, .strikethrough_thickness, m);
|
if (config.@"adjust-strikethrough-thickness") |m| try set.put(alloc, .strikethrough_thickness, m);
|
||||||
if (config.@"adjust-cursor-thickness") |m| try set.put(alloc, .cursor_thickness, m);
|
if (config.@"adjust-cursor-thickness") |m| try set.put(alloc, .cursor_thickness, m);
|
||||||
|
if (config.@"adjust-cursor-height") |m| try set.put(alloc, .cursor_height, m);
|
||||||
break :set set;
|
break :set set;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@ strikethrough_thickness: u32,
|
|||||||
/// because it is not determined by fonts but rather by user configuration.
|
/// because it is not determined by fonts but rather by user configuration.
|
||||||
cursor_thickness: u32 = 1,
|
cursor_thickness: u32 = 1,
|
||||||
|
|
||||||
|
/// cursor height as a percentage of cell_height
|
||||||
|
cursor_height: u32 = 100,
|
||||||
|
|
||||||
/// Original cell width and height. These are used to render the cursor
|
/// Original cell width and height. These are used to render the cursor
|
||||||
/// in the original cell size after modification.
|
/// in the original cell size after modification.
|
||||||
original_cell_width: ?u32 = null,
|
original_cell_width: ?u32 = null,
|
||||||
@ -32,6 +35,9 @@ original_cell_height: ?u32 = null,
|
|||||||
|
|
||||||
/// Apply a set of modifiers.
|
/// Apply a set of modifiers.
|
||||||
pub fn apply(self: *Metrics, mods: ModifierSet) void {
|
pub fn apply(self: *Metrics, mods: ModifierSet) void {
|
||||||
|
if (mods.get(.cursor_height)) |mod| {
|
||||||
|
self.cursor_height = mod.apply(self.cursor_height);
|
||||||
|
}
|
||||||
var it = mods.iterator();
|
var it = mods.iterator();
|
||||||
while (it.next()) |entry| {
|
while (it.next()) |entry| {
|
||||||
switch (entry.key_ptr.*) {
|
switch (entry.key_ptr.*) {
|
||||||
@ -45,10 +51,9 @@ pub fn apply(self: *Metrics, mods: ModifierSet) void {
|
|||||||
const new = @max(entry.value_ptr.apply(original), 1);
|
const new = @max(entry.value_ptr.apply(original), 1);
|
||||||
if (new == original) continue;
|
if (new == original) continue;
|
||||||
|
|
||||||
// Preserve the original cell width and height if not set.
|
|
||||||
if (self.original_cell_width == null) {
|
if (self.original_cell_width == null) {
|
||||||
self.original_cell_width = self.cell_width;
|
self.original_cell_width = self.cell_width;
|
||||||
self.original_cell_height = self.cell_height;
|
self.original_cell_height = self.cell_height * self.cursor_height / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the new value
|
// Set the new value
|
||||||
|
Reference in New Issue
Block a user