diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2008-09-21 21:12:42 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2008-09-21 21:12:42 -0400 |
commit | f385296bc2069c23f21accb2d55fdda5906e607d (patch) | |
tree | ae7508413b1b5dc46f35acc77127dc6d4917ffee /src | |
parent | f3c91bbbca5ebc55f001083207765c717e2fdbf9 (diff) | |
download | lynx-snapshots-f385296bc2069c23f21accb2d55fdda5906e607d.tar.gz |
snapshot of project "lynx", label v2-8-7dev_9n
Diffstat (limited to 'src')
-rw-r--r-- | src/GridText.c | 187 | ||||
-rw-r--r-- | src/HTML.c | 64 | ||||
-rw-r--r-- | src/LYMainLoop.c | 8 |
3 files changed, 130 insertions, 129 deletions
diff --git a/src/GridText.c b/src/GridText.c index 0acce669..ed66c4f9 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.153 2008/09/07 22:38:54 tom Exp $ + * $LynxId: GridText.c,v 1.156 2008/09/21 19:48:41 tom Exp $ * * Character grid hypertext object * =============================== @@ -9706,7 +9706,7 @@ int HText_beginInput(HText *text, BOOL underline, int MaximumSize; char marker[16]; - CTRACE((tfp, "GridText: Entering HText_beginInput\n")); + CTRACE((tfp, "GridText: Entering HText_beginInput type=%s\n", NonNull(I->type))); POOLtypecalloc(TextAnchor, a); @@ -9770,7 +9770,7 @@ int HText_beginInput(HText *text, BOOL underline, f->select_list = 0; f->number = HTFormNumber; - f->disabled = HTFormDisabled; + f->disabled = HTFormDisabled || I->disabled; f->no_cache = NO; HTFormFields++; @@ -12555,41 +12555,23 @@ static BOOLEAN IsFormsTextarea(FormInfo * form, TextAnchor *anchor_ptr) !strcmp(anchor_ptr->input_field->name, form->name)); } -/* - * 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). - * - * 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 - */ -int HText_ExtEditForm(LinkInfo * form_link) +static int finish_ExtEditForm(LinkInfo * form_link, TextAnchor *start_anchor, + char *ed_temp, + int orig_cnt) { struct stat stat_info; size_t size; - char *ed_temp; FILE *fp; TextAnchor *anchor_ptr; - TextAnchor *start_anchor = NULL; TextAnchor *end_anchor = NULL; - BOOLEAN firstanchor = TRUE; BOOLEAN wrapalert = FALSE; - char ed_offset[10]; - int start_line = 0; int entry_line = form_link->anchor_line_num; int exit_line = 0; - int orig_cnt = 0; int line_cnt = 1; - FormInfo *form = form_link->l_form; - HTLine *htline = NULL; char *ebuf; @@ -12605,60 +12587,6 @@ int HText_ExtEditForm(LinkInfo * form_link) CTRACE((tfp, "GridText: entered HText_ExtEditForm()\n")); - ed_temp = (char *) malloc(LY_MAXPATH); - if ((fp = LYOpenTemp(ed_temp, "", "w")) == 0) { - FREE(ed_temp); - return (0); - } - - /* - * Begin at the beginning, to find 1st anchor in the TEXTAREA, then - * write all of its lines (anchors) out to the edit temp file. - */ - anchor_ptr = HTMainText->first_anchor; - - while (anchor_ptr) { - - if (IsFormsTextarea(form, anchor_ptr)) { - - if (firstanchor) { - firstanchor = FALSE; - start_anchor = anchor_ptr; - start_line = anchor_ptr->line_num; - } - orig_cnt++; - - /* - * Write the anchors' text to the temp edit file. - */ - fputs(anchor_ptr->input_field->value, fp); - fputc('\n', fp); - - } else { - - if (!firstanchor) - break; - } - anchor_ptr = anchor_ptr->next; - } - LYCloseTempFP(fp); - - CTRACE((tfp, "GridText: TEXTAREA name=|%s| dumped to tempfile\n", form->name)); - CTRACE((tfp, "GridText: invoking editor (%s) on tempfile\n", editor)); - - /* - * Go edit the TEXTAREA temp file, with the initial editor line - * corresponding to the TEXTAREA line the cursor is on (if such - * positioning is supported by the editor [as lynx knows it]). - */ - ed_offset[0] = 0; /* pre-ANSI compilers don't initialize aggregates - TD */ - if (((entry_line - start_line) > 0) && editor_can_position()) - sprintf(ed_offset, "%d", ((entry_line - start_line) + 1)); - - edit_temporary_file(ed_temp, ed_offset, NULL); - - CTRACE((tfp, "GridText: returned from editor (%s)\n", editor)); - /* * Read back the edited temp file into our buffer. */ @@ -12680,7 +12608,6 @@ int HText_ExtEditForm(LinkInfo * form_link) * to recover the file manually from the temp space while * the lynx session is not over. - kw */ - free(ed_temp); HTAlwaysAlert(NULL, MEMORY_EXHAUSTED_FILE); return 0; } @@ -12866,6 +12793,106 @@ int HText_ExtEditForm(LinkInfo * form_link) */ FREE(line); FREE(ebuf); + + /* + * 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); +} + +/* + * 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). + * + * 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 + */ +int HText_ExtEditForm(LinkInfo * form_link) +{ + char *ed_temp; + FILE *fp; + + TextAnchor *anchor_ptr; + TextAnchor *start_anchor = NULL; + BOOLEAN firstanchor = TRUE; + + char ed_offset[10]; + int start_line = 0; + int entry_line = form_link->anchor_line_num; + int orig_cnt = 0; + int offset; + + FormInfo *form = form_link->l_form; + + CTRACE((tfp, "GridText: entered HText_ExtEditForm()\n")); + + ed_temp = (char *) malloc(LY_MAXPATH); + if ((fp = LYOpenTemp(ed_temp, "", "w")) == 0) { + FREE(ed_temp); + return (0); + } + + /* + * Begin at the beginning, to find 1st anchor in the TEXTAREA, then + * write all of its lines (anchors) out to the edit temp file. + */ + anchor_ptr = HTMainText->first_anchor; + + while (anchor_ptr) { + + if (IsFormsTextarea(form, anchor_ptr)) { + + if (firstanchor) { + firstanchor = FALSE; + start_anchor = anchor_ptr; + start_line = anchor_ptr->line_num; + } + orig_cnt++; + + /* + * Write the anchors' text to the temp edit file. + */ + fputs(anchor_ptr->input_field->value, fp); + fputc('\n', fp); + + } else { + + if (!firstanchor) + break; + } + anchor_ptr = anchor_ptr->next; + } + LYCloseTempFP(fp); + + CTRACE((tfp, "GridText: TEXTAREA name=|%s| dumped to tempfile\n", form->name)); + CTRACE((tfp, "GridText: invoking editor (%s) on tempfile\n", editor)); + + /* + * Go edit the TEXTAREA temp file, with the initial editor line + * corresponding to the TEXTAREA line the cursor is on (if such + * positioning is supported by the editor [as lynx knows it]). + */ + ed_offset[0] = 0; /* pre-ANSI compilers don't initialize aggregates - TD */ + if (((entry_line - start_line) > 0) && editor_can_position()) + sprintf(ed_offset, "%d", ((entry_line - start_line) + 1)); + + edit_temporary_file(ed_temp, ed_offset, NULL); + + CTRACE((tfp, "GridText: returned from editor (%s)\n", editor)); + + if (form->disabled) + offset = 0; + else + offset = finish_ExtEditForm(form_link, start_anchor, ed_temp, orig_cnt); + LYRemoveTemp(ed_temp); FREE(ed_temp); @@ -12877,7 +12904,7 @@ int HText_ExtEditForm(LinkInfo * form_link) * (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); + return offset; } /* diff --git a/src/HTML.c b/src/HTML.c index a66ba5b4..c9064dba 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTML.c,v 1.114 2008/09/06 14:33:02 tom Exp $ + * $LynxId: HTML.c,v 1.115 2008/09/21 17:46:32 tom Exp $ * * Structured stream to Rich hypertext converter * ============================================ @@ -4478,26 +4478,7 @@ static int HTML_start_element(HTStructured * me, int element_number, HTkcode specified_kcode = NOKANJI; /* init */ - I.align = NULL; - I.accept = NULL; - I.checked = NO; - I.iclass = NULL; - I.disabled = NO; - I.error = NULL; - I.height = NULL; - I.id = NULL; - I.lang = NULL; - I.max = NULL; - I.maxlength = NULL; - I.md = NULL; - I.min = NULL; - I.name = NULL; - I.size = 0; - I.src = NULL; - I.type = NULL; - I.value = NULL; - I.width = NULL; - I.accept_cs = NULL; + memset(&I, 0, sizeof(I)); I.name_cs = ATTR_CS_IN; I.value_cs = ATTR_CS_IN; @@ -4780,6 +4761,8 @@ static int HTML_start_element(HTStructured * me, int element_number, */ I.value = ImageSrc; } + if (present && present[HTML_INPUT_READONLY]) + I.disabled = YES; if (present && present[HTML_INPUT_CHECKED]) I.checked = YES; if (present && present[HTML_INPUT_SIZE] && @@ -5015,9 +4998,9 @@ static int HTML_start_element(HTStructured * me, int element_number, if (present && present[HTML_TEXTAREA_COLS] && value[HTML_TEXTAREA_COLS] && - isdigit(UCH(*value[HTML_TEXTAREA_COLS]))) + isdigit(UCH(*value[HTML_TEXTAREA_COLS]))) { me->textarea_cols = atoi(value[HTML_TEXTAREA_COLS]); - else { + } else { int width; width = LYcolLimit - @@ -5034,16 +5017,23 @@ static int HTML_start_element(HTStructured * me, int element_number, if (present && present[HTML_TEXTAREA_ROWS] && value[HTML_TEXTAREA_ROWS] && - isdigit(UCH(*value[HTML_TEXTAREA_ROWS]))) + isdigit(UCH(*value[HTML_TEXTAREA_ROWS]))) { me->textarea_rows = atoi(value[HTML_TEXTAREA_ROWS]); - else + } else { me->textarea_rows = DFT_TEXTAREA_ROWS; + } LimitValue(me->textarea_rows, MAX_TEXTAREA_ROWS); + /* + * Lynx treats disabled and readonly textarea's the same - + * unmodifiable in either case. + */ + me->textarea_disabled = NO; + if (present && present[HTML_TEXTAREA_READONLY]) + me->textarea_disabled = YES; + if (present && present[HTML_TEXTAREA_DISABLED]) me->textarea_disabled = YES; - else - me->textarea_disabled = NO; if (present && present[HTML_TEXTAREA_ID] && non_empty(value[HTML_TEXTAREA_ID])) { @@ -6800,25 +6790,7 @@ static int HTML_end_element(HTStructured * me, int element_number, /* * Initialize. */ - I.align = NULL; - I.accept = NULL; - I.checked = NO; - I.iclass = NULL; - I.disabled = NO; - I.error = NULL; - I.height = NULL; - I.id = NULL; - I.lang = NULL; - I.max = NULL; - I.maxlength = NULL; - I.md = NULL; - I.min = NULL; - I.name = NULL; - I.size = 0; - I.src = NULL; - I.type = NULL; - I.value = NULL; - I.width = NULL; + memset(&I, 0, sizeof(I)); I.value_cs = current_char_set; UPDATE_STYLE; diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index d7e0cde3..5cbcafe7 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1,4 +1,6 @@ -/* $LynxId: LYMainLoop.c,v 1.152 2008/09/07 16:28:33 tom Exp $ */ +/* + * $LynxId: LYMainLoop.c,v 1.153 2008/09/17 22:52:58 tom Exp $ + */ #include <HTUtils.h> #include <HTAccess.h> #include <HTParse.h> @@ -2182,7 +2184,7 @@ static int handle_LYK_DOWNLOAD(int *cmd, newdoc.isHEAD = HDOC(number).isHEAD; newdoc.safe = HDOC(number).safe; newdoc.internal_link = FALSE; - newdoc.link = 0; + newdoc.link = (user_mode == NOVICE_MODE) ? 1 : 0; HTOutputFormat = HTAtom_for("www/download"); LYUserSpecifiedURL = TRUE; /* @@ -2256,7 +2258,7 @@ static int handle_LYK_DOWNLOAD(int *cmd, newdoc.safe = FALSE; } newdoc.internal_link = FALSE; - newdoc.link = 0; + newdoc.link = (user_mode == NOVICE_MODE) ? 1 : 0; HTOutputFormat = HTAtom_for("www/download"); /* * Force the document to be reloaded. |