[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev Re: [-dev.12] experimental text entry fields patch (updated)
From: |
Kim DeVaughn |
Subject: |
lynx-dev Re: [-dev.12] experimental text entry fields patch (updated) |
Date: |
Fri, 8 Jan 1999 18:19:07 -0800 |
On Thu, Jan 07, 1999, I said:
|
| | One thing that I've now (unfortunately) noticed, is that some of the
| | time, when the edited/converted text is "submitted", some extraneous
| | bits of text coming from elsewhere on the original page (not out of
| | a text entry area), are getting appended to the edited text submitted.
|
| When some garbage text is getting added to a CONVERTED text entry field
| on submission, it seems that subsequent submit's of the page (with no
| changes made to the text field, etc), will also have garbage appended,
| BUT the actual garbage-text will vary on each "submit".
I think I've fixed this bug now. The attached patch should be applied
on top of originally posted text area patch (ie, ignore or -R the other
patches that I've posted).
Seems that there were no provisions to insure a null at the end of the
buffer that the text file was being read into, for parsing into the
submitted post_data.
Since I'm not yet trying to "lynxify" the code, for the moment, I've just
increased the buffer size to filesize + 1, and used calloc() instead of
malloc().
I've also added some code to eliminate any trailing whitespace following
the last non-whitespace char. Specifically, trailing SP's, \t's, \n's
and \r's are eliminated. This seems to conform to the way text entry
fields usually work (I think), and also allows one to ignore having any
extra trailing blank lines in the editor's buffer.
I'd like some feedback on doing this, and also whether I should be testing
for any other trailing chars.
One other thing I've added is a bit of code to unlink() leftover emacs
style backup files~ . I'm wondering how best to handle that problem, in
general.
Probably the best way would be to have one's backup file "extension"
defined in the .lynxrc file (though that probably means another line in
the options menu).
Alternatively, several common backup extensions could be tried, in addition
to the trailing tilde form (.bak, .BAK, etc)>
Or, I could just leave the garbage laying around, and tell the user to
write a "wrapper" shell-script/etc to cleanup the extraneous files, but I
really don't like doing something like that. And yes, I know that the
"make backup" function of the editor could be turned off, but remembering
to do that each time would be a real PITA (besides which, I'm sure most
users wouldn't know that they needed to).
I'd also like some feedback on this issue.
/kim
Against 2.8.2dev.12, with textarea patch 0.1.3 applied:
diff -uNr lynx-2.8.2-dev.12.orig/src/GridText.c
lynx-2.8.2-dev.12+kd/src/GridText.c
--- lynx-2.8.2-dev.12.orig/src/GridText.c Tue Jan 5 10:40:09 1999
+++ lynx-2.8.2-dev.12+kd/src/GridText.c Fri Jan 8 16:59:43 1999
@@ -7570,10 +7570,21 @@
HTAlert("File too big"); /*FIXME better
message*/
} else {
fp = fopen (anchor_ptr->input_field->filename,
"r");
- val = malloc (B.st_size * (sizeof (char)));
+ val = calloc (1, (B.st_size + 1) * (sizeof
(char)));
fread (val, 1, B.st_size, fp);
fclose (fp);
freeval = TRUE;
+
+ for (p = val + B.st_size;
+ B.st_size;
+ p--, B.st_size--) {
+ if ((*p == '\n') || (*p == '\r') ||
+ (*p == '\t') || (*p == ' ') ||
+ (*p == '\0'))
+ *p = '\0';
+ else
+ break;
+ }
}
skiparea = TRUE;
}
@@ -7846,10 +7857,21 @@
* to streams.
*/
fp = fopen (anchor_ptr->input_field->filename,
"r");
- val_used = malloc (B.st_size * (sizeof (char)));
+ val_used = calloc (1, (B.st_size + 1) * (sizeof
(char)));
freeval = TRUE;
fread (val_used, 1, B.st_size, fp);
fclose (fp);
+
+ for (p = val_used + B.st_size;
+ B.st_size;
+ p--, B.st_size--) {
+ if ((*p == '\n') || (*p == '\r') ||
+ (*p == '\t') || (*p == ' ') ||
+ (*p == '\0'))
+ *p = '\0';
+ else
+ break;
+ }
}
skiparea = TRUE;
}
diff -uNr lynx-2.8.2-dev.12.orig/src/LYKeymap.c
lynx-2.8.2-dev.12+kd/src/LYKeymap.c
--- lynx-2.8.2-dev.12.orig/src/LYKeymap.c Fri Jan 8 17:16:29 1999
+++ lynx-2.8.2-dev.12+kd/src/LYKeymap.c Wed Jan 6 09:12:00 1999
@@ -614,8 +614,9 @@
{ "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" },
-{ "CONVERT", "Puts a set of textarea fields into a file to edit"},
-{ "CONVERTEDIT", "Edits file generated by CONVERTion"},
+{ "CONVERT", "puts a set of textarea fields into a file to edit" },
+{ "CONVERTEDIT", "edits file generated by CONVERT operation" },
+{ "EDITTEXTAREA", "performs CONVERT followed by CONVERTEDIT on field" },
#ifdef USE_EXTERNALS
{ "EXTERN", "run external program with url" },
#endif
diff -uNr lynx-2.8.2-dev.12.orig/src/LYKeymap.h
lynx-2.8.2-dev.12+kd/src/LYKeymap.h
--- lynx-2.8.2-dev.12.orig/src/LYKeymap.h Fri Jan 8 17:16:29 1999
+++ lynx-2.8.2-dev.12+kd/src/LYKeymap.h Wed Jan 6 09:04:26 1999
@@ -115,15 +115,16 @@
* imagine using a preprocessor in other
* programming languages */
#define LYK_EDITCONVERT 76
+#define LYK_CONVERT_AND_EDIT 77
#ifdef USE_EXTERNALS
-#define LYK_EXTERN 77
+#define LYK_EXTERN 78
#if defined(VMS) || defined(DIRED_SUPPORT)
-#define LYK_DIRED_MENU 78
+#define LYK_DIRED_MENU 79
#endif /* VMS || DIRED_SUPPORT */
#else /* USE_EXTERNALS */
#if defined(VMS) || defined(DIRED_SUPPORT)
-#define LYK_DIRED_MENU 77
+#define LYK_DIRED_MENU 78
#endif /* VMS || DIRED_SUPPORT */
#endif /* !defined(USE_EXTERNALS) */
diff -uNr lynx-2.8.2-dev.12.orig/src/LYMainLoop.c
lynx-2.8.2-dev.12+kd/src/LYMainLoop.c
--- lynx-2.8.2-dev.12.orig/src/LYMainLoop.c Fri Jan 8 17:16:29 1999
+++ lynx-2.8.2-dev.12+kd/src/LYMainLoop.c Fri Jan 8 17:06:13 1999
@@ -4269,6 +4269,7 @@
break;
case LYK_CONVERT: /* put textarea text into file */
+ case LYK_CONVERT_AND_EDIT: /* case that combines both ops */
/*if curent link is part of a textarea*/
if (links[curdoc.link].type == WWW_FORM_LINK_TYPE &&
links[curdoc.link].form->type == F_TEXTAREA_TYPE)
@@ -4280,11 +4281,21 @@
* the objects I need, is this supposed to be a
module?
*/
HText_FileForm( &links[curdoc.link] );
- cmd = LYK_REFRESH;
+ if (cmd == LYK_CONVERT_AND_EDIT)
+ cmd = LYK_EDITCONVERT;
+ else
+ cmd = LYK_REFRESH;
goto new_cmd;
}
} else {
- HTInfoMsg("This textarea is already file");
+ if (cmd == LYK_CONVERT_AND_EDIT) {
+ cmd = LYK_EDITCONVERT;
+ goto new_cmd;
+ }
+ else
+ {
+ HTInfoMsg("This textarea is already file");
+ }
}
} else { /* not a textarea */
HTInfoMsg("CONVERT: Not in a textarea");
@@ -4296,7 +4307,7 @@
if (links[curdoc.link].type == WWW_FORM_LINK_TYPE &&
links[curdoc.link].form->type == F_TEXTAREA_TYPE)
{
- char com[200]; /* groan */
+ char com[512], tbuf[512]; /* groan */
/* Check to see if in a file */
if (links[curdoc.link].form->filename != NULL) {
struct stat B;
@@ -4304,10 +4315,27 @@
stop_curses();
/* editor should be lynx.cfg option */
/* StrAllocCopy? */
- snprintf(com, 200, "%s %s", editor,
links[curdoc.link].form->filename);
- system(com);
+ snprintf(com, 511, "%s %s",
+ editor,
+ links[curdoc.link].form->filename);
+
+ system (com);
+
+ /* blow off emacs-style backup file names~ ..
+ .. should probably generalize to include
+ .bak, .BAK, and (?), or make it a config
+ item in user's .lynxrc (?), or punt on
+ cleaning these up, leaving it up to the
+ user to do it in a wrapper script (?)
+ */
+ snprintf(tbuf, 512, "%s~",
+ links[curdoc.link].form->filename);
+ if (stat(tbuf, &B) == 0)
+ unlink(tbuf);
+
/* start screen */
start_curses();
+ refresh_screen = TRUE;
stat (links[curdoc.link].form->filename, &B);
if (B.st_size > g_maxfile_size) { /* too big */
##--eof--##
- Re: lynx-dev Any word on status of extended text entry fields?, (continued)
- Re: lynx-dev Any word on status of extended text entry fields?, Larry W. Virden, 1999/01/05
- lynx-dev [-dev.12] experimental text entry fields patch (updated), Kim DeVaughn, 1999/01/05
- lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Kim DeVaughn, 1999/01/06
- lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Kim DeVaughn, 1999/01/07
- Re: lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Philip Webb, 1999/01/07
- lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Kim DeVaughn, 1999/01/07
- lynx-dev Re: [-dev.12] experimental text entry fields patch (updated),
Kim DeVaughn <=
- Re: lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Michael Warner, 1999/01/09
- Re: lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Larry W. Virden, 1999/01/09
- lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Kim DeVaughn, 1999/01/09
- Re: lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Bela Lubkin, 1999/01/09
- lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Kim DeVaughn, 1999/01/09
- Re: lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Serge MUNHOVEN, 1999/01/10
- lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Kim DeVaughn, 1999/01/10
- Re: lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), Bela Lubkin, 1999/01/10
- Re: lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), pg, 1999/01/11
- Re: lynx-dev Re: [-dev.12] experimental text entry fields patch (updated), dickey, 1999/01/11