lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [dev.15] patch for TEXTAREA edit (bug fixes)


From: Kim DeVaughn
Subject: lynx-dev [dev.15] patch for TEXTAREA edit (bug fixes)
Date: Tue, 2 Feb 1999 03:15:17 -0800

This is an update of my edit TEXTAREA patch, which was taken against
a clean 2.8.2dev.15 (so previously posted patches to that version
should be -R'd, or use a fresh copy of the release).

The main change is that if tagging of "everything" is turned on (ie,
LINKS_AND_FORM_FIELDS_ARE_NUMBERED is on), the tag numbers on fields
in and following an expanded TEXTAREA, are now corrected.

There is still one possible "glitch" in re-rendering that part of the
document which follows a TEXTAREA (when running with full tags turned
on):

If the actual tag string (eg, "[123]") breaks across a line boundary
in the original rendering, the re-rendering fixup routine will not
detect that, so the tag will not get incremented.  Nor will the tags
on any fields following the line-crosser get fixed.

Rather than trying to handle such line-crossers, I propose preventing
them in the first place, by forcing such a field to start on the next
line, when the document is originally rendered (but I haven't looked
for the relevant code, just yet).  Thought I'd ask about possible
unforseen implications, before implementing this.  Comments ...?


Also a few cosmetic changes (statusline msg, help file entry) suggested
by LP, a few CTRACE msgs, and a bit more code cleanup.

/kim


Against a clean 2.8.2dev.15:

diff -uNr lynx-2.8.2-dev.15.virgin/LYMessages_en.h 
lynx-2.8.2-dev.15+kd/LYMessages_en.h
--- lynx-2.8.2-dev.15.virgin/LYMessages_en.h    Thu Jan 28 08:31:29 1999
+++ lynx-2.8.2-dev.15+kd/LYMessages_en.h        Tue Feb  2 00:07:25 1999
@@ -49,6 +49,8 @@
 /* Forms messages */
 #define FORM_LINK_TEXT_MESSAGE \
  gettext("(Text entry field) Enter text.  Use UP or DOWN arrows or tab to move 
off.")
+#define FORM_LINK_TEXTAREA_MESSAGE \
+ gettext("(Textarea) Enter text. Use UP/DOWN arrows or TAB to move off (^Ve 
for editor).")
 #define FORM_LINK_TEXT_UNM_MSG \
  gettext("UNMODIFIABLE form text field.  Use UP or DOWN arrows or tab to move 
off.")
 #define FORM_LINK_TEXT_SUBMIT_MESSAGE \
diff -uNr lynx-2.8.2-dev.15.virgin/lynx_help/keystrokes/alt_edit_help.html 
lynx-2.8.2-dev.15+kd/lynx_help/keystrokes/alt_edit_help.html
--- lynx-2.8.2-dev.15.virgin/lynx_help/keystrokes/alt_edit_help.html    Wed Jan 
13 03:37:34 1999
+++ lynx-2.8.2-dev.15+kd/lynx_help/keystrokes/alt_edit_help.html        Mon Feb 
 1 23:29:29 1999
@@ -32,7 +32,7 @@
      EOL    Go to end   of  line  -  Ctrl-E, End,  Select
 
      DELP   Delete prev     char  -  Ctrl-H, DELETE, Remove
-     DELN   Delete next [*] char  -  Ctrl-D
+     DELN   Delete next [1] char  -  Ctrl-D
      DELPW  Delete prev     word  -  Ctrl-R
      DELNW  Delete next     word  -  Ctrl-T
      DELBL  Delete to beg of line -  Ctrl-X
@@ -41,11 +41,14 @@
      UPPER  Upper case the line   -  Ctrl-^
      LOWER  Lower case the line   -  Ctrl-_
 
-     LKCMD  Invoke cmd prompt     -  Ctrl-V (in form text fields, only)
+     LKCMD  Invoke cmd prompt     -  Ctrl-V (in form text areas, only) [2]
 
-[*] "next" means the character "under" a box or underline style cursor; it
+[1] "next" means the character "under" a box or underline style cursor; it
      means "to the immediate right of" an I-beam (between characters) type
      cursor.
+
+[2]  Follow Ctrl-V with the key bound to the EDIT function (default: "e"),
+     to edit the textarea using an external editor.
 </pre>
 </body>
 </html>
diff -uNr lynx-2.8.2-dev.15.virgin/lynx_help/keystrokes/edit_help.html 
lynx-2.8.2-dev.15+kd/lynx_help/keystrokes/edit_help.html
--- lynx-2.8.2-dev.15.virgin/lynx_help/keystrokes/edit_help.html        Wed Jan 
13 03:37:34 1999
+++ lynx-2.8.2-dev.15+kd/lynx_help/keystrokes/edit_help.html    Mon Feb  1 
23:28:42 1999
@@ -35,7 +35,7 @@
      EOL    Go to end   of  line  -  Ctrl-E, End,  Select
 
      DELP   Delete prev     char  -  Ctrl-H, DELETE, Remove
-     DELN   Delete next [*] char  -  Ctrl-D, Ctrl-R
+     DELN   Delete next [1] char  -  Ctrl-D, Ctrl-R
      DELPW  Delete prev     word  -  Ctrl-B
      DELNW  Delete next     word  -  Ctrl-F
      DELEL  Delete to end of line -  Ctrl-_
@@ -43,12 +43,15 @@
      UPPER  Upper case the line   -  Ctrl-T
      LOWER  Lower case the line   -  Ctrl-K
 
-     LKCMD  Invoke cmd prompt     -  Ctrl-V (in form text fields, only)
+     LKCMD  Invoke cmd prompt     -  Ctrl-V (in form text areas, only) [2]
      SWMAP  Switch input keymap   -  Ctrl-^
 
-[*] "next" means the character "under" a box or underline style cursor; it
+[1] "next" means the character "under" a box or underline style cursor; it
      means "to the immediate right of" an I-beam (between characters) type
      cursor.
+
+[2]  Follow Ctrl-V with the key bound to the EDIT function (default: "e"),
+     to edit the text area using an external editor.
 </pre>
 </body>
 </html>
diff -uNr lynx-2.8.2-dev.15.virgin/src/GridText.c 
lynx-2.8.2-dev.15+kd/src/GridText.c
--- lynx-2.8.2-dev.15.virgin/src/GridText.c     Thu Jan 28 08:31:29 1999
+++ lynx-2.8.2-dev.15+kd/src/GridText.c Tue Feb  2 00:35:38 1999
@@ -8688,14 +8688,148 @@
     return(FALSE);
 }
 
+
+/*
+ *  Re-render the text of a tagged ("[123]") HTLine (arg1), with the tag
+ *  number incremented by some value (arg4).  The re-rendered string may
+ *  be allowed to expand in the event of a tag width change (eg, 99 -> 100)
+ *  as controlled by arg5 (CHOP or NOCHOP).  Arg3 is either (the address
+ *  of) a value which must match, in order for the tag to be incremented,
+ *  or (the address of) a 0-value, which matches any value, and will cause
+ *  any valid tag to be incremented.  Arg2 is a pointer to the first/only
+ *  Anchor that exists on the line (if any); we may need to adjust their
+ *  position(s) on the line.
+ *
+ *  All tags fields in a line which individually match an expected new value,
+ *  are incremented.
+ *
+ *  Untagged or improperly tagged lines are not altered.
+ *
+ *  Returns the number of chars added to the original string's length, if
+ *  any.   KED  02/01/99
+ */
+PRIVATE int increment_tagged_htline ARGS5(
+        char *,         lp,
+       TextAnchor *,   a,
+       int  *,         old_val,
+       int,            incr,
+       int,            mode)
+{
+    char  buf[MAX_LINE];
+
+    TextAnchor *st_anchor  = a;
+    TextAnchor *nxt_anchor;
+
+    char *p   = lp;
+    char *s   = buf;
+    char *t;
+
+    BOOLEAN   valid;
+
+    int   val;
+    int   n;
+    int   new_n;
+
+
+    /*
+     *  Walk thru the line looking for tags (ie, "[nnn]" strings).
+     */
+    while (*p != '\0') {
+        if (*p != '[') {
+          *s++ = *p++;
+          continue;
+
+       } else {
+          *s++ = *p++;
+          t = p;
+          n = 0;
+          valid = TRUE;
+
+          /*
+           *  Make sure there are only digits between "[" and "]"
+           */
+          while (*t != ']') {
+              if (isdigit (*t++) != 0) {
+                 n++;
+                 continue;
+              } else {
+                 valid = FALSE;
+                 break;
+              }
+          }
+
+          /*
+           *  It the format is OK, we check to see if the value is what
+           *  we expect.  If not, we have a random [nn] string in the text,
+           *  and leave it alone.
+           *
+           *  [It is *possible* to have a false match here, *if* there are
+           *   two identical [nn] strings (including the numeric value of
+           *   nn), one of which is the [tag], and the other being part of
+           *   a document.  In such a case, the 1st [nn] string will get
+           *   incremented; the 2nd one won't, which makes it a 50-50 chance
+           *   of being correct, if and when such an unlikely juxitposition
+           *   of text ever occurs.  Further validation tests of the [nnn]
+           *   string are probably not possible, since little of the actual
+           *   anchor-associated-text is retained in the TextAnchor or the
+           *   FormInfo structs.  Fortunately, I think the current method is
+           *   more than adequate to weed out 99.99% of any possible false
+           *   matches, just as it stands.  Caveat emptor.]
+           */
+          if ((valid) && (n > 0)) {
+             val = atoi (p);
+             if ((val == *old_val) || (*old_val == 0)) {
+                if (*old_val != 0)
+                   (*old_val)++;
+                val += incr;
+                sprintf (s, "%d", val);
+                new_n = strlen (s);
+                s += new_n;
+                p += n;
+
+                /*
+                 *  If the number of digits in an existing [tag] increased
+                 *  (eg, [99] --> [100], etc), we need to "adjust" its
+                 *  horizontal position, and that of all subsequant tags
+                 *  that may be on the same line.  PITA.
+                 */
+                if (new_n > n) {
+                   for (nxt_anchor = st_anchor;
+                        (nxt_anchor) && (nxt_anchor->line_num == a->line_num);
+                        nxt_anchor = nxt_anchor->next) {
+                       nxt_anchor->line_pos++;
+                   }
+                   st_anchor = st_anchor->next;
+                }
+             }
+          }
+       }
+    }
+
+    *s = '\0';
+
+    n = strlen (lp);
+    if (mode == CHOP)
+       *(buf + n) = '\0';
+    strcpy (lp, buf);
+    return (strlen (buf) - n);
+}
+
+
 /*
  *  Transfer the initial contents of a TEXTAREA to a temp file, invoke the
  *  user's editor on that file, then transfer the contents of the resultant
  *  edited file back into the TEXTAREA (expanding the size of the area, if
- *  required).   KED  01/26/99
+ *  required).
+ *
+ *  Returns the number of lines that the cursor should be moved so that it
+ *  will end up on the 1st blank line of whatever number of trailing blank
+ *  lines there are in the TEXTAREA (there will *always* be at least one).
+ *
+ *  --KED  02/01/99
  */
-PUBLIC void HText_ExtEditForm ARGS1(
-            struct link *, form_link)
+PUBLIC int HText_ExtEditForm ARGS1(
+           struct link *,  form_link)
 {
     struct stat stat_info;
 
@@ -8704,16 +8838,18 @@
 
     TextAnchor *anchor_ptr;
     TextAnchor *start_anchor = NULL;
-    TextAnchor *end_anchor  = NULL;
-    BOOLEAN    firstanchor = TRUE;
-    int        orig_cnt    = 0;
-    int        line_cnt    = 1;
+    TextAnchor *end_anchor   = NULL;
+    BOOLEAN    firstanchor  = TRUE;
+    int         entry_line   = form_link->anchor_line_num;
+    int         exit_line    = 0;
+    int        orig_cnt     = 0;
+    int        line_cnt     = 1;
 
     FormInfo   *form    = form_link->form;
     char       *areaname = form->name;
     int        form_num = form->number;
 
-    HTLine     *htline;
+    HTLine     *htline  = NULL;
 
     TextAnchor *a = 0;
     FormInfo   *f = 0;
@@ -8722,17 +8858,25 @@
     char       *ebuf;
     char       *tbuf = NULL;
     char       *line;
+    char       *lp;
     char       *cp;
     char       *p;
+    char       *s;
+    int         curr_tag;
+    int         line_adj = 0;
+    int         tag_adj  = 0;
     int        len;
     int        i;
     int        n;
     size_t     size;
 
-    ed_temp = (char *)malloc(LY_MAXPATH);
+
+    CTRACE(tfp, "GridText: entered HText_ExtEditForm()\n");
+
+    ed_temp = (char *) malloc (LY_MAXPATH);
     if ((fp = LYOpenTemp (ed_temp, "", "w")) == 0) {
        FREE(ed_temp);
-       return;
+       return (0);
     }
 
     /*
@@ -8761,13 +8905,13 @@
            !strcmp (anchor_ptr->input_field->name, areaname))   {
 
            if (firstanchor) {
-               firstanchor = FALSE;
+               firstanchor = FALSE;
                start_anchor = anchor_ptr;
            }
            orig_cnt++;
 
            /*
-            * Write the anchor's text to the temp edit file.
+            *  Write the anchors' text to the temp edit file.
             */
            fputs (anchor_ptr->input_field->value, fp);
            fputc ('\n', fp);
@@ -8781,6 +8925,8 @@
     }
     fclose (fp);
 
+    CTRACE(tfp, "GridText: TEXTAREA name=|%s| dumped to tempfile\n", areaname);
+
     /*
      * Go edit the TEXTAREA temp file.
      */
@@ -8798,14 +8944,16 @@
 #endif
     free (tbuf);
 
+    CTRACE(tfp, "GridText: returned from editor (%s)\n", editor);
+
     /*
-     * Read back the edited temp file, whacking off any trailing whitespace.
+     * Read back the edited temp file.
      */
-    if (stat (ed_temp, &stat_info) < 0
-     || !S_ISREG(stat_info.st_mode)
-     || (size = stat_info.st_size) == 0) {
+    if ((stat (ed_temp, &stat_info) < 0)   ||
+       !S_ISREG(stat_info.st_mode)        ||
+        ((size = stat_info.st_size) == 0)) {
        size = 0;
-       ebuf = malloc(1);
+       ebuf = (char *) calloc (1, 1);
     } else {
        ebuf = (char *) calloc (size + 1, (sizeof(char)));
 
@@ -8819,58 +8967,102 @@
     /*
      * Nuke any blank lines from the end of the edited data.
      */
-    while ((size != 0) && isspace(ebuf[size-1]))
+    while ((size != 0) && (isspace (ebuf[size-1]) || (ebuf[size-1] == '\0')))
        ebuf[--size] = '\0';
 
     /*
      * Copy each line from the temp file into the corresponding anchor
-     * struct, removing any trailing whitespace.  Add new lines to the
-     * TEXTAREA if needed.  (Always leave the user with a blank line at
-     * the end of the TEXTAREA.)
+     *  struct, removing any trailing whitespace, expanding any embedded
+     *  tab's, and substituting a printable char for any other embedded
+     *  control chars.  Add new lines to the TEXTAREA if needed.  (Always
+     *  leave the user with a blank line at the end of the TEXTAREA.)
      */
-    if ((line = (char *) malloc (MAX_LINE)) == 0)
+    if (((line = (char *) malloc (MAX_LINE)) == 0) ||
+       ((tbuf = (char *) malloc (MAX_LINE)) == 0))
        outofmem(__FILE__, "HText_ExtEditForm");
 
     anchor_ptr = start_anchor;
+
     len = 0;
-    p = ebuf;
+    lp  = ebuf;
 
-    while ((line_cnt <= orig_cnt) || (*p) || ((len != 0) && (*p == '\0'))) {
+    while ((line_cnt <= orig_cnt) || (*lp) || ((len != 0) && (*lp == '\0'))) {
 
-       if ((cp = strchr (p, '\n')) != 0)
-          len = cp - p;
+       if ((cp = strchr (lp, '\n')) != 0)
+          len = cp - lp;
        else
-          len = strlen (p);
+          len = strlen (lp);
 
-       strncpy(line, "\0", MAX_LINE);
-       strncpy(line, p, len);
-
-       cp = p;
+       strncpy (line, lp, len);
+       *(line + len) = '\0';
 
        /*
         *  Whack off trailing whitespace from the line.
-        *
-        *  [maybe use isspace() here instead, too (portable ?)]
         */
-       for (size = MAX_LINE, p = line + size - 1; size != 0; p--, size--) {
+       for (i = len, p = line + (len - 1); i != 0; p--, i--) {
            if (isspace(*p))
-               *p = '\0';
+              *p = '\0';
            else
-               break;
+              break;
+       }
+
+       if (strlen (line) != 0) {
+          /*
+           *  Expand any tab's, since they won't render properly in a
+           *  TEXTAREA.
+           *
+           *  [is that "by spec", or just a "lynxism" ? ... as may be, it
+           *   seems they may cause other problems, too ... haven't really
+           *   looked into that very deeply though]
+           */
+          p = line;
+          s = tbuf;
+
+          while (*p) {
+              if ((cp = strchr (p, '\t')) != 0) {
+                 i  = cp - p;
+                 s  = (strncpy (s, p, i))      + i;
+                 n  = TABSTOP - (i % TABSTOP);
+                 s  = (strncpy (s, SPACES, n)) + n;
+                 p += (i + 1);
+
+              } else {
+
+                 strcpy (s, p);
+                 break;
+              }
+          }
+
+          /*
+           *  Replace control chars with something printable.  Note that
+           *  we leave any chars above 0x7f alone (ie, no translation is
+           *  performed ... the assumption being that the charset used in
+           *  the editor is compatible with the charset rendered by lynx).
+           */
+          for (p = line, s = tbuf; *s != '\0'; p++, s++)
+              *p = (*s < ' ') ? SPLAT : *s;
+          *p = '\0';
        }
 
+
        /*
         *  If there are more lines in the edit buffer than were in the
         *  original TEXTAREA, we need to add some new lines, continuing
         *  until the edit buffer is empty.
         *
-        *  [cloning structs should me moved to a seperate fn(), or three]
+        *  [cloning structs could be moved to a seperate fn(), or three]
         */
        if (line_cnt > orig_cnt) {
 
           /*
            *  Find line in the text that matches ending anchorline of
            *  the TEXTAREA.
+           *
+           *  [Yes, Virginia ... we *do* have to go thru this for each
+           *   anchor being added, since there is NOT a 1-to-1 mapping
+           *   between anchors and htlines.  I suppose we could create
+           *   YAS (Yet Another Struct), but there are too many structs{}
+           *   floating around in here, as it is.  IMNSHO.]
            */
           for (htline = HTMainText->last_line->next, i = 0;
                i != end_anchor->line_num;
@@ -8880,12 +9072,12 @@
            *  Clone and initialize the structs needed to add a new
            *  TEXTAREA anchor.
            */
-          if ((a = (TextAnchor *) calloc (1, sizeof(*a))) == 0
-           || (f = (FormInfo   *) calloc (1, sizeof(*f))) == 0
-           || (l = (HTLine     *) calloc (1, LINE_SIZE(MAX_LINE))) == 0)
-               outofmem(__FILE__, "HText_ExtEditForm");
+          if (((a = (TextAnchor *) calloc (1, sizeof(*a)))          == 0)  ||
+              ((f = (FormInfo   *) calloc (1, sizeof(*f)))          == 0)  ||
+              ((l = (HTLine     *) calloc (1, LINE_SIZE(MAX_LINE))) == 0))
+             outofmem(__FILE__, "HText_ExtEditForm");
 
-          /*  Init all the fields in the new anchor.  */
+          /*  Init all the fields in the new TextAnchor.  */
           a->next             = end_anchor->next;
           a->number           = end_anchor->number;
           a->start            = end_anchor->start +
@@ -8893,7 +9085,7 @@
           a->line_pos         = end_anchor->line_pos;
           a->extent           = end_anchor->extent;
           a->line_num         = end_anchor->line_num + 1;
-          StrAllocCopy (a->hightext, end_anchor->hightext);
+          StrAllocCopy (a->hightext,  end_anchor->hightext);
           StrAllocCopy (a->hightext2, end_anchor->hightext2);
           a->hightext2offset  = end_anchor->hightext2offset;
           a->link_type        = end_anchor->link_type;
@@ -8902,7 +9094,7 @@
           a->inUnderline      = end_anchor->inUnderline;
           a->anchor           = end_anchor->anchor;
 
-          /*  Just the (seemingly) relevant fields in the FormInfo.    */
+          /*  Just the (seemingly) relevant fields in the new FormInfo.  */
           StrAllocCopy (f->name, end_anchor->input_field->name);
           f->number           = end_anchor->input_field->number;
           f->type             = end_anchor->input_field->type;
@@ -8911,7 +9103,7 @@
           f->maxlength        = end_anchor->input_field->maxlength;
           f->no_cache         = end_anchor->input_field->no_cache;
 
-          /*  Init all the fields in the new HTLine (but see the #if).  */
+          /*  Init all the fields in the new HTLine (but see the #if).   */
           l->next             = htline->next;
           l->prev             = htline;
           l->offset           = htline->offset;
@@ -8922,9 +9114,12 @@
           /* dup styles[] if needed [no need in TEXTAREA (?); leave 0's] */
           l->numstyles        = htline->numstyles;
 #endif
-          for (i = 0; htline->data[i] != '\0'; i++)
-              l->data[i] = htline->data[i];
-          l->data[i] = '\0';
+          strcpy (l->data,      htline->data);
+          if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) {
+             a->number++;
+             curr_tag = 0;  /* 0 matches any [tag] number */
+             increment_tagged_htline (l->data, a, &curr_tag, 1, CHOP);
+          }
 
           /*
            *  Link in the new TextAnchor and make it current; link in
@@ -8938,54 +9133,97 @@
           htline = l;
        }
 
+
        /*
         *  Finally copy the new line from the edit buffer into the anchor.
         */
        StrAllocCopy(anchor_ptr->input_field->value, line);
 
+
        /*
         *  And do the next line, for the next anchor ...
         */
-       p = cp + len;
-       if (*p) p++;
+       lp += len;
+       if (*lp) lp++;
+
+       if (len > 0)
+          exit_line = 0;
+       else if (exit_line == 0)
+          exit_line = anchor_ptr->line_num;
 
        end_anchor = anchor_ptr;
        anchor_ptr = anchor_ptr->next;
+       curr_tag   = anchor_ptr->number;
+
+       if (htline != NULL)
+          htline   = htline->next;
 
        line_cnt++;
     }
 
+    CTRACE(tfp, "GridText: edited text inserted into lynx struct's\n");
 
     /*
      * If new anchors were added, we need to ripple the new line numbers
-     * (and char counts ?) thru the subsequent anchors.  Also update the
-     * HText counts.
+     * (and char counts ?) thru the subsequent anchors.  If form lines
+     *  are getting tagged, we need to update the displayed tag values
+     *  to match (which means re-rendering them ...sigh).  Finally update
+     *  the HText counts.
      *
      * [dunno if the char counts really need to be done, or if we're using
-     *  the proper values ... seems OK though ...]
+     *  the exactly proper values ... seems to be OK though ...]
      */
     if ((n = (line_cnt - 1) - orig_cnt) > 0) {
         i = (end_anchor->input_field->size + 1) * n;
 
         while (anchor_ptr) {
+           if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED)
+              anchor_ptr->number += n;
            anchor_ptr->line_num  += n;
            anchor_ptr->start     += i;
            anchor_ptr             = anchor_ptr->next;
         }
+       anchor_ptr = end_anchor;
+
+       /*
+        *  [if a number tag (eg, "[177]") is itself broken across a line
+        *   boundary, this fixup doesn't work, leaving subsequent tag
+        *   numbers incorrect; the fix is to prevent such tag-breaking
+        *   elsewhere (dunno where yet, though)]
+        */
+       if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) {
+          while (htline != HTMainText->last_line->next) {
+              while (anchor_ptr) {
+                  if ((anchor_ptr->number - n) == curr_tag)
+                     break;
+                  else
+                     anchor_ptr = anchor_ptr->next;
+              }
+              line_adj = increment_tagged_htline (htline->data, anchor_ptr,
+                                                   &curr_tag, n, NOCHOP);
+              htline->size += line_adj;
+              tag_adj      += line_adj;
+              htline = htline->next;
+          }
+       }
+
         HTMainText->Lines += n;
-        HTMainText->chars += i;
+        HTMainText->chars += (i + tag_adj);
     }
 
-    /*** MOVE the cursor to some logical place ... 1st/only blank line in
-     ***         the textarea seems most reasonable; lacking that, the end
-     ***         line of the textarea; lacking that ... the 1st line of the
-     ***         textarea; else leave it where it is (as we now do).
-     ***/
+    CTRACE(tfp, "GridText: struct's adjusted - exiting HText_ExtEditForm()\n");
 
     free (line);
     free (ebuf);
+    free (tbuf);
     LYRemoveTemp (ed_temp);
     free (ed_temp);
 
-    return;
+    /*
+     *  Return the offset needed to move the cursor from its current
+     *  (on entry) line number, to the 1st blank line of the trailing
+     *  (group of) blank line(s), which is where we want to be.  Let
+     *  the caller deal with moving us there, however ... :-) ...
+     */
+    return (exit_line - entry_line);
 }
diff -uNr lynx-2.8.2-dev.15.virgin/src/GridText.h 
lynx-2.8.2-dev.15+kd/src/GridText.h
--- lynx-2.8.2-dev.15.virgin/src/GridText.h     Thu Jan 28 08:31:29 1999
+++ lynx-2.8.2-dev.15+kd/src/GridText.h Mon Feb  1 20:42:23 1999
@@ -27,6 +27,13 @@
 
 #define IsSpecialAttrChar(a)  ((a > '\002') && (a <= '\010'))
 
+#define TABSTOP 8
+#define SPACES  "        "  /* must be at least TABSTOP spaces long */
+#define SPLAT   '.'
+
+#define NOCHOP 0
+#define CHOP   1
+
 /* just for information:
 US-ASCII control characters <32 which are not defined in Unicode standard
 =00    U+0000  NULL
@@ -248,7 +255,7 @@
        HTParentAnchor *        anchor,
        CONST char *            full_address));
 
-extern void HText_ExtEditForm PARAMS((
-       struct link *   form_link));
+extern int HText_ExtEditForm PARAMS((
+       struct link *   form_link));
 
 #endif /* LYGRIDTEXT_H */
diff -uNr lynx-2.8.2-dev.15.virgin/src/LYForms.c 
lynx-2.8.2-dev.15+kd/src/LYForms.c
--- lynx-2.8.2-dev.15.virgin/src/LYForms.c      Mon Jan 18 04:29:20 1999
+++ lynx-2.8.2-dev.15+kd/src/LYForms.c  Mon Feb  1 23:57:57 1999
@@ -311,8 +311,10 @@
                    }
                    break;
                case F_TEXT_TYPE:
-               case F_TEXTAREA_TYPE:
                    statusline(FORM_LINK_TEXT_MESSAGE);
+                   break;
+               case F_TEXTAREA_TYPE:
+                   statusline(FORM_LINK_TEXTAREA_MESSAGE);
                    break;
                default:
                    break;
diff -uNr lynx-2.8.2-dev.15.virgin/src/LYKeymap.c 
lynx-2.8.2-dev.15+kd/src/LYKeymap.c
--- lynx-2.8.2-dev.15.virgin/src/LYKeymap.c     Thu Jan 28 08:31:29 1999
+++ lynx-2.8.2-dev.15+kd/src/LYKeymap.c Sat Jan 30 01:45:19 1999
@@ -577,7 +577,7 @@
 { "WHEREIS",           "search within the current document" },
 { "NEXT",              "search for the next occurence" },
 { "COMMENT",           "send a comment to the author of the current document" 
},
-{ "EDIT",              "edit the current document" },
+{ "EDIT",              "edit the current document or a form's textarea" },
 { "INFO",              "display information on the current document and link" 
},
 { "PRINT",             "display choices for printing the current document" },
 { "ADD_BOOKMARK",      "add to your personal bookmark list" },
@@ -607,7 +607,7 @@
 { "SWITCH_DTD",                "switch between two ways of parsing HTML" },
 { "ELGOTO",            "edit the current link's URL or ACTION and go to it" },
 { "CHANGE_LINK",       "force reset of the current link on the page" },
-{ "EDITTEXTAREA",      "use defined external editor to edit the text area" },
+{ "EDITTEXTAREA",      "use an external editor to edit a form's textarea" },
 #ifdef USE_EXTERNALS
 { "EXTERN",            "run external program with url" },
 #endif
diff -uNr lynx-2.8.2-dev.15.virgin/src/LYMainLoop.c 
lynx-2.8.2-dev.15+kd/src/LYMainLoop.c
--- lynx-2.8.2-dev.15.virgin/src/LYMainLoop.c   Thu Jan 28 08:31:29 1999
+++ lynx-2.8.2-dev.15+kd/src/LYMainLoop.c       Tue Feb  2 00:00:23 1999
@@ -269,6 +269,7 @@
     BOOLEAN override_LYresubmit_posts = FALSE;
     unsigned int len;
     int i;
+    int n;
 
 #ifdef DIRED_SUPPORT
     char *tp = NULL;
@@ -1449,12 +1450,17 @@
                            statusline(FORM_LINK_RESET_MESSAGE);
                        break;
                    case F_TEXT_TYPE:
-                   case F_TEXTAREA_TYPE:
                        if (links[curdoc.link].form->disabled == YES)
                            statusline(FORM_LINK_TEXT_UNM_MSG);
                        else
                            statusline(FORM_LINK_TEXT_MESSAGE);
                        break;
+                   case F_TEXTAREA_TYPE:
+                       if (links[curdoc.link].form->disabled == YES)
+                           statusline(FORM_LINK_TEXT_UNM_MSG);
+                       else
+                           statusline(FORM_LINK_TEXTAREA_MESSAGE);
+                       break;
                    }
                } else {
                    statusline(NORMAL_LINK_MESSAGE);
@@ -4142,6 +4148,15 @@
                break;
            }
 
+           /*
+            *  If we're in a forms TEXTAREA, invoke the editor on it.
+            */
+           if (links[curdoc.link].type       == WWW_FORM_LINK_TYPE &&
+               links[curdoc.link].form->type == F_TEXTAREA_TYPE)   {
+              cmd = LYK_EDIT_TEXTAREA;
+              goto new_cmd;
+           }
+
 #ifdef DIRED_SUPPORT
            /*
             *  Allow the user to edit the link rather
@@ -4304,25 +4319,28 @@
                break;
            }
 
-               /* is curent link part of a textarea */
-           if (links[curdoc.link].type == WWW_FORM_LINK_TYPE &&
-               links[curdoc.link].form->type == F_TEXTAREA_TYPE) {
+           /*
+            *  See if the current link is in a form TEXTAREA.
+            */
+           if (links[curdoc.link].type       == WWW_FORM_LINK_TYPE &&
+               links[curdoc.link].form->type == F_TEXTAREA_TYPE)   {
 
                /* stop screen */
                stop_curses();
 
-               HText_ExtEditForm (&links[curdoc.link]);
+               n = HText_ExtEditForm (&links[curdoc.link]);
+
+               /*
+                *  TODO: Move cursor "n" lines to position it on the first
+                *        trailing blank line in the now edited TEXTAREA.
+                */
 
                /* start screen */
                start_curses();
                refresh_screen = TRUE;
 
-               /*
-               cmd = LYK_REFRESH;
-               goto new_cmd;
-               */
-
            } else {
+
                HTInfoMsg (NOT_IN_TEXTAREA);
            }
            break;
diff -uNr lynx-2.8.2-dev.15.virgin/src/structdump.h 
lynx-2.8.2-dev.15+kd/src/structdump.h
--- lynx-2.8.2-dev.15.virgin/src/structdump.h   Thu Jan 28 08:31:29 1999
+++ lynx-2.8.2-dev.15+kd/src/structdump.h       Thu Jan 28 15:09:12 1999
@@ -9,24 +9,24 @@
 /* usage: DUMPSTRUCT_LINK(link_ptr, "message"); */
 #define   DUMPSTRUCT_LINK(L,X) \
 CTRACE(tfp, "\n" \
-            "KED:     link_ptr=%08x  sizeof=%d  ["X"]\n" \
-            "link       struct {\n" \
-            "           *lname=%08x\n" \
-            "            lname=|%s|\n" \
-            "          *target=%08x\n" \
-            "           target=|%s|\n" \
-            "        *hightext=%08x\n" \
-            "         hightext=|%s|\n" \
-            "       *hightext2=%08x\n" \
-            "        hightext2=|%s|\n" \
-            " hightext2_offset=%d\n"   \
-            "      inUnderline=%1x\n"  \
-            "               lx=%d\n"   \
-            "               ly=%d\n"   \
-            "             type=%d\n"   \
-            "    anchor_number=%d\n"   \
-            "  anchor_line_num=%d\n"   \
-            "            *form=%08x\n" \
+            "KED:     link_ptr=0x%08x  sizeof=%d  ["X"]\n" \
+            "link       struct {\n"      \
+            "           *lname=0x%08x\n" \
+            "            lname=|%s|\n"   \
+            "          *target=0x%08x\n" \
+            "           target=|%s|\n"   \
+            "        *hightext=0x%08x\n" \
+            "         hightext=|%s|\n"   \
+            "       *hightext2=0x%08x\n" \
+            "        hightext2=|%s|\n"   \
+            " hightext2_offset=%d\n"     \
+            "      inUnderline=%1x\n"    \
+            "               lx=%d\n"     \
+            "               ly=%d\n"     \
+            "             type=%d\n"     \
+            "    anchor_number=%d\n"     \
+            "  anchor_line_num=%d\n"     \
+            "            *form=0x%08x\n" \
             "}\n", \
             (L), sizeof(*((L))), \
             (L)->lname, (L)->lname, (L)->target, (L)->target, \
@@ -39,25 +39,25 @@
 /* usage: DUMPSTRUCT_ANCHOR(anchor_ptr, "message"); */
 #define   DUMPSTRUCT_ANCHOR(A,X) \
 CTRACE(tfp, "\n" \
-            "KED:   anchor_ptr=%08x  sizeof=%d  ["X"]\n" \
-            "TextAnchor struct {\n"    \
-            "            *next=%08x\n" \
-            "           number=%d\n"   \
-            "            start=%d\n"   \
-            "         line_pos=%d\n"   \
-            "           extent=%d\n"   \
-            "         line_num=%d\n"   \
-            "        *hightext=%08x\n" \
-            "         hightext=|%s|\n" \
-            "       *hightext2=%08x\n" \
-            "        hightext2=|%s|\n" \
-            "  hightext2offset=%d\n"   \
-            "        link_type=%d\n"   \
-            "     *input_field=%08x\n" \
-            "      input_field=|%s|\n" \
-            "      show_anchor=%1x\n"  \
-            "      inUnderline=%1x\n"  \
-            "          *anchor=%08x\n" \
+            "KED:   anchor_ptr=0x%08x  sizeof=%d  ["X"]\n" \
+            "TextAnchor struct {\n"      \
+            "            *next=0x%08x\n" \
+            "           number=%d\n"     \
+            "            start=%d\n"     \
+            "         line_pos=%d\n"     \
+            "           extent=%d\n"     \
+            "         line_num=%d\n"     \
+            "        *hightext=0x%08x\n" \
+            "         hightext=|%s|\n"   \
+            "       *hightext2=0x%08x\n" \
+            "        hightext2=|%s|\n"   \
+            "  hightext2offset=%d\n"     \
+            "        link_type=%d\n"     \
+            "     *input_field=0x%08x\n" \
+            "      input_field=|%s|\n"   \
+            "      show_anchor=%1x\n"    \
+            "      inUnderline=%1x\n"    \
+            "          *anchor=0x%08x\n" \
             "}\n", \
             (A), sizeof(*((A))), \
             (A)->next, (A)->number, (A)->start, (A)->line_pos, \
@@ -72,35 +72,35 @@
 /* usage: DUMPSTRUCT_FORM(forminfo_ptr, "message"); */
 #define   DUMPSTRUCT_FORMINFO(F,X) \
 CTRACE(tfp, "\n" \
-            "KED: forminfo_ptr=%08x  sizeof=%d  ["X"]\n" \
-            "FormInfo   struct {\n"    \
-            "            *name=%08x\n" \
-            "             name=|%s|\n" \
-            "           number=%d\n"   \
-            "             type=%d\n"   \
-            "           *value=%08x\n" \
-            "            value=|%s|\n" \
-            "      *orig_value=%08x\n" \
-            "       orig_value=|%s|\n" \
-            "             size=%d\n"   \
-            "        maxlength=%d\n"   \
-            "            group=%d\n"   \
-            "        num_value=%d\n"   \
-            "           hrange=%d\n"   \
-            "           lrange=%d\n"   \
-            "     *select_list=%08x\n" \
-            "    submit_action=|%s|\n" \
-            "    submit_method=%d\n"   \
-            "   submit_enctype=|%s|\n" \
-            "     submit_title=|%s|\n" \
-            "         no_cache=%1x\n"  \
-            "  cp_submit_value=|%s|\n" \
-            "orig_submit_value=|%s|\n" \
-            "           size_l=%d\n"   \
-            "         disabled=%d\n"   \
-            "          name_cs=%d\n"   \
-            "         value_cs=%d\n"   \
-            "        accept_cs=|%s|\n" \
+            "KED: forminfo_ptr=0x%08x  sizeof=%d  ["X"]\n" \
+            "FormInfo   struct {\n"      \
+            "            *name=0x%08x\n" \
+            "             name=|%s|\n"   \
+            "           number=%d\n"     \
+            "             type=%d\n"     \
+            "           *value=0x%08x\n" \
+            "            value=|%s|\n"   \
+            "      *orig_value=0x%08x\n" \
+            "       orig_value=|%s|\n"   \
+            "             size=%d\n"     \
+            "        maxlength=%d\n"     \
+            "            group=%d\n"     \
+            "        num_value=%d\n"     \
+            "           hrange=%d\n"     \
+            "           lrange=%d\n"     \
+            "     *select_list=0x%08x\n" \
+            "    submit_action=|%s|\n"   \
+            "    submit_method=%d\n"     \
+            "   submit_enctype=|%s|\n"   \
+            "     submit_title=|%s|\n"   \
+            "         no_cache=%1x\n"    \
+            "  cp_submit_value=|%s|\n"   \
+            "orig_submit_value=|%s|\n"   \
+            "           size_l=%d\n"     \
+            "         disabled=%d\n"     \
+            "          name_cs=%d\n"     \
+            "         value_cs=%d\n"     \
+            "        accept_cs=|%s|\n"   \
             "}\n", \
             (F), sizeof(*((F))), \
             (F)->name, (F)->name, (F)->number, (F)->type, \
@@ -117,17 +117,17 @@
 /* usage: DUMPSTRUCT_LINE(htline_ptr, "message"); */
 #define   DUMPSTRUCT_LINE(L,X) \
 CTRACE(tfp, "\n" \
-            "KED: htline_ptr=%08x  sizeof=%d  ["X"]\n" \
-            "HTLine struct {\n"    \
-            "        *next=%08x\n" \
-            "        *prev=%08x\n" \
-            "       offset=%d\n"   \
-            "         size=%d\n"   \
-            "  split_after=%1x\n"  \
-            "       bullet=%1x\n"  \
-            "nodef U_C_S\n"        \
-            "       data[]=%08x\n" \
-            "         data=|%s|\n" \
+            "KED: htline_ptr=0x%08x  sizeof=%d  ["X"]\n" \
+            "HTLine struct {\n"      \
+            "        *next=0x%08x\n" \
+            "        *prev=0x%08x\n" \
+            "       offset=%d\n"     \
+            "         size=%d\n"     \
+            "  split_after=%1x\n"    \
+            "       bullet=%1x\n"    \
+            "nodef U_C_S\n"          \
+            "       data[]=0x%08x\n" \
+            "         data=|%s|\n"   \
             "}\n", \
             (L), sizeof(*((L))), \
             (L)->next, (L)->prev, (L)->offset, (L)->size, (L)->split_after, \
##--eof--##

reply via email to

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