diff --git a/Terminal.Gui/Windows/MessageBox.cs b/Terminal.Gui/Windows/MessageBox.cs index 4f509f146..915d1b3cc 100644 --- a/Terminal.Gui/Windows/MessageBox.cs +++ b/Terminal.Gui/Windows/MessageBox.cs @@ -38,7 +38,7 @@ namespace Terminal.Gui { /// public static int Query (int width, int height, ustring title, ustring message, params ustring [] buttons) { - return QueryFull (false, width, height, title, message, 0, null, buttons); + return QueryFull (false, width, height, title, message, 0, null, true, buttons); } /// @@ -54,7 +54,7 @@ namespace Terminal.Gui { /// public static int Query (ustring title, ustring message, params ustring [] buttons) { - return QueryFull (false, 0, 0, title, message, 0, null, buttons); + return QueryFull (false, 0, 0, title, message, 0, null, true, buttons); } /// @@ -71,7 +71,7 @@ namespace Terminal.Gui { /// public static int ErrorQuery (int width, int height, ustring title, ustring message, params ustring [] buttons) { - return QueryFull (true, width, height, title, message, 0, null, buttons); + return QueryFull (true, width, height, title, message, 0, null, true, buttons); } /// @@ -87,7 +87,7 @@ namespace Terminal.Gui { /// public static int ErrorQuery (ustring title, ustring message, params ustring [] buttons) { - return QueryFull (true, 0, 0, title, message, 0, null, buttons); + return QueryFull (true, 0, 0, title, message, 0, null, true, buttons); } /// @@ -105,7 +105,7 @@ namespace Terminal.Gui { /// public static int Query (int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring [] buttons) { - return QueryFull (false, width, height, title, message, defaultButton, null, buttons); + return QueryFull (false, width, height, title, message, defaultButton, null, true, buttons); } /// @@ -122,7 +122,7 @@ namespace Terminal.Gui { /// public static int Query (ustring title, ustring message, int defaultButton = 0, params ustring [] buttons) { - return QueryFull (false, 0, 0, title, message, defaultButton, null, buttons); + return QueryFull (false, 0, 0, title, message, defaultButton, null, true, buttons); } /// @@ -139,9 +139,9 @@ namespace Terminal.Gui { /// /// Use instead; it automatically sizes the MessageBox based on the contents. /// - public static int Query (int width, int height, ustring title, ustring message, int defaultButton = 0, Border border = null, params ustring [] buttons) + public static int Query (int width, int height, ustring title, ustring message, int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons) { - return QueryFull (false, width, height, title, message, defaultButton, border, buttons); + return QueryFull (false, width, height, title, message, defaultButton, border, wrapMessagge, buttons); } /// @@ -157,9 +157,9 @@ namespace Terminal.Gui { /// The message box will be vertically and horizontally centered in the container and the size will be automatically determined /// from the size of the message and buttons. /// - public static int Query (ustring title, ustring message, int defaultButton = 0, Border border = null, params ustring [] buttons) + public static int Query (ustring title, ustring message, int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons) { - return QueryFull (false, 0, 0, title, message, defaultButton, border, buttons); + return QueryFull (false, 0, 0, title, message, defaultButton, border, wrapMessagge, buttons); } @@ -178,7 +178,7 @@ namespace Terminal.Gui { /// public static int ErrorQuery (int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring [] buttons) { - return QueryFull (true, width, height, title, message, defaultButton, null, buttons); + return QueryFull (true, width, height, title, message, defaultButton, null, true, buttons); } /// @@ -195,7 +195,7 @@ namespace Terminal.Gui { /// public static int ErrorQuery (ustring title, ustring message, int defaultButton = 0, params ustring [] buttons) { - return QueryFull (true, 0, 0, title, message, defaultButton, null, buttons); + return QueryFull (true, 0, 0, title, message, defaultButton, null, true, buttons); } /// @@ -212,9 +212,9 @@ namespace Terminal.Gui { /// /// Use instead; it automatically sizes the MessageBox based on the contents. /// - public static int ErrorQuery (int width, int height, ustring title, ustring message, int defaultButton = 0, Border border = null, params ustring [] buttons) + public static int ErrorQuery (int width, int height, ustring title, ustring message, int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons) { - return QueryFull (true, width, height, title, message, defaultButton, border, buttons); + return QueryFull (true, width, height, title, message, defaultButton, border, wrapMessagge, buttons); } /// @@ -230,20 +230,20 @@ namespace Terminal.Gui { /// The message box will be vertically and horizontally centered in the container and the size will be automatically determined /// from the size of the title, message. and buttons. /// - public static int ErrorQuery (ustring title, ustring message, int defaultButton = 0, Border border = null, params ustring [] buttons) + public static int ErrorQuery (ustring title, ustring message, int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons) { - return QueryFull (true, 0, 0, title, message, defaultButton, border, buttons); + return QueryFull (true, 0, 0, title, message, defaultButton, border, wrapMessagge, buttons); } static int QueryFull (bool useErrorColors, int width, int height, ustring title, ustring message, - int defaultButton = 0, Border border = null, params ustring [] buttons) + int defaultButton = 0, Border border = null, bool wrapMessagge = true, params ustring [] buttons) { int defaultWidth = 50; if (defaultWidth > Application.Driver.Cols / 2) { defaultWidth = (int)(Application.Driver.Cols * 0.60f); } int maxWidthLine = TextFormatter.MaxWidthLine (message); - if (maxWidthLine > Application.Driver.Cols) { + if (wrapMessagge && maxWidthLine > Application.Driver.Cols) { maxWidthLine = Application.Driver.Cols; } if (width == 0) { @@ -251,10 +251,14 @@ namespace Terminal.Gui { } else { maxWidthLine = width; } - int textWidth = Math.Min (TextFormatter.MaxWidth (message, maxWidthLine), Application.Driver.Cols); + int textWidth = TextFormatter.MaxWidth (message, maxWidthLine); int textHeight = TextFormatter.MaxLines (message, textWidth); // message.Count (ustring.Make ('\n')) + 1; - int msgboxHeight = Math.Min (Math.Max (1, textHeight) + 4, Application.Driver.Rows); // textHeight + (top + top padding + buttons + bottom) + int msgboxHeight = Math.Max (1, textHeight) + 4; // textHeight + (top + top padding + buttons + bottom) + if (wrapMessagge) { + textWidth = Math.Min (textWidth, Application.Driver.Cols); + msgboxHeight = Math.Min (msgboxHeight, Application.Driver.Rows); + } // Create button array for Dialog int count = 0; List