mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Make title pretty and informative
This commit is contained in:
@@ -425,7 +425,19 @@ namespace Terminal.Gui {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var padding = ((bounds.Width - this.Title.Sum (c => Rune.ColumnWidth (c))) / 2) - 1;
|
var title = this.Title.ToString ();
|
||||||
|
var titleWidth = title.Sum (c => Rune.ColumnWidth (c));
|
||||||
|
|
||||||
|
if (titleWidth > bounds.Width) {
|
||||||
|
title = title.Substring (0, bounds.Width);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(titleWidth +2 < bounds.Width) {
|
||||||
|
title = '╡' + this.Title.ToString () + '╞';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var padding = ((bounds.Width - title.Sum (c => Rune.ColumnWidth (c))) / 2) - 1;
|
||||||
|
|
||||||
padding = Math.Min (bounds.Width, padding);
|
padding = Math.Min (bounds.Width, padding);
|
||||||
padding = Math.Max (0, padding);
|
padding = Math.Max (0, padding);
|
||||||
@@ -437,7 +449,7 @@ namespace Terminal.Gui {
|
|||||||
|
|
||||||
Driver.SetAttribute (
|
Driver.SetAttribute (
|
||||||
new Attribute (this.ColorScheme.Normal.Foreground, this.ColorScheme.Normal.Background));
|
new Attribute (this.ColorScheme.Normal.Foreground, this.ColorScheme.Normal.Background));
|
||||||
Driver.AddStr (this.Title);
|
Driver.AddStr (title);
|
||||||
|
|
||||||
Driver.SetAttribute (
|
Driver.SetAttribute (
|
||||||
new Attribute (this.ColorScheme.Normal.Foreground, this.ColorScheme.Normal.Background));
|
new Attribute (this.ColorScheme.Normal.Foreground, this.ColorScheme.Normal.Background));
|
||||||
@@ -492,13 +504,13 @@ namespace Terminal.Gui {
|
|||||||
if (ustring.IsNullOrEmpty (Title)) {
|
if (ustring.IsNullOrEmpty (Title)) {
|
||||||
switch (OpenMode) {
|
switch (OpenMode) {
|
||||||
case OpenMode.File:
|
case OpenMode.File:
|
||||||
this.Title = " OPEN FILE ";
|
this.Title = $" OPEN {(MustExist ? "EXISTING ":"")}FILE ";
|
||||||
break;
|
break;
|
||||||
case OpenMode.Directory:
|
case OpenMode.Directory:
|
||||||
this.Title = " OPEN DIRECTORY ";
|
this.Title = $" OPEN {(MustExist ? "EXISTING " : "")}DIRECTORY ";
|
||||||
break;
|
break;
|
||||||
case OpenMode.Mixed:
|
case OpenMode.Mixed:
|
||||||
this.Title = " OPEN ";
|
this.Title = $" OPEN {(MustExist ? "EXISTING":"")}";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user