Query font size and DPI from terminal

This commit is contained in:
Kovid Goyal
2024-05-07 19:59:59 +05:30
parent d826265fd7
commit b6e92dd79d
5 changed files with 100 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ package loop
import (
"encoding/base64"
"encoding/hex"
"fmt"
"os"
"runtime"
@@ -89,6 +90,9 @@ type Loop struct {
// Called when a response to an rc command is received
OnRCResponse func(data []byte) error
// Called when a response to a query command is received
OnQueryResponse func(key, val string, valid bool) error
// Called when any input from tty is received
OnReceivedData func(data []byte) error
@@ -481,6 +485,17 @@ func (self *Loop) CopyTextToClipboard(text string) {
self.copy_text_to(text, "c")
}
func (self *Loop) QueryTerminal(fields ...string) IdType {
if len(fields) == 0 {
return 0
}
q := make([]string, len(fields))
for i, x := range fields {
q[i] = hex.EncodeToString(utils.UnsafeStringToBytes("kitty-query-" + x))
}
return self.QueueWriteString(fmt.Sprintf("\x1bP+q%s\a", strings.Join(q, ";")))
}
func (self *Loop) PushPointerShape(s PointerShape) {
self.pointer_shapes = append(self.pointer_shapes, s)
self.QueueWriteString("\x1b]22;" + s.String() + "\x1b\\")