mirror of https://github.com/liamg/aminal.git
introduced different sets of OSC terminators for Unix and Windows
This commit is contained in:
parent
f4a3e23a3d
commit
646fcb12c4
|
@ -17,4 +17,5 @@ type Pty interface {
|
||||||
|
|
||||||
Resize(x int, y int) error
|
Resize(x int, y int) error
|
||||||
CreateGuestProcess(imagePath string) (Process, error)
|
CreateGuestProcess(imagePath string) (Process, error)
|
||||||
|
GetPlatformDependentSettings() PlatformDependentSettings
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package platform
|
||||||
|
|
||||||
|
// PlatformDependentSettings Settings specific to the platform
|
||||||
|
type PlatformDependentSettings struct {
|
||||||
|
OSCTerminators map[rune]struct{}
|
||||||
|
}
|
|
@ -13,8 +13,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type unixPty struct {
|
type unixPty struct {
|
||||||
pty *os.File
|
pty *os.File
|
||||||
tty *os.File
|
tty *os.File
|
||||||
|
platformDependentSettings PlatformDependentSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
type winsize struct {
|
type winsize struct {
|
||||||
|
@ -81,6 +82,10 @@ func (p *unixPty) CreateGuestProcess(imagePath string) (Process, error) {
|
||||||
return shell, nil
|
return shell, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pty *unixPty) GetPlatformDependentSettings() PlatformDependentSettings {
|
||||||
|
return pty.platformDependentSettings
|
||||||
|
}
|
||||||
|
|
||||||
func NewPty(x, y int) (Pty, error) {
|
func NewPty(x, y int) (Pty, error) {
|
||||||
innerPty, innerTty, err := pty.Open()
|
innerPty, innerTty, err := pty.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -89,5 +94,8 @@ func NewPty(x, y int) (Pty, error) {
|
||||||
return &unixPty{
|
return &unixPty{
|
||||||
pty: innerPty,
|
pty: innerPty,
|
||||||
tty: innerTty,
|
tty: innerTty,
|
||||||
|
platformDependentSettings: PlatformDependentSettings{
|
||||||
|
OSCTerminators: map[rune]struct{}{0x07: {}, 0x5c: {}},
|
||||||
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,11 +92,12 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
type winConPty struct {
|
type winConPty struct {
|
||||||
inPipe syscall.Handle
|
inPipe syscall.Handle
|
||||||
outPipe syscall.Handle
|
outPipe syscall.Handle
|
||||||
innerInPipe syscall.Handle
|
innerInPipe syscall.Handle
|
||||||
innerOutPipe syscall.Handle
|
innerOutPipe syscall.Handle
|
||||||
hcon uintptr
|
hcon uintptr
|
||||||
|
platformDependentSettings PlatformDependentSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pty *winConPty) Read(p []byte) (n int, err error) {
|
func (pty *winConPty) Read(p []byte) (n int, err error) {
|
||||||
|
@ -181,6 +182,10 @@ func (pty *winConPty) Resize(x, y int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pty *winConPty) GetPlatformDependentSettings() PlatformDependentSettings {
|
||||||
|
return pty.platformDependentSettings
|
||||||
|
}
|
||||||
|
|
||||||
// NewPty creates a new instance of a Pty implementation for Windows on a newly allocated ConPTY
|
// NewPty creates a new instance of a Pty implementation for Windows on a newly allocated ConPTY
|
||||||
func NewPty(x, y int) (pty Pty, err error) {
|
func NewPty(x, y int) (pty Pty, err error) {
|
||||||
if !ptyInitSucceeded {
|
if !ptyInitSucceeded {
|
||||||
|
@ -217,6 +222,9 @@ func NewPty(x, y int) (pty Pty, err error) {
|
||||||
innerInPipe: inputReadSide,
|
innerInPipe: inputReadSide,
|
||||||
innerOutPipe: outputWriteSide,
|
innerOutPipe: outputWriteSide,
|
||||||
hcon: uintptr(hc),
|
hcon: uintptr(hc),
|
||||||
|
platformDependentSettings: PlatformDependentSettings{
|
||||||
|
OSCTerminators: map[rune]struct{}{0x00: {}},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return pty, nil
|
return pty, nil
|
||||||
|
|
|
@ -12,7 +12,7 @@ func oscHandler(pty chan rune, terminal *Terminal) error {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
b := <-pty
|
b := <-pty
|
||||||
if b == 0x07 || b == 0x5c {
|
if terminal.IsOSCTerminator(b) {
|
||||||
params = append(params, param)
|
params = append(params, param)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,23 +30,24 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Terminal struct {
|
type Terminal struct {
|
||||||
program uint32
|
program uint32
|
||||||
buffers []*buffer.Buffer
|
buffers []*buffer.Buffer
|
||||||
activeBuffer *buffer.Buffer
|
activeBuffer *buffer.Buffer
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
pty platform.Pty
|
pty platform.Pty
|
||||||
logger *zap.SugaredLogger
|
logger *zap.SugaredLogger
|
||||||
title string
|
title string
|
||||||
size Winsize
|
size Winsize
|
||||||
config *config.Config
|
config *config.Config
|
||||||
titleHandlers []chan bool
|
titleHandlers []chan bool
|
||||||
modes Modes
|
modes Modes
|
||||||
mouseMode MouseMode
|
mouseMode MouseMode
|
||||||
bracketedPasteMode bool
|
bracketedPasteMode bool
|
||||||
isDirty bool
|
isDirty bool
|
||||||
charWidth float32
|
charWidth float32
|
||||||
charHeight float32
|
charHeight float32
|
||||||
lastBuffer uint8
|
lastBuffer uint8
|
||||||
|
platformDependentSettings platform.PlatformDependentSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
type Modes struct {
|
type Modes struct {
|
||||||
|
@ -85,6 +86,7 @@ func New(pty platform.Pty, logger *zap.SugaredLogger, config *config.Config) *Te
|
||||||
modes: Modes{
|
modes: Modes{
|
||||||
ShowCursor: true,
|
ShowCursor: true,
|
||||||
},
|
},
|
||||||
|
platformDependentSettings: pty.GetPlatformDependentSettings(),
|
||||||
}
|
}
|
||||||
t.activeBuffer = t.buffers[0]
|
t.activeBuffer = t.buffers[0]
|
||||||
return t
|
return t
|
||||||
|
@ -121,6 +123,11 @@ func (terminal *Terminal) GetMouseMode() MouseMode {
|
||||||
return terminal.mouseMode
|
return terminal.mouseMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (terminal *Terminal) IsOSCTerminator(char rune) bool {
|
||||||
|
_, ok := terminal.platformDependentSettings.OSCTerminators[char]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
func (terminal *Terminal) UseMainBuffer() {
|
func (terminal *Terminal) UseMainBuffer() {
|
||||||
terminal.activeBuffer = terminal.buffers[MainBuffer]
|
terminal.activeBuffer = terminal.buffers[MainBuffer]
|
||||||
terminal.SetSize(uint(terminal.size.Width), uint(terminal.size.Height))
|
terminal.SetSize(uint(terminal.size.Width), uint(terminal.size.Height))
|
||||||
|
|
Loading…
Reference in New Issue