Continue refactoring of non-PHP syntax highlighting
timw4mail/php-kilo/pipeline/head This commit looks good Details

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

View File

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