blob: 90b090257d6d1377c502569ff1e8c82589881c28 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
/// pardes's patch (its build.zig): whether `CSI ... R` answers a cursor
/// position query. Only `CSI 1 ; mods R` with mods past 1 is a modified F3
/// (a bare F3 is `SS3 R`); a report has another row, or col 1 (mods 1).
fn cursorReport(sequence: []const u8) bool {
const params = sequence[2 .. sequence.len - 1];
if (params.len > 0 and params[0] == '?') return true;
var fields = std.mem.splitScalar(u8, params, ';');
const row = fields.first();
const col = fields.next() orelse return false;
if (fields.next() != null or row.len == 0 or col.len == 0) return false;
for (params) |c| if (c != ';' and !std.ascii.isDigit(c)) return false;
return !std.mem.eql(u8, row, "1") or std.mem.eql(u8, col, "1");
}
|