"Fossies" - the Fresh Open Source Software Archive

Member "lynx2.9.0dev.1/src/DefaultStyle.c" (27 Nov 2009, 12443 Bytes) of package /linux/www/lynx2.9.0dev.1.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "DefaultStyle.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * $LynxId: DefaultStyle.c,v 1.20 2009/11/27 13:04:27 tom Exp $
    3  *
    4  *  A real style sheet for the Character Grid browser
    5  *
    6  *  The dimensions are all in characters!
    7  */
    8 
    9 #include <HTUtils.h>
   10 #include <HTFont.h>
   11 #include <HTStyle.h>
   12 
   13 #include <LYGlobalDefs.h>
   14 #include <LYLeaks.h>
   15 
   16 /*  Tab arrays:
   17 */
   18 static const HTTabStop tabs_8[] =
   19 {
   20     {0, 8},
   21     {0, 16},
   22     {0, 24},
   23     {0, 32},
   24     {0, 40},
   25     {0, 48},
   26     {0, 56},
   27     {0, 64},
   28     {0, 72},
   29     {0, 80},
   30     {0, 88},
   31     {0, 96},
   32     {0, 104},
   33     {0, 112},
   34     {0, 120},
   35     {0, 128},
   36     {0, 136},
   37     {0, 144},
   38     {0, 152},
   39     {0, 160},
   40     {0, 168},
   41     {0, 176},
   42     {0, 0}          /* Terminate */
   43 };
   44 
   45 /* Template:
   46  *  link to next, name, name id (enum), tag,
   47  *  font, size, colour, superscript, anchor id,
   48  *  indents: 1st, left, right, alignment    lineheight, descent,    tabs,
   49  *  word wrap, free format, space: before, after, flags.
   50  */
   51 
   52 static HTStyle HTStyleNormal =
   53 HTStyleInit(
   54            0, Normal, "P",
   55            HT_FONT, 1, HT_BLACK, 0, 0,
   56            3, 3, 6, HT_LEFT, 1, 0, tabs_8,
   57            YES, YES, 1, 0, 0);
   58 
   59 static HTStyle HTStyleDivCenter =
   60 HTStyleInit(
   61            &HTStyleNormal, DivCenter, "DCENTER",
   62            HT_FONT, 1, HT_BLACK, 0, 0,
   63            3, 3, 6, HT_CENTER, 1, 0, tabs_8,
   64            YES, YES, 1, 0, 0);
   65 
   66 static HTStyle HTStyleDivLeft =
   67 HTStyleInit(
   68            &HTStyleDivCenter, DivLeft, "DLEFT",
   69            HT_FONT, 1, HT_BLACK, 0, 0,
   70            3, 3, 6, HT_LEFT, 1, 0, tabs_8,
   71            YES, YES, 1, 0, 0);
   72 
   73 static HTStyle HTStyleDivRight =
   74 HTStyleInit(
   75            &HTStyleDivLeft, DivRight, "DRIGHT",
   76            HT_FONT, 1, HT_BLACK, 0, 0,
   77            3, 3, 6, HT_RIGHT, 1, 0, tabs_8,
   78            YES, YES, 1, 0, 0);
   79 
   80 static HTStyle HTStyleBanner =
   81 HTStyleInit(
   82            &HTStyleDivRight, Banner, "BANNER",
   83            HT_FONT, 1, HT_BLACK, 0, 0,
   84            3, 3, 6, HT_LEFT, 1, 0, tabs_8,
   85            YES, YES, 1, 0, 0);
   86 
   87 static HTStyle HTStyleBlockquote =
   88 HTStyleInit(
   89            &HTStyleBanner, Blockquote, "BLOCKQUOTE",
   90            HT_FONT, 1, HT_BLACK, 0, 0,
   91            5, 5, 7, HT_LEFT, 1, 0, tabs_8,
   92            YES, YES, 1, 0, 0);
   93 
   94 static HTStyle HTStyleBq =
   95 HTStyleInit(            /* HTML 3.0 BLOCKQUOTE - FM */
   96            &HTStyleBlockquote, Bq, "BQ",
   97            HT_FONT, 1, HT_BLACK, 0, 0,
   98            5, 5, 7, HT_LEFT, 1, 0, tabs_8,
   99            YES, YES, 1, 0, 0);
  100 
  101 static HTStyle HTStyleFootnote =
  102 HTStyleInit(            /* HTML 3.0 FN - FM */
  103            &HTStyleBq, Footnote, "FN",
  104            HT_FONT, 1, HT_BLACK, 0, 0,
  105            5, 5, 7, HT_LEFT, 1, 0, tabs_8,
  106            YES, YES, 1, 0, 0);
  107 
  108 static HTStyle HTStyleList =
  109 HTStyleInit(
  110            &HTStyleFootnote, List, "UL",
  111            HT_FONT, 1, HT_BLACK, 0, 0,
  112            3, 7, 6, HT_LEFT, 1, 0, 0,
  113            YES, YES, 0, 0, 0);
  114 
  115 static HTStyle HTStyleList1 =
  116 HTStyleInit(
  117            &HTStyleList, List1, "UL",
  118            HT_FONT, 1, HT_BLACK, 0, 0,
  119            8, 12, 6, HT_LEFT, 1, 0, 0,
  120            YES, YES, 0, 0, 0);
  121 
  122 static HTStyle HTStyleList2 =
  123 HTStyleInit(
  124            &HTStyleList1, List2, "UL",
  125            HT_FONT, 1, HT_BLACK, 0, 0,
  126            13, 17, 6, HT_LEFT, 1, 0, 0,
  127            YES, YES, 0, 0, 0);
  128 
  129 static HTStyle HTStyleList3 =
  130 HTStyleInit(
  131            &HTStyleList2, List3, "UL",
  132            HT_FONT, 1, HT_BLACK, 0, 0,
  133            18, 22, 6, HT_LEFT, 1, 0, 0,
  134            YES, YES, 0, 0, 0);
  135 
  136 static HTStyle HTStyleList4 =
  137 HTStyleInit(
  138            &HTStyleList3, List4, "UL",
  139            HT_FONT, 1, HT_BLACK, 0, 0,
  140            23, 27, 6, HT_LEFT, 1, 0, 0,
  141            YES, YES, 0, 0, 0);
  142 
  143 static HTStyle HTStyleList5 =
  144 HTStyleInit(
  145            &HTStyleList4, List5, "UL",
  146            HT_FONT, 1, HT_BLACK, 0, 0,
  147            28, 32, 6, HT_LEFT, 1, 0, 0,
  148            YES, YES, 0, 0, 0);
  149 
  150 static HTStyle HTStyleList6 =
  151 HTStyleInit(
  152            &HTStyleList5, List6, "UL",
  153            HT_FONT, 1, HT_BLACK, 0, 0,
  154            33, 37, 6, HT_LEFT, 1, 0, 0,
  155            YES, YES, 0, 0, 0);
  156 
  157 static HTStyle HTStyleMenu =
  158 HTStyleInit(
  159            &HTStyleList6, Menu, "MENU",
  160            HT_FONT, 1, HT_BLACK, 0, 0,
  161            3, 7, 6, HT_LEFT, 1, 0, 0,
  162            YES, YES, 0, 0, 0
  163 );
  164 
  165 static HTStyle HTStyleMenu1 =
  166 HTStyleInit(
  167            &HTStyleMenu, Menu1, "MENU",
  168            HT_FONT, 1, HT_BLACK, 0, 0,
  169            8, 12, 6, HT_LEFT, 1, 0, 0,
  170            YES, YES, 0, 0, 0
  171 );
  172 
  173 static HTStyle HTStyleMenu2 =
  174 HTStyleInit(
  175            &HTStyleMenu1, Menu2, "MENU",
  176            HT_FONT, 1, HT_BLACK, 0, 0,
  177            13, 17, 6, HT_LEFT, 1, 0, 0,
  178            YES, YES, 0, 0, 0
  179 );
  180 
  181 static HTStyle HTStyleMenu3 =
  182 HTStyleInit(
  183            &HTStyleMenu2, Menu3, "MENU",
  184            HT_FONT, 1, HT_BLACK, 0, 0,
  185            18, 22, 6, HT_LEFT, 1, 0, 0,
  186            YES, YES, 0, 0, 0
  187 );
  188 
  189 static HTStyle HTStyleMenu4 =
  190 HTStyleInit(
  191            &HTStyleMenu3, Menu4, "MENU",
  192            HT_FONT, 1, HT_BLACK, 0, 0,
  193            23, 27, 6, HT_LEFT, 1, 0, 0,
  194            YES, YES, 0, 0, 0
  195 );
  196 
  197 static HTStyle HTStyleMenu5 =
  198 HTStyleInit(
  199            &HTStyleMenu4, Menu5, "MENU",
  200            HT_FONT, 1, HT_BLACK, 0, 0,
  201            28, 33, 6, HT_LEFT, 1, 0, 0,
  202            YES, YES, 0, 0, 0
  203 );
  204 
  205 static HTStyle HTStyleMenu6 =
  206 HTStyleInit(
  207            &HTStyleMenu5, Menu6, "MENU",
  208            HT_FONT, 1, HT_BLACK, 0, 0,
  209            33, 38, 6, HT_LEFT, 1, 0, 0,
  210            YES, YES, 0, 0, 0
  211 );
  212 
  213 static HTStyle HTStyleGlossary =
  214 HTStyleInit(
  215            &HTStyleMenu6, Glossary, "DL",
  216            HT_FONT, 1, HT_BLACK, 0, 0,
  217            3, 10, 6, HT_LEFT, 1, 0, 0,
  218            YES, YES, 1, 1, 0
  219 );
  220 
  221 static HTStyle HTStyleGlossary1 =
  222 HTStyleInit(
  223            &HTStyleGlossary, Glossary1, "DL",
  224            HT_FONT, 1, HT_BLACK, 0, 0,
  225            8, 16, 6, HT_LEFT, 1, 0, 0,
  226            YES, YES, 1, 1, 0
  227 );
  228 
  229 static HTStyle HTStyleGlossary2 =
  230 HTStyleInit(
  231            &HTStyleGlossary1, Glossary2, "DL",
  232            HT_FONT, 1, HT_BLACK, 0, 0,
  233            14, 22, 6, HT_LEFT, 1, 0, 0,
  234            YES, YES, 1, 1, 0
  235 );
  236 
  237 static HTStyle HTStyleGlossary3 =
  238 HTStyleInit(
  239            &HTStyleGlossary2, Glossary3, "DL",
  240            HT_FONT, 1, HT_BLACK, 0, 0,
  241            20, 28, 6, HT_LEFT, 1, 0, 0,
  242            YES, YES, 1, 1, 0
  243 );
  244 
  245 static HTStyle HTStyleGlossary4 =
  246 HTStyleInit(
  247            &HTStyleGlossary3, Glossary4, "DL",
  248            HT_FONT, 1, HT_BLACK, 0, 0,
  249            26, 34, 6, HT_LEFT, 1, 0, 0,
  250            YES, YES, 1, 1, 0
  251 );
  252 
  253 static HTStyle HTStyleGlossary5 =
  254 HTStyleInit(
  255            &HTStyleGlossary4, Glossary5, "DL",
  256            HT_FONT, 1, HT_BLACK, 0, 0,
  257            32, 40, 6, HT_LEFT, 1, 0, 0,
  258            YES, YES, 1, 1, 0
  259 );
  260 
  261 static HTStyle HTStyleGlossary6 =
  262 HTStyleInit(
  263            &HTStyleGlossary5, Glossary6, "DL",
  264            HT_FONT, 1, HT_BLACK, 0, 0,
  265            38, 46, 6, HT_LEFT, 1, 0, 0,
  266            YES, YES, 1, 1, 0
  267 );
  268 
  269 static HTStyle HTStyleGlossaryCompact =
  270 HTStyleInit(
  271            &HTStyleGlossary6, GlossaryCompact, "DLC",
  272            HT_FONT, 1, HT_BLACK, 0, 0,
  273            3, 10, 6, HT_LEFT, 1, 0, 0,
  274            YES, YES, 0, 0, 0
  275 );
  276 
  277 static HTStyle HTStyleGlossaryCompact1 =
  278 HTStyleInit(
  279            &HTStyleGlossaryCompact,
  280            GlossaryCompact1, "DLC",
  281            HT_FONT, 1, HT_BLACK, 0, 0,
  282            8, 15, 6, HT_LEFT, 1, 0, 0,
  283            YES, YES, 0, 0, 0
  284 );
  285 
  286 static HTStyle HTStyleGlossaryCompact2 =
  287 HTStyleInit(
  288            &HTStyleGlossaryCompact1,
  289            GlossaryCompact2, "DLC",
  290            HT_FONT, 1, HT_BLACK, 0, 0,
  291            13, 20, 6, HT_LEFT, 1, 0, 0,
  292            YES, YES, 0, 0, 0
  293 );
  294 
  295 static HTStyle HTStyleGlossaryCompact3 =
  296 HTStyleInit(
  297            &HTStyleGlossaryCompact2,
  298            GlossaryCompact3, "DLC",
  299            HT_FONT, 1, HT_BLACK, 0, 0,
  300            18, 25, 6, HT_LEFT, 1, 0, 0,
  301            YES, YES, 0, 0, 0
  302 );
  303 
  304 static HTStyle HTStyleGlossaryCompact4 =
  305 HTStyleInit(
  306            &HTStyleGlossaryCompact3,
  307            GlossaryCompact4, "DLC",
  308            HT_FONT, 1, HT_BLACK, 0, 0,
  309            23, 30, 6, HT_LEFT, 1, 0, 0,
  310            YES, YES, 0, 0, 0
  311 );
  312 
  313 static HTStyle HTStyleGlossaryCompact5 =
  314 HTStyleInit(
  315            &HTStyleGlossaryCompact4,
  316            GlossaryCompact5, "DLC",
  317            HT_FONT, 1, HT_BLACK, 0, 0,
  318            28, 35, 6, HT_LEFT, 1, 0, 0,
  319            YES, YES, 0, 0, 0
  320 );
  321 
  322 static HTStyle HTStyleGlossaryCompact6 =
  323 HTStyleInit(
  324            &HTStyleGlossaryCompact5,
  325            GlossaryCompact6, "DLC",
  326            HT_FONT, 1, HT_BLACK, 0, 0,
  327            33, 40, 6, HT_LEFT, 1, 0, 0,
  328            YES, YES, 0, 0, 0
  329 );
  330 
  331 static HTStyle HTStyleExample =
  332 HTStyleInit(
  333            &HTStyleGlossaryCompact6,
  334            Example, "XMP",
  335            HT_FONT, 1, HT_BLACK, 0, 0,
  336            0, 0, 0, HT_LEFT, 1, 0, tabs_8,
  337            NO, NO, 0, 0, 0
  338 );
  339 
  340 static HTStyle HTStylePreformatted =
  341 HTStyleInit(
  342            &HTStyleExample,
  343            Preformatted, "PRE",
  344            HT_FONT, 1, HT_BLACK, 0, 0,
  345            0, 0, 0, HT_LEFT, 1, 0, tabs_8,
  346            NO, NO, 0, 0, 0
  347 );
  348 
  349 static HTStyle HTStyleListing =
  350 HTStyleInit(
  351            &HTStylePreformatted, Listing, "LISTING",
  352            HT_FONT, 1, HT_BLACK, 0, 0,
  353            0, 0, 0, HT_LEFT, 1, 0, tabs_8,
  354            NO, NO, 0, 0, 0);
  355 
  356 static HTStyle HTStyleAddress =
  357 HTStyleInit(
  358            &HTStyleListing, Address, "ADDRESS",
  359            HT_FONT, 1, HT_BLACK, 0, 0,
  360            4, 4, 7, HT_LEFT, 1, 0, tabs_8,
  361            YES, YES, 2, 0, 0);
  362 
  363 static HTStyle HTStyleNote =
  364 HTStyleInit(            /* HTML 3.0 NOTE - FM */
  365            &HTStyleAddress, Note, "NOTE",
  366            HT_FONT, 1, HT_BLACK, 0, 0,
  367            5, 5, 7, HT_LEFT, 1, 0, tabs_8,
  368            YES, YES, 1, 0, 0);
  369 
  370 static HTStyle HTStyleHeading1 =
  371 HTStyleInit(
  372            &HTStyleNote, Heading1, "H1",
  373            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  374            0, 0, 0, HT_CENTER, 1, 0, 0,
  375            YES, YES, 1, 1, 0);
  376 
  377 static HTStyle HTStyleHeading2 =
  378 HTStyleInit(
  379            &HTStyleHeading1, Heading2, "H2",
  380            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  381            0, 0, 0, HT_LEFT, 1, 0, 0,
  382            YES, YES, 1, 1, 0);
  383 
  384 static HTStyle HTStyleHeading3 =
  385 HTStyleInit(
  386            &HTStyleHeading2, Heading3, "H3",
  387            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  388            2, 2, 0, HT_LEFT, 1, 0, 0,
  389            YES, YES, 1, 0, 0);
  390 
  391 static HTStyle HTStyleHeading4 =
  392 HTStyleInit(
  393            &HTStyleHeading3, Heading4, "H4",
  394            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  395            4, 4, 0, HT_LEFT, 1, 0, 0,
  396            YES, YES, 1, 0, 0);
  397 
  398 static HTStyle HTStyleHeading5 =
  399 HTStyleInit(
  400            &HTStyleHeading4, Heading5, "H5",
  401            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  402            6, 6, 0, HT_LEFT, 1, 0, 0,
  403            YES, YES, 1, 0, 0);
  404 
  405 static HTStyle HTStyleHeading6 =
  406 HTStyleInit(
  407            &HTStyleHeading5, Heading6, "H6",
  408            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  409            8, 8, 0, HT_LEFT, 1, 0, 0,
  410            YES, YES, 1, 0, 0);
  411 
  412 static HTStyle HTStyleHeadingCenter =
  413 HTStyleInit(
  414            &HTStyleHeading6, HeadingCenter, "HCENTER",
  415            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  416            0, 0, 3, HT_CENTER, 1, 0, tabs_8,
  417            YES, YES, 1, 0, 0);
  418 
  419 static HTStyle HTStyleHeadingLeft =
  420 HTStyleInit(
  421            &HTStyleHeadingCenter, HeadingLeft, "HLEFT",
  422            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  423            0, 0, 3, HT_LEFT, 1, 0, tabs_8,
  424            YES, YES, 1, 0, 0);
  425 
  426 static HTStyle HTStyleHeadingRight =
  427 HTStyleInit(
  428            &HTStyleHeadingLeft, HeadingRight, "HRIGHT",
  429            HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
  430            0, 0, 3, HT_RIGHT, 1, 0, tabs_8,
  431            YES, YES, 1, 0, 0);
  432 
  433 /* Style sheet points to the last in the list:
  434 */
  435 static HTStyleSheet sheet =
  436 {"default.style",
  437  &HTStyleHeadingRight};     /* sheet */
  438 
  439 static HTStyle *st_array[ST_HeadingRight + 1] =
  440 {NULL};
  441 
  442 static HTStyleSheet *result = NULL;
  443 
  444 #ifdef LY_FIND_LEAKS
  445 static void FreeDefaultStyle(void)
  446 {
  447     HTStyle *style;
  448 
  449     while ((style = result->styles) != 0) {
  450     result->styles = style->next;
  451     FREE(style);
  452     }
  453     FREE(result);
  454 }
  455 #endif /* LY_FIND_LEAKS */
  456 
  457 HTStyleSheet *DefaultStyle(HTStyle ***result_array)
  458 {
  459     HTStyle *p, *q;
  460 
  461     /*
  462      * The first time we're called, allocate a copy of the 'sheet' linked
  463      * list.  Thereafter, simply copy the data from 'sheet' into our copy
  464      * (preserving the copy's linked-list pointers).  We do this to reset the
  465      * parameters of a style that might be altered while processing a page.
  466      */
  467     if (result == 0) {      /* allocate & copy */
  468     result = HTStyleSheetNew();
  469     *result = sheet;
  470     result->styles = 0;
  471 #ifdef LY_FIND_LEAKS
  472     atexit(FreeDefaultStyle);
  473 #endif
  474     for (p = sheet.styles; p != 0; p = p->next) {
  475         q = HTStyleNew();
  476         *q = *p;
  477         if (no_margins) {
  478         q->indent1st = 0;
  479         q->leftIndent = 0;
  480         q->rightIndent = 0;
  481         }
  482         st_array[q->id] = q;
  483         q->next = result->styles;
  484         result->styles = q;
  485     }
  486     } else {            /* recopy the data */
  487     for (q = result->styles, p = sheet.styles;
  488          p != 0 && q != 0;
  489          p = p->next, q = q->next) {
  490         HTStyle *r = q->next;
  491 
  492         *q = *p;
  493         if (no_margins) {
  494         q->indent1st = 0;
  495         q->leftIndent = 0;
  496         q->rightIndent = 0;
  497         }
  498         st_array[q->id] = q;
  499         q->next = r;
  500     }
  501     }
  502     *result_array = st_array;
  503     return result;
  504 }