mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-05-31 20:42:43 -05:00
Add headers to tables with named elements
This commit is contained in:
parent
f55991e85a
commit
bfeed682d4
|
|
@ -1,4 +1,5 @@
|
|||
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
|
||||
using HavenSoft.HexManiac.Core.ViewModels;
|
||||
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -55,6 +56,7 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
|||
}
|
||||
|
||||
public static void AppendTo(ITableRun self, IDataModel data, StringBuilder text, int start, int length, bool deep) {
|
||||
var names = self.ElementNames;
|
||||
var offsets = self.ConvertByteOffsetToArrayOffset(start);
|
||||
length += offsets.SegmentOffset;
|
||||
for (int i = offsets.ElementIndex; i < self.ElementCount && length > 0; i++) {
|
||||
|
|
@ -62,6 +64,10 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
|||
if (offsets.SegmentIndex == 0 && offsets.ElementIndex > 0) text.Append(ArrayRun.ExtendArray);
|
||||
for (int j = offsets.SegmentIndex; j < self.ElementContent.Count && length > 0; j++) {
|
||||
var segment = self.ElementContent[j];
|
||||
if (j == 0 && segment.Type != ElementContentType.PCS && names != null && names.Count > i && !string.IsNullOrEmpty(names[i])) {
|
||||
text.Append($"{ViewPort.CommentStart}{names[i]}{ViewPort.CommentStart}, ");
|
||||
}
|
||||
|
||||
text.Append(segment.ToText(data, offset, deep).Trim());
|
||||
if (j + 1 < self.ElementContent.Count) text.Append(", ");
|
||||
offset += segment.Length;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using HavenSoft.HexManiac.Core.ViewModels;
|
||||
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
|
||||
|
||||
namespace HavenSoft.HexManiac.Core.Models.Runs {
|
||||
|
|
@ -143,6 +144,10 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
|||
tokens[i] = tokens[i].Substring(0, tokens[i].Length - 1);
|
||||
}
|
||||
|
||||
// remove comments
|
||||
var comment = ViewPort.CommentStart.ToString();
|
||||
tokens = tokens.Where(token => !token.StartsWith(comment)).ToList();
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace HavenSoft.HexManiac.Tests {
|
|||
var menuItem = ViewPort.GetContextMenuItems(ViewPort.SelectionStart).Single(item => item.Text == "Deep Copy");
|
||||
menuItem.Command.Execute(fileSystem);
|
||||
|
||||
Assert.Equal(@"^table[pointer<"""">]1 @{ ""Hello World!"" @}", fileSystem.CopyText);
|
||||
Assert.Equal(@"^table[pointer<"""">]1 #""Hello World!""#, @{ ""Hello World!"" @}", fileSystem.CopyText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user