Resolve merge conflict

This commit is contained in:
Timothy Warren 2021-04-14 13:24:13 -04:00
parent 2956999737
commit 8f5986e91e
7 changed files with 245 additions and 98 deletions

View File

@ -223,7 +223,7 @@ class Document {
$newChars = substr($chars, 0, $at->x); $newChars = substr($chars, 0, $at->x);
// Truncate the previous row // Truncate the previous row
$row->chars = $newChars; $row->setChars($newChars);
// Add a new row with the contents of the previous row at the point of the split // Add a new row with the contents of the previous row at the point of the split
$this->insertRow($at->y + 1, substr($chars, $at->x)); $this->insertRow($at->y + 1, substr($chars, $at->x));
@ -255,7 +255,7 @@ class Document {
public function refreshSyntax(): void public function refreshSyntax(): void
{ {
// Update the syntax highlighting for all the rows of the file // Update the syntax highlighting for all the rows of the file
array_walk($this->rows, static fn (Row $row) => $row->highlight()); array_walk($this->rows, static fn (Row $row) => $row->update());
} }
private function refreshPHPSyntax(): void private function refreshPHPSyntax(): void

View File

@ -11,7 +11,7 @@ use Aviat\Kilo\Enum\RawKeyCode;
* @property string $chars * @property string $chars
*/ */
class Row { class Row {
use Traits\MagicProperties; // use Traits\MagicProperties;
/** /**
* The version of the row to be displayed (where tabs are converted to display spaces) * The version of the row to be displayed (where tabs are converted to display spaces)
@ -89,15 +89,6 @@ class Row {
}; };
} }
public function __set(string $name, mixed $value): void
{
if ($name === 'chars')
{
$this->chars = $value;
$this->highlight();
}
}
/** /**
* Convert the row contents to a string for saving * Convert the row contents to a string for saving
* *
@ -187,6 +178,12 @@ class Row {
$this->parent->dirty = true; $this->parent->dirty = true;
} }
public function setChars(string $chars): void
{
$this->chars = $chars;
$this->update();
}
/** /**
* Convert tabs to spaces for display, and update syntax highlighting * Convert tabs to spaces for display, and update syntax highlighting
*/ */

View File

@ -1,6 +1,6 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Aviat\Kilo\Tests\Traits; namespace Aviat\Kilo\Tests;
use Aviat\Kilo\ANSI; use Aviat\Kilo\ANSI;
use Aviat\Kilo\Enum\Color; use Aviat\Kilo\Enum\Color;

View File

@ -1,6 +1,6 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Aviat\Kilo\Tests\Traits; namespace Aviat\Kilo\Tests;
use Aviat\Kilo\Editor; use Aviat\Kilo\Editor;
use Aviat\Kilo\Type\TerminalSize; use Aviat\Kilo\Type\TerminalSize;
@ -47,8 +47,6 @@ class EditorTest extends TestCase {
public function testOpen(): void public function testOpen(): void
{ {
$this->markTestSkipped();
$editor = MockEditor::mock('src/ffi.h'); $editor = MockEditor::mock('src/ffi.h');
$state = json_encode($editor->__debugInfo(), JSON_THROW_ON_ERROR); $state = json_encode($editor->__debugInfo(), JSON_THROW_ON_ERROR);

View File

@ -1,6 +1,6 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Aviat\Kilo\Tests\Traits; namespace Aviat\Kilo\Tests;
use Aviat\Kilo\ use Aviat\Kilo\
{ {
@ -17,7 +17,9 @@ class RowTest extends TestCase {
parent::setUp(); parent::setUp();
$this->document = Document::new(); $this->document = Document::new();
$this->row = Row::new($this->document, '', 0); $this->document->insertRow(0, '');
$this->row = $this->document->rows[0];
} }
public function testSanity(): void public function testSanity(): void
@ -31,17 +33,17 @@ class RowTest extends TestCase {
public function testSetRunsUpdate(): void public function testSetRunsUpdate(): void
{ {
$this->markTestSkipped('Hangs'); // $this->markTestSkipped('Hangs');
$this->row->setChars('abcde');
$this->row->chars = 'abcde'; // $this->assertNotEmpty($this->row->chars);
$this->assertEquals('abcde', $this->row->render); // $this->assertEquals('abcde', $this->row->render);
} }
public function test__toString(): void public function test__toString(): void
{ {
$this->markTestSkipped('Hangs'); $this->markTestSkipped('Hangs');
$this->row->chars = 'abcde'; $this->row->setChars('abcde');
$this->assertEquals("abcde\n", (string)$this->row); $this->assertEquals("abcde\n", (string)$this->row);
} }
@ -64,7 +66,7 @@ class RowTest extends TestCase {
{ {
$this->markTestSkipped('Hangs'); $this->markTestSkipped('Hangs');
$this->row->chars = 'abde'; $this->row->setChars('abde');
$this->row->insert(2, 'c'); $this->row->insert(2, 'c');
$this->assertEquals('abcde', $this->row->chars); $this->assertEquals('abcde', $this->row->chars);
@ -76,7 +78,7 @@ class RowTest extends TestCase {
{ {
$this->markTestSkipped('Hangs'); $this->markTestSkipped('Hangs');
$this->row->chars = 'ab'; $this->row->setChars('ab');
$this->row->insert(5, 'c'); $this->row->insert(5, 'c');
$this->assertEquals('abc', $this->row->chars); $this->assertEquals('abc', $this->row->chars);
@ -88,7 +90,7 @@ class RowTest extends TestCase {
{ {
$this->markTestSkipped('Hangs'); $this->markTestSkipped('Hangs');
$this->row->chars = 'abcdef'; $this->row->setChars('abcdef');
$this->row->delete(5); $this->row->delete(5);
$this->assertEquals('abcde', $this->row->chars); $this->assertEquals('abcde', $this->row->chars);
@ -100,7 +102,7 @@ class RowTest extends TestCase {
{ {
$this->markTestSkipped('Hangs'); $this->markTestSkipped('Hangs');
$this->row->chars = 'ab'; $this->row->setChars('ab');
$this->row->delete(5); $this->row->delete(5);
$this->assertEquals('ab', $this->row->chars); $this->assertEquals('ab', $this->row->chars);

View File

@ -1,6 +1,6 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Aviat\Kilo\Tests\Traits; namespace Aviat\Kilo\Tests;
use Aviat\Kilo\{Termios, TermiosException}; use Aviat\Kilo\{Termios, TermiosException};
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -10,7 +10,13 @@
"tokens": [], "tokens": [],
"filetype": "C", "filetype": "C",
"keywords1": [ "keywords1": [
"auto",
"break",
"case",
"const",
"continue", "continue",
"default",
"do",
"typedef", "typedef",
"switch", "switch",
"return", "return",
@ -18,13 +24,23 @@
"while", "while",
"break", "break",
"struct", "struct",
"extern",
"union", "union",
"class", "class",
"else", "else",
"enum", "enum",
"for", "for",
"case", "case",
"if" "if",
"inline",
"register",
"restrict",
"return",
"sizeof",
"switch",
"typedef",
"union",
"volatile"
], ],
"keywords2": [ "keywords2": [
"#include", "#include",
@ -38,16 +54,50 @@
"float", "float",
"#error", "#error",
"#undef", "#undef",
"#elif",
"long", "long",
"char", "char",
"int", "int",
"void", "void",
"#if" "#if",
"uint32_t",
"wchar_t",
"int32_t",
"int64_t",
"uint64_t",
"int16_t",
"uint16_t",
"uint8_t",
"int8_t"
],
"operators": [
"<=>",
"<<=",
">>=",
"++",
"--",
"==",
"!=",
">=",
"<=",
"&&",
"||",
"<<",
">>",
"+=",
"-=",
"*=",
"\/=",
"%=",
"&=",
"|=",
"^=",
"->",
"::"
], ],
"singleLineCommentStart": "\/\/", "singleLineCommentStart": "\/\/",
"multiLineCommentStart": "\/*", "multiLineCommentStart": "\/*",
"multiLineCommentEnd": "*\/", "multiLineCommentEnd": "*\/"
"flags": 3
} }
}, },
"tokens": [], "tokens": [],
@ -570,11 +620,11 @@
4, 4,
4, 4,
4, 4,
7,
0, 0,
0, 0,
0, 0,
0, 7,
0,
0, 0,
5, 5,
5, 5,
@ -604,7 +654,7 @@
5, 5,
5, 5,
5, 5,
0 7
], ],
"idx": 16 "idx": 16
}, },
@ -623,12 +673,12 @@
0, 0,
0, 0,
0, 0,
7,
0, 0,
0, 13,
5, 13,
5, 13,
5, 7
0
], ],
"idx": 17 "idx": 17
}, },
@ -933,7 +983,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 25 "idx": 25
}, },
@ -1011,7 +1061,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 28 "idx": 28
}, },
@ -1089,7 +1139,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 31 "idx": 31
}, },
@ -1161,15 +1211,36 @@
{ {
"render": "{", "render": "{",
"hl": [ "hl": [
0 9
], ],
"idx": 35 "idx": 35
}, },
{ {
"render": " \/* Input modes. *\/", "render": " \/* Input modes. *\/",
"hl": [ "hl": [
0, 2,
0, 2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2, 2,
2, 2,
2, 2,
@ -1213,7 +1284,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 37 "idx": 37
}, },
@ -1225,8 +1296,28 @@
{ {
"render": " \/* Output modes. *\/", "render": " \/* Output modes. *\/",
"hl": [ "hl": [
0, 2,
0, 2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2, 2,
2, 2,
2, 2,
@ -1271,7 +1362,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 40 "idx": 40
}, },
@ -1283,8 +1374,27 @@
{ {
"render": " \/* Control modes. *\/", "render": " \/* Control modes. *\/",
"hl": [ "hl": [
0, 2,
0, 2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2, 2,
2, 2,
2, 2,
@ -1330,7 +1440,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 43 "idx": 43
}, },
@ -1342,8 +1452,29 @@
{ {
"render": " \/* Local modes. *\/", "render": " \/* Local modes. *\/",
"hl": [ "hl": [
0, 2,
0, 2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2, 2,
2, 2,
2, 2,
@ -1387,7 +1518,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 46 "idx": 46
}, },
@ -1399,8 +1530,22 @@
{ {
"render": " \/* Control characters. *\/", "render": " \/* Control characters. *\/",
"hl": [ "hl": [
0, 2,
0, 2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2, 2,
2, 2,
2, 2,
@ -1444,11 +1589,11 @@
0, 0,
0, 0,
0, 0,
0, 9,
6, 6,
6, 6,
0, 9,
0 7
], ],
"idx": 49 "idx": 49
}, },
@ -1460,8 +1605,13 @@
{ {
"render": " \/* Input and output baud rates. *\/", "render": " \/* Input and output baud rates. *\/",
"hl": [ "hl": [
0, 2,
0, 2,
2,
2,
2,
2,
2,
2, 2,
2, 2,
2, 2,
@ -1521,6 +1671,7 @@
0, 0,
0, 0,
0, 0,
7,
0, 0,
0, 0,
0, 0,
@ -1530,16 +1681,15 @@
0, 0,
0, 0,
0, 0,
0, 7
0
], ],
"idx": 52 "idx": 52
}, },
{ {
"render": "};", "render": "};",
"hl": [ "hl": [
0, 9,
0 7
], ],
"idx": 53 "idx": 53
}, },
@ -1565,14 +1715,14 @@
0, 0,
0, 0,
0, 0,
0, 9,
4, 4,
4, 4,
4, 4,
0, 0,
0, 0,
0, 0,
0, 7,
0, 0,
3, 3,
3, 3,
@ -1589,6 +1739,7 @@
0, 0,
0, 0,
0, 0,
7,
0, 0,
0, 0,
0, 0,
@ -1598,9 +1749,8 @@
0, 0,
0, 0,
0, 0,
0, 9,
0, 7
0
], ],
"idx": 55 "idx": 55
}, },
@ -1621,14 +1771,14 @@
0, 0,
0, 0,
0, 0,
0, 9,
4, 4,
4, 4,
4, 4,
0, 0,
0, 0,
0, 0,
0, 7,
0, 0,
4, 4,
4, 4,
@ -1650,13 +1800,13 @@
0, 0,
0, 0,
0, 0,
7,
0, 0,
0, 3,
0, 3,
0, 3,
0, 3,
0, 3,
0,
0, 0,
3, 3,
3, 3,
@ -1673,6 +1823,7 @@
0, 0,
0, 0,
0, 0,
7,
0, 0,
0, 0,
0, 0,
@ -1682,9 +1833,8 @@
0, 0,
0, 0,
0, 0,
0, 9,
0, 7
0
], ],
"idx": 56 "idx": 56
}, },
@ -1906,7 +2056,7 @@
0, 0,
0, 0,
0, 0,
0 9
], ],
"idx": 61 "idx": 61
}, },
@ -1938,7 +2088,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 62 "idx": 62
}, },
@ -1970,7 +2120,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 63 "idx": 63
}, },
@ -2005,7 +2155,7 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 64 "idx": 64
}, },
@ -2040,15 +2190,15 @@
0, 0,
0, 0,
0, 0,
0 7
], ],
"idx": 65 "idx": 65
}, },
{ {
"render": "};", "render": "};",
"hl": [ "hl": [
0, 9,
0 7
], ],
"idx": 66 "idx": 66
}, },
@ -2065,22 +2215,22 @@
0, 0,
0, 0,
0, 0,
9,
4,
4,
4,
7,
0, 0,
4, 4,
4, 4,
4, 4,
0, 7,
0,
4,
4,
4,
0, 0,
0, 0,
0, 0,
0, 0,
0, 9,
0, 7
0
], ],
"idx": 67 "idx": 67
} }