Skip to content

Commit 055af28

Browse files
committed
Invert all CSS colors
1 parent 7e8aaef commit 055af28

32 files changed

+631
-548
lines changed

Classes/Controllers/PBWebController.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
#include <SystemConfiguration/SCNetworkReachability.h>
1616

17+
static BOOL isDarkMode() {
18+
return [[[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"] isEqualToString:@"Dark"];
19+
}
20+
1721
@interface PBWebController () <WebUIDelegate, WebFrameLoadDelegate, WebResourceLoadDelegate>
1822
- (void)preferencesChangedWithNotification:(NSNotification *)theNotification;
1923
@end
@@ -41,6 +45,10 @@ - (void) awakeFromNib
4145
[self.view setResourceLoadDelegate:self];
4246
[self.view.preferences setDefaultFontSize:(int)[NSFont systemFontSize]];
4347
[self.view.mainFrame loadRequest:request];
48+
49+
// mainly for dark mode so it doesn't look white in bounce region
50+
//FIXME ideally would be black though!
51+
self.view.drawsBackground = false;
4452
}
4553

4654
- (WebScriptObject *) script
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//#!/usr/bin/swift
2+
3+
import Foundation
4+
5+
////////////////////////////////// library
6+
7+
extension String {
8+
var isDirectory: Bool {
9+
var isDir: ObjCBool = false
10+
return FileManager.default.fileExists(atPath: self, isDirectory: &isDir) && isDir.boolValue
11+
}
12+
}
13+
14+
func /(lhs: String, rhs: String) -> String {
15+
return (lhs as NSString).appendingPathComponent(rhs)
16+
}
17+
18+
func invert(c: Character) -> Character {
19+
let value = Int(String(c), radix: 16)!
20+
let inverted = 15 - value
21+
let cc = String.init(inverted, radix: 16, uppercase: true)
22+
return cc.first!
23+
}
24+
25+
func mangle(path: String) throws {
26+
print(path)
27+
var html = try String(contentsOfFile: path)
28+
let regex = try NSRegularExpression(pattern: "#[a-fA-F0-9]+")
29+
let matches = regex.matches(in: html, options: [], range: NSRange(location: 0, length: html.count))
30+
for match in matches {
31+
guard (4...7).contains(match.range.length) else { continue }
32+
let range = Range<String.Index>(match.range, in: html)!
33+
let color = html[range].dropFirst()
34+
let inverted = String(color.map(invert))
35+
html.replaceSubrange(range, with: "#\(inverted)")
36+
print(color, inverted)
37+
}
38+
html.replacingOccurrences(of: "color: white", with: "color: black")
39+
html.replacingOccurrences(of: "background-color: white", with: "background-color: black")
40+
try html.write(toFile: path, atomically: true, encoding: .utf8)
41+
}
42+
43+
44+
////////////////////////////////// main
45+
let fm = FileManager.default
46+
let path = fm.currentDirectoryPath == "/" ? "/Users/mxcl/src/GitX/Resources/html" : "."
47+
let enumerator = fm.enumerator(atPath: path)!
48+
49+
while let node = enumerator.nextObject() as? String {
50+
guard node.hasSuffix(".css") else { continue }
51+
try mangle(path: path/node)
52+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='macos' executeOnSourceChanges='false'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

Resources/html/convert.playground/playground.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Resources/html/css/GitX.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ table {
3535
.hidden {
3636
display: none;
3737
}
38+
39+
html {
40+
background: black;
41+
color: white;
42+
}

Resources/html/css/diff.css

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.diff .file {
22
margin: 11px;
3-
border: 1px solid #CCC;
3+
border: 1px solid #333;
44
}
55

66
.diff .file .fileHeader {
@@ -9,7 +9,7 @@
99
}
1010

1111
.diff .file .fileHeader a {
12-
color: #000;
12+
color: #FFF;
1313
text-decoration: none;
1414
}
1515

@@ -22,9 +22,9 @@
2222
float: left;
2323
padding-left: 3px;
2424
padding-right: 3px;
25-
background-color: #ECECEC;
26-
color: #A9A9A9;
27-
border-right: 1px solid #DDDDDD;
25+
background-color: #131313;
26+
color: #565656;
27+
border-right: 1px solid #222222;
2828
text-align: right;
2929
}
3030

@@ -33,22 +33,22 @@
3333
}
3434

3535
.diff .file .diffContent .lines .hunkheader {
36-
background-color: #f7f7f7;
37-
color: #bbb;
36+
background-color: #080808;
37+
color: #444;
3838
}
3939

4040
.diff .file .diffContent .lines > div {
4141
padding-left: 2px;
4242
}
4343

4444
.diff .file .diffcontent .lines .delline {
45-
background-color: #FEE;
46-
color: #B00;
45+
background-color: #011;
46+
color: #4FF;
4747
}
4848

4949
.diff .file .diffcontent .lines .addline {
50-
background-color: #DFD;
51-
color: #080;
50+
background-color: #202;
51+
color: #F7F;
5252
}
5353

5454
.diff .file .diffcontent .lines .markerline {
@@ -60,21 +60,21 @@
6060
font-family: -apple-system, "Helvetica Neue", sans-serif;
6161
}
6262
.diff .file .diffcontent .lines .whitespace {
63-
background-color: rgba(255,0,0,0.5);
63+
background-color: rgba(0,255,255,0.5);
6464
}
6565
.diff .file .diffcontent .lines del,
6666
.diff .file .diffcontent .lines ins {
6767
text-decoration: none; border-radius: 0.2em;
6868
}
6969
.diff .file .diffcontent .lines .delline del {
70-
background-color: #febfbf;
71-
color: #A00;
70+
background-color: #014040;
71+
color: #5FF;
7272
}
7373
.diff .file .diffcontent .lines .addline ins {
74-
background-color: #b2ffaf;
75-
color: #070;
74+
background-color: #4D0050;
75+
color: #F8F;
7676
}
7777

7878
#CurrentHunk {
7979
border-left: 5px solid black;
80-
}
80+
}

Resources/html/css/notification.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
clear: both;
55

66
border: 1px solid black;
7-
background-color: #f3f3f3;
7+
background-color: #0C0C0C;
88

99
text-align: center;
1010
font-size: 80%;
@@ -13,11 +13,11 @@
1313
}
1414

1515
#notification.success {
16-
background-color: #CCFF99;
17-
border: 1px solid #99CC66;
16+
background-color: #330066;
17+
border: 1px solid #663399;
1818
}
1919

2020
#notification.fail {
21-
background-color: #ff9999;
22-
border: 1px solid #cc6666;
21+
background-color: #006666;
22+
border: 1px solid #339999;
2323
}

Resources/html/css/shCoreGitX.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
background: none !important;
170170
}
171171
.syntaxhighlighter.printing .line .number {
172-
color: #bbbbbb !important;
172+
color: #444444 !important;
173173
}
174174
.syntaxhighlighter.printing .line .content {
175175
color: black !important;
@@ -184,29 +184,29 @@
184184
color: black !important;
185185
}
186186
.syntaxhighlighter.printing .comments, .syntaxhighlighter.printing .comments a {
187-
color: #008200 !important;
187+
color: #FF7DFF !important;
188188
}
189189
.syntaxhighlighter.printing .string, .syntaxhighlighter.printing .string a {
190190
color: blue !important;
191191
}
192192
.syntaxhighlighter.printing .keyword {
193-
color: #006699 !important;
193+
color: #FF9966 !important;
194194
font-weight: bold !important;
195195
}
196196
.syntaxhighlighter.printing .preprocessor {
197197
color: gray !important;
198198
}
199199
.syntaxhighlighter.printing .variable {
200-
color: #aa7700 !important;
200+
color: #5588FF !important;
201201
}
202202
.syntaxhighlighter.printing .value {
203-
color: #009900 !important;
203+
color: #FF66FF !important;
204204
}
205205
.syntaxhighlighter.printing .functions {
206-
color: #ff1493 !important;
206+
color: #00EB6C !important;
207207
}
208208
.syntaxhighlighter.printing .constants {
209-
color: #0066cc !important;
209+
color: #FF9933 !important;
210210
}
211211
.syntaxhighlighter.printing .script {
212212
font-weight: bold !important;
@@ -215,7 +215,7 @@
215215
color: gray !important;
216216
}
217217
.syntaxhighlighter.printing .color2, .syntaxhighlighter.printing .color2 a {
218-
color: #ff1493 !important;
218+
color: #00EB6C !important;
219219
}
220220
.syntaxhighlighter.printing .color3, .syntaxhighlighter.printing .color3 a {
221221
color: red !important;

Resources/html/css/shThemeGitX.css

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
background-color: white !important;
2626
}
2727
.syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 {
28-
background-color: #e0e0e0 !important;
28+
background-color: #1F1F1F !important;
2929
}
3030
.syntaxhighlighter .line.highlighted.number {
3131
color: black !important;
@@ -34,21 +34,21 @@
3434
color: black !important;
3535
}
3636
.syntaxhighlighter .gutter {
37-
border: 1px solid #dddddd !important;
37+
border: 1px solid #222222 !important;
3838
padding: 5px 0 !important;
39-
background-color: #ececec !important;
39+
background-color: #131313 !important;
4040
}
4141
.syntaxhighlighter table td.gutter .line {
4242
text-align: right !important;
4343
padding: 0 2px 0 2px !important;
4444
min-width: 20px;
4545
}
4646
.syntaxhighlighter .gutter .line {
47-
background-color: #ececec !important;
48-
color: #a9a9a9 !important;
47+
background-color: #131313 !important;
48+
color: #565656 !important;
4949
}
5050
.syntaxhighlighter .gutter .line.highlighted {
51-
background-color: #6ce26c !important;
51+
background-color: #931D93 !important;
5252
color: white !important;
5353
}
5454
.syntaxhighlighter.printing .line .content {
@@ -60,7 +60,7 @@
6060
.syntaxhighlighter.collapsed .toolbar {
6161
color: blue !important;
6262
background: white !important;
63-
border: 1px solid #6ce26c !important;
63+
border: 1px solid #931D93 !important;
6464
}
6565
.syntaxhighlighter.collapsed .toolbar a {
6666
color: blue !important;
@@ -70,7 +70,7 @@
7070
}
7171
.syntaxhighlighter .toolbar {
7272
color: white !important;
73-
background: #6ce26c !important;
73+
background: #931D93 !important;
7474
border: none !important;
7575
}
7676
.syntaxhighlighter .toolbar a {
@@ -83,39 +83,39 @@
8383
color: black !important;
8484
}
8585
.syntaxhighlighter .comments, .syntaxhighlighter .comments a {
86-
color: #008200 !important;
86+
color: #FF7DFF !important;
8787
}
8888
.syntaxhighlighter .string, .syntaxhighlighter .string a {
8989
color: blue !important;
9090
}
9191
.syntaxhighlighter .keyword {
92-
color: #006699 !important;
92+
color: #FF9966 !important;
9393
}
9494
.syntaxhighlighter .preprocessor {
9595
color: gray !important;
9696
}
9797
.syntaxhighlighter .variable {
98-
color: #aa7700 !important;
98+
color: #5588FF !important;
9999
}
100100
.syntaxhighlighter .value {
101-
color: #009900 !important;
101+
color: #FF66FF !important;
102102
}
103103
.syntaxhighlighter .functions {
104-
color: #ff1493 !important;
104+
color: #00EB6C !important;
105105
}
106106
.syntaxhighlighter .constants {
107-
color: #0066cc !important;
107+
color: #FF9933 !important;
108108
}
109109
.syntaxhighlighter .script {
110110
font-weight: bold !important;
111-
color: #006699 !important;
111+
color: #FF9966 !important;
112112
background-color: none !important;
113113
}
114114
.syntaxhighlighter .color1, .syntaxhighlighter .color1 a {
115115
color: gray !important;
116116
}
117117
.syntaxhighlighter .color2, .syntaxhighlighter .color2 a {
118-
color: #ff1493 !important;
118+
color: #00EB6C !important;
119119
}
120120
.syntaxhighlighter .color3, .syntaxhighlighter .color3 a {
121121
color: red !important;

0 commit comments

Comments
 (0)