Fossil

Check-in [6ead94abf8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | syntax-hl-with-linenumbers
Files: files | file ages | folders
SHA3-256: 6ead94abf8e10ee3c215b5e7d98db865a4e453fb2615819e46c963987b6f5b34
User & Date: lmartin92 2019-09-26 23:41:09.012
Context
2019-09-26
23:41
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. Closed-Leaf check-in: 6ead94abf8 user: lmartin92 tags: syntax-hl-with-linenumbers
17:58
Remove the discussion of the "close" command from the fiveminutes.wiki document as the "close" command is not really needed, is rarely used, and serves no purpose in the document but to confuse the reader. check-in: f6e635308c user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/db.c.
3598
3599
3600
3601
3602
3603
3604





3605
3606
3607
3608
3609
3610
3611
/*
** SETTING: web-browser      width=30
** A shell command used to launch your preferred
** web browser when given a URL as an argument.
** Defaults to "start" on windows, "open" on Mac,
** and "firefox" on Unix.
*/






/*
** Look up a control setting by its name.  Return a pointer to the Setting
** object, or NULL if there is no such setting.
**
** If allowPrefix is true, then the Setting returned is the first one for
** which zName is a prefix of the Setting name.







>
>
>
>
>







3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
/*
** SETTING: web-browser      width=30
** A shell command used to launch your preferred
** web browser when given a URL as an argument.
** Defaults to "start" on windows, "open" on Mac,
** and "firefox" on Unix.
*/
/*
** SETTING: syntax-hl        boolean default=off
** This is a boolean set such that themes can use TH1 code
** to detect if they should enable syntax highlighting.
*/

/*
** Look up a control setting by its name.  Return a pointer to the Setting
** object, or NULL if there is no such setting.
**
** If allowPrefix is true, then the Setting returned is the first one for
** which zName is a prefix of the Setting name.
Changes to src/info.c.
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
      if( zLn==0 || atoi(zLn)==0 ){
        style_submenu_checkbox("ln", "Line Numbers", 0, 0);
      }
      blob_to_utf8_no_bom(&content, 0);
      zMime = mimetype_from_content(&content);
      @ <blockquote>
      if( zMime==0 ){
        const char *z, *zFileName, *zExt;
        z = blob_str(&content);
        zFileName = db_text(0,
         "SELECT name FROM mlink, filename"
         " WHERE filename.fnid=mlink.fnid"
         "   AND mlink.fid=%d",
         rid);
        zExt = zFileName ? strrchr(zFileName, '.') : 0;
        if( zLn ){
          output_text_with_line_numbers(z, zLn);
        }else if( zExt && zExt[1] ){
          @ <pre>
          @ <code class="language-%s(zExt+1)">%h(z)</code>
          @ </pre>
        }else{
          @ <pre>
          @ %h(z)
          @ </pre>
        }
      }else if( strncmp(zMime, "image/", 6)==0 ){
        @ <p>(file is %d(blob_size(&content)) bytes of image data)</i></p>
        @ <p><img src="%R/raw/%s(zUuid)?m=%s(zMime)"></p>
        style_submenu_element("Image", "%R/raw/%s?m=%s", zUuid, zMime);
      }else{







|

|
|
<
<
<
|
|

<
<
<
<


|







2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346



2347
2348
2349




2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
      if( zLn==0 || atoi(zLn)==0 ){
        style_submenu_checkbox("ln", "Line Numbers", 0, 0);
      }
      blob_to_utf8_no_bom(&content, 0);
      zMime = mimetype_from_content(&content);
      @ <blockquote>
      if( zMime==0 ){
        const char *z, *zFileName, *zExt, *zLanguage, *tmp;
        z = blob_str(&content);
        zFileName = blob_str(&downloadName);
        zExt = (tmp = strrchr(zFileName, '.')) == NULL ? "" : tmp+1;



        zLanguage = strrchr(zFileName, '.') == NULL ? "" : "language-";
        if( zLn && (db_get_boolean("syntax-hl", 0) == 0) ) {
          output_text_with_line_numbers(z, zLn);




        }else{
          @ <pre>
          @ <code class="%s(zLanguage)%s(zExt)">%h(z)</code>
          @ </pre>
        }
      }else if( strncmp(zMime, "image/", 6)==0 ){
        @ <p>(file is %d(blob_size(&content)) bytes of image data)</i></p>
        @ <p><img src="%R/raw/%s(zUuid)?m=%s(zMime)"></p>
        style_submenu_element("Image", "%R/raw/%s?m=%s", zUuid, zMime);
      }else{