diff --git a/src/Editor.php b/src/Editor.php index 1d72022..063dff5 100644 --- a/src/Editor.php +++ b/src/Editor.php @@ -114,7 +114,7 @@ class Editor { // In PHP, `strchr` and `strstr` are the same function $ext = (string)strstr($this->filename, '.'); - foreach (get_hldb() as $syntax) + foreach (get_file_syntax_map() as $syntax) { foreach ($syntax->filematch as $searchExt) { diff --git a/src/Row.php b/src/Row.php index 3325ebd..5808963 100644 --- a/src/Row.php +++ b/src/Row.php @@ -221,6 +221,17 @@ class Row { 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 { if ($at < 0 || $at > $this->size) diff --git a/src/Termios.php b/src/Termios.php index b275bb7..159cf30 100644 --- a/src/Termios.php +++ b/src/Termios.php @@ -24,14 +24,6 @@ class 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 @@ -48,12 +40,17 @@ class Termios { $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... - $termios = $instance->originalTermios; - $termios->c_iflag = 0; //$termios->c_iflag & ~(C::BRKINT | C::ICRNL | C::INPCK | C::ISTRIP | C::IXON); - $termios->c_oflag = 0; // $termios->c_oflag && ~(C::OPOST); + $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 = $termios->c_lflag & ~( C::ECHO | C::ICANON | C::IEXTEN | C::ISIG ); $termios->c_cc[C::VMIN] = 0; $termios->c_cc[C::VTIME] = 1; diff --git a/src/functions.php b/src/functions.php index 52bddcc..9123d7c 100644 --- a/src/functions.php +++ b/src/functions.php @@ -376,7 +376,7 @@ function get_php_tokens(string $code): array * * @return array */ -function get_hldb(): array +function get_file_syntax_map(): array { static $db = [];