mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
enq and cursor report with origin mode
This commit is contained in:
@ -731,15 +731,25 @@ pub fn deviceStatusReport(
|
|||||||
log.warn("error queueing device attr response: {}", .{err}),
|
log.warn("error queueing device attr response: {}", .{err}),
|
||||||
|
|
||||||
.cursor_position => {
|
.cursor_position => {
|
||||||
if (self.terminal.mode_origin) unreachable; // TODO
|
const pos: struct {
|
||||||
|
x: usize,
|
||||||
|
y: usize,
|
||||||
|
} = if (self.terminal.mode_origin) .{
|
||||||
|
// TODO: what do we do if cursor is outside scrolling region?
|
||||||
|
.x = self.terminal.cursor.x,
|
||||||
|
.y = self.terminal.cursor.y -| self.terminal.scrolling_region.top,
|
||||||
|
} else .{
|
||||||
|
.x = self.terminal.cursor.x,
|
||||||
|
.y = self.terminal.cursor.y,
|
||||||
|
};
|
||||||
|
|
||||||
// Response always is at least 4 chars, so this leaves the
|
// Response always is at least 4 chars, so this leaves the
|
||||||
// remainder for the row/column as base-10 numbers. This
|
// remainder for the row/column as base-10 numbers. This
|
||||||
// will support a very large terminal.
|
// will support a very large terminal.
|
||||||
var buf: [32]u8 = undefined;
|
var buf: [32]u8 = undefined;
|
||||||
const resp = try std.fmt.bufPrint(&buf, "\x1B[{};{}R", .{
|
const resp = try std.fmt.bufPrint(&buf, "\x1B[{};{}R", .{
|
||||||
self.terminal.cursor.y + 1,
|
pos.y + 1,
|
||||||
self.terminal.cursor.x + 1,
|
pos.x + 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
try self.queueWrite(resp);
|
try self.queueWrite(resp);
|
||||||
@ -789,3 +799,7 @@ pub fn saveCursor(self: *Window) !void {
|
|||||||
pub fn restoreCursor(self: *Window) !void {
|
pub fn restoreCursor(self: *Window) !void {
|
||||||
self.terminal.restoreCursor();
|
self.terminal.restoreCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn enquiry(self: *Window) !void {
|
||||||
|
try self.queueWrite("");
|
||||||
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
pub const C0 = enum(u7) {
|
pub const C0 = enum(u7) {
|
||||||
/// Null
|
/// Null
|
||||||
NUL = 0x00,
|
NUL = 0x00,
|
||||||
|
/// Enquiry
|
||||||
|
ENQ = 0x05,
|
||||||
/// Bell
|
/// Bell
|
||||||
BEL = 0x07,
|
BEL = 0x07,
|
||||||
/// Backspace
|
/// Backspace
|
||||||
|
@ -71,6 +71,11 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
switch (@intToEnum(ansi.C0, c)) {
|
switch (@intToEnum(ansi.C0, c)) {
|
||||||
.NUL => {},
|
.NUL => {},
|
||||||
|
|
||||||
|
.ENQ => if (@hasDecl(T, "enquiry"))
|
||||||
|
try self.handler.enquiry()
|
||||||
|
else
|
||||||
|
log.warn("unimplemented execute: {x}", .{c}),
|
||||||
|
|
||||||
.BEL => if (@hasDecl(T, "bell"))
|
.BEL => if (@hasDecl(T, "bell"))
|
||||||
try self.handler.bell()
|
try self.handler.bell()
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user