mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
renderer: render lock for password input
This commit is contained in:
@ -55,6 +55,11 @@ const NullPty = struct {
|
|||||||
_ = self;
|
_ = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getMode(self: Pty) error{GetModeFailed}!Mode {
|
||||||
|
_ = self;
|
||||||
|
return .{};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setSize(self: *Pty, size: winsize) !void {
|
pub fn setSize(self: *Pty, size: winsize) !void {
|
||||||
_ = self;
|
_ = self;
|
||||||
_ = size;
|
_ = size;
|
||||||
|
@ -947,11 +947,14 @@ pub fn updateFrame(
|
|||||||
errdefer screen_copy.deinit();
|
errdefer screen_copy.deinit();
|
||||||
|
|
||||||
// Whether to draw our cursor or not.
|
// Whether to draw our cursor or not.
|
||||||
const cursor_style = renderer.cursorStyle(
|
const cursor_style = if (state.terminal.flags.password_input)
|
||||||
state,
|
.lock
|
||||||
self.focused,
|
else
|
||||||
cursor_blink_visible,
|
renderer.cursorStyle(
|
||||||
);
|
state,
|
||||||
|
self.focused,
|
||||||
|
cursor_blink_visible,
|
||||||
|
);
|
||||||
|
|
||||||
// Get our preedit state
|
// Get our preedit state
|
||||||
const preedit: ?renderer.State.Preedit = preedit: {
|
const preedit: ?renderer.State.Preedit = preedit: {
|
||||||
@ -2652,24 +2655,52 @@ fn addCursor(
|
|||||||
break :alpha @intFromFloat(@ceil(alpha));
|
break :alpha @intFromFloat(@ceil(alpha));
|
||||||
};
|
};
|
||||||
|
|
||||||
const sprite: font.Sprite = switch (cursor_style) {
|
const render = switch (cursor_style) {
|
||||||
.block => .cursor_rect,
|
.block,
|
||||||
.block_hollow => .cursor_hollow_rect,
|
.block_hollow,
|
||||||
.bar => .cursor_bar,
|
.bar,
|
||||||
.underline => .underline,
|
.underline,
|
||||||
};
|
=> render: {
|
||||||
|
const sprite: font.Sprite = switch (cursor_style) {
|
||||||
|
.block => .cursor_rect,
|
||||||
|
.block_hollow => .cursor_hollow_rect,
|
||||||
|
.bar => .cursor_bar,
|
||||||
|
.underline => .underline,
|
||||||
|
.lock => unreachable,
|
||||||
|
};
|
||||||
|
|
||||||
const render = self.font_grid.renderGlyph(
|
break :render self.font_grid.renderGlyph(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
font.sprite_index,
|
font.sprite_index,
|
||||||
@intFromEnum(sprite),
|
@intFromEnum(sprite),
|
||||||
.{
|
.{
|
||||||
.cell_width = if (wide) 2 else 1,
|
.cell_width = if (wide) 2 else 1,
|
||||||
.grid_metrics = self.grid_metrics,
|
.grid_metrics = self.grid_metrics,
|
||||||
|
},
|
||||||
|
) catch |err| {
|
||||||
|
log.warn("error rendering cursor glyph err={}", .{err});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
.lock => self.font_grid.renderCodepoint(
|
||||||
|
self.alloc,
|
||||||
|
0xF023, // lock symbol
|
||||||
|
.regular,
|
||||||
|
.text,
|
||||||
|
.{
|
||||||
|
.cell_width = if (wide) 2 else 1,
|
||||||
|
.grid_metrics = self.grid_metrics,
|
||||||
|
},
|
||||||
|
) catch |err| {
|
||||||
|
log.warn("error rendering cursor glyph err={}", .{err});
|
||||||
|
return;
|
||||||
|
} orelse {
|
||||||
|
// This should never happen because we embed nerd
|
||||||
|
// fonts so we just log and return instead of fallback.
|
||||||
|
log.warn("failed to find lock symbol for cursor codepoint=0xF023", .{});
|
||||||
|
return;
|
||||||
},
|
},
|
||||||
) catch |err| {
|
|
||||||
log.warn("error rendering cursor glyph err={}", .{err});
|
|
||||||
return;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.cells.setCursor(.{
|
self.cells.setCursor(.{
|
||||||
|
@ -767,11 +767,14 @@ pub fn updateFrame(
|
|||||||
errdefer screen_copy.deinit();
|
errdefer screen_copy.deinit();
|
||||||
|
|
||||||
// Whether to draw our cursor or not.
|
// Whether to draw our cursor or not.
|
||||||
const cursor_style = renderer.cursorStyle(
|
const cursor_style = if (state.terminal.flags.password_input)
|
||||||
state,
|
.lock
|
||||||
self.focused,
|
else
|
||||||
cursor_blink_visible,
|
renderer.cursorStyle(
|
||||||
);
|
state,
|
||||||
|
self.focused,
|
||||||
|
cursor_blink_visible,
|
||||||
|
);
|
||||||
|
|
||||||
// Get our preedit state
|
// Get our preedit state
|
||||||
const preedit: ?renderer.State.Preedit = preedit: {
|
const preedit: ?renderer.State.Preedit = preedit: {
|
||||||
@ -1537,24 +1540,52 @@ fn addCursor(
|
|||||||
break :alpha @intFromFloat(@ceil(alpha));
|
break :alpha @intFromFloat(@ceil(alpha));
|
||||||
};
|
};
|
||||||
|
|
||||||
const sprite: font.Sprite = switch (cursor_style) {
|
const render = switch (cursor_style) {
|
||||||
.block => .cursor_rect,
|
.block,
|
||||||
.block_hollow => .cursor_hollow_rect,
|
.block_hollow,
|
||||||
.bar => .cursor_bar,
|
.bar,
|
||||||
.underline => .underline,
|
.underline,
|
||||||
};
|
=> render: {
|
||||||
|
const sprite: font.Sprite = switch (cursor_style) {
|
||||||
|
.block => .cursor_rect,
|
||||||
|
.block_hollow => .cursor_hollow_rect,
|
||||||
|
.bar => .cursor_bar,
|
||||||
|
.underline => .underline,
|
||||||
|
.lock => unreachable,
|
||||||
|
};
|
||||||
|
|
||||||
const render = self.font_grid.renderGlyph(
|
break :render self.font_grid.renderGlyph(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
font.sprite_index,
|
font.sprite_index,
|
||||||
@intFromEnum(sprite),
|
@intFromEnum(sprite),
|
||||||
.{
|
.{
|
||||||
.cell_width = if (wide) 2 else 1,
|
.cell_width = if (wide) 2 else 1,
|
||||||
.grid_metrics = self.grid_metrics,
|
.grid_metrics = self.grid_metrics,
|
||||||
|
},
|
||||||
|
) catch |err| {
|
||||||
|
log.warn("error rendering cursor glyph err={}", .{err});
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
.lock => self.font_grid.renderCodepoint(
|
||||||
|
self.alloc,
|
||||||
|
0xF023, // lock symbol
|
||||||
|
.regular,
|
||||||
|
.text,
|
||||||
|
.{
|
||||||
|
.cell_width = if (wide) 2 else 1,
|
||||||
|
.grid_metrics = self.grid_metrics,
|
||||||
|
},
|
||||||
|
) catch |err| {
|
||||||
|
log.warn("error rendering cursor glyph err={}", .{err});
|
||||||
|
return null;
|
||||||
|
} orelse {
|
||||||
|
// This should never happen because we embed nerd
|
||||||
|
// fonts so we just log and return instead of fallback.
|
||||||
|
log.warn("failed to find lock symbol for cursor codepoint=0xF023", .{});
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
) catch |err| {
|
|
||||||
log.warn("error rendering cursor glyph err={}", .{err});
|
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
try self.cells.append(self.alloc, .{
|
try self.cells.append(self.alloc, .{
|
||||||
|
@ -6,11 +6,15 @@ const State = @import("State.zig");
|
|||||||
/// This is a superset of terminal cursor styles since the renderer supports
|
/// This is a superset of terminal cursor styles since the renderer supports
|
||||||
/// some additional cursor states such as the hollow block.
|
/// some additional cursor states such as the hollow block.
|
||||||
pub const Style = enum {
|
pub const Style = enum {
|
||||||
|
// Typical cursor input styles
|
||||||
block,
|
block,
|
||||||
block_hollow,
|
block_hollow,
|
||||||
bar,
|
bar,
|
||||||
underline,
|
underline,
|
||||||
|
|
||||||
|
// Special cursor styles
|
||||||
|
lock,
|
||||||
|
|
||||||
/// Create a cursor style from the terminal style request.
|
/// Create a cursor style from the terminal style request.
|
||||||
pub fn fromTerminal(term: terminal.CursorStyle) ?Style {
|
pub fn fromTerminal(term: terminal.CursorStyle) ?Style {
|
||||||
return switch (term) {
|
return switch (term) {
|
||||||
|
Reference in New Issue
Block a user