コード例 #1
0
        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);
        }
コード例 #2
0
        public void NextElementInTableToolWorksEvenIfOtherDataIsCurrentlySelected()
        {
            ViewPort.Edit("^table[data<>]3 <020> <030> <040> @04 ");
            ViewPort.ExpandSelection(0, 0); // follows the pointer to 030
            var tableTool = ViewPort.Tools.TableTool;

            ViewPort.Tools.SelectedIndex = ViewPort.Tools.IndexOf(tableTool);
            tableTool.Next.Execute();

            Assert.EndsWith("/2", tableTool.CurrentElementName);
        }
コード例 #3
0
        public void RedoAvailable_Copy_CanRedo()
        {
            var fs = new StubFileSystem();

            ViewPort.Edit("<020> @20 @!put(FF) ^\"\" text @180 DEADBEEF");
            ViewPort.Undo.Execute();

            ViewPort.Goto.Execute(0x20);
            ViewPort.ExpandSelection(0, 0);
            ViewPort.Copy.Execute(fs);

            Assert.True(ViewPort.Redo.CanExecute(default));
コード例 #4
0
        public void NamelessAnchor_Copy_StillHasNoName()
        {
            var fs = new StubFileSystem();

            ViewPort.Edit("<100> @100 @!put(FF) ^\"\" text");

            ViewPort.ExpandSelection(0, 0);
            ViewPort.Copy.Execute(fs);

            Assert.Contains("misc", fs.CopyText.value);
            Assert.Equal("^\"\"", ViewPort.AnchorText);
        }
コード例 #5
0
        public void NamelessAnchor_Cut_PointerGetsName()
        {
            var fs = new StubFileSystem();

            ViewPort.Edit("<100> @100 @!put(FF) ^\"\" text");

            ViewPort.ExpandSelection(0, 0);
            ViewPort.Cut(fs);

            var pointer = Model.ExportMetadata(Singletons.MetadataInfo).UnmappedPointers.Single();

            Assert.Equal(0, pointer.Address);
            Assert.Contains("misc", pointer.Name);
        }
コード例 #6
0
        public void CopyAnUnnamedStringInsertsAName()
        {
            var text   = "This is the song that never ends.";
            var bytes  = PCSString.Convert(text).ToArray();
            var buffer = new byte[0x200];

            Array.Copy(bytes, 0, buffer, 0x30, bytes.Length);
            Array.Copy(new byte[] { 0x30, 0, 0, 0x08 }, 0, buffer, 0x10, 4); // the pointer to the data. Pointer is aligned, but data is not.
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("test.gba", model)
            {
                Width = 0x10, Height = 0x10
            };
            var fileSystem = new StubFileSystem();

            viewPort.SelectionStart = new Point(0, 3);
            viewPort.ExpandSelection(0, 3);
            viewPort.Copy.Execute(fileSystem);

            Assert.Contains("^This", fileSystem.CopyText);
            Assert.Contains("\"\" \"This", fileSystem.CopyText); // format, then space, then start of text
        }