little rawmode cleanup

This commit is contained in:
Timothy Warren 2019-11-08 21:48:46 -05:00
parent 5787fe3822
commit 9c23194feb
4 changed files with 22 additions and 14 deletions

View File

@ -114,7 +114,7 @@ class Editor {
// In PHP, `strchr` and `strstr` are the same function // In PHP, `strchr` and `strstr` are the same function
$ext = (string)strstr($this->filename, '.'); $ext = (string)strstr($this->filename, '.');
foreach (get_hldb() as $syntax) foreach (get_file_syntax_map() as $syntax)
{ {
foreach ($syntax->filematch as $searchExt) foreach ($syntax->filematch as $searchExt)
{ {

View File

@ -221,6 +221,17 @@ class Row {
return $this->chars . "\n"; return $this->chars . "\n";
} }
public function __debugInfo()
{
return [
'size' => $this->size,
'rsize' => $this->rsize,
'chars' => $this->chars,
'render' => $this->render,
'hlOpenComment' => $this->hlOpenComment,
];
}
public function insertChar(int $at, string $c): void public function insertChar(int $at, string $c): void
{ {
if ($at < 0 || $at > $this->size) if ($at < 0 || $at > $this->size)

View File

@ -24,14 +24,6 @@ class Termios {
} }
$this->originalTermios = $termios; $this->originalTermios = $termios;
// Make sure to restore normal mode on exit/die/crash
register_shutdown_function([$this, '__destruct']);
}
public function __destruct()
{
self::disableRawMode();
} }
public static function enableRawMode(): void public static function enableRawMode(): void
@ -48,12 +40,17 @@ class Termios {
$instance = self::getInstance(); $instance = self::getInstance();
// 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... // So, the only thing that seems to really matter here is that c_oflag is 0...
$termios = $instance->originalTermios; $termios = clone $instance->originalTermios;
$termios->c_iflag = 0; //$termios->c_iflag & ~(C::BRKINT | C::ICRNL | C::INPCK | C::ISTRIP | C::IXON); // $termios->c_iflag &= ~(C::BRKINT | C::ICRNL | C::INPCK | C::ISTRIP | C::IXON);
$termios->c_oflag = 0; // $termios->c_oflag && ~(C::OPOST); // $termios->c_oflag &= ~(C::OPOST);
$termios->c_iflag = 0;
$termios->c_oflag = 0;
$termios->c_cflag |= (C::CS8); $termios->c_cflag |= (C::CS8);
$termios->c_lflag = $termios->c_lflag & ~( C::ECHO | C::ICANON | C::IEXTEN | C::ISIG); $termios->c_lflag = $termios->c_lflag & ~( C::ECHO | C::ICANON | C::IEXTEN | C::ISIG );
$termios->c_cc[C::VMIN] = 0; $termios->c_cc[C::VMIN] = 0;
$termios->c_cc[C::VTIME] = 1; $termios->c_cc[C::VTIME] = 1;

View File

@ -376,7 +376,7 @@ function get_php_tokens(string $code): array
* *
* @return array * @return array
*/ */
function get_hldb(): array function get_file_syntax_map(): array
{ {
static $db = []; static $db = [];