From 43477eb4b899b1e2aab126e2ddee2416660bb1ba Mon Sep 17 00:00:00 2001 From: Benjamin Popp Date: Tue, 16 Apr 2019 09:06:16 -0500 Subject: [PATCH] make it easier to change items in the item table - typing a closing " closes the element - newline or selection change closes the element --- src/HexManiac.Core/ViewModels/ViewPort.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/HexManiac.Core/ViewModels/ViewPort.cs b/src/HexManiac.Core/ViewModels/ViewPort.cs index 1c6d2c83..c9820e99 100644 --- a/src/HexManiac.Core/ViewModels/ViewPort.cs +++ b/src/HexManiac.Core/ViewModels/ViewPort.cs @@ -133,7 +133,9 @@ namespace HavenSoft.HexManiac.Core.ViewModels { var element = currentView[location.X, location.Y]; var underEdit = element.Format as UnderEdit; if (underEdit != null) { - currentView[location.X, location.Y] = new HexElement(element.Value, underEdit.Edit(" ")); + var endEdit = " "; + if (underEdit.CurrentText.Count(c => c == '"') % 2 == 1) endEdit = "\""; + currentView[location.X, location.Y] = new HexElement(element.Value, underEdit.Edit(endEdit)); if (!TryCompleteEdit(location)) ClearEdits(location); } } @@ -1035,11 +1037,17 @@ namespace HavenSoft.HexManiac.Core.ViewModels { return false; } else if (originalFormat is IntegerEnum integerEnum) { var currentText = underEdit.CurrentText; - // must end in whitespace, and must have matching quotation marks (ex. "Mr. Mime") - if (char.IsWhiteSpace(currentText.Last()) && currentText.Count(c => c == '"') % 2 == 0) { + + // must end in whitespace or must have matching quotation marks (ex. "Mr. Mime") + var quoteCount = currentText.Count(c => c == '"'); + if (quoteCount == 2) { + CompleteIntegerEnumEdit(point, currentText); + return true; + } else if (quoteCount == 0 && char.IsWhiteSpace(currentText.Last())) { CompleteIntegerEnumEdit(point, currentText); return true; } + return false; }