lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev source syntax highlighting patch


From: Leonid Pauzner
Subject: Re: lynx-dev source syntax highlighting patch
Date: Mon, 29 Mar 1999 12:59:01 +0400 (MSD)

25-Mar-99 22:59 Vlad Harchev wrote:
>     Here is a big patch (~165Kb unzipped!) that will:
> * Added HTML source syntax highlighting (when option -prettysrc that is added
>   is given to lynx). It's available for lynx compiled with and without lss
>   support (it can be much more beatiful when compiled with lss support - read
>   lynx.cfg for description). This functionality coexists with old source view
>   and with -preparsed logic (ie different commandline options make source view
>   logic different).

>     Inconsistences/Defficiencies/extended description:

> * All modifications that add support for psrc mode are wrapped in
>   the preprocesor conditionals '#ifdef USE_PSRC'. Macro USE_PSRC is defined
>   in LYPrettySrc.h. If you undefine this macro there, and recompile, all
>   will work as should (without psrc support of course). All modifications that
>   improve perfomance are also wrapped in cpp conditionals (they are in 
> HTML.c),
>   but I didn't tested recompiling without them. If you (lynx developers and
>   maintainers) decide to accept all changes, eliminating false cpp 
> conditionals
>   can be performed by the script i'm attaching. There is a description of
>   the script in it's code, but here is an example of the usage:

At least this looks wrong
- unnecesary complication in SGML.c/handle_entities() -
it should be an obvious substitution of "entity_string"
possible coloured differently depending on  FoundEntity value.



diff -ruP lynx-2.8.2dev20-orig/WWW/Library/Implementation/SGML.c 
lynx-2.8.2dev20-fixed/WWW/Library/Implementation/SGML.c
--- lynx-2.8.2dev20-orig/WWW/Library/Implementation/SGML.c      Mon Mar 15 
23:55:38 1999
+++ lynx-2.8.2dev20-fixed/WWW/Library/Implementation/SGML.c     Thu Mar 25 
21:19:25 1999
@@ -336,11 +454,17 @@
        /*
        **  Use Lynx special character for nbsp.
        */
+#ifdef USE_PSRC
+        if (!psrc_view)
+#endif
        PUTC(HT_NON_BREAK_SPACE);
     } else  if (code == CH_SHY) {
        /*
        **  Use Lynx special character for shy.
        */
+#ifdef USE_PSRC
+        if (!psrc_view)
+#endif
        PUTC(LY_SOFT_HYPHEN);
     } else if (code == 8194 || code == 8201) {
        /*
@@ -355,13 +479,23 @@
        **  with a single '32' for all (but do line wrapping more fancy).
        **  Assume emsp as two ensp (below).
        */
+#ifdef USE_PSRC
+        if (!psrc_view)
+#endif
        PUTC(HT_EN_SPACE);
     } else if (code == 8195) {
        /*
        **  Use Lynx special character for emsp.
        */
+#ifdef USE_PSRC
+        if (!psrc_view) {
+#endif
        PUTC(HT_EN_SPACE);
        PUTC(HT_EN_SPACE);
+#ifdef USE_PSRC
+        };
+#endif
+
     } else {
        /*
        **  Return NO if nothing done.
@@ -391,6 +525,7 @@
 PRIVATE char replace_buf [64];       /* buffer for replacement strings */
 PRIVATE BOOL FoundEntity = FALSE;

+
 PRIVATE void handle_entity ARGS2(
        HTStream *,     context,
        char,           term)
@@ -411,6 +546,13 @@
        **  Check for special Unicodes. - FM
        */
        if (put_special_unicodes(context, code)) {
+#ifdef USE_PSRC
+            if (psrc_view) {
+                HTMLSRC_apply_markup(context,HTL_entity,START);
+                PUTC('&'); PUTS(entity_string); if (term) PUTC(term);
+                HTMLSRC_apply_markup(context,HTL_entity,STOP);
+            };
+#endif
            FoundEntity = TRUE;
            return;
        }
@@ -422,6 +564,13 @@
            uck < 256 &&
            (uck < 127 ||
             uck >= LYlowest_eightbit[context->outUCLYhndl])) {
+#ifdef USE_PSRC
+            if (psrc_view) {
+                HTMLSRC_apply_markup(context,HTL_entity,START);
+                PUTC('&'); PUTS(entity_string); if (term) PUTC(term);
+                HTMLSRC_apply_markup(context,HTL_entity,STOP);
+            } else
+#endif
            PUTC(FROMASCII((char)uck));
            FoundEntity = TRUE;
            return;
@@ -433,6 +582,13 @@
                   */
                   (uck = UCTransUniCharStr(replace_buf, 60, code,
                                            context->outUCLYhndl, 0) >= 0)) {
+#ifdef USE_PSRC
+            if (psrc_view) {
+                HTMLSRC_apply_markup(context,HTL_entity,START);
+                PUTC('&'); PUTS(entity_string); if (term) PUTC(term);
+                HTMLSRC_apply_markup(context,HTL_entity,STOP);
+            } else
+#endif
            for (p = replace_buf; *p; p++)
                PUTC(*p);
            FoundEntity = TRUE;
@@ -441,14 +597,38 @@
        /*
        **  If we're displaying UTF-8, try that now. - FM
        */
+#ifndef USE_PSRC
        if (context->T.output_utf8 && PUTUTF8(code)) {
            FoundEntity = TRUE;
            return;
        }
+#else
+       if (context->T.output_utf8 && (psrc_view ?
+              (UCPutUtf8_charstring((HTStream *)context->target,
+             (putc_func_t*)(&fake_put_character), code)): PUTUTF8(code) ) ) {
+
+            if (psrc_view) {
+                HTMLSRC_apply_markup(context,HTL_entity,START);
+                PUTC('&'); PUTS(entity_string); if (term) PUTC(term);
+                HTMLSRC_apply_markup(context,HTL_entity,STOP);
+            };
+
+           FoundEntity = TRUE;
+           return;
+       }
+#endif
        /*
        **  If it's safe ASCII, use it. - FM
        */
        if (code >= 32 && code < 127) {
+#ifdef USE_PSRC
+            if (psrc_view) {
+                HTMLSRC_apply_markup(context,HTL_entity,START);
+                PUTC('&'); PUTS(entity_string); if (term) PUTC(term);
+                HTMLSRC_apply_markup(context,HTL_entity,STOP);
+            } else
+#endif
+
            PUTC(FROMASCII((char)code));
            FoundEntity = TRUE;
            return;
@@ -462,6 +642,13 @@
        if (!strcmp(s, "zwnj") ||
            !strcmp(s, "zwj")) {
            CTRACE(tfp, "handle_entity: Ignoring '%s'.\n", s);
+#ifdef USE_PSRC
+            if (psrc_view) {
+                HTMLSRC_apply_markup(context,HTL_entity,START);
+                PUTC('&'); PUTS(entity_string); if (term) PUTC(term);
+                HTMLSRC_apply_markup(context,HTL_entity,STOP);
+            };
+#endif
            FoundEntity = TRUE;
            return;
        }
@@ -471,6 +658,14 @@
        if (!strcmp(s, "lrm") ||
            !strcmp(s, "rlm")) {
            CTRACE(tfp, "handle_entity: Ignoring '%s'.\n", s);
+
+#ifdef USE_PSRC
+            if (psrc_view) {
+                HTMLSRC_apply_markup(context,HTL_entity,START);
+                PUTC('&'); PUTS(entity_string); if (term) PUTC(term);
+                HTMLSRC_apply_markup(context,HTL_entity,STOP);
+            };
+#endif
            FoundEntity = TRUE;
            return;
        }
@@ -479,6 +674,10 @@
     /*
     ** If entity string not found, display as text.
     */
+#ifdef USE_PSRC
+    if (psrc_view)
+        PSRCSTART(badseq);
+#endif
     CTRACE(tfp, "SGML: Unknown entity '%s' %ld %ld\n", s, (long)code, uck); /* 
S/390 -- gil -- 0695 */
     PUTC('&');
     for (p = s; *p; p++) {
@@ -486,6 +685,10 @@
     }
     if (term != '\0')
        PUTC(term);
+#ifdef USE_PSRC
+    if (psrc_view)
+        PSRCSTOP(badseq);
+#endif
 }



...
>   IMO this script is very useful for maintaining (at least for stabializing 
> the
>   code after my patch :).

> NOTE to Klaus and Leonid:
>   Now there is a type information about attributes and you can translate the
>   attribute values to the appropriate charset. If the information contained
>   there is not sufficient, consider adding new flags for atrtibutes.


> Here is a script:

>  Here is a patch

> --ATTACHMENT-- Binary file <patch1.gz>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]