Aptivi - Manual
ProjectsWebsiteBlog
Nitrocid KS - Manual
Nitrocid KS - Manual
  • Welcome!
  • Versions and Compatibility
    • Supported Versions
    • EOL Versions
    • Version Release Notes
      • v0.0.1.x series
      • v0.0.2.x series
      • v0.0.3.x series
      • v0.0.4.x series
      • v0.0.5.x series
        • v0.0.5.0 Beta Versions
      • v0.0.6.x series
        • v0.0.6.0 Beta Versions
      • v0.0.7.x series
        • v0.0.7.0 Beta Versions
      • v0.0.8.x series
      • v0.0.9.x series
      • v0.0.10.x series
      • v0.0.11.x series
      • v0.0.12.x series
      • v0.0.13.x series
      • v0.0.14.x series
      • v0.0.15.x series
      • v0.0.16.x series
      • v0.0.17.x series
      • v0.0.18.x series
      • v0.0.19.x series
      • v0.0.20.x series
      • v0.0.21.x series
      • v0.0.22.x series
      • v0.0.23.x series
      • v0.0.24.x series
      • v0.1.0.x and 0.1.1.x series
      • v0.1.2.x and v0.1.3.x series
    • Compatibility Notes for KS API Revisions
      • Upgrading to API v1.0 series
      • Upgrading to API v1.1 series
      • Upgrading to API v1.2 series
      • Upgrading to API v1.3 series
      • Upgrading to API v2.0 series
      • Upgrading to API v2.1 series
      • Upgrading to API v3.0 series
        • From 0.0.24.x to 0.1.0 Beta 1
        • From 0.1.0 Beta 1 to 0.1.0 Beta 2
        • From 0.1.0 Beta 2 to 0.1.0 Beta 3
        • From 0.1.0 Beta 3 to 0.1.0 RC
        • From 0.1.0 RC to 0.1.0 Final
      • Upgrading to API v3.1 series
  • Installation and Maintenance
    • Installing the Kernel
      • Windows
      • macOS
      • Linux
      • Android
    • Upgrading the Kernel
      • Windows
      • macOS
      • Linux
      • Android
    • Dependency Information
  • Fundamentals
    • What is the Kernel?
    • What is Nitrocid KS?
    • Simulated Kernel Features
      • Extra Features
        • More Networking
          • FTP Client
          • SSH Connection
          • SFTP Client
          • RSS Client
          • HTTP Client
          • Mail Client
        • Games and Amusements
          • Hangman
          • BackRace
          • Meteor
          • Pong
          • Russian Roulette
          • ShipDuet
          • Snaker
          • Solver
          • SpeedPress
          • Wordle
        • More Editors
          • JSON Editor
          • SQL Editor
        • Common Programs
          • Archive
          • Caffeine
          • Calendar
          • Calculator
          • Contacts
          • Dictionary
          • Git Shell
          • Notes
          • Stocks
          • Timers
          • To-do List
          • Unit Converter
          • Weather
        • Docking
        • Language Studio
        • Theme Studio
      • Accounts
        • Groups
        • Permissions
      • Editors
        • Text Editor
        • Hex Editor
      • Shells
        • Commands List
        • Addon Commands List
      • Files and Folders
        • Hashing and Encryption
      • The Nitrocid Homepage
      • Networking
      • Localization
      • Screensavers
      • Lockscreen Widgets
      • Audio Cues
  • Advanced and Power Users
    • Building the Kernel
      • Building on Windows
      • Building on macOS
      • Building on Linux
      • Building on Android
    • Kernel Modifications
      • Building your Mod
      • Analyzing your Mod
        • Text - NKS0001
        • ConsoleBase - NKS0002
        • ConsoleBase - NKS0003
        • ConsoleBase - NKS0004
        • ConsoleBase - NKS0005
        • ConsoleBase - NKS0006
        • ConsoleBase - NKS0007
        • ConsoleBase - NKS0008
        • ConsoleBase - NKS0009
        • Files - NKS0010
        • Files - NKS0011
        • Files - NKS0012
        • Files - NKS0013
        • Files - NKS0014
        • Files - NKS0015
        • Files - NKS0016
        • Files - NKS0017
        • Files - NKS0018
        • Files - NKS0019
        • Files - NKS0020
        • Files - NKS0021
        • Files - NKS0022
        • Files - NKS0023
        • Kernel - NKS0024
        • Kernel - NKS0025
        • Kernel - NKS0026
        • Kernel - NKS0027
        • Kernel - NKS0031
        • Kernel - NKS0032
        • Kernel - NKS0033
        • Kernel - NKS0037
        • Kernel - NKS0038
        • Kernel - NKS0039
        • Kernel - NKS0040
        • Kernel - NKS0041
        • Kernel - NKS0042
        • Kernel - NKS0043
        • Kernel - NKS0052
        • Kernel - NKS0053
        • Languages - NKS0044
        • Languages - NKS0045
        • Languages - NKS0046
        • Network - NKS0051
        • Text - NKS0047
        • Text - NKS0048
        • Text - NKS0049
        • Text - NKS0050
        • Text - NKS0054
        • Text - NKS0055
      • Managing your Mod
        • Inter-Mod Communication
        • Inter-Addon Communication
    • Diagnostics
      • Debugging
        • Local Debugging
        • Remote Debugging
      • Testing
      • Other Diagnostics
    • Bootloader
      • Boot Choices
      • Kernel Environments
      • Custom Boot Styles
    • Inner Workings
      • Kernel Settings
        • Mechanics of Settings App
        • Settings Format
        • Custom Settings
      • Shell Structure
        • Help System
        • Command Parsing
        • Command Information
        • Command Switches
        • Shell History
        • Shell Scripting
        • Shell Presets
        • Extra Shell Features
      • Multilingual Kernel
        • Locale Tools
        • Custom Languages
      • Inner Essentials
        • Kernel Drivers
          • Console Drivers
          • Debug Logger Drivers
          • Encoding Drivers
          • Encryption Drivers
          • Filesystem Drivers
          • Hardware Prober Drivers
          • Input Drivers
          • Network Drivers
          • RNG Drivers
          • Regular Expression Drivers
          • Sorting Drivers
        • Kernel Placeholders
        • The Permissions
        • The Users
        • Kernel Threads
        • Kernel Arguments
        • Kernel Journaling
        • Remote Procedure
        • Nitrocid Filesystem
        • Screensaver Internals
        • Splash Internals
        • Kernel Platform
        • Theme Internals
        • Color Internals
        • Privacy Consents
        • System Notifications
        • MAL and MOTD
        • Progress Handlers
        • Assembly Signing
        • Assembly Reflection
        • Random Number Generation
        • Network Tools
        • Date and Time
        • Mod Manual Pages
      • Miscellaneous APIs
  • Project Dependencies
  • Report an issue
  • Source code
  • API Reference
Powered by GitBook
On this page
  • Theme tools
  • Getting the installed themes
  • Getting colors from a theme
  • Using ThemeInfo or GetThemeInfo() to get theme information
  • Checking to see if a theme exists
  • Theme application
  • Checking the color requirements
  • Theme preview tools
  • Simple previews
  • Interactive preview
  • Other tools
  • Color conversion
Edit on GitHub
  1. Advanced and Power Users
  2. Inner Workings
  3. Inner Essentials

Theme Internals

Coloring things...

Last updated 4 months ago

Nitrocid KS first came with color theme support in the fourth major version, 0.0.4, but only supported 16 colors defined by the ConsoleColor enumeration. Since then, various themes have been added to the point that we once reached 95+ themes before going down to 65+ themes.

Themes for the kernel consist of color information for each kernel color type. They are made with a simple JSON syntax that's easy to use. Here's the format of each theme JSON file:

{
    "Metadata": {
        "Name": "Theme name",
        "Description": "This is my theme",
        "IsEvent": false,
        "StartMonth": 2,
        "StartDay": 1,
        "EndMonth": 2,
        "EndDay": 22,
        "Calendar": "Gregorian",
        "Category": "Exciting",
        "UseAccentTypes": [
            "LicenseColor",
            (...)
        ],
        "Localizable": true
    },
    "InputColor": "15",
    "LicenseColor": "15",
    "ContKernelErrorColor": "15",
    (...)
}

We'll explain things one by one. The Metadata key consists of some basic information about the theme, like the name and the description. Themes can also be event-based by setting the appropriate property.

  • Name: Display name of the theme

  • Description: Short and concise description of the theme

  • IsEvent: Indicates whether the theme is for a specific event (holidays, celebrations, etc.) [optional]

  • StartMonth: The month in which the event starts [optional]

  • StartDay: The day in which the event starts [optional]

  • EndMonth: The month in which the event ends [optional]

  • EndDay: The day in which the event ends [optional]

  • Calendar: The calendar to use, such as Hijri, Chinese, etc. [optional]

  • Category: The category to use, such as Mesmerizing, Exciting, etc. [optional]

  • UseAccentTypes: The color types which the theme management will switch their values with the accent color configurable by the user from the kernel settings [optional]

  • Localizable: Whether the description is localizable [internal, optional]

The following color categories are supported:

  • Miscellaneous: Themes that don't fit in the available categories

  • Aesthetic: Aesthetically beautiful themes

  • Chinese: Themes that are based on the Chinese culture

  • Exciting: Themes that make you excited

  • Mesmerizing: Mesmerizing and relaxing themes

  • Standard: Standard themes (usually housing the first themes ever released)

  • Linux: Linux flavor themes

What follows the metadata is a list of available kernel color types and their color representations using Terminaux's supported color formats, which are linked in the below page:

Make sure that the event start month and day is earlier than the end month and day. The theme parser will swap the day values and will add a year (end month is bigger than the start) if it detects that the start date is later than the end date (i.e. events can't end before they start).

For themes with accent colors, you have to re-apply the theme using themeset after setting the accent color.

Theme tools

The kernel theming system provides you with various theme tools that allow you to manage your themes, such as getting the addon-installed themes, setting the theme, and more.

Getting the installed themes

You can get the installed themes using the two convenience functions:

ThemeTools.cs
public static Dictionary<string, ThemeInfo> GetInstalledThemes()
public static Dictionary<string, ThemeInfo> GetInstalledThemesByCategory(ThemeCategory category)

The below two functions do the following:

  • The first function gets all the installed themes, including those that are installed by the themes pack.

  • The second function gets all the installed themes by the category mentioned above.

Getting colors from a theme

You can get all the used colors from either a theme name or a ThemeInfo instance using the two functions:

ThemeTools.cs
public static Dictionary<KernelColorType, Color> GetColorsFromTheme(string theme)
public static Dictionary<KernelColorType, Color> GetColorsFromTheme(ThemeInfo themeInfo)

Each function does the following:

  • The first function gets the theme name and fetches its ThemeInfo instance. Then, it calls the second one.

  • The second function gets all the colors from a theme and updates them if there are color types that use the color accent.

Using ThemeInfo or GetThemeInfo() to get theme information

To get theme information for a specific theme, you need to use the ThemeInfo constructor. The below constructors can be used:

  • ThemeInfo()

    • This gives you a new instance of ThemeInfo with the default theme parameters

  • ThemeInfo(themePath)

    • This gives you a new instance of ThemeInfo with the theme parameters from the given theme JSON file

  • ThemeInfo(ThemeFileStream)

    • This gives you a new instance of ThemeInfo with the theme parameters from the given stream containing the theme JSON contents

Alternatively, you can use GetThemeInfo() to get theme information about a specified theme using the theme name. After that, you can apply a theme using this instance using ApplyTheme.

ThemeInfo() constructor with theme names is now deprecated in favor of the theme packs. Please use the GetInstalledThemes() output and get the theme info instance from there instead.

Checking to see if a theme exists

There is a function that lets you check to see if a built-in or an addon theme exists. IsThemeFound() is usable for such themes and can be provided a name of the theme.

ThemeTools.cs
public static bool IsThemeFound(string theme)

Theme application

You can also change all your kernel colors so that a theme can be applied using either a theme name, a theme file name, or a ThemeInfo instance using the below functions:

ThemeTools.cs
public static void ApplyThemeFromResources(string theme, bool dry = false)
public static void ApplyThemeFromFile(string ThemeFile, bool dry = false)
public static void ApplyTheme(ThemeInfo themeInfo, bool dry = false)
public static void SetColorsTheme(ThemeInfo ThemeInfo, bool dry = false)
public static bool TrySetColorsTheme(ThemeInfo ThemeInfo, bool dry = false)

Each function does the following:

  • The first function gets a theme name and gets an instance of ThemeInfo for it. Then, it sets the kernel colors to the colors that are defined by a theme.

  • The second function parses a theme JSON file while getting an instance of ThemeInfo from it and sets the kernel colors to the colors that are set by that theme.

  • The third function gets all the colors from ThemeInfo and sets the kernel colors to the colors that are defined by that instance. If not dry, the kernel configuration is saved to save the new changes.

Checking the color requirements

You can also check to see if a theme requires a level of colors using the below functions:

ThemeTools.cs
public static bool MinimumTypeRequired(string theme, ColorType type)
public static bool MinimumTypeRequired(ThemeInfo theme, ColorType type)
public static bool MinimumTypeRequired(Dictionary<KernelColorType, Color> colors, ColorType type)

Each function takes either a theme name, an instance of ThemeInfo, or a dictionary of each kernel color type with their color instance.

  • If you pass the EightBit type to this function, it checks the Color instance for the type and return true if the type is 255 colors or higher.

  • If you pass the TrueColor type to this function, it checks the Color instance for the type and return true if the type is true colors.

  • If you pass the FourBit type to this function, it always returns false.

Theme preview tools

In addition to the theme tools, you can also access the theme preview tools using the ThemePreviewTools class. Currently, the theme preview tools provides you two types of theme preview:

  • Simple preview

  • Interactive preview

The two below sections explains the two previews.

Simple previews

The simple theme preview shows you a wrapped list of color types and their examples, colored with the foreground color in the placeholder text. You can get access to this preview by calling these functions:

ThemePreviewTools.cs
public static void PreviewThemeSimple(string theme) 
public static void PreviewThemeSimple(ThemeInfo theme)

Each of these two functions get a list of kernel color types known by the color management tools and their associated colors. Then, they show you a preview of the theme colors.

Interactive preview

The interactive theme preview shows you a full-screen colored box that changes its color according to the selected kernel color type and the list of theme colors. You can get access to this preview by calling these functions:

ThemePreviewTools.cs
public static void PreviewTheme(string theme)
public static void PreviewTheme(ThemeInfo theme)

Each of these two functions get a list of kernel color types known by the color management tools and their associated colors. Then, they show you a preview of the theme colors. You can use the following key bindings in this interactive preview:

  • ENTER: Exits the preview

  • Arrow Left: Switches to the previous kernel color type

  • Arrow Right: Switches to the next kernel color type

Other tools

There are other color-related tools that are relevant when making themes, such as the color conversion.

Color conversion

Your theme files can also support any specifier, as long as the specifier is supported by Terminaux. Consult the below page for more information about how colors are processed in Nitrocid KS with the help of Terminaux:

Color Internals
Color SequencesWe need colors!