diff options
| author | Přemysl Eric Janouch <p@janouch.name> | 2026-01-04 16:04:49 +0100 |
|---|---|---|
| committer | Přemysl Eric Janouch <p@janouch.name> | 2026-01-04 16:05:09 +0100 |
| commit | 691b3a1a241a0b086a316506c068618b58bcd8c0 (patch) | |
| tree | 92086334438ce129a9efd10ef65b5c508a33520e | |
| parent | b766c9ef2064b5a63f59aac0aa27ae46b66ae66b (diff) | |
| download | acid-master.tar.gz acid-master.tar.xz acid-master.zip | |
Improve Homebrew output parsingHEADorigin/mastermaster
It likes to output CSI 0 G in particular, expecting that it works
(the coordinates are normally 1-based).
| -rw-r--r-- | LICENSE | 2 | ||||
| -rw-r--r-- | terminal.go | 13 |
2 files changed, 11 insertions, 4 deletions
@@ -1,4 +1,4 @@ -Copyright (c) 2024 - 2025, Přemysl Eric Janouch <p@janouch.name> +Copyright (c) 2024 - 2026, Přemysl Eric Janouch <p@janouch.name> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. diff --git a/terminal.go b/terminal.go index 9886ef0..68be363 100644 --- a/terminal.go +++ b/terminal.go @@ -206,17 +206,24 @@ func (tw *terminalWriter) processParsedCSI( } tw.column = 0 return true + case final == 'G': // Cursor Character Absolute + if len(params) == 0 { + tw.column = 0 + } else { + tw.column = max(params[0]-1, 0) + } + return true case final == 'H': // Cursor Position if len(params) == 0 { tw.line = tw.lineTop tw.column = 0 - } else if len(params) < 2 || params[0] <= 0 || params[1] <= 0 { + } else if len(params) < 2 { return false } else if params[0] >= 32766 && params[1] >= 32766 { // Ignore attempts to scan terminal bounds. } else { - tw.line = tw.lineTop + params[0] - 1 - tw.column = params[1] - 1 + tw.line = tw.lineTop + max(params[0]-1, 0) + tw.column = max(params[1]-1, 0) } return true case final == 'J': // Erase in Display |
