Skip to content

Commit

Permalink
Truncate frame titles as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Nov 24, 2017
1 parent e829579 commit cb9272c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ConsoleUI/Toolkit/ConsoleFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ public override void Draw(bool focused)
Console.SetCursorPosition(l, t);
Console.Write(doubleBorder ? Symbols.upperLeftCornerDouble : Symbols.upperLeftCorner);
if (title.Length > 0) {
int topLeftSidePad = (w - 4 - title.Length) / 2;
int topLeftSidePad = (w - 4 - title.Length) / 2;
int topRightSidePad = (w - 4 - title.Length) - topLeftSidePad;
if (topLeftSidePad < 0) {
topLeftSidePad = 0;
}
if (topRightSidePad < 0) {
if (topLeftSidePad < 0 || topRightSidePad < 0) {
topLeftSidePad = 0;
topRightSidePad = 0;
title = title.Substring(0, w - 4);
}
Console.Write(new string(doubleBorder ? Symbols.horizLineDouble : Symbols.horizLine, topLeftSidePad));
Console.Write($" {title} ");
Expand Down

0 comments on commit cb9272c

Please sign in to comment.