From 52ea9507dd7b2d7b584e666f5aaf5497bf8cbdbe Mon Sep 17 00:00:00 2001 From: Thomas Nind <31306100+tznind@users.noreply.github.com> Date: Fri, 11 Aug 2023 13:58:55 +0100 Subject: [PATCH] True Color File Icons (Requires True Color branch) (#2736) * Added ClipRegion; cleaned up driver code * clip region unit tests * api docs * Moved color stuff from ConsoleDriver to Color.cs * Removes unused ConsoleDriver APIs * Code cleanup and Removes unused ConsoleDriver APIs * Code cleanup and Removes unused ConsoleDriver APIs * Work around https://github.com/gui-cs/Terminal.Gui/issues/2610 * adjusted unit tests * initial commit * Made Rows, Cols, Top, Left virtual * Made Clipboard non-virtual * Made EnableConsoleScrolling non-virtual * Made Contents non-virtual * Pulled Row/Col up * Made MoveTo virtual; fixed stupid FakeDriver cursor issue * Made CurrentAttribute non-virtual * Made SetAttribute non-virtual * Moved clipboard code out * Code cleanup * Removes dependecy on NStack from ConsoleDrivers - WIP * Fixed unit tests * Fixed unit tests * Added list of unit tests needed * Did some perf testing; tweaked code and charmap to address * Brough in code from PR #2264 (but commented) * Tons of code cleanup * Fighting with ScrollView * Fixing bugs * Fixed TabView tests * Fixed View.Visible test that was not really working * Fixed unit tests * Cleaned up clipboard APIs in attempt to track down unit test failure * Add Cut_Preserves_Selection test * Removed invalid code * Removed invalid test code; unit tests now pass * EscSeq* - Adjusted naming, added more sequences, made code more consistent, simplified, etc... * Added CSI_SetGraphicsRendition * NetDriver code cleanup * code cleanup * Cleaned up color handling in NetDriver * refixed tabview unit test * WindowsDriver color code cleanup * WindowsDriver color code cleanup * CursesDriver color code cleanup * CursesDriver - Adding _BOLD has no effect. Further up the stack we cast the return of ColorToCursesColor from int to short and the _BOLD values don't fit in a short. * CursesDriver color code - make code more accurate * CursesDriver color code - make code more accurate * Simplified ConsoleDriver.GetColors API * Simplified ConsoleDriver.GetColors API further * Improved encapslation of Attribute; prep for TrueColor & other attributes like blink * Fixes #2249. CharacterMap isn't refreshing well non-BMP code points on scroll. * Use GetRange to take some of the runes before convert to string. * Attempting to fix unit tests not being cleaned up * Fixes #2658 - ConsoleDriver.IsRuneSupported * Fixes #2658 - ConsoleDriver.IsRuneSupported (for WindowsDriver) * Check all the range values and not only the max value. * Reducing code. * Fixes #2674 - Unit test process doesn't exit * Changed Cell to support IsDirty and list of Runes * add support for rendering TrueColor output on Windows merging veeman & tznind code * add colorconverter changes * fixed merged v2_develop * Fixing merge bugs * Fixed merge bugs * Add outline for FileSystemColorProvider * Add other known folders * Added remaining cases and test for file colors * Use color provider in FileDialog * Fix default color when UseColors to white * Remove `TestDirectoryContents_Windows_Colors` * Remove unused helper method * Fix formatting * Fixed merge bugs - all unit tests pass * Debugging netdriver * More netdriver diag * API docs for escutils * Update unicode scenario to stress more stuff * Contents: Now a 2D array of Cells; WIP * AddRune and ClearContents no longer virtual/abstract * WindowsDriver renders correctly again * Progress on Curses * Progress on Curses * broke windowsdriver * Cleaned up FakeMainLoop * Cleaned up some build warnings * Removed _init from AutoInitShutdown as it's not needed anymore * Removed unused var * Removed unused var * Fixed nullabiltiy warning in LineCanvas * Fixed charmap crash * Fixes #2758 in v2 * Remove accidentally re-added test * Removed unit test xml file * Remove redundant test --------- Co-authored-by: Tig Kindel Co-authored-by: BDisp Co-authored-by: adstep --- Terminal.Gui/FileServices/FileDialogStyle.cs | 58 +-- Terminal.Gui/Views/FileDialog.cs | 24 +- Terminal.Gui/Views/FileSystemColorProvider.cs | 446 ++++++++++++++++++ UnitTests/FileServices/FileDialogTests.cs | 40 -- .../FileSystemColorProviderTests.cs | 14 + UnitTests/FileServices/NerdFontsTests.cs | 2 +- 6 files changed, 479 insertions(+), 105 deletions(-) create mode 100644 Terminal.Gui/Views/FileSystemColorProvider.cs create mode 100644 UnitTests/FileServices/FileSystemColorProviderTests.cs diff --git a/Terminal.Gui/FileServices/FileDialogStyle.cs b/Terminal.Gui/FileServices/FileDialogStyle.cs index 923dd6c795..b8d55430f3 100644 --- a/Terminal.Gui/FileServices/FileDialogStyle.cs +++ b/Terminal.Gui/FileServices/FileDialogStyle.cs @@ -45,34 +45,17 @@ public class FileDialogStyle { public FileSystemIconProvider IconProvider { get; set;} = new FileSystemIconProvider(); /// - /// Gets or sets the culture to use (e.g. for number formatting). - /// Defaults to . - /// - public CultureInfo Culture {get;set;} = CultureInfo.CurrentUICulture; - - /// - /// Sets a to use for directories rows of - /// the . - /// - public ColorScheme ColorSchemeDirectory { get; set; } - - /// - /// Sets a to use for file rows with an image extension - /// of the . Defaults to White text on Black background. - /// - public ColorScheme ColorSchemeImage { get; set; } - - /// - /// Sets a to use for file rows with an executable extension - /// or that match in the . + /// Gets or sets the class thatis responsible for determining which color + /// to use to represent files and directories when is + /// . /// - public ColorScheme ColorSchemeExeOrRecommended { get; set; } + public FileSystemColorProvider ColorProvider { get;set;} = new FileSystemColorProvider(); /// - /// Colors to use when is true but file does not match any other - /// classification (, etc). + /// Gets or sets the culture to use (e.g. for number formatting). + /// Defaults to . /// - public ColorScheme ColorSchemeOther { get; set; } + public CultureInfo Culture {get;set;} = CultureInfo.CurrentUICulture; /// /// Gets or sets the header text displayed in the Filename column of the files table. @@ -186,33 +169,6 @@ public FileDialogStyle (IFileSystem fileSystem) TreeRootGetter = DefaultTreeRootGetter; DateFormat = CultureInfo.CurrentCulture.DateTimeFormat.SortableDateTimePattern; - - ColorSchemeDirectory = new ColorScheme { - Normal = Application.Driver.MakeAttribute (Color.Blue, Color.Black), - HotNormal = Application.Driver.MakeAttribute (Color.Blue, Color.Black), - Focus = Application.Driver.MakeAttribute (Color.Black, Color.Blue), - HotFocus = Application.Driver.MakeAttribute (Color.Black, Color.Blue), - - }; - - ColorSchemeImage = new ColorScheme { - Normal = Application.Driver.MakeAttribute (Color.Magenta, Color.Black), - HotNormal = Application.Driver.MakeAttribute (Color.Magenta, Color.Black), - Focus = Application.Driver.MakeAttribute (Color.Black, Color.Magenta), - HotFocus = Application.Driver.MakeAttribute (Color.Black, Color.Magenta), - }; - ColorSchemeExeOrRecommended = new ColorScheme { - Normal = Application.Driver.MakeAttribute (Color.Green, Color.Black), - HotNormal = Application.Driver.MakeAttribute (Color.Green, Color.Black), - Focus = Application.Driver.MakeAttribute (Color.Black, Color.Green), - HotFocus = Application.Driver.MakeAttribute (Color.Black, Color.Green), - }; - ColorSchemeOther = new ColorScheme { - Normal = Application.Driver.MakeAttribute (Color.White, Color.Black), - HotNormal = Application.Driver.MakeAttribute (Color.White, Color.Black), - Focus = Application.Driver.MakeAttribute (Color.Black, Color.White), - HotFocus = Application.Driver.MakeAttribute (Color.Black, Color.White), - }; } diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index af7f77cc85..bf5b9adf2e 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -1172,20 +1172,18 @@ private ColorScheme ColorGetter (CellColorGetterArgs args) return tableView.ColorScheme; } - if (stats.IsDir ()) { - return Style.ColorSchemeDirectory; - } - if (stats.IsImage ()) { - return Style.ColorSchemeImage; - } - if (stats.IsExecutable ()) { - return Style.ColorSchemeExeOrRecommended; - } - if (stats.FileSystemInfo is IFileInfo f && this.MatchesAllowedTypes (f)) { - return Style.ColorSchemeExeOrRecommended; - } - return Style.ColorSchemeOther; + var color = Style.ColorProvider.GetTrueColor(stats.FileSystemInfo) + ?? TrueColor.FromConsoleColor(Color.White); + var black = TrueColor.FromConsoleColor(Color.Black); + + // TODO: Add some kind of cache for this + return new ColorScheme{ + Normal = new Attribute (color,black), + HotNormal = new Attribute (color, black), + Focus = new Attribute (black, color), + HotFocus = new Attribute (black, color), + }; } /// diff --git a/Terminal.Gui/Views/FileSystemColorProvider.cs b/Terminal.Gui/Views/FileSystemColorProvider.cs new file mode 100644 index 0000000000..42ae34c9bc --- /dev/null +++ b/Terminal.Gui/Views/FileSystemColorProvider.cs @@ -0,0 +1,446 @@ +// This code is adapted from https://github.com/devblackops/Terminal-Icons (which also uses the MIT license). + +using System.Collections.Generic; +using System.IO.Abstractions; + +namespace Terminal.Gui { + + + public class FileSystemColorProvider { + + + + public TrueColor? GetTrueColor (IFileSystemInfo file) + { + if (FilenameToColor.ContainsKey (file.Name)) { + return FilenameToColor [file.Name]; + } + + if (ExtensionToColor.ContainsKey (file.Extension)) { + return ExtensionToColor [file.Extension]; + } + + return null; + } + + /// + /// Mapping of file/dir name to color. + /// + public Dictionary FilenameToColor { get; set; } = new () + { + {"docs",StringToColor("#00BFFF")}, + {"documents",StringToColor("#00BFFF")}, + {"desktop",StringToColor("#00FBFF")}, + {"benchmark",StringToColor("#F08519")}, + {"demo",StringToColor("#5F3EC3")}, + {"samples",StringToColor("#5F3EC3")}, + {"contacts",StringToColor("#00FBFF")}, + {"apps",StringToColor("#FF143C")}, + {"applications",StringToColor("#FF143C")}, + {"artifacts",StringToColor("#D49653")}, + {"shortcuts",StringToColor("#FF143C")}, + {"links",StringToColor("#FF143C")}, + {"fonts",StringToColor("#DC143C")}, + {"images",StringToColor("#9ACD32")}, + {"photos",StringToColor("#9ACD32")}, + {"pictures",StringToColor("#9ACD32")}, + {"videos",StringToColor("#FFA500")}, + {"movies",StringToColor("#FFA500")}, + {"media",StringToColor("#D3D3D3")}, + {"music",StringToColor("#DB7093")}, + {"songs",StringToColor("#DB7093")}, + {"onedrive",StringToColor("#D3D3D3")}, + {"downloads",StringToColor("#D3D3D3")}, + {"src",StringToColor("#00FF7F")}, + {"development",StringToColor("#00FF7F")}, + {"projects",StringToColor("#00FF7F")}, + {"bin",StringToColor("#00FFF7")}, + {"tests",StringToColor("#87CEEB")}, + {"windows",StringToColor("#00A8E8")}, + {"users",StringToColor("#F4F4F4")}, + {"favorites",StringToColor("#F7D72C")}, + {"output",StringToColor("#00FF7F")}, + {".config",StringToColor("#87CEAF")}, + {".cache",StringToColor("#87ECAF")}, + {".vscode",StringToColor("#87CEFA")}, + {".vscode-insiders",StringToColor("#24BFA5")}, + {".git",StringToColor("#FF4500")}, + {".github",StringToColor("#C0C0C0")}, + {"github",StringToColor("#C0C0C0")}, + {"node_modules",StringToColor("#6B8E23")}, + {".terraform",StringToColor("#948EEC")}, + {".azure",StringToColor("#00BFFF")}, + {".aws",StringToColor("#EC912D")}, + {".kube",StringToColor("#326DE6")}, + {".docker",StringToColor("#2391E6")}, + {".gitattributes",StringToColor("#FF4500")}, + {".gitconfig",StringToColor("#FF4500")}, + {".gitignore",StringToColor("#FF4500")}, + {".gitmodules",StringToColor("#FF4500")}, + {".gitkeep",StringToColor("#FF4500")}, + {"git-history",StringToColor("#FF4500")}, + {"LICENSE",StringToColor("#CD5C5C")}, + {"LICENSE.md",StringToColor("#CD5C5C")}, + {"LICENSE.txt",StringToColor("#CD5C5C")}, + {"CHANGELOG.md",StringToColor("#98FB98")}, + {"CHANGELOG.txt",StringToColor("#98FB98")}, + {"CHANGELOG",StringToColor("#98FB98")}, + {"README.md",StringToColor("#00FFFF")}, + {"README.txt",StringToColor("#00FFFF")}, + {"README",StringToColor("#00FFFF")}, + {".DS_Store",StringToColor("#696969")}, + {".tsbuildinfo",StringToColor("#F4A460")}, + {".jscsrc",StringToColor("#F4A460")}, + {".jshintrc",StringToColor("#F4A460")}, + {"tsconfig.json",StringToColor("#F4A460")}, + {"tslint.json",StringToColor("#F4A460")}, + {"composer.lock",StringToColor("#F4A460")}, + {".jsbeautifyrc",StringToColor("#F4A460")}, + {".esformatter",StringToColor("#F4A460")}, + {"cdp.pid",StringToColor("#F4A460")}, + {".htaccess",StringToColor("#9ACD32")}, + {".jshintignore",StringToColor("#87CEEB")}, + {".buildignore",StringToColor("#87CEEB")}, + {".mrconfig",StringToColor("#87CEEB")}, + {".yardopts",StringToColor("#87CEEB")}, + {"manifest.mf",StringToColor("#87CEEB")}, + {".clang-format",StringToColor("#87CEEB")}, + {".clang-tidy",StringToColor("#87CEEB")}, + {"favicon.ico",StringToColor("#FFD700")}, + {".travis.yml",StringToColor("#FFE4B5")}, + {".gitlab-ci.yml",StringToColor("#FF4500")}, + {".jenkinsfile",StringToColor("#6495ED")}, + {"bitbucket-pipelines.yml",StringToColor("#87CEFA")}, + {"bitbucket-pipelines.yaml",StringToColor("#87CEFA")}, + {".azure-pipelines.yml",StringToColor("#00BFFF")}, + {"firebase.json",StringToColor("#FFA500")}, + {".firebaserc",StringToColor("#FFA500")}, + {".bowerrc",StringToColor("#CD5C5C")}, + {"bower.json",StringToColor("#CD5C5C")}, + {"code_of_conduct.md",StringToColor("#FFFFE0")}, + {"code_of_conduct.txt",StringToColor("#FFFFE0")}, + {"Dockerfile",StringToColor("#4682B4")}, + {"docker-compose.yml",StringToColor("#4682B4")}, + {"docker-compose.yaml",StringToColor("#4682B4")}, + {"docker-compose.dev.yml",StringToColor("#4682B4")}, + {"docker-compose.local.yml",StringToColor("#4682B4")}, + {"docker-compose.ci.yml",StringToColor("#4682B4")}, + {"docker-compose.override.yml",StringToColor("#4682B4")}, + {"docker-compose.staging.yml",StringToColor("#4682B4")}, + {"docker-compose.prod.yml",StringToColor("#4682B4")}, + {"docker-compose.production.yml",StringToColor("#4682B4")}, + {"docker-compose.test.yml",StringToColor("#4682B4")}, + {"vue.config.js",StringToColor("#778899")}, + {"vue.config.ts",StringToColor("#778899")}, + {"gulpfile.js",StringToColor("#CD5C5C")}, + {"gulpfile.ts",StringToColor("#CD5C5C")}, + {"gulpfile.babel.js",StringToColor("#CD5C5C")}, + {"gruntfile.js",StringToColor("#CD5C5C")}, + {"package.json",StringToColor("#6B8E23")}, + {"package-lock.json",StringToColor("#6B8E23")}, + {".nvmrc",StringToColor("#6B8E23")}, + {".esmrc",StringToColor("#6B8E23")}, + {".nmpignore",StringToColor("#00BFFF")}, + {".npmrc",StringToColor("#00BFFF")}, + {"authors",StringToColor("#FF6347")}, + {"authors.md",StringToColor("#FF6347")}, + {"authors.txt",StringToColor("#FF6347")}, + {".terraform.lock.hcl",StringToColor("#948EEC")}, + {"gradlew",StringToColor("#39D52D")}, + }; + + + /// + /// Mapping of file extension to color. + /// + public Dictionary ExtensionToColor = new () + { + {".7z",StringToColor("#DAA520")}, + {".bz",StringToColor("#DAA520")}, + {".tar",StringToColor("#DAA520")}, + {".zip",StringToColor("#DAA520")}, + {".gz",StringToColor("#DAA520")}, + {".xz",StringToColor("#DAA520")}, + {".br",StringToColor("#DAA520")}, + {".bzip2",StringToColor("#DAA520")}, + {".gzip",StringToColor("#DAA520")}, + {".brotli",StringToColor("#DAA520")}, + {".rar",StringToColor("#DAA520")}, + {".tgz",StringToColor("#DAA520")}, + {".bat",StringToColor("#008000")}, + {".cmd",StringToColor("#008000")}, + {".exe",StringToColor("#00FA9A")}, + {".pl",StringToColor("#8A2BE2")}, + {".sh",StringToColor("#FF4500")}, + {".msi",StringToColor("#FFC77A")}, + {".msix",StringToColor("#FFC77A")}, + {".msixbundle",StringToColor("#FFC77A")}, + {".appx",StringToColor("#FFC77A")}, + {".AppxBundle",StringToColor("#FFC77A")}, + {".deb",StringToColor("#FFC77A")}, + {".rpm",StringToColor("#FFC77A")}, + {".ps1",StringToColor("#00BFFF")}, + {".psm1",StringToColor("#00BFFF")}, + {".psd1",StringToColor("#00BFFF")}, + {".ps1xml",StringToColor("#00BFFF")}, + {".psc1",StringToColor("#00BFFF")}, + {".pssc",StringToColor("#00BFFF")}, + {".js",StringToColor("#F0E68C")}, + {".esx",StringToColor("#F0E68C")}, + {".mjs",StringToColor("#F0E68C")}, + {".java",StringToColor("#F89820")}, + {".jar",StringToColor("#F89820")}, + {".gradle",StringToColor("#39D52D")}, + {".py",StringToColor("#4B8BBE")}, + {".ipynb",StringToColor("#4B8BBE")}, + {".jsx",StringToColor("#20B2AA")}, + {".tsx",StringToColor("#20B2AA")}, + {".ts",StringToColor("#F0E68C")}, + {".dll",StringToColor("#87CEEB")}, + {".clixml",StringToColor("#00BFFF")}, + {".csv",StringToColor("#9ACD32")}, + {".tsv",StringToColor("#9ACD32")}, + {".ini",StringToColor("#6495ED")}, + {".dlc",StringToColor("#6495ED")}, + {".config",StringToColor("#6495ED")}, + {".conf",StringToColor("#6495ED")}, + {".properties",StringToColor("#6495ED")}, + {".prop",StringToColor("#6495ED")}, + {".settings",StringToColor("#6495ED")}, + {".option",StringToColor("#6495ED")}, + {".reg",StringToColor("#6495ED")}, + {".props",StringToColor("#6495ED")}, + {".toml",StringToColor("#6495ED")}, + {".prefs",StringToColor("#6495ED")}, + {".sln.dotsettings",StringToColor("#6495ED")}, + {".sln.dotsettings.user",StringToColor("#6495ED")}, + {".cfg",StringToColor("#6495ED")}, + {".c",StringToColor("#A9A9A9")}, + {".cpp",StringToColor("#A9A9A9")}, + {".go",StringToColor("#20B2AA")}, + {".php",StringToColor("#6A5ACD")}, + {".csproj",StringToColor("#EE82EE")}, + {".ruleset",StringToColor("#EE82EE")}, + {".sln",StringToColor("#EE82EE")}, + {".slnf",StringToColor("#EE82EE")}, + {".suo",StringToColor("#EE82EE")}, + {".vb",StringToColor("#EE82EE")}, + {".vbs",StringToColor("#EE82EE")}, + {".vcxitems",StringToColor("#EE82EE")}, + {".vcxitems.filters",StringToColor("#EE82EE")}, + {".vcxproj",StringToColor("#EE82EE")}, + {".vsxproj.filters",StringToColor("#EE82EE")}, + {".cs",StringToColor("#7B68EE")}, + {".csx",StringToColor("#7B68EE")}, + {".hs",StringToColor("#9932CC")}, + {".xaml",StringToColor("#87CEFA")}, + {".rs",StringToColor("#FF4500")}, + {".pdb",StringToColor("#FFD700")}, + {".sql",StringToColor("#FFD700")}, + {".pks",StringToColor("#FFD700")}, + {".pkb",StringToColor("#FFD700")}, + {".accdb",StringToColor("#FFD700")}, + {".mdb",StringToColor("#FFD700")}, + {".sqlite",StringToColor("#FFD700")}, + {".pgsql",StringToColor("#FFD700")}, + {".postgres",StringToColor("#FFD700")}, + {".psql",StringToColor("#FFD700")}, + {".patch",StringToColor("#FF4500")}, + {".user",StringToColor("#00BFFF")}, + {".code-workspace",StringToColor("#00BFFF")}, + {".log",StringToColor("#F0E68C")}, + {".txt",StringToColor("#00CED1")}, + {".srt",StringToColor("#00CED1")}, + {".lrc",StringToColor("#00CED1")}, + {".ass",StringToColor("#C50000")}, + {".html",StringToColor("#CD5C5C")}, + {".htm",StringToColor("#CD5C5C")}, + {".xhtml",StringToColor("#CD5C5C")}, + {".html_vm",StringToColor("#CD5C5C")}, + {".asp",StringToColor("#CD5C5C")}, + {".css",StringToColor("#87CEFA")}, + {".sass",StringToColor("#FF00FF")}, + {".scss",StringToColor("#FF00FF")}, + {".less",StringToColor("#6B8E23")}, + {".md",StringToColor("#00BFFF")}, + {".markdown",StringToColor("#00BFFF")}, + {".rst",StringToColor("#00BFFF")}, + {".hbs",StringToColor("#E37933")}, + {".json",StringToColor("#FFD700")}, + {".tsbuildinfo",StringToColor("#FFD700")}, + {".yml",StringToColor("#FF6347")}, + {".yaml",StringToColor("#FF6347")}, + {".lua",StringToColor("#87CEFA")}, + {".clj",StringToColor("#00FF7F")}, + {".cljs",StringToColor("#00FF7F")}, + {".cljc",StringToColor("#00FF7F")}, + {".groovy",StringToColor("#87CEFA")}, + {".vue",StringToColor("#20B2AA")}, + {".dart",StringToColor("#4682B4")}, + {".ex",StringToColor("#8B4513")}, + {".exs",StringToColor("#8B4513")}, + {".eex",StringToColor("#8B4513")}, + {".leex",StringToColor("#8B4513")}, + {".erl",StringToColor("#FF6347")}, + {".elm",StringToColor("#9932CC")}, + {".applescript",StringToColor("#4682B4")}, + {".xml",StringToColor("#98FB98")}, + {".plist",StringToColor("#98FB98")}, + {".xsd",StringToColor("#98FB98")}, + {".dtd",StringToColor("#98FB98")}, + {".xsl",StringToColor("#98FB98")}, + {".xslt",StringToColor("#98FB98")}, + {".resx",StringToColor("#98FB98")}, + {".iml",StringToColor("#98FB98")}, + {".xquery",StringToColor("#98FB98")}, + {".tmLanguage",StringToColor("#98FB98")}, + {".manifest",StringToColor("#98FB98")}, + {".project",StringToColor("#98FB98")}, + {".chm",StringToColor("#87CEEB")}, + {".pdf",StringToColor("#CD5C5C")}, + {".xls",StringToColor("#9ACD32")}, + {".xlsx",StringToColor("#9ACD32")}, + {".pptx",StringToColor("#DC143C")}, + {".ppt",StringToColor("#DC143C")}, + {".pptm",StringToColor("#DC143C")}, + {".potx",StringToColor("#DC143C")}, + {".potm",StringToColor("#DC143C")}, + {".ppsx",StringToColor("#DC143C")}, + {".ppsm",StringToColor("#DC143C")}, + {".pps",StringToColor("#DC143C")}, + {".ppam",StringToColor("#DC143C")}, + {".ppa",StringToColor("#DC143C")}, + {".doc",StringToColor("#00BFFF")}, + {".docx",StringToColor("#00BFFF")}, + {".rtf",StringToColor("#00BFFF")}, + {".mp3",StringToColor("#DB7093")}, + {".flac",StringToColor("#DB7093")}, + {".m4a",StringToColor("#DB7093")}, + {".wma",StringToColor("#DB7093")}, + {".aiff",StringToColor("#DB7093")}, + {".wav",StringToColor("#DB7093")}, + {".aac",StringToColor("#DB7093")}, + {".opus",StringToColor("#DB7093")}, + {".png",StringToColor("#20B2AA")}, + {".jpeg",StringToColor("#20B2AA")}, + {".jpg",StringToColor("#20B2AA")}, + {".gif",StringToColor("#20B2AA")}, + {".ico",StringToColor("#20B2AA")}, + {".tif",StringToColor("#20B2AA")}, + {".tiff",StringToColor("#20B2AA")}, + {".psd",StringToColor("#20B2AA")}, + {".psb",StringToColor("#20B2AA")}, + {".ami",StringToColor("#20B2AA")}, + {".apx",StringToColor("#20B2AA")}, + {".bmp",StringToColor("#20B2AA")}, + {".bpg",StringToColor("#20B2AA")}, + {".brk",StringToColor("#20B2AA")}, + {".cur",StringToColor("#20B2AA")}, + {".dds",StringToColor("#20B2AA")}, + {".dng",StringToColor("#20B2AA")}, + {".eps",StringToColor("#20B2AA")}, + {".exr",StringToColor("#20B2AA")}, + {".fpx",StringToColor("#20B2AA")}, + {".gbr",StringToColor("#20B2AA")}, + {".jbig2",StringToColor("#20B2AA")}, + {".jb2",StringToColor("#20B2AA")}, + {".jng",StringToColor("#20B2AA")}, + {".jxr",StringToColor("#20B2AA")}, + {".pbm",StringToColor("#20B2AA")}, + {".pgf",StringToColor("#20B2AA")}, + {".pic",StringToColor("#20B2AA")}, + {".raw",StringToColor("#20B2AA")}, + {".webp",StringToColor("#20B2AA")}, + {".svg",StringToColor("#F4A460")}, + {".webm",StringToColor("#FFA500")}, + {".mkv",StringToColor("#FFA500")}, + {".flv",StringToColor("#FFA500")}, + {".vob",StringToColor("#FFA500")}, + {".ogv",StringToColor("#FFA500")}, + {".ogg",StringToColor("#FFA500")}, + {".gifv",StringToColor("#FFA500")}, + {".avi",StringToColor("#FFA500")}, + {".mov",StringToColor("#FFA500")}, + {".qt",StringToColor("#FFA500")}, + {".wmv",StringToColor("#FFA500")}, + {".yuv",StringToColor("#FFA500")}, + {".rm",StringToColor("#FFA500")}, + {".rmvb",StringToColor("#FFA500")}, + {".mp4",StringToColor("#FFA500")}, + {".mpg",StringToColor("#FFA500")}, + {".mp2",StringToColor("#FFA500")}, + {".mpeg",StringToColor("#FFA500")}, + {".mpe",StringToColor("#FFA500")}, + {".mpv",StringToColor("#FFA500")}, + {".m2v",StringToColor("#FFA500")}, + {".ics",StringToColor("#00CED1")}, + {".cer",StringToColor("#FF6347")}, + {".cert",StringToColor("#FF6347")}, + {".crt",StringToColor("#FF6347")}, + {".pfx",StringToColor("#FF6347")}, + {".pem",StringToColor("#66CDAA")}, + {".pub",StringToColor("#66CDAA")}, + {".key",StringToColor("#66CDAA")}, + {".asc",StringToColor("#66CDAA")}, + {".gpg",StringToColor("#66CDAA")}, + {".woff",StringToColor("#DC143C")}, + {".woff2",StringToColor("#DC143C")}, + {".ttf",StringToColor("#DC143C")}, + {".eot",StringToColor("#DC143C")}, + {".suit",StringToColor("#DC143C")}, + {".otf",StringToColor("#DC143C")}, + {".bmap",StringToColor("#DC143C")}, + {".fnt",StringToColor("#DC143C")}, + {".odttf",StringToColor("#DC143C")}, + {".ttc",StringToColor("#DC143C")}, + {".font",StringToColor("#DC143C")}, + {".fonts",StringToColor("#DC143C")}, + {".sui",StringToColor("#DC143C")}, + {".ntf",StringToColor("#DC143C")}, + {".mrg",StringToColor("#DC143C")}, + {".rb",StringToColor("#FF0000")}, + {".erb",StringToColor("#FF0000")}, + {".gemfile",StringToColor("#FF0000")}, + {"Rakefile",StringToColor("#FF0000")}, + {".fs",StringToColor("#00BFFF")}, + {".fsx",StringToColor("#00BFFF")}, + {".fsi",StringToColor("#00BFFF")}, + {".fsproj",StringToColor("#00BFFF")}, + {".dockerignore",StringToColor("#4682B4")}, + {".dockerfile",StringToColor("#4682B4")}, + {".vscodeignore",StringToColor("#6495ED")}, + {".vsixmanifest",StringToColor("#6495ED")}, + {".vsix",StringToColor("#6495ED")}, + {".code-workplace",StringToColor("#6495ED")}, + {".sublime-project",StringToColor("#F4A460")}, + {".sublime-workspace",StringToColor("#F4A460")}, + {".lock",StringToColor("#DAA520")}, + {".tf",StringToColor("#948EEC")}, + {".tfvars",StringToColor("#948EEC")}, + {".auto.tfvars",StringToColor("#948EEC")}, + {".bicep",StringToColor("#00BFFF")}, + {".vmdk",StringToColor("#E1E3E6")}, + {".vhd",StringToColor("#E1E3E6")}, + {".vhdx",StringToColor("#E1E3E6")}, + {".img",StringToColor("#E1E3E6")}, + {".iso",StringToColor("#E1E3E6")}, + {".R",StringToColor("#276DC3")}, + {".Rmd",StringToColor("#276DC3")}, + {".Rproj",StringToColor("#276DC3")}, + {".jl",StringToColor("#9259a3")}, + {".vim",StringToColor("#019833")}, + {".pp",StringToColor("#FFA61A")}, + {".epp",StringToColor("#FFA61A")}, + {".scala",StringToColor("#DE3423")}, + {".sc",StringToColor("#DE3423")}, + {".iLogicVb",StringToColor("#A63B22")}, + }; + + + private static TrueColor StringToColor (string str) + { + TrueColor.TryParse (str, out var c); + return c ?? throw new System.Exception ("Failed to parse TrueColor from " + str); + } + } +} \ No newline at end of file diff --git a/UnitTests/FileServices/FileDialogTests.cs b/UnitTests/FileServices/FileDialogTests.cs index 96e3012339..88fe00230d 100644 --- a/UnitTests/FileServices/FileDialogTests.cs +++ b/UnitTests/FileServices/FileDialogTests.cs @@ -440,46 +440,6 @@ public void TestDirectoryContents_Windows () TestHelpers.AssertDriverContentsAre (expected, output, true); } - [Fact, AutoInitShutdown] - public void TestDirectoryContents_Windows_Colors () - { - if (!IsWindows ()) { - return; - } - - var fd = GetWindowsDialog (); - fd.Title = string.Empty; - - fd.Style.Culture = new CultureInfo ("en-US"); - fd.Style.UseColors = true; - - var dir = new Attribute (Color.Magenta); - fd.Style.ColorSchemeDirectory = GetColorScheme (dir); - - var img = new Attribute (Color.Cyan); - fd.Style.ColorSchemeImage = GetColorScheme (img); - - var other = new Attribute (Color.BrightGreen); - fd.Style.ColorSchemeOther = GetColorScheme (other); - - var exe = new Attribute (Color.BrightYellow); - fd.Style.ColorSchemeExeOrRecommended = GetColorScheme (exe); - - fd.Draw (); - - TestHelpers.AssertDriverUsedColors (other, dir, img, exe); - } - - private ColorScheme GetColorScheme (Attribute a) - { - return new ColorScheme { - Normal = a, - Focus = a, - Disabled = a, - HotFocus = a, - HotNormal = a, - }; - } [Theory] [InlineData (".csv", null, false)] diff --git a/UnitTests/FileServices/FileSystemColorProviderTests.cs b/UnitTests/FileServices/FileSystemColorProviderTests.cs new file mode 100644 index 0000000000..58b9c1492f --- /dev/null +++ b/UnitTests/FileServices/FileSystemColorProviderTests.cs @@ -0,0 +1,14 @@ +using Xunit; + +namespace Terminal.Gui.FileServicesTests { + public class FileSystemColorProviderTests + { + [Fact] + public void CanConstruct() + { + var prov = new FileSystemColorProvider(); + Assert.NotNull(prov); + } + } + +} \ No newline at end of file diff --git a/UnitTests/FileServices/NerdFontsTests.cs b/UnitTests/FileServices/NerdFontsTests.cs index 37db65fa68..4f38d07ba0 100644 --- a/UnitTests/FileServices/NerdFontsTests.cs +++ b/UnitTests/FileServices/NerdFontsTests.cs @@ -10,7 +10,7 @@ namespace Terminal.Gui.FileServicesTests { - public class NerdFontTests + public class NerdFontTests { [Fact] public void TestAllFilenamesMapToKnownGlyphs()