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);
// 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
$this->insertRow($at->y + 1, substr($chars, $at->x));
@ -255,7 +255,7 @@ class Document {
public function refreshSyntax(): void
{
// 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

View File

@ -11,7 +11,7 @@ use Aviat\Kilo\Enum\RawKeyCode;
* @property string $chars
*/
class Row {
use Traits\MagicProperties;
// use Traits\MagicProperties;
/**
* 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
*
@ -187,6 +178,12 @@ class Row {
$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
*/

View File

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

View File

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

View File

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

View File

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

View File

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