Slight tweak of php token handling

This commit is contained in:
Timothy Warren 2019-11-13 16:26:19 -05:00
parent 9c23194feb
commit 99799e1d5a
3 changed files with 64 additions and 64 deletions

View File

@ -7,7 +7,7 @@ due to requiring the `FFI` extension.
* The `editor` prefix has been removed from all the relevant functions, instead they are methods on the `Editor` class.
* Enums are faked with class constants
* Basic PHP class auto-loading is used
* Composer is used for autoloading
* Properties that must be manually updated in the C version (like counts/string length) are implemented with magic methods,
so they are essentially calculated on read.
* Generally, if a function exists in PHP, with the same name as the C function, the PHP version will be used.

View File

@ -43,14 +43,13 @@ class Termios {
// Make sure to restore normal mode on exit/die/crash
register_shutdown_function([static::class, 'disableRawMode']);
// So, the only thing that seems to really matter here is that c_oflag is 0...
$termios = clone $instance->originalTermios;
// $termios->c_iflag &= ~(C::BRKINT | C::ICRNL | C::INPCK | C::ISTRIP | C::IXON);
// $termios->c_oflag &= ~(C::OPOST);
$termios->c_iflag = 0;
$termios->c_oflag = 0;
$termios->c_cflag |= (C::CS8);
$termios->c_lflag = $termios->c_lflag & ~( C::ECHO | C::ICANON | C::IEXTEN | C::ISIG );
$termios->c_lflag &= ~( C::ECHO | C::ICANON | C::IEXTEN | C::ISIG );
$termios->c_cc[C::VMIN] = 0;
$termios->c_cc[C::VTIME] = 1;

View File

@ -294,17 +294,8 @@ function get_php_tokens(string $code): array
$line = [];
foreach($rawTokens as $t)
{
// Simple characters, usually delimiters or single character operators
if ( ! is_array($t))
if (is_array($t))
{
$line[] = [
'type' => -1,
'typeName' => 'RAW',
'char' => tabs_to_spaces($t),
];
continue;
}
[$type, $rawChar, $currentLine] = $t;
$char = tabs_to_spaces($rawChar);
@ -363,6 +354,16 @@ function get_php_tokens(string $code): array
$line[] = $current;
}
else if (is_string($t))
{
// Simple characters, usually delimiters or single character operators
$line[] = [
'type' => -1,
'typeName' => 'RAW',
'char' => tabs_to_spaces($t),
];
}
}
$tokens[$lineNum] = array_merge($tokens[$lineNum] ?? [], $line);