Skip to content

Commit a2eecd4

Browse files
committed
* Set the encoding for webkit and allow the user to specify it.
* add .hrl extension for erlang headers
1 parent 61cea7e commit a2eecd4

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

ChangeLog.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
1.1: (in progress)
2-
* Added support for "textEncoding" option to set encoding, with default UTF-8.
3-
2+
* Added support for "textEncoding" option to set encoding for highlight
3+
portion of renderer, with default UTF-8.
4+
* Added support for "webkitTextEncoding" option to set encoding for webkit
5+
portion of renderer, with default UTF-8.
6+
7+
XXX: enabled plain-text handling!
8+
49
1.0:
510
* Hopefully fixed the crasher bug by keeping us single-threaded
611
* Added Actionscript, Lisp, IDL, Verilog, VHDL, XHTML (any others I forgot?)

Common.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
@"ide-xcode", @"hlTheme",
7171
@"", @"extraHLFlags",
7272
@"", @"maxFileSize",
73-
@"UTF-8", @"textEncoding", nil]];
73+
@"UTF-8", @"textEncoding",
74+
@"UTF-8", @"webkitTextEncoding", nil]];
7475
[env addEntriesFromDictionary:[defaults persistentDomainForName:myDomain]];
7576

7677
NSString *cmd = [NSString stringWithFormat:

GeneratePreviewForURL.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,26 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
3131
CFBundleRef bundle = QLPreviewRequestGetGeneratorBundle(preview);
3232
int status;
3333
NSData *output = colorizeURL(bundle, url, &status, 0);
34-
n8log(@"Generated preview html page in %.3f sec", -[startDate timeIntervalSinceNow] );
34+
n8log(@"Generated preview html page in %.3f sec",
35+
-[startDate timeIntervalSinceNow] );
3536

3637
if (status != 0 || QLPreviewRequestIsCancelled(preview)) {
3738
#ifndef DEBUG
3839
goto done;
3940
#endif
4041
}
4142
// Now let WebKit do its thing
42-
CFDictionaryRef emptydict =
43-
(CFDictionaryRef)[[[NSDictionary alloc] init] autorelease];
43+
NSString *textEncoding = [[NSUserDefaults standardUserDefaults]
44+
stringForKey:@"webkitTextEncoding"];
45+
if (!textEncoding || [textEncoding length] == 0)
46+
textEncoding = @"UTF-8";
47+
CFDictionaryRef properties =
48+
(CFDictionaryRef)[NSDictionary dictionaryWithObject:textEncoding
49+
forKey:(NSString *)kQLPreviewPropertyTextEncodingNameKey];
4450
QLPreviewRequestSetDataRepresentation(preview, (CFDataRef)output,
4551
//kUTTypePlainText,
4652
kUTTypeHTML,
47-
emptydict);
53+
properties);
4854

4955
done:
5056
n8log(@"Finished preview in %.3f sec", -[startDate timeIntervalSinceNow] );

Info.plist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<string>public.xml</string>
1616
<string>com.apple.property-list</string>
1717
<string>org.tug.tex</string>
18+
<string>public.plain-text</string>
1819
</array>
1920
</dict>
2021
</array>
@@ -72,7 +73,7 @@
7273
a given file is "source-code". For things like .c and .m files that's
7374
not a problem; they're in the system already. But for .ml files
7475
we have to inform the system ourselves. If there is a file type that
75-
is supported by pygments but this plugin is not being called to
76+
is supported by highlight but this plugin is not being called to
7677
quicklook it, try adding a type identifier for it below. -->
7778
<key>UTImportedTypeDeclarations</key>
7879
<array>
@@ -231,6 +232,7 @@
231232
<key>public.filename-extension</key>
232233
<array>
233234
<string>erl</string>
235+
<string>hrl</string>
234236
</array>
235237
</dict>
236238
</dict>

QLColorCode.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@
189189
children = (
190190
0EF57F2E0D128219006084D5 /* c.lang */,
191191
0EF57F7D0D133C0F006084D5 /* css.lang */,
192-
0EF57D6D0D122934006084D5 /* objc.lang */,
193192
0EB4960D0D0FC24000E86E0B /* ml.lang */,
193+
0EF57D6D0D122934006084D5 /* objc.lang */,
194194
0EF57D430D122791006084D5 /* ide-xcode.style */,
195195
0EF57E690D125AB2006084D5 /* slateGreen.style */,
196196
0E913A090D10B8060067BAD6 /* filetypes.conf */,

ReadMe.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ that could be useful:
1313

1414
Setting the text encoding (default is UTF-8):
1515
defaults write org.n8gray.QLColorCode textEncoding UTF-16
16+
defaults write org.n8gray.QLColorCode webkitTextEncoding UTF-16
1617
Setting the font:
1718
defaults write org.n8gray.QLColorCode font Monaco
1819
the font size:

0 commit comments

Comments
 (0)