Change dirty flag from int to bool
This commit is contained in:
parent
1b7e8216ef
commit
cec69cfb93
@ -52,7 +52,7 @@ class Editor {
|
|||||||
*/
|
*/
|
||||||
public array $rows = [];
|
public array $rows = [];
|
||||||
|
|
||||||
public int $dirty = 0;
|
public bool $dirty = TRUE;
|
||||||
public string $filename = '';
|
public string $filename = '';
|
||||||
protected string $statusMsg = '';
|
protected string $statusMsg = '';
|
||||||
protected int $statusMsgTime;
|
protected int $statusMsgTime;
|
||||||
@ -258,7 +258,7 @@ class Editor {
|
|||||||
|
|
||||||
$this->rows[$at]->update();
|
$this->rows[$at]->update();
|
||||||
|
|
||||||
$this->dirty++;
|
$this->dirty = true;
|
||||||
|
|
||||||
// Re-tokenize the file
|
// Re-tokenize the file
|
||||||
if ($updateSyntax)
|
if ($updateSyntax)
|
||||||
@ -287,7 +287,7 @@ class Editor {
|
|||||||
// Re-tokenize the file
|
// Re-tokenize the file
|
||||||
$this->refreshPHPSyntax();
|
$this->refreshPHPSyntax();
|
||||||
|
|
||||||
$this->dirty++;
|
$this->dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -394,7 +394,7 @@ class Editor {
|
|||||||
|
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
|
|
||||||
$this->dirty = 0;
|
$this->dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function save(): void
|
protected function save(): void
|
||||||
@ -418,7 +418,7 @@ class Editor {
|
|||||||
if ($res === strlen($contents))
|
if ($res === strlen($contents))
|
||||||
{
|
{
|
||||||
$this->setStatusMessage('%d bytes written to disk', strlen($contents));
|
$this->setStatusMessage('%d bytes written to disk', strlen($contents));
|
||||||
$this->dirty = 0;
|
$this->dirty = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,7 +673,7 @@ class Editor {
|
|||||||
|
|
||||||
$statusFilename = $this->filename !== '' ? $this->filename : '[No Name]';
|
$statusFilename = $this->filename !== '' ? $this->filename : '[No Name]';
|
||||||
$syntaxType = ($this->syntax !== NULL) ? $this->syntax->filetype : 'no ft';
|
$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);
|
$status = sprintf('%.20s - %d lines %s', $statusFilename, $this->numRows, $isDirty);
|
||||||
$rstatus = sprintf('%s | %d/%d', $syntaxType, $this->cursor->y + 1, $this->numRows);
|
$rstatus = sprintf('%s | %d/%d', $syntaxType, $this->cursor->y + 1, $this->numRows);
|
||||||
$len = strlen($status);
|
$len = strlen($status);
|
||||||
@ -938,7 +938,7 @@ class Editor {
|
|||||||
|
|
||||||
protected function quitAttempt(): ?string
|
protected function quitAttempt(): ?string
|
||||||
{
|
{
|
||||||
if ($this->dirty > 0 && $this->quitTimes > 0)
|
if ($this->dirty && $this->quitTimes > 0)
|
||||||
{
|
{
|
||||||
$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.',
|
||||||
|
@ -89,7 +89,7 @@ class Row {
|
|||||||
$this->chars = substr($this->chars, 0, $at) . $c . substr($this->chars, $at);
|
$this->chars = substr($this->chars, 0, $at) . $c . substr($this->chars, $at);
|
||||||
$this->update();
|
$this->update();
|
||||||
|
|
||||||
$this->parent->dirty++;
|
$this->parent->dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function appendString(string $s): void
|
public function appendString(string $s): void
|
||||||
@ -97,7 +97,7 @@ class Row {
|
|||||||
$this->chars .= $s;
|
$this->chars .= $s;
|
||||||
$this->update();
|
$this->update();
|
||||||
|
|
||||||
$this->parent->dirty++;
|
$this->parent->dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteChar(int $at): void
|
public function deleteChar(int $at): void
|
||||||
@ -110,7 +110,7 @@ class Row {
|
|||||||
$this->chars = substr_replace($this->chars, '', $at, 1);
|
$this->chars = substr_replace($this->chars, '', $at, 1);
|
||||||
$this->update();
|
$this->update();
|
||||||
|
|
||||||
$this->parent->dirty++;
|
$this->parent->dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(): void
|
public function update(): void
|
||||||
|
Loading…
Reference in New Issue
Block a user