Skip to content

Commit

Permalink
Add support for colors that work in light and dark modes
Browse files Browse the repository at this point in the history
  • Loading branch information
chipsenkbeil committed Jun 3, 2020
1 parent cdc986e commit 66e0f51
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions SDAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ - (void) setupWindow:(NSRect)winRect {
self.window.titlebarAppearsTransparent = YES;
NSVisualEffectView* blur = [[NSVisualEffectView alloc] initWithFrame: [[self.window contentView] bounds]];
[blur setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ];
blur.material = NSVisualEffectMaterialLight;
blur.material = NSVisualEffectMaterialMenu;
blur.state = NSVisualEffectBlendingModeBehindWindow;
[[self.window contentView] addSubview: blur];
}
Expand Down Expand Up @@ -287,7 +287,7 @@ - (void) setupDivider:(NSRect)dividerRect {
NSBox* border = [[NSBox alloc] initWithFrame: dividerRect];
[border setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin ];
[border setBoxType: NSBoxCustom];
[border setFillColor: [NSColor lightGrayColor]];
[border setFillColor: [NSColor systemGrayColor]];
[border setBorderWidth: 0.0];
[[self.window contentView] addSubview: border];
}
Expand Down Expand Up @@ -595,6 +595,16 @@ - (void) writeOutput:(NSString*)str {
alpha: 1.0];
}

static char* HexFromSDColor(NSColor* color) {
char* buffer = (char*) malloc(6 * sizeof(char));
NSColor* c = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
sprintf(buffer, "%2X%2X%2X",
(unsigned int) ([c redComponent] * 255.99999),
(unsigned int) ([c greenComponent] * 255.99999),
(unsigned int) ([c blueComponent] * 255.99999));
return buffer;
}

/******************************************************************************/
/* Getting input list */
/******************************************************************************/
Expand Down Expand Up @@ -656,8 +666,8 @@ int main(int argc, const char * argv[]) {

SDReturnsIndex = NO;
SDUnderlineDisabled = NO;
const char* hexColor = "0000FF";
const char* hexBackgroundColor = "222222";
const char* hexColor = HexFromSDColor(NSColor.systemBlueColor);
const char* hexBackgroundColor = HexFromSDColor(NSColor.systemGrayColor);
const char* queryFontName = "Menlo";
CGFloat queryFontSize = 26.0;
SDNumRows = 10;
Expand Down

0 comments on commit 66e0f51

Please sign in to comment.