From 7f06fdc079f5920a3e604f756498b4e225711305 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 21 Oct 2018 17:51:07 -0700 Subject: [PATCH] Define a max asm column width --- SourceGen/AppForms/EditAppSettings.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/SourceGen/AppForms/EditAppSettings.cs b/SourceGen/AppForms/EditAppSettings.cs index ddb07e1..b45d779 100644 --- a/SourceGen/AppForms/EditAppSettings.cs +++ b/SourceGen/AppForms/EditAppSettings.cs @@ -428,22 +428,29 @@ namespace SourceGen.AppForms { } private AssemblerConfig GetAsmConfigFromUi() { + const int MIN_WIDTH = 1; + const int MAX_WIDTH = 200; + int[] widths = new int[4]; for (int i = 0; i < widths.Length; i++) { - widths[i] = 1; // minimum width for all fields is 1 + widths[i] = MIN_WIDTH; } int result; - if (int.TryParse(asmLabelColWidthTextBox.Text, out result) && result > 0) { + if (int.TryParse(asmLabelColWidthTextBox.Text, out result) && result >= MIN_WIDTH && + result <= MAX_WIDTH) { widths[0] = result; } - if (int.TryParse(asmOpcodeColWidthTextBox.Text, out result) && result > 0) { + if (int.TryParse(asmOpcodeColWidthTextBox.Text, out result) && result >= MIN_WIDTH && + result <= MAX_WIDTH) { widths[1] = result; } - if (int.TryParse(asmOperandColWidthTextBox.Text, out result) && result > 0) { + if (int.TryParse(asmOperandColWidthTextBox.Text, out result) && result >= MIN_WIDTH && + result <= MAX_WIDTH) { widths[2] = result; } - if (int.TryParse(asmCommentColWidthTextBox.Text, out result) && result > 0) { + if (int.TryParse(asmCommentColWidthTextBox.Text, out result) && result >= MIN_WIDTH && + result <= MAX_WIDTH) { widths[3] = result; }