/// <summary> /// Sets the text style to Bold and White. /// </summary> /// <param name="value">The value.</param> /// <returns>TextSpan.</returns> public static TextSpan BoldWhite(this string value) => new ContainerSpan( ForegroundColorSpan.White(), StyleSpan.BoldOn(), new ContentSpan(value), StyleSpan.BoldOff(), ForegroundColorSpan.Reset());
public DirectoryView(DirectoryInfo directory) { if (directory == null) { throw new ArgumentNullException(nameof(directory)); } var formatter = new SpanFormatter(); formatter.AddFormatter <DateTime>(d => $"{d:d} {ForegroundColorSpan.DarkGray()}{d:t}"); Add(new ContentView("")); Add(new ContentView("")); Add(new ContentView($"Directory: {directory.FullName}")); Add(new ContentView("")); Add(new ContentView("")); var directoryContents = directory.EnumerateFileSystemInfos() .OrderBy(f => f is DirectoryInfo ? 0 : 1).ToList(); var tableView = new TableView <FileSystemInfo>(); tableView.Items = directoryContents; tableView.AddColumn(f => f is DirectoryInfo ? Span($"{ForegroundColorSpan.LightGreen()}{f.Name} ") : Span($"{ForegroundColorSpan.White()}{f.Name} "), new ContentView(formatter.ParseToSpan($"{Ansi.Text.UnderlinedOn}Name{Ansi.Text.UnderlinedOff}"))); tableView.AddColumn(f => formatter.Format(f.CreationTime), new ContentView(formatter.ParseToSpan($"{Ansi.Text.UnderlinedOn}Created{Ansi.Text.UnderlinedOff}"))); tableView.AddColumn(f => formatter.Format(f.LastWriteTime), new ContentView(formatter.ParseToSpan($"{Ansi.Text.UnderlinedOn}Modified{Ansi.Text.UnderlinedOff}"))); Add(tableView); Span Span(FormattableString formattableString) { return(formatter.ParseToSpan(formattableString)); } }
public static Span White(this string value) => new ContainerSpan(ForegroundColorSpan.White(), new ContentSpan(value), ForegroundColorSpan.Reset());