2015-04-16 17:01:37 -04:00
|
|
|
package ansiterm
|
|
|
|
|
2016-04-25 18:55:12 -04:00
|
|
|
type oscStringState struct {
|
|
|
|
baseState
|
2015-04-16 17:01:37 -04:00
|
|
|
}
|
|
|
|
|
2016-04-25 18:55:12 -04:00
|
|
|
func (oscState oscStringState) Handle(b byte) (s state, e error) {
|
2015-04-16 17:01:37 -04:00
|
|
|
logger.Infof("OscString::Handle %#x", b)
|
2016-04-25 18:55:12 -04:00
|
|
|
nextState, err := oscState.baseState.Handle(b)
|
2015-04-16 17:01:37 -04:00
|
|
|
if nextState != nil || err != nil {
|
|
|
|
return nextState, err
|
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case isOscStringTerminator(b):
|
2016-04-25 18:55:12 -04:00
|
|
|
return oscState.parser.ground, nil
|
2015-04-16 17:01:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return oscState, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// See below for OSC string terminators for linux
|
|
|
|
// http://man7.org/linux/man-pages/man4/console_codes.4.html
|
|
|
|
func isOscStringTerminator(b byte) bool {
|
|
|
|
|
|
|
|
if b == ANSI_BEL || b == 0x5C {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|