Fossil SCM

Adds syntax-hl boolean option, fixes file extension retrieval. The addition of the syntax-hl boolean allows fossil to detect at the behest of the user that a syntax highlighting system that will handle line numbering is being used in cooperation with fossil such that fossil need not try to do line numbering, selection, highlighting, etc, itself. The file extension retrieval is now done with no use of extra or one off queries.

lmartin92 2019-09-26 23:41 trunk
Commit 6ead94abf8e10ee3c215b5e7d98db865a4e453fb2615819e46c963987b6f5b34
2 files changed +5 +6 -13
+5
--- src/db.c
+++ src/db.c
@@ -3600,10 +3600,15 @@
36003600
** A shell command used to launch your preferred
36013601
** web browser when given a URL as an argument.
36023602
** Defaults to "start" on windows, "open" on Mac,
36033603
** and "firefox" on Unix.
36043604
*/
3605
+/*
3606
+** SETTING: syntax-hl boolean default=off
3607
+** This is a boolean set such that themes can use TH1 code
3608
+** to detect if they should enable syntax highlighting.
3609
+*/
36053610
36063611
/*
36073612
** Look up a control setting by its name. Return a pointer to the Setting
36083613
** object, or NULL if there is no such setting.
36093614
**
36103615
--- src/db.c
+++ src/db.c
@@ -3600,10 +3600,15 @@
3600 ** A shell command used to launch your preferred
3601 ** web browser when given a URL as an argument.
3602 ** Defaults to "start" on windows, "open" on Mac,
3603 ** and "firefox" on Unix.
3604 */
 
 
 
 
 
3605
3606 /*
3607 ** Look up a control setting by its name. Return a pointer to the Setting
3608 ** object, or NULL if there is no such setting.
3609 **
3610
--- src/db.c
+++ src/db.c
@@ -3600,10 +3600,15 @@
3600 ** A shell command used to launch your preferred
3601 ** web browser when given a URL as an argument.
3602 ** Defaults to "start" on windows, "open" on Mac,
3603 ** and "firefox" on Unix.
3604 */
3605 /*
3606 ** SETTING: syntax-hl boolean default=off
3607 ** This is a boolean set such that themes can use TH1 code
3608 ** to detect if they should enable syntax highlighting.
3609 */
3610
3611 /*
3612 ** Look up a control setting by its name. Return a pointer to the Setting
3613 ** object, or NULL if there is no such setting.
3614 **
3615
+6 -13
--- src/info.c
+++ src/info.c
@@ -2338,27 +2338,20 @@
23382338
}
23392339
blob_to_utf8_no_bom(&content, 0);
23402340
zMime = mimetype_from_content(&content);
23412341
@ <blockquote>
23422342
if( zMime==0 ){
2343
- const char *z, *zFileName, *zExt;
2343
+ const char *z, *zFileName, *zExt, *zLanguage, *tmp;
23442344
z = blob_str(&content);
2345
- zFileName = db_text(0,
2346
- "SELECT name FROM mlink, filename"
2347
- " WHERE filename.fnid=mlink.fnid"
2348
- " AND mlink.fid=%d",
2349
- rid);
2350
- zExt = zFileName ? strrchr(zFileName, '.') : 0;
2351
- if( zLn ){
2345
+ zFileName = blob_str(&downloadName);
2346
+ zExt = (tmp = strrchr(zFileName, '.')) == NULL ? "" : tmp+1;
2347
+ zLanguage = strrchr(zFileName, '.') == NULL ? "" : "language-";
2348
+ if( zLn && (db_get_boolean("syntax-hl", 0) == 0) ) {
23522349
output_text_with_line_numbers(z, zLn);
2353
- }else if( zExt && zExt[1] ){
2354
- @ <pre>
2355
- @ <code class="language-%s(zExt+1)">%h(z)</code>
2356
- @ </pre>
23572350
}else{
23582351
@ <pre>
2359
- @ %h(z)
2352
+ @ <code class="%s(zLanguage)%s(zExt)">%h(z)</code>
23602353
@ </pre>
23612354
}
23622355
}else if( strncmp(zMime, "image/", 6)==0 ){
23632356
@ <p>(file is %d(blob_size(&content)) bytes of image data)</i></p>
23642357
@ <p><img src="%R/raw/%s(zUuid)?m=%s(zMime)"></p>
23652358
--- src/info.c
+++ src/info.c
@@ -2338,27 +2338,20 @@
2338 }
2339 blob_to_utf8_no_bom(&content, 0);
2340 zMime = mimetype_from_content(&content);
2341 @ <blockquote>
2342 if( zMime==0 ){
2343 const char *z, *zFileName, *zExt;
2344 z = blob_str(&content);
2345 zFileName = db_text(0,
2346 "SELECT name FROM mlink, filename"
2347 " WHERE filename.fnid=mlink.fnid"
2348 " AND mlink.fid=%d",
2349 rid);
2350 zExt = zFileName ? strrchr(zFileName, '.') : 0;
2351 if( zLn ){
2352 output_text_with_line_numbers(z, zLn);
2353 }else if( zExt && zExt[1] ){
2354 @ <pre>
2355 @ <code class="language-%s(zExt+1)">%h(z)</code>
2356 @ </pre>
2357 }else{
2358 @ <pre>
2359 @ %h(z)
2360 @ </pre>
2361 }
2362 }else if( strncmp(zMime, "image/", 6)==0 ){
2363 @ <p>(file is %d(blob_size(&content)) bytes of image data)</i></p>
2364 @ <p><img src="%R/raw/%s(zUuid)?m=%s(zMime)"></p>
2365
--- src/info.c
+++ src/info.c
@@ -2338,27 +2338,20 @@
2338 }
2339 blob_to_utf8_no_bom(&content, 0);
2340 zMime = mimetype_from_content(&content);
2341 @ <blockquote>
2342 if( zMime==0 ){
2343 const char *z, *zFileName, *zExt, *zLanguage, *tmp;
2344 z = blob_str(&content);
2345 zFileName = blob_str(&downloadName);
2346 zExt = (tmp = strrchr(zFileName, '.')) == NULL ? "" : tmp+1;
2347 zLanguage = strrchr(zFileName, '.') == NULL ? "" : "language-";
2348 if( zLn && (db_get_boolean("syntax-hl", 0) == 0) ) {
 
 
 
2349 output_text_with_line_numbers(z, zLn);
 
 
 
 
2350 }else{
2351 @ <pre>
2352 @ <code class="%s(zLanguage)%s(zExt)">%h(z)</code>
2353 @ </pre>
2354 }
2355 }else if( strncmp(zMime, "image/", 6)==0 ){
2356 @ <p>(file is %d(blob_size(&content)) bytes of image data)</i></p>
2357 @ <p><img src="%R/raw/%s(zUuid)?m=%s(zMime)"></p>
2358

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button