Continue refactoring of non-PHP syntax highlighting
All checks were successful
timw4mail/php-kilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2021-04-09 16:27:16 -04:00
parent 644f27bb37
commit 30b4c3818a
3 changed files with 25 additions and 8 deletions

View File

@ -772,10 +772,11 @@ class Editor {
{
$this->document->delete($this->cursor);
}
else if ($ch === KeyType::BACKSPACE && ($this->cursor->x > 0 || $this->cursor->y > 0))
if ($ch === KeyType::BACKSPACE && ($this->cursor->x > 0 || $this->cursor->y > 0))
{
$this->document->delete($this->cursor);
$this->moveCursor(KeyType::ARROW_LEFT);
$this->document->delete($this->cursor);
}
}
@ -783,10 +784,16 @@ class Editor {
{
if ($this->document->isDirty() && $this->quitTimes > 0)
{
if ($this->quitTimes === KILO_QUIT_TIMES)
{
Terminal::ding();
}
$this->setStatusMessage(
'WARNING!!! File has unsaved changes. Press Ctrl-Q %d more times to quit.',
$this->quitTimes
);
$this->quitTimes--;
return;
}

View File

@ -219,12 +219,14 @@ class Row {
return;
}
$keywords1 = $this->parent->fileType->syntax->keywords1;
$keywords2 = $this->parent->fileType->syntax->keywords2;
$syntax = $this->parent->fileType->syntax;
$scs = $this->parent->fileType->syntax->singleLineCommentStart;
$mcs = $this->parent->fileType->syntax->multiLineCommentStart;
$mce = $this->parent->fileType->syntax->multiLineCommentEnd;
$keywords1 = $syntax->keywords1;
$keywords2 = $syntax->keywords2;
$scs = $syntax->singleLineCommentStart;
$mcs = $syntax->multiLineCommentStart;
$mce = $syntax->multiLineCommentEnd;
$scsLen = strlen($scs);
$mcsLen = strlen($mcs);
@ -281,7 +283,7 @@ class Row {
$this->highlightString($i);
// Numbers, including decimal points
if ($this->parent->fileType->syntax->flags & Syntax::HIGHLIGHT_NUMBERS)
if ($syntax->flags & Syntax::HIGHLIGHT_NUMBERS)
{
if (
($char === '.' && $prevHl === Highlight::NUMBER) ||

View File

@ -115,6 +115,14 @@ class Terminal {
};
}
/**
* Ring the terminal bell
*/
public static function ding(): void
{
self::write(RawKeyCode::BELL);
}
/**
* Write to the stdout stream
*