Please allow us to change one color on the fly? #19983

Closed
opened 2026-01-31 06:59:28 +00:00 by claunia · 9 comments
Owner

Originally created by @ClaireCJS on GitHub (May 26, 2023).

Description of the new feature/enhancement

A way to change one color on the fly without having to create a scheme

Proposed technical implementation details (optional)

I propose a new command line argument:

ColorTool --set BLACK=100,100,100

So that we may quickly change one color on-the-fly in order to more easily experiment, as well as to be able to create dynamic situations.

My use case is irrelevant, but I'll share: It's accessibility-related in my opinion.

Windows 10 changed window borders to no longer be configurable in width, so now i literally cannot see the edge of my console windows, which have a black background. I used to set these borders to be 5-10px to eliminate this problem, but they've taken that away.

So I want to simply redefine the black background of my console to a random shade between 0,0,0 and 100,100,100 (i want to experiment to find the right range), so that each window has a slightly different shade of black. I am at wit's end with typing into the wrong window because I literally cannot see the beginning of one and the end of another.

My kludgey solution in the current situation now would be to programmatically generate 100 ini files for black=0,0,0, 1,1,1, 2,2,2, 3,3,3 ... 100,100,100

In my case, if I could simply do this via my (TCC) command-line:
set RANDOM=%@RANDOM[0,100]
ColorTool --set BLACK=%RANDOM%,%RANDOM%,%RANDOM%

It would be much more elegant than creating 100 INI files.

Thank you.

Originally created by @ClaireCJS on GitHub (May 26, 2023). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement A way to change one color on the fly without having to create a scheme # Proposed technical implementation details (optional) I propose a new command line argument: ColorTool --set BLACK=100,100,100 So that we may quickly change one color on-the-fly in order to more easily experiment, as well as to be able to create dynamic situations. My use case is irrelevant, but I'll share: It's accessibility-related in my opinion. Windows 10 changed window borders to no longer be configurable in width, so now i literally cannot see the edge of my console windows, which have a black background. I used to set these borders to be 5-10px to eliminate this problem, but they've taken that away. So I want to simply redefine the black background of my console to a random shade between 0,0,0 and 100,100,100 (i want to experiment to find the right range), so that each window has a slightly different shade of black. I am at wit's end with typing into the wrong window because I literally cannot see the beginning of one and the end of another. My kludgey solution in the current situation now would be to programmatically generate 100 ini files for black=0,0,0, 1,1,1, 2,2,2, 3,3,3 ... 100,100,100 In my case, if I could simply do this via my (TCC) command-line: set RANDOM=%@RANDOM[0,100] ColorTool --set BLACK=%RANDOM%,%RANDOM%,%RANDOM% It would be much more elegant than creating 100 INI files. Thank you.
Author
Owner

@zadjii-msft commented on GitHub (May 26, 2023):

I'll give you one better - this is already doable today.

Admittedly, this is a python script that'll rotate through all the hues and set the background.

import sys
import time
import colorsys

for i in range(0, 2560):
    h = i / 256.0
    (r, g, b) = tuple(round(j * 255) for j in colorsys.hsv_to_rgb(h,1.0,1.0))
    sys.stdout.write(f'\x1b]11;rgb:{r:x}/{g:x}/{b:x}\x1b\\')
    sys.stdout.write(f'\rrgb:{r:x}/{g:x}/{b:x}')
    sys.stdout.flush()
    time.sleep(.05)

But the important part is:

    sys.stdout.write(f'\x1b]11;rgb:{r:x}/{g:x}/{b:x}\x1b\\')

so you could do something similar (with PowerShell 7):

Write-Host "`e]11;rgb:16/16/16`e\"

and that'll temporarily change the BG to rgb(16,16,16).

Does that work for you/?

@zadjii-msft commented on GitHub (May 26, 2023): I'll give you one better - this is already doable today. Admittedly, this is a python script that'll rotate through all the hues and set the background. ```python3 import sys import time import colorsys for i in range(0, 2560): h = i / 256.0 (r, g, b) = tuple(round(j * 255) for j in colorsys.hsv_to_rgb(h,1.0,1.0)) sys.stdout.write(f'\x1b]11;rgb:{r:x}/{g:x}/{b:x}\x1b\\') sys.stdout.write(f'\rrgb:{r:x}/{g:x}/{b:x}') sys.stdout.flush() time.sleep(.05) ``` But the important part is: ```py sys.stdout.write(f'\x1b]11;rgb:{r:x}/{g:x}/{b:x}\x1b\\') ``` so you could do something similar (with PowerShell 7): ```pwsh Write-Host "`e]11;rgb:16/16/16`e\" ``` and that'll temporarily change the BG to `rgb(16,16,16)`. Does that work for you/?
Author
Owner

@ClaireCJS commented on GitHub (May 26, 2023):

Does that work for you/?

Nope.

I tried, and while it was neat (and trippy to watch--i'm saving this script for visual candy), it actually gives me output like (see attached), which is not actually defining what the color black is, but is simply changing the background color of text that is rendered.

What I would want would be the whole background changed, not just of the text.

image

@ClaireCJS commented on GitHub (May 26, 2023): > Does that work for you/? Nope. I tried, and while it was neat (and trippy to watch--i'm saving this script for visual candy), it actually gives me output like (see attached), which is not actually defining what the color black is, but is simply changing the background color of text that is rendered. What I would want would be the whole background changed, not just of the text. ![image](https://github.com/microsoft/terminal/assets/789591/d7aea497-713c-4ce8-b253-646a54d135eb)
Author
Owner

@ClaireCJS commented on GitHub (May 26, 2023):

Note that I actually have my desired results now, it just isn't elegant at all, and is a solution that is really only for me.

But it's a great example of why we need that option.

First, I used colortool --output to output my existing colors into a scheme.

I then incorporated that scheme into a python script as a template that can take different RGB values

When I ran this, it generated 64 INI files that represent the current range and stepping of randomness that seems to fit my current accessibility needs.

lower_range = 00
upper_range = 35
stepping    = 10                       #amount to step between each color, i.e. stepping of 5 would mean #000000 -> #000005 might be the smallest color difference we can perceive

template_content = """
[table]
DARK_BLACK = {},{},{}
DARK_BLUE = 0,55,218
DARK_GREEN = 19,161,14
DARK_CYAN = 58,150,221
DARK_RED = 197,15,31
DARK_MAGENTA = 136,23,152
DARK_YELLOW = 193,156,0
DARK_WHITE = 204,204,204
BRIGHT_BLACK = 118,118,118
BRIGHT_BLUE = 59,120,255
BRIGHT_GREEN = 22,198,12
BRIGHT_CYAN = 97,214,214
BRIGHT_RED = 231,72,86
BRIGHT_MAGENTA = 180,0,158
BRIGHT_YELLOW = 249,241,165
BRIGHT_WHITE = 242,242,242

[screen]
FOREGROUND = DARK_WHITE
BACKGROUND = DARK_BLACK

[popup]
FOREGROUND = DARK_MAGENTA
BACKGROUND = BRIGHT_WHITE
"""
file_number = 0
for         r in range(lower_range, upper_range, stepping):
    for     g in range(lower_range, upper_range, stepping):
        for b in range(lower_range, upper_range, stepping):
            file_name = f"demona-default-win10_darkblack_rgb_seq_1_0-50_{r},{g},{b}.ini"
            file_content = template_content.format(r, g, b)
            with open(file_name, 'w') as file: file.write(file_content)
            file_number += 1
            print(f"* Generated file #{file_number}: {file_name} for R={r}, G={g}, B={b}")

When I ran this, it generated 64 INI files that represent the current range and stepping of randomness that seems to fit my current accessibility needs.

@ClaireCJS commented on GitHub (May 26, 2023): Note that I actually have my desired results now, it just isn't elegant at all, and is a solution that is really only for me. But it's a great example of why we need that option. First, I used colortool --output to output my existing colors into a scheme. I then incorporated that scheme into a python script as a template that can take different RGB values When I ran this, it generated 64 INI files that represent the current range and stepping of randomness that seems to fit my current accessibility needs. ```python lower_range = 00 upper_range = 35 stepping = 10 #amount to step between each color, i.e. stepping of 5 would mean #000000 -> #000005 might be the smallest color difference we can perceive template_content = """ [table] DARK_BLACK = {},{},{} DARK_BLUE = 0,55,218 DARK_GREEN = 19,161,14 DARK_CYAN = 58,150,221 DARK_RED = 197,15,31 DARK_MAGENTA = 136,23,152 DARK_YELLOW = 193,156,0 DARK_WHITE = 204,204,204 BRIGHT_BLACK = 118,118,118 BRIGHT_BLUE = 59,120,255 BRIGHT_GREEN = 22,198,12 BRIGHT_CYAN = 97,214,214 BRIGHT_RED = 231,72,86 BRIGHT_MAGENTA = 180,0,158 BRIGHT_YELLOW = 249,241,165 BRIGHT_WHITE = 242,242,242 [screen] FOREGROUND = DARK_WHITE BACKGROUND = DARK_BLACK [popup] FOREGROUND = DARK_MAGENTA BACKGROUND = BRIGHT_WHITE """ file_number = 0 for r in range(lower_range, upper_range, stepping): for g in range(lower_range, upper_range, stepping): for b in range(lower_range, upper_range, stepping): file_name = f"demona-default-win10_darkblack_rgb_seq_1_0-50_{r},{g},{b}.ini" file_content = template_content.format(r, g, b) with open(file_name, 'w') as file: file.write(file_content) file_number += 1 print(f"* Generated file #{file_number}: {file_name} for R={r}, G={g}, B={b}") ``` When I ran this, it generated 64 INI files that represent the current range and stepping of randomness that seems to fit my current accessibility needs.
Author
Owner

@ClaireCJS commented on GitHub (May 26, 2023):

I then made a simply "redefine-black.bat" which uses a wildcard matching the generated files to randomly pick an INI file to send to colortool:

    call set-randfile c:\ColorTool\schemes\demona-default-win10_darkblack_rgb_seq_1_*.ini
    ColorTool.exe --quiet %RANDFILE_FILENAME%

The only part here that would be hard for someone else to reproduce would be my "set-randfile" tool which sets the RANDFILE_FILENAME environment variable to a random file. It's written for TCC shell, so this is not very portable to most uses, but here it is for completeness's sake:

@echo off

REM PURPOSE:
REM         sets RANDFILE to randomfile in current folder, or in parameters
REM SIDE-EFFECTS:
REM         also sets RANDFILE_FULL for the full-path filename, and RANDFILE_FILENAME for the filename-only
REM USAGE:
REM        call set-randomfile
REM        call set-randomfile c:\util\tool\profiles\*.ini

REM get parameters
    set MASK=%1
    if "%MASK%" eq "" (set MASK=*.*)

REM get folder
    set "folder=%~1"
    if "%folder%"=="" set "folder=%CD%"

REM get file list and count
    set FILES=%@EXPAND[%MASK%]
    set COUNT=%@FILES[/h %MASK%]
    if "%COUNT%" == "0" (%COLOR_ERROR% %+ echos * FATAL ERROR! set-randomfile called in a folder (%_CWP) that has no files matching %MASK% in it! %+ %COLOR_NORMAL%+ echo. %+ echo. %+ pause %+ pause %+ pause %+ goto :END)

REM generate random index
    set randomIndex=%@RANDOM[1,%COUNT%]

REM go through filelist to find our index
    set currentIndex=0
    for %%tmpFile in (%FILES%) do (
        set /a "currentIndex+=1"
        if %currentIndex% == %randomIndex% set RANDFILE=%tmpFile%
    )


REM set side/audit/extra variables based on our results
    :et RANDFILE=%RANDFILE%
    set RANDFILE_FULL=%RANDFILE%
    set RANDFILE_FILENAME=%@FILENAME[%RANDFILE%]
    set RANDOMFILE=%RANDFILE%
    set RANDOMFILE_FULL=%RANDFILE%
    set RANDOMFILE_FILENAME=%@FILENAME[%RANDFILE%]


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:END

    if "%DEBUG%" eq "1" (
        %COLOR_DEBUG%
        echo *** RANDFILE          = %RANDFILE%
        echo *** RANDFILE_FULL     = %RANDFILE_FULL%
        echo *** RANDFILE_FILENAME = %RANDFILE_FILENAME%
    )

@ClaireCJS commented on GitHub (May 26, 2023): I then made a simply "redefine-black.bat" which uses a wildcard matching the generated files to randomly pick an INI file to send to colortool: ```bat call set-randfile c:\ColorTool\schemes\demona-default-win10_darkblack_rgb_seq_1_*.ini ColorTool.exe --quiet %RANDFILE_FILENAME% ``` The only part here that would be hard for someone else to reproduce would be my "set-randfile" tool which sets the RANDFILE_FILENAME environment variable to a random file. It's written for TCC shell, so this is not very portable to most uses, but here it is for completeness's sake: ```bat @echo off REM PURPOSE: REM sets RANDFILE to randomfile in current folder, or in parameters REM SIDE-EFFECTS: REM also sets RANDFILE_FULL for the full-path filename, and RANDFILE_FILENAME for the filename-only REM USAGE: REM call set-randomfile REM call set-randomfile c:\util\tool\profiles\*.ini REM get parameters set MASK=%1 if "%MASK%" eq "" (set MASK=*.*) REM get folder set "folder=%~1" if "%folder%"=="" set "folder=%CD%" REM get file list and count set FILES=%@EXPAND[%MASK%] set COUNT=%@FILES[/h %MASK%] if "%COUNT%" == "0" (%COLOR_ERROR% %+ echos * FATAL ERROR! set-randomfile called in a folder (%_CWP) that has no files matching %MASK% in it! %+ %COLOR_NORMAL%+ echo. %+ echo. %+ pause %+ pause %+ pause %+ goto :END) REM generate random index set randomIndex=%@RANDOM[1,%COUNT%] REM go through filelist to find our index set currentIndex=0 for %%tmpFile in (%FILES%) do ( set /a "currentIndex+=1" if %currentIndex% == %randomIndex% set RANDFILE=%tmpFile% ) REM set side/audit/extra variables based on our results :et RANDFILE=%RANDFILE% set RANDFILE_FULL=%RANDFILE% set RANDFILE_FILENAME=%@FILENAME[%RANDFILE%] set RANDOMFILE=%RANDFILE% set RANDOMFILE_FULL=%RANDFILE% set RANDOMFILE_FILENAME=%@FILENAME[%RANDFILE%] :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :END if "%DEBUG%" eq "1" ( %COLOR_DEBUG% echo *** RANDFILE = %RANDFILE% echo *** RANDFILE_FULL = %RANDFILE_FULL% echo *** RANDFILE_FILENAME = %RANDFILE_FILENAME% ) ```
Author
Owner

@zadjii-msft commented on GitHub (May 26, 2023):

Ah, I think I see why that script didn't work. Probably some combo of being on Windows 10 and using the vintage Console Host (conhost.exe), rather than the Windows Terminal. I'm pretty sure that OSC 11 wasn't fully implemented on that version, or had other bugs which are probably already fixed on the repo somewhere.

It should look more like:
rgb-bg-dot-py

And I just tried that on the Windows 11 conhost, to the same effect:

rgb-bg-dot-py-conhost

@zadjii-msft commented on GitHub (May 26, 2023): Ah, I think I see why that script didn't work. Probably some combo of being on Windows 10 and using the vintage Console Host (conhost.exe), rather than the Windows Terminal. I'm pretty sure that `OSC 11` wasn't fully implemented on that version, or had _other bugs_ which are probably already fixed on the repo somewhere. It should look more like: ![rgb-bg-dot-py](https://github.com/microsoft/terminal/assets/18356694/8311d5b5-1911-4552-a17d-71004aeadc89) And I just tried that on the Windows 11 `conhost`, to the same effect: ![rgb-bg-dot-py-conhost](https://github.com/microsoft/terminal/assets/18356694/2866745a-2c34-41f5-a18e-25798dcc14f8)
Author
Owner

@ClaireCJS commented on GitHub (May 26, 2023):

That's pretty cool! We're on a tangent here, but I would love something that would cycle the color of my text like that. I used to have a TSR utility that did this in the DOS days and it was the coolest thing. But it had to run in the background which is.... sensible under dos days, but "Weird" nowadays to have something run in the background of a console process. It's not an area i know much about.

@ClaireCJS commented on GitHub (May 26, 2023): That's pretty cool! We're on a tangent here, but I would love something that would cycle the color of my *text* like that. I used to have a TSR utility that did this in the DOS days and it was the coolest thing. But it had to run in the background which is.... sensible under dos days, but "Weird" nowadays to have something run in the background of a console process. It's not an area i know much about.
Author
Owner

@zadjii-msft commented on GitHub (May 26, 2023):

I mean, change that 11 to a `10, and it'll change the "default foreground":

rgb-fg-dot-py-conhost

but if you want to get really wild with it, you could always write a pixel shader for the Windows Terminal that just changes the color over time. Something like: https://github.com/Hammster/windows-terminal-shaders#hue-shift. There's a lot that's possible there.

@zadjii-msft commented on GitHub (May 26, 2023): I mean, change that `11` to a `10, and it'll change the "default foreground": ![rgb-fg-dot-py-conhost](https://github.com/microsoft/terminal/assets/18356694/ebc412e9-cf6d-4571-b8cd-4ca21427237d) but if you want to get _really wild with it_, you could always write a pixel shader for the Windows Terminal that just changes the color over time. Something like: https://github.com/Hammster/windows-terminal-shaders#hue-shift. There's a _lot_ that's possible there.
Author
Owner

@ClaireCJS commented on GitHub (May 26, 2023):

Lol good point! But how to keep it running in the background while continuing to use my console window 😅

@ClaireCJS commented on GitHub (May 26, 2023): Lol good point! But how to keep it running in the background while continuing to use my console window 😅
Author
Owner

@zadjii-msft commented on GitHub (May 31, 2023):

(I'm gonna close this one as answered, but feel free to continue the discussion)

@zadjii-msft commented on GitHub (May 31, 2023): (I'm gonna close this one as answered, but feel free to continue the discussion)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19983