Note that there are some explanatory texts on larger screens.

plurals
  1. POReading the RGB values of the console color palette
    primarykey
    data
    text
    <h1>Meat</h1> <p>In C or C++ is there any way to read the color palette RGB values directly? Especially interesting is the extended color space used by xterm (and others) to define up to 256 terminal colors.</p> <h1>Potatoes</h1> <p>The case in point is that I want to define my own colors (using ANSI escape sequences, like <code>\e]4;3;rgb:cc/78/33\e\\</code>, or directly in c) but I need to save the users colors before I redefine them (in the unlikely event that they have already redefined their colors) so that I can restore them when my program finishes. Clobbering user setting is not nice.</p> <p>Right now I'm aiming to use ANSI escape sequences to do this the client way. But since I cant find how you get the colors out I'm starting to look into doing this in c or c++ instead.</p> <p>The solution will be written as a ruby gem with a native extension (basically embedded c or c++ code) and I'll aim to get a cross platform solution, even though the main target is OS X and secondly Linux environments...</p> <h1>Sause</h1> <p>From my initial experiments I have gotten to the point where I can define whatever colors I want for a code point in the color palette. I can also easily restore the default system colors (since they are ANSI standard). I have looked high and low for a way to do this in ANSI escape codes, but found none. I figure that this is kept in memory somewhere and if there is any way to find where, reading the colors should be easy...</p> <h1>Dessert</h1> <p>To sum up the information in the comments so far:</p> <p>It looks like the only way to do this consistently is to print a screen of █ characters in the different colors and grabbing the colors off of that. Since this project is supposed to be cross platform over the three major OS's and since Linux currently have 3 display managers in user on on they way into use and windows has two (7 and 8) I can only imagine the hours and hours of fun that would be :)</p> <p>So my "solution"™ is to just clobber the users colors (if they had anything other than the system defaults ... which, let's face it is pretty uncommon). I will provide a settings file where the user can tell the plugin what colors should be restored if they are not happy with the system defaults. Pragmatic and boring, but it get's me going on this again :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload