Remove unused ffi prototypes, make php equivalent functions

This commit is contained in:
Timothy Warren 2019-10-23 13:34:40 -04:00
parent 0b66606e6c
commit bb1ee20964
3 changed files with 23 additions and 10 deletions

View File

@ -785,7 +785,7 @@ class Editor {
{ {
$buffer = substr($buffer, 0, -1); $buffer = substr($buffer, 0, -1);
} }
else if ($cord < 128 && $this->ffi->iscntrl($cord) === 0 && ! in_array($c, $modifiers, TRUE)) else if (isascii($c) && ( ! iscntrl($c)) && ! in_array($c, $modifiers, TRUE))
{ {
$buffer .= $c; $buffer .= $c;
} }

View File

@ -49,15 +49,6 @@ struct termios
int tcgetattr (int fd, struct termios *termios_p); int tcgetattr (int fd, struct termios *termios_p);
int tcsetattr (int fd, int optional_actions, const struct termios *termios_p); int tcsetattr (int fd, int optional_actions, const struct termios *termios_p);
void cfmakeraw (struct termios *termios_p);
// -----------------------------------------------------------------------------
//! <ctype.h>
// -----------------------------------------------------------------------------
int iscntrl (int);
ssize_t read(int, void *, size_t);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
//! <sys/ioctl.h> //! <sys/ioctl.h>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -98,3 +98,25 @@ function ctrl_key(string $char): int
// b1,100,010 (b) & b0,011,111 = b0,000,010 // b1,100,010 (b) & b0,011,111 = b0,000,010
return ord($char) & 0x1f; return ord($char) & 0x1f;
} }
function isascii(string $single_char): bool
{
if (strlen($single_char) > 1)
{
return FALSE;
}
return ord($single_char) < 0x80;
}
function iscntrl(string $char): bool
{
$c = ord($char);
return isascii($char) && ( $c < 0x20 || $c === 0x7f );
}
function isdigit(string $char): bool
{
$c = ord($char);
return isascii($char) && ( $c > 0x2f && $c < 0x3a );
}