mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 09:18:01 +01:00
Added unicode symbols option to UICatalog
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NStack;
|
||||
|
||||
namespace Terminal.Gui {
|
||||
|
||||
@@ -892,13 +893,13 @@ namespace Terminal.Gui {
|
||||
string lineBody = tree.AspectGetter(Model);
|
||||
|
||||
// How much space is left after prefix and expansion symbol?
|
||||
var remainingWidth = availableWidth - (prefix.Length + 1 );
|
||||
var remainingWidth = availableWidth - (prefix.Sum(Rune.ColumnWidth) + Rune.ColumnWidth(expansion) );
|
||||
|
||||
// If body of line is too long
|
||||
if(lineBody.Length > remainingWidth)
|
||||
if(lineBody.Sum(l=>Rune.ColumnWidth(l)) > remainingWidth)
|
||||
{
|
||||
// remaining space is zero and truncate the line
|
||||
lineBody = lineBody.Substring(0,remainingWidth);
|
||||
lineBody = new string(lineBody.TakeWhile(c=>(remainingWidth -= Rune.ColumnWidth(c)) > 0).ToArray());
|
||||
remainingWidth = 0;
|
||||
}
|
||||
else{
|
||||
@@ -909,8 +910,9 @@ namespace Terminal.Gui {
|
||||
|
||||
tree.Move(0,y);
|
||||
|
||||
foreach(Rune r in prefix)
|
||||
foreach(Rune r in prefix){
|
||||
driver.AddRune(r);
|
||||
}
|
||||
|
||||
// pick color for expanded symbol
|
||||
if(tree.Style.ColorExpandSymbol || tree.Style.InvertExpandSymbolColors)
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace UICatalog.Scenarios {
|
||||
private MenuItem miNoSymbols;
|
||||
private MenuItem miColoredSymbols;
|
||||
private MenuItem miInvertSymbols;
|
||||
private MenuItem miUnicodeSymbols;
|
||||
private Terminal.Gui.Attribute green;
|
||||
private Terminal.Gui.Attribute red;
|
||||
|
||||
@@ -51,6 +52,7 @@ namespace UICatalog.Scenarios {
|
||||
miPlusMinus = new MenuItem ("_PlusMinusSymbols", "", () => SetExpandableSymbols('+','-')){Checked = true, CheckType = MenuItemCheckStyle.Radio},
|
||||
miArrowSymbols = new MenuItem ("_ArrowSymbols", "", () => SetExpandableSymbols('>','v')){Checked = false, CheckType = MenuItemCheckStyle.Radio},
|
||||
miNoSymbols = new MenuItem ("_NoSymbols", "", () => SetExpandableSymbols(null,null)){Checked = false, CheckType = MenuItemCheckStyle.Radio},
|
||||
miUnicodeSymbols = new MenuItem ("_Unicode", "", () => SetExpandableSymbols('ஹ','﷽')){Checked = false, CheckType = MenuItemCheckStyle.Radio},
|
||||
null /*separator*/,
|
||||
miColoredSymbols = new MenuItem ("_ColoredSymbols", "", () => ShowColoredExpandableSymbols()){Checked = false, CheckType = MenuItemCheckStyle.Checked},
|
||||
miInvertSymbols = new MenuItem ("_InvertSymbols", "", () => InvertExpandableSymbols()){Checked = false, CheckType = MenuItemCheckStyle.Checked},
|
||||
@@ -143,6 +145,7 @@ namespace UICatalog.Scenarios {
|
||||
miPlusMinus.Checked = expand == '+';
|
||||
miArrowSymbols.Checked = expand == '>';
|
||||
miNoSymbols.Checked = expand == null;
|
||||
miUnicodeSymbols.Checked = expand == 'ஹ';
|
||||
|
||||
treeViewNodes.Style.ExpandableSymbol = expand;
|
||||
treeViewNodes.Style.CollapseableSymbol = collapse;
|
||||
|
||||
Reference in New Issue
Block a user