osc_string_state.go 620 B

1234567891011121314151617181920212223242526272829303132
  1. package ansiterm
  2. type oscStringState struct {
  3. baseState
  4. }
  5. func (oscState oscStringState) Handle(b byte) (s state, e error) {
  6. oscState.parser.logf("OscString::Handle %#x", b)
  7. nextState, err := oscState.baseState.Handle(b)
  8. if nextState != nil || err != nil {
  9. return nextState, err
  10. }
  11. switch {
  12. case isOscStringTerminator(b):
  13. return oscState.parser.ground, nil
  14. }
  15. return oscState, nil
  16. }
  17. // See below for OSC string terminators for linux
  18. // http://man7.org/linux/man-pages/man4/console_codes.4.html
  19. func isOscStringTerminator(b byte) bool {
  20. if b == ANSI_BEL || b == 0x5C {
  21. return true
  22. }
  23. return false
  24. }