mirror of
https://github.com/rkd77/elinks.git
synced 2024-09-13 00:38:32 -04:00
Fold load_textarea_file into textarea_edit.
This commit is contained in:
parent
517bb03da4
commit
9959f4d788
@ -311,22 +311,6 @@ save_textarea_file(unsigned char *value)
|
|||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *
|
|
||||||
load_textarea_file(unsigned char *filename, size_t maxlength)
|
|
||||||
{
|
|
||||||
struct string file;
|
|
||||||
|
|
||||||
if (!init_string(&file)
|
|
||||||
|| !add_file_to_string(&file, filename))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
unlink(filename);
|
|
||||||
|
|
||||||
if (file.length > maxlength) { done_string(&file); return NULL; }
|
|
||||||
|
|
||||||
return file.source;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
textarea_edit(int op, struct terminal *term_, struct form_state *fs_,
|
textarea_edit(int op, struct terminal *term_, struct form_state *fs_,
|
||||||
struct document_view *doc_view_, struct link *link_)
|
struct document_view *doc_view_, struct link *link_)
|
||||||
@ -388,16 +372,28 @@ textarea_edit(int op, struct terminal *term_, struct form_state *fs_,
|
|||||||
textarea_editor = 1;
|
textarea_editor = 1;
|
||||||
|
|
||||||
} else if (op == 1 && fs) {
|
} else if (op == 1 && fs) {
|
||||||
unsigned char *value = load_textarea_file(fn, fc_maxlength);
|
struct string file;
|
||||||
|
|
||||||
|
if (!init_string(&file)
|
||||||
|
|| !add_file_to_string(&file, fn)) {
|
||||||
|
textarea_editor = 0;
|
||||||
|
goto free_and_return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink(fn);
|
||||||
|
|
||||||
|
if (file.length > fc_maxlength) {
|
||||||
|
done_string(&file);
|
||||||
|
textarea_editor = 0;
|
||||||
|
goto free_and_return;
|
||||||
|
}
|
||||||
|
|
||||||
if (value) {
|
|
||||||
mem_free(fs->value);
|
mem_free(fs->value);
|
||||||
fs->value = value;
|
fs->value = file.source;
|
||||||
fs->state = strlen(value);
|
fs->state = file.length;
|
||||||
|
|
||||||
if (doc_view && link)
|
if (doc_view && link)
|
||||||
draw_form_entry(term, doc_view, link);
|
draw_form_entry(term, doc_view, link);
|
||||||
}
|
|
||||||
|
|
||||||
textarea_editor = 0;
|
textarea_editor = 0;
|
||||||
goto free_and_return;
|
goto free_and_return;
|
||||||
|
Loading…
Reference in New Issue
Block a user