public void StreamWithCustomEnd_CutPaste_DataUpdates() { SetFullModel(0xFF); var fileSystem = new StubFileSystem(); Array.Copy(new byte[] { 2, 2, 2, 3, 3, 3, 0xFF, 0xFF, 0x00 }, Model.RawData, 9); ViewPort.Edit("^table[a. b. c.]!FFFF00 "); // cut ViewPort.SelectionStart = ViewPort.ConvertAddressToViewPoint(0); ViewPort.ExpandSelection(0, 0); ViewPort.Copy.Execute(fileSystem); ViewPort.Clear.Execute(); // paste ViewPort.Goto.Execute(0x10); ViewPort.Edit(fileSystem.CopyText); var table = Model.GetTable("table"); Assert.Equal(0x10, table.Start); Assert.Equal(2, table.ElementCount); Assert.Equal(3, table.ElementLength); Assert.Equal(9, table.Length); }
public void TextWithNamedAnchor_EditScript_KeepsAnchor() { SetFullModel(0xFF); ViewPort.Edit("@10 ^text\"\" \"Hello\" @00 02 @00 ^script`xse` 0F 00 <010> 02 "); ViewPort.SelectionStart = ViewPort.ConvertAddressToViewPoint(0); var tool = ViewPort.Tools.CodeTool.Contents[0]; var lines = tool.Content.SplitLines(); lines[3] = "Hello!"; tool.Content = Environment.NewLine.Join(lines); Assert.Equal(0x10, Model.GetAddressFromAnchor(new ModelDelta(), -1, "text")); }
public void CanCutPasteArrayToFreeSpace() { // arrange var delta = new ModelDelta(); SetFullModel(0xFF); var(model, viewPort) = (Model, ViewPort); ViewPort.Edit("<020> "); var elements = new[] { "123", "alice", "candy land", "hello world", "fortify" }; CreateTextTable("testdata", 0x20, elements); viewPort.Goto.Execute(0); // act -> cut var fileSystem = new StubFileSystem(); viewPort.SelectionStart = ViewPort.ConvertAddressToViewPoint(0x20); viewPort.MoveSelectionEnd.Execute(Direction.End); // select entire table viewPort.Copy.Execute(fileSystem); viewPort.Clear.Execute(); string text = fileSystem.CopyText; // act -> paste viewPort.SelectionStart = new Point(0, 8); viewPort.Edit(text); // assert -> pointer moved var destination = model.ReadPointer(0x00); Assert.Equal(0x80, destination); // assert -> anchor moved var run = model.GetNextRun(0x10); Assert.Equal(0x80, run.Start); Assert.Equal("testdata", model.GetAnchorFromAddress(-1, run.Start)); Assert.Equal(5, ((ArrayRun)run).ElementCount); var lines = viewPort.Tools.StringTool.Content.Split(Environment.NewLine); Assert.All(elements, element => Assert.Contains(element, lines)); // assert -> nothing left behind Assert.All(Enumerable.Range(0x20, 0x50), i => Assert.Equal(0xFF, model[i])); }
private Point ToPoint(int address) => ViewPort.ConvertAddressToViewPoint(address);