|
@@ -38,7 +38,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -54,7 +54,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -71,7 +71,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -87,7 +87,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -105,7 +105,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -122,7 +122,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -135,13 +135,14 @@ namespace Terminal.Gui {
|
|
|
/// <param name="message">Message to display, might contain multiple lines.</param>
|
|
|
/// <param name="defaultButton">Index of the default button.</param>
|
|
|
/// <param name="border">The border settings.</param>
|
|
|
+ /// <param name="wrapMessagge">If wrap the message or not.</param>
|
|
|
/// <param name="buttons">Array of buttons to add.</param>
|
|
|
/// <remarks>
|
|
|
/// Use <see cref="Query(ustring, ustring, ustring[])"/> instead; it automatically sizes the MessageBox based on the contents.
|
|
|
/// </remarks>
|
|
|
- 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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -152,14 +153,15 @@ namespace Terminal.Gui {
|
|
|
/// <param name="message">Message to display, might contain multiple lines.</param>
|
|
|
/// <param name="defaultButton">Index of the default button.</param>
|
|
|
/// <param name="border">The border settings.</param>
|
|
|
+ /// <param name="wrapMessagge">If wrap the message or not.</param>
|
|
|
/// <param name="buttons">Array of buttons to add.</param>
|
|
|
/// <remarks>
|
|
|
/// 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.
|
|
|
/// </remarks>
|
|
|
- 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 +180,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -195,7 +197,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -208,13 +210,14 @@ namespace Terminal.Gui {
|
|
|
/// <param name="message">Message to display, might contain multiple lines.</param>
|
|
|
/// <param name="defaultButton">Index of the default button.</param>
|
|
|
/// <param name="border">The border settings.</param>
|
|
|
+ /// <param name="wrapMessagge">If wrap the message or not.</param>
|
|
|
/// <param name="buttons">Array of buttons to add.</param>
|
|
|
/// <remarks>
|
|
|
/// Use <see cref="ErrorQuery(ustring, ustring, ustring[])"/> instead; it automatically sizes the MessageBox based on the contents.
|
|
|
/// </remarks>
|
|
|
- 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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -225,25 +228,26 @@ namespace Terminal.Gui {
|
|
|
/// <param name="message">Message to display, might contain multiple lines.</param>
|
|
|
/// <param name="defaultButton">Index of the default button.</param>
|
|
|
/// <param name="border">The border settings.</param>
|
|
|
+ /// <param name="wrapMessagge">If wrap the message or not.</param>
|
|
|
/// <param name="buttons">Array of buttons to add.</param>
|
|
|
/// <remarks>
|
|
|
/// 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.
|
|
|
/// </remarks>
|
|
|
- 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 +255,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<Button> buttonList = new List<Button> ();
|
|
@@ -273,22 +281,24 @@ namespace Terminal.Gui {
|
|
|
// Create Dialog (retain backwards compat by supporting specifying height/width)
|
|
|
Dialog d;
|
|
|
if (width == 0 & height == 0) {
|
|
|
- d = new Dialog (title, buttonList.ToArray ()) {
|
|
|
+ d = new Dialog (title, border, buttonList.ToArray ()) {
|
|
|
Height = msgboxHeight
|
|
|
};
|
|
|
} else {
|
|
|
- d = new Dialog (title, width, Math.Max (height, 4), buttonList.ToArray ());
|
|
|
- }
|
|
|
-
|
|
|
- if (border != null) {
|
|
|
- d.Border = border;
|
|
|
+ d = new Dialog (title, width, Math.Max (height, 4), border, buttonList.ToArray ());
|
|
|
}
|
|
|
|
|
|
if (useErrorColors) {
|
|
|
d.ColorScheme = Colors.Error;
|
|
|
+ d.Border.BorderBrush = Colors.Error.Normal.Foreground;
|
|
|
+ d.Border.Background = Colors.Error.Normal.Background;
|
|
|
+ } else {
|
|
|
+ d.ColorScheme = Colors.Dialog;
|
|
|
+ d.Border.BorderBrush = Colors.Dialog.Normal.Foreground;
|
|
|
+ d.Border.Background = Colors.Dialog.Normal.Background;
|
|
|
}
|
|
|
|
|
|
- if (message != null) {
|
|
|
+ if (!ustring.IsNullOrEmpty (message)) {
|
|
|
var l = new Label (message) {
|
|
|
LayoutStyle = LayoutStyle.Computed,
|
|
|
TextAlignment = TextAlignment.Centered,
|
|
@@ -303,7 +313,12 @@ namespace Terminal.Gui {
|
|
|
|
|
|
if (width == 0 & height == 0) {
|
|
|
// Dynamically size Width
|
|
|
- d.Width = Math.Min (Math.Max (maxWidthLine, Math.Max (title.ConsoleWidth, Math.Max (textWidth + 2, d.GetButtonsWidth () + d.buttons.Count + 2))), Application.Driver.Cols); // textWidth + (left + padding + padding + right)
|
|
|
+ var dWidth = Math.Max (maxWidthLine, Math.Max (title.ConsoleWidth, Math.Max (textWidth + 2, d.GetButtonsWidth () + d.buttons.Count + 2))); // textWidth + (left + padding + padding + right)
|
|
|
+ if (wrapMessagge) {
|
|
|
+ d.Width = Math.Min (dWidth, Application.Driver.Cols);
|
|
|
+ } else {
|
|
|
+ d.Width = dWidth;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Setup actions
|