public void RightClickOptionToOpenTextTool() { CreateSimpleRun(); viewPort.SelectionStart = new Point(2, 0); var items = viewPort.GetContextMenuItems(viewPort.SelectionStart); Assert.Contains(items, item => item.ShortcutText == "Ctrl+Click"); }
public void CanCreateDataFromNull() { for (int i = 0x80; i < Model.RawData.Length; i++) { Model.RawData[i] = 0xFF; } ViewPort.Edit("^table[number: value: pointer<\"\">]8 @04 "); // verify that it's in the context menu var items = ViewPort.GetContextMenuItems(new Point(4, 0)); var createNewItem = items.Single(item => item.Text == "Create New Data"); // verify that it's in the table var toolElements = ViewPort.Tools.TableTool.Children; var createNewTool = toolElements.Single(element => element is TextStreamElementViewModel stream && stream.CanCreateNew); // verify that the command works createNewItem.Command.Execute(); Assert.NotEqual(0, Model.ReadValue(0x04)); var run = (PCSRun)Model.GetNextRun(Model.ReadPointer(0x04)); Assert.Equal(1, run.Length); // verify that you can't use the table tool's version anymore Assert.False(((TextStreamElementViewModel)createNewTool).CanRepoint); }
public void ClearFormatOnNamedAnchorRemovesAnchorButDoesNotClearFalsePointers() { ViewPort.Edit("<000004> ^fake "); var items = ViewPort.GetContextMenuItems(new Point(4, 0)); var clear = items.Single(item => item.Text.Contains("Clear Format")); clear.Command.Execute(); Assert.Equal(4, Model[0]); }
public void CanDeepCopy() { ViewPort.Edit("^table[pointer<\"\">]1 @{ Hello World!\" @} @00 "); var fileSystem = new StubFileSystem(); var menuItem = ViewPort.GetContextMenuItems(ViewPort.SelectionStart).Single(item => item.Text == "Deep Copy"); menuItem.Command.Execute(fileSystem); Assert.Equal(@"@!00(4) ^table[pointer<"""">]1 #""Hello World!""#, @{ ""Hello World!"" @}", fileSystem.CopyText); }
public void FocusTable_ClearFormat_SelectionDoesNotMoveSeeRawBytes() { ViewPort.Edit("@40 ^table[a:: b:: c:: d::]20 "); var menuItem = ViewPort.GetContextMenuItems(new Point(0, 0)).Single(item => item.Text == "Clear Format"); menuItem.Command.Execute(); Assert.Equal(0, ViewPort.MinimumScroll); Assert.Equal(4, ViewPort.ScrollValue); Assert.Equal(0x20 - 1, ViewPort.MaximumScroll); }
public void ClearTable_CheckTableTool_NoTable() { CreateTextTable("names", 0, "adam", "bob", "carl", "dave"); ViewPort.Goto.Execute(0); ViewPort.GetContextMenuItems(new Point(0, 0)) .Single(item => item.Text == "Clear Format") .Command.Execute(); var tableTool = ViewPort.Tools.TableTool; Assert.Equal(0, tableTool.Address); Assert.Empty(tableTool.Children); }
public void TextBytes_FormatAsText_CanUndo() { "FF EB D5 ED AB FF".ToByteArray().WriteInto(Model.RawData, 0); Model.WritePointer(new ModelDelta(), 6, 1); // needs a pointer in order to get recognized by the algorithm var watcher = new CommandWatcher(ViewPort.Undo); ViewPort.SelectionStart = new Point(1, 0); var items = ViewPort.GetContextMenuItems(ViewPort.SelectionStart); items = (ContextItemGroup)items.Single(item => item.Text == "Display As..."); items.Single(item => item.Text == "Text").Command.Execute(); Assert.True(watcher.LastCanExecute); }
public void DisplayAsText_PreviousByteRandom_StillFindTextStartingHere() { PCSString.Convert("Some Content").WriteInto(Model.RawData, 0x21); Model.WritePointer(new ModelDelta(), 3, 0x21); ViewPort.Goto.Execute(0x21); var menu = ViewPort.GetContextMenuItems(ViewPort.SelectionStart); menu = menu.GetSubmenu("Display As..."); var displayText = menu.Single(item => item.Text == "Text"); displayText.Command.Execute(); Assert.IsType <PCSRun>(Model.GetNextRun(0x21)); }
public void CanCreateXseScriptFromContextMenu() { Model[0x22] = 0xFF; ViewPort.Refresh(); ViewPort.SelectionStart = new Point(2, 2); var group = (ContextItemGroup)ViewPort.GetContextMenuItems(new Point(2, 2)).Single(cmi => cmi.Text == "Create New..."); var item = group.Single(cmi => cmi.Text == "Event Script"); item.Command.Execute(); Assert.Equal(ViewPort.Tools.CodeTool, ViewPort.Tools.SelectedTool); Assert.Equal(CodeMode.Script, ViewPort.Tools.CodeTool.Mode); Assert.EndsWith("end", ViewPort.Tools.CodeTool.Contents.Single().Content.Trim()); Assert.IsType <XSERun>(Model.GetNextRun(0x22)); var anchorName = Model.GetAnchorFromAddress(-1, 0x22); Assert.NotEmpty(anchorName); Assert.Equal(anchorName, ViewPort.AnchorText.Substring(ViewPort.AnchorTextSelectionStart, ViewPort.AnchorTextSelectionLength)); }
public void TableToolNotOfferedOnNormalText() { // Arrange var data = Enumerable.Range(0, 0x200).Select(i => (byte)0xFF).ToArray(); var model = new PokemonModel(data); var viewPort = new ViewPort("name.txt", model) { Width = 0x10, Height = 0x10 }; viewPort.Edit("^array[name\"\"16]3 "); viewPort.SelectionStart = new Point(0, 4); viewPort.Edit("^text\"\" Some Text\""); // Act viewPort.SelectionStart = new Point(2, 4); var items = viewPort.GetContextMenuItems(viewPort.SelectionStart); // Assert var matches = items.Where(item => item.Text.Contains("Table")); Assert.Empty(matches); }