Minor tweaks
timw4mail/php-kilo/pipeline/head There was a failure building this commit Details

This commit is contained in:
Timothy Warren 2021-03-05 20:47:59 -05:00
parent e6f7095a45
commit 113cc1a0a1
3 changed files with 8 additions and 3 deletions

View File

@ -78,7 +78,9 @@ class ANSI {
*/
public static function moveCursor(int $line, int $column): string
{
return self::seq('%d;%dH', $line, $column);
// The terminal has a 1-based coordinate system,
// add one to each to allow 0-based coordinate system input
return self::seq('%d;%dH', $line + 1, $column + 1);
}
/**

View File

@ -688,8 +688,8 @@ class Editor {
// Specify the current cursor position
$this->outputBuffer .= ANSI::moveCursor(
($this->cursorY - $this->rowOffset) + 1,
($this->renderX - $this->colOffset) + 1
$this->cursorY - $this->rowOffset,
$this->renderX - $this->colOffset
);
$this->outputBuffer .= ANSI::SHOW_CURSOR;

View File

@ -33,6 +33,9 @@ class Terminal {
return [25, 80];
}
/**
* Clear the screen and reset the cursor position
*/
public static function clear(): void
{
self::write(ANSI::CLEAR_SCREEN . ANSI::RESET_CURSOR);