-
-
Notifications
You must be signed in to change notification settings - Fork 7
Feature/add ss2 ss3 support #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,12 @@ are supported as defined in [ISO/IEC 2022](https://en.wikipedia.org/wiki/ISO/IEC | |
|
||
* PM (Privacy Message) | ||
|
||
* SS2 (Single Shift 2) | ||
this means select the following character form the G2 character set | ||
|
||
* SS3 (Single Shift 3) | ||
this means select the following character form the G3 character set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: from |
||
|
||
Each code sequence gets emitted with a dedicated event with its raw byte sequence: | ||
|
||
```php | ||
|
@@ -90,6 +96,8 @@ $stream->on('osc', function ($sequence) { … }); | |
$stream->on('apc', function ($sequence) { … }); | ||
$stream->on('dps', function ($sequence) { … }); | ||
$stream->on('pm', function ($sequence) { … }); | ||
$stream->on('ss2', function ($sequence) { … }); | ||
$stream->on('ss3', function ($sequence) { … }); | ||
``` | ||
|
||
Other lesser known [C1 control codes](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_set) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ class ControlCodeParser extends EventEmitter implements ReadableStreamInterface | |
* followed by "_" means it's APC (Application Program-Control) | ||
* followed by "P" means it's DPS (Device-Control string) | ||
* followed by "^" means it's PM (Privacy Message) | ||
* followed by "N" means it's SS2 (Single Shift 2) | ||
* followed by "O" means it's SS3 (Single Shift 3) | ||
* | ||
* Each of these will be parsed until the sequence ends and then emitted | ||
* under their respective name. | ||
|
@@ -39,6 +41,8 @@ class ControlCodeParser extends EventEmitter implements ReadableStreamInterface | |
'_' => 'apc', | ||
'P' => 'dps', | ||
'^' => 'pm', | ||
'N' => 'ss2', | ||
'O' => 'ss3', | ||
); | ||
|
||
public function __construct(ReadableStreamInterface $input) | ||
|
@@ -171,6 +175,12 @@ public function handleData($data) | |
break; | ||
} | ||
} | ||
} else if ($type === 'ss2' || $type === 'ss3') { | ||
$data = substr($this->buffer, 0, 3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic looks about right! 👍 This needs an additional check to ensure that 3 bytes are available in the buffer and set |
||
$this->buffer = (string) substr($this->buffer, 3); | ||
|
||
$this->emit($type, array($data)); | ||
$found = true; | ||
} else { | ||
// all other types are terminated by ST | ||
// only OSC can also be terminted by BEL (whichever comes first) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: from