mirror of
https://github.com/hyprwm/hyprpicker.git
synced 2025-02-03 16:09:49 +01:00
feat: adds flag for lowercase hex code (#105)
* feat: adds flag for lowercase hexcodes * formatting changes
This commit is contained in:
parent
444c40e5e3
commit
18af93f0ff
3 changed files with 15 additions and 4 deletions
|
@ -427,7 +427,11 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) {
|
|||
|
||||
if (!m_bDisableHexPreview) {
|
||||
const auto currentColor = getColorFromPixel(pSurface, CLICKPOS);
|
||||
std::string hexBuffer = std::format("#{:02X}{:02X}{:02X}", currentColor.r, currentColor.g, currentColor.b);
|
||||
std::string hexBuffer;
|
||||
if (m_bUseLowerCase)
|
||||
hexBuffer = std::format("#{:02x}{:02x}{:02x}", currentColor.r, currentColor.g, currentColor.b);
|
||||
else
|
||||
hexBuffer = std::format("#{:02X}{:02X}{:02X}", currentColor.r, currentColor.g, currentColor.b);
|
||||
|
||||
cairo_set_source_rgba(PCAIRO, 0.0, 0.0, 0.0, 0.5);
|
||||
|
||||
|
@ -647,8 +651,8 @@ void CHyprpicker::initMouse() {
|
|||
break;
|
||||
}
|
||||
case OUTPUT_HEX: {
|
||||
auto toHex = [](int i) -> std::string {
|
||||
const char* DS = "0123456789ABCDEF";
|
||||
auto toHex = [this](int i) -> std::string {
|
||||
const char* DS = m_bUseLowerCase ? "0123456789abcdef" : "0123456789ABCDEF";
|
||||
|
||||
std::string result = "";
|
||||
|
||||
|
@ -657,6 +661,9 @@ void CHyprpicker::initMouse() {
|
|||
|
||||
return result;
|
||||
};
|
||||
auto hexR = toHex(COL.r);
|
||||
auto hexG = toHex(COL.g);
|
||||
auto hexB = toHex(COL.b);
|
||||
|
||||
if (m_bFancyOutput)
|
||||
Debug::log(NONE, "\033[38;2;%i;%i;%i;48;2;%i;%i;%im#%s%s%s\033[0m", FG, FG, FG, COL.r, COL.g, COL.b, toHex(COL.r).c_str(), toHex(COL.g).c_str(),
|
||||
|
|
|
@ -45,6 +45,7 @@ class CHyprpicker {
|
|||
bool m_bNoZoom = false;
|
||||
bool m_bNoFractional = false;
|
||||
bool m_bDisableHexPreview = false;
|
||||
bool m_bUseLowerCase = false;
|
||||
|
||||
bool m_bRunning = true;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ static void help(void) {
|
|||
<< " -v | --verbose | Enable more logs\n"
|
||||
<< " -t | --no-fractional | Disable fractional scaling support\n"
|
||||
<< " -d | --disable-hex-preview | Disable live preview of Hex code\n"
|
||||
<< " -l | --lowercase-hex | Outputs the hexcode in lowercase\n"
|
||||
<< " -V | --version | Print version info\n";
|
||||
}
|
||||
|
||||
|
@ -34,10 +35,11 @@ int main(int argc, char** argv, char** envp) {
|
|||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"disable-hex-preview", no_argument, NULL, 'd'},
|
||||
{"lowercase-hex", no_argument, NULL, 'l'},
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{NULL, 0, NULL, 0}};
|
||||
|
||||
int c = getopt_long(argc, argv, ":f:hnarzqvtdV", long_options, &option_index);
|
||||
int c = getopt_long(argc, argv, ":f:hnarzqvtdlV", long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
|
@ -67,6 +69,7 @@ int main(int argc, char** argv, char** envp) {
|
|||
case 'q': Debug::quiet = true; break;
|
||||
case 'v': Debug::verbose = true; break;
|
||||
case 'd': g_pHyprpicker->m_bDisableHexPreview = true; break;
|
||||
case 'l': g_pHyprpicker->m_bUseLowerCase = true; break;
|
||||
case 'V': {
|
||||
std::cout << "hyprpicker v" << HYPRPICKER_VERSION << "\n";
|
||||
exit(0);
|
||||
|
|
Loading…
Reference in a new issue