Change dirty flag from int to bool

This commit is contained in:
Timothy Warren 2021-03-10 22:47:57 -05:00
parent 1b7e8216ef
commit cec69cfb93
2 changed files with 10 additions and 10 deletions

View File

@ -52,7 +52,7 @@ class Editor {
*/
public array $rows = [];
public int $dirty = 0;
public bool $dirty = TRUE;
public string $filename = '';
protected string $statusMsg = '';
protected int $statusMsgTime;
@ -258,7 +258,7 @@ class Editor {
$this->rows[$at]->update();
$this->dirty++;
$this->dirty = true;
// Re-tokenize the file
if ($updateSyntax)
@ -287,7 +287,7 @@ class Editor {
// Re-tokenize the file
$this->refreshPHPSyntax();
$this->dirty++;
$this->dirty = true;
}
// ------------------------------------------------------------------------
@ -394,7 +394,7 @@ class Editor {
fclose($handle);
$this->dirty = 0;
$this->dirty = false;
}
protected function save(): void
@ -418,7 +418,7 @@ class Editor {
if ($res === strlen($contents))
{
$this->setStatusMessage('%d bytes written to disk', strlen($contents));
$this->dirty = 0;
$this->dirty = false;
return;
}
@ -673,7 +673,7 @@ class Editor {
$statusFilename = $this->filename !== '' ? $this->filename : '[No Name]';
$syntaxType = ($this->syntax !== NULL) ? $this->syntax->filetype : 'no ft';
$isDirty = ($this->dirty > 0) ? '(modified)' : '';
$isDirty = $this->dirty ? '(modified)' : '';
$status = sprintf('%.20s - %d lines %s', $statusFilename, $this->numRows, $isDirty);
$rstatus = sprintf('%s | %d/%d', $syntaxType, $this->cursor->y + 1, $this->numRows);
$len = strlen($status);
@ -938,7 +938,7 @@ class Editor {
protected function quitAttempt(): ?string
{
if ($this->dirty > 0 && $this->quitTimes > 0)
if ($this->dirty && $this->quitTimes > 0)
{
$this->setStatusMessage(
'WARNING!!! File has unsaved changes. Press Ctrl-Q %d more times to quit.',

View File

@ -89,7 +89,7 @@ class Row {
$this->chars = substr($this->chars, 0, $at) . $c . substr($this->chars, $at);
$this->update();
$this->parent->dirty++;
$this->parent->dirty = true;
}
public function appendString(string $s): void
@ -97,7 +97,7 @@ class Row {
$this->chars .= $s;
$this->update();
$this->parent->dirty++;
$this->parent->dirty = true;
}
public function deleteChar(int $at): void
@ -110,7 +110,7 @@ class Row {
$this->chars = substr_replace($this->chars, '', $at, 1);
$this->update();
$this->parent->dirty++;
$this->parent->dirty = true;
}
public function update(): void