📄 dialogs.c
字号:
/* Form history related dialogs *//* $Id: dialogs.c,v 1.38.2.3 2005/04/06 09:11:18 jonas Exp $ */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <string.h>#include "elinks.h"#include "bfu/dialog.h"#include "formhist/dialogs.h"#include "formhist/formhist.h"#include "dialogs/edit.h"#include "intl/gettext/libintl.h"#include "protocol/uri.h"#include "sched/session.h"#include "terminal/terminal.h"#include "util/lists.h"#include "util/memory.h"#include "util/object.h"#include "util/string.h"#include "viewer/text/form.h"static voidlock_formhist_data(struct listbox_item *item){ object_lock((struct formhist_data *) item->udata);}static voidunlock_formhist_data(struct listbox_item *item){ object_unlock((struct formhist_data *) item->udata);}static intis_formhist_data_used(struct listbox_item *item){ return is_object_used((struct formhist_data *) item->udata);}static unsigned char *get_formhist_data_text(struct listbox_item *item, struct terminal *term){ struct formhist_data *formhist_data = item->udata; return stracpy(formhist_data->url);}static unsigned char *get_formhist_data_info(struct listbox_item *item, struct terminal *term){ struct formhist_data *formhist_data = item->udata; struct string info; struct submitted_value *sv; if (item->type == BI_FOLDER) return NULL; if (!init_string(&info)) return NULL; add_format_to_string(&info, "%s: %s", _("URL", term), formhist_data->url); add_char_to_string(&info, '\n'); if (formhist_data->dontsave) add_to_string(&info, _("Forms are never saved for this URL.", term)); else add_to_string(&info, _("Forms are saved for this URL.", term)); add_char_to_string(&info, '\n'); foreach (sv, *formhist_data->submit) { add_format_to_string(&info, "\n[%8s] ", form_type2str(sv->type)); add_to_string(&info, sv->name); add_to_string(&info, " = "); if (sv->value && *sv->value) { if (sv->type != FC_PASSWORD) add_to_string(&info, sv->value); else add_to_string(&info, "********"); } } return info.source;}static struct uri *get_formhist_data_uri(struct listbox_item *item){ struct formhist_data *formhist_data = item->udata; return get_uri(formhist_data->url, 0);}static struct listbox_item *get_formhist_data_root(struct listbox_item *item){ return NULL;}static intcan_delete_formhist_data(struct listbox_item *item){ return 1;}static voiddelete_formhist_data(struct listbox_item *item, int last){ struct formhist_data *formhist_data = item->udata; assert(!is_object_used(formhist_data)); del_from_list(formhist_data); free_form(formhist_data);}static struct listbox_ops_messages formhist_messages = { /* cant_delete_item */ N_("Sorry, but form \"%s\" cannot be deleted."), /* cant_delete_used_item */ N_("Sorry, but form \"%s\" is being used by something else."), /* cant_delete_folder */ NULL, /* cant_delete_used_folder */ NULL, /* delete_marked_items_title */ N_("Delete marked forms"), /* delete_marked_items */ N_("Delete marked forms?"), /* delete_folder_title */ NULL, /* delete_folder */ NULL, /* delete_item_title */ N_("Delete form"), /* delete_item */ N_("Delete this form?"), /* clear_all_items_title */ N_("Clear all forms"), /* clear_all_items_title */ N_("Do you really want to remove all forms?"),};static struct listbox_ops formhist_listbox_ops = { lock_formhist_data, unlock_formhist_data, is_formhist_data_used, get_formhist_data_text, get_formhist_data_info, get_formhist_data_uri, get_formhist_data_root, NULL, can_delete_formhist_data, delete_formhist_data, NULL, &formhist_messages,};static t_handler_event_statuspush_login_button(struct dialog_data *dlg_data, struct widget_data *button){ struct listbox_data *box = get_dlg_listbox_data(dlg_data); struct formhist_data *formhist_data; struct terminal *term = dlg_data->win->term; if (!box->sel || !box->sel->udata) return EVENT_PROCESSED; formhist_data = box->sel->udata; if (formhist_data->dontsave) { info_box(term, 0, N_("Form not saved"), ALIGN_CENTER, N_("No saved information for this URL.\n" "If you want to save passwords for this URL, enable " "it by pressing the \"Toggle saving\" button.")); return EVENT_PROCESSED; } push_hierbox_goto_button(dlg_data, button); return EVENT_PROCESSED;}static t_handler_event_statuspush_toggle_dontsave_button(struct dialog_data *dlg_data, struct widget_data *button){ struct listbox_data *box = get_dlg_listbox_data(dlg_data); struct formhist_data *formhist_data; if (!box->sel || !box->sel->udata) return EVENT_PROCESSED; formhist_data = box->sel->udata; formhist_data->dontsave = !formhist_data->dontsave; return EVENT_PROCESSED;}static t_handler_event_statuspush_save_button(struct dialog_data *dlg_data, struct widget_data *button){ save_forms_to_file(); return EVENT_PROCESSED;}static struct hierbox_browser_button formhist_buttons[] = { { N_("~Login"), push_login_button, 1 }, { N_("~Info"), push_hierbox_info_button, 1 }, { N_("~Delete"), push_hierbox_delete_button, 1 }, { N_("~Toggle saving"), push_toggle_dontsave_button, 0 }, { N_("Clea~r"), push_hierbox_clear_button, 1 }, { N_("Sa~ve"), push_save_button, 0 },};struct_hierbox_browser( formhist_browser, N_("Form history manager"), formhist_buttons, &formhist_listbox_ops);voidformhist_manager(struct session *ses){ load_forms_from_file(); hierbox_browser(&formhist_browser, ses);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -