📄 action.c
字号:
/* Sessions action management *//* $Id: action.c,v 1.129.4.2 2005/02/28 02:07:05 jonas Exp $ */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <stdlib.h>#include "elinks.h"#include "main.h"#include "bookmarks/dialogs.h"#include "cache/dialogs.h"#include "config/conf.h"#include "config/dialogs.h"#include "config/kbdbind.h"#include "config/options.h"#include "cookies/cookies.h"#include "cookies/dialogs.h"#include "dialogs/document.h"#include "dialogs/download.h"#include "dialogs/exmode.h"#include "dialogs/info.h"#include "dialogs/menu.h"#include "dialogs/options.h"#include "dialogs/status.h"#include "document/document.h"#include "document/view.h"#include "formhist/dialogs.h"#include "globhist/dialogs.h"#include "protocol/auth/auth.h"#include "protocol/auth/dialogs.h"#include "terminal/tab.h"#include "terminal/terminal.h"#include "terminal/window.h"#include "sched/action.h"#include "sched/connection.h"#include "sched/event.h"#include "sched/session.h"#include "sched/task.h"#include "viewer/text/draw.h"#include "viewer/text/form.h"#include "viewer/text/link.h"#include "viewer/text/search.h"#include "viewer/text/view.h"static voidtoggle_document_option(struct session *ses, unsigned char *option_name){ struct option *option; long number; assert(ses && ses->doc_view && ses->tab && ses->tab->term); if_assert_failed return; if (!ses->doc_view->vs) { nowhere_box(ses->tab->term, NULL); return; } option = get_opt_rec(config_options, option_name); number = option->value.number + 1; assert(option->type == OPT_BOOL || option->type == OPT_INT); assert(option->max); /* TODO: toggle per document. --Zas */ /* TODO: call change hooks. --jonas */ option->value.number = (number <= option->max) ? number : option->min; draw_formatted(ses, 1);}typedef enum frame_event_status (*frame_action)(struct session *, struct document_view *, int);static enum frame_event_statusdo_frame_action(struct session *ses, struct document_view *doc_view, frame_action action, int magic, int jump_to_link_number){ assert(ses && action); if_assert_failed return FRAME_EVENT_OK; if (!have_location(ses)) return FRAME_EVENT_OK; /* There is a bug for this current_frame() returning NULL for recursive * framesets unfortunately bugzilla is down ATM so the number is * missing. --jonas */ if (action == set_frame && !doc_view) return FRAME_EVENT_OK; assertm(doc_view, "document not formatted"); if_assert_failed return FRAME_EVENT_OK; assertm(doc_view->vs, "document view has no state"); if_assert_failed return FRAME_EVENT_OK; if (jump_to_link_number && !try_jump_to_link_number(ses, doc_view)) return FRAME_EVENT_OK; return action(ses, doc_view, magic);}static voidgoto_url_action(struct session *ses, unsigned char *(*get_url)(struct session *, unsigned char *, size_t)){ unsigned char url[MAX_STR_LEN]; if (!get_url || !get_url(ses, url, sizeof(url))) url[0] = 0; dialog_goto_url(ses, url);}/* This could gradually become some multiplexor / switch noodle containing * most if not all default handling of actions (for the main mapping) that * frame_ev() and/or send_event() could use as a backend. *//* Many execution paths may lead to this code so it needs to take appropriate * precausions to stuff like doc_view and doc_view->vs being NULL. */enum frame_event_statusdo_action(struct session *ses, enum main_action action, int verbose){ enum frame_event_status status = FRAME_EVENT_OK; struct terminal *term = ses->tab->term; struct document_view *doc_view = current_frame(ses); int has_vs = (doc_view && doc_view->vs); struct link *link = has_vs ? get_current_link(doc_view) : NULL; int anonymous = get_cmd_opt_bool("anonymous"); /* Please keep in alphabetical order for now. Later we can sort by most * used or something. */ switch (action) { case ACT_MAIN_ABORT_CONNECTION: abort_loading(ses, 1); print_screen_status(ses); break; case ACT_MAIN_ADD_BOOKMARK:#ifdef CONFIG_BOOKMARKS if (anonymous) break; launch_bm_add_doc_dialog(term, NULL, ses);#endif break; case ACT_MAIN_ADD_BOOKMARK_LINK:#ifdef CONFIG_BOOKMARKS if (anonymous) break; launch_bm_add_link_dialog(term, NULL, ses);#endif break; case ACT_MAIN_ADD_BOOKMARK_TABS:#ifdef CONFIG_BOOKMARKS if (anonymous) break; bookmark_terminal_tabs_dialog(term);#endif break; case ACT_MAIN_AUTH_MANAGER: auth_manager(ses); break; case ACT_MAIN_BOOKMARK_MANAGER:#ifdef CONFIG_BOOKMARKS bookmark_manager(ses);#endif break; case ACT_MAIN_CACHE_MANAGER: cache_manager(ses); break; case ACT_MAIN_CACHE_MINIMIZE: shrink_memory(1); break; case ACT_MAIN_COOKIES_LOAD:#ifdef CONFIG_COOKIES if (anonymous || !get_opt_bool("cookies.save")) break; load_cookies();#endif break; case ACT_MAIN_COOKIE_MANAGER:#ifdef CONFIG_COOKIES cookie_manager(ses);#endif break; case ACT_MAIN_COPY_CLIPBOARD: if (!has_vs) break; status = do_frame_action(ses, doc_view, copy_current_link_to_clipboard, 0, 1); break; case ACT_MAIN_DOCUMENT_INFO: document_info_dialog(ses); break; case ACT_MAIN_DOWNLOAD_MANAGER: download_manager(ses); break; case ACT_MAIN_EXMODE:#ifdef CONFIG_EXMODE exmode_start(ses);#endif break; case ACT_MAIN_FILE_MENU: activate_bfu_technology(ses, 0); break; case ACT_MAIN_FIND_NEXT: if (!has_vs) break; status = do_frame_action(ses, doc_view, find_next, 1, 0); break; case ACT_MAIN_FIND_NEXT_BACK: if (!has_vs) break; status = do_frame_action(ses, doc_view, find_next, -1, 0); break; case ACT_MAIN_FORGET_CREDENTIALS: free_auth(); shrink_memory(1); /* flush caches */ break; case ACT_MAIN_FORMHIST_MANAGER:#ifdef CONFIG_FORMHIST formhist_manager(ses);#endif break; case ACT_MAIN_FRAME_EXTERNAL_COMMAND: if (!has_vs) break; status = do_frame_action(ses, doc_view, pass_uri_to_command, PASS_URI_FRAME, 0); break; case ACT_MAIN_FRAME_NEXT: next_frame(ses, 1); draw_formatted(ses, 0); break; case ACT_MAIN_FRAME_MAXIMIZE: if (!has_vs) break; status = do_frame_action(ses, doc_view, set_frame, 0, 0); break; case ACT_MAIN_FRAME_PREV: next_frame(ses, -1); draw_formatted(ses, 0); break; case ACT_MAIN_GOTO_URL: goto_url_action(ses, NULL); break; case ACT_MAIN_GOTO_URL_CURRENT: goto_url_action(ses, get_current_url); break; case ACT_MAIN_GOTO_URL_CURRENT_LINK: goto_url_action(ses, get_current_link_url); break; case ACT_MAIN_GOTO_URL_HOME: goto_url_home(ses); break; case ACT_MAIN_HEADER_INFO: protocol_header_dialog(ses); break; case ACT_MAIN_HISTORY_MANAGER:#ifdef CONFIG_GLOBHIST history_manager(ses);#endif break; case ACT_MAIN_HISTORY_MOVE_BACK: go_back(ses); break; case ACT_MAIN_HISTORY_MOVE_FORWARD: go_unback(ses); break; case ACT_MAIN_JUMP_TO_LINK: try_jump_to_link_number(ses, doc_view); break; case ACT_MAIN_KEYBINDING_MANAGER: if (anonymous) break; keybinding_manager(ses); break; case ACT_MAIN_KILL_BACKGROUNDED_CONNECTIONS: abort_background_connections(); break; case ACT_MAIN_LINK_DOWNLOAD: if (!has_vs || anonymous) break; status = do_frame_action(ses, doc_view, download_link, action, 1); break; case ACT_MAIN_LINK_DOWNLOAD_IMAGE: if (!has_vs || anonymous) break; status = do_frame_action(ses, doc_view, download_link, action, 1); break; case ACT_MAIN_LINK_DOWNLOAD_RESUME: if (!has_vs || anonymous) break; status = do_frame_action(ses, doc_view, download_link, action, 1); break; case ACT_MAIN_LINK_EXTERNAL_COMMAND: if (!has_vs) break; status = do_frame_action(ses, doc_view, pass_uri_to_command, PASS_URI_LINK, 0); break; case ACT_MAIN_LINK_FOLLOW: if (!has_vs) break; status = do_frame_action(ses, doc_view, enter, 0, 1); break; case ACT_MAIN_LINK_FOLLOW_RELOAD: if (!has_vs) break; status = do_frame_action(ses, doc_view, enter, 1, 1); break; case ACT_MAIN_LINK_MENU: if (!try_jump_to_link_number(ses, doc_view)) break; link_menu(term, NULL, ses); break; case ACT_MAIN_LUA_CONSOLE:#ifdef CONFIG_LUA trigger_event_name("dialog-lua-console", ses);#endif break; case ACT_MAIN_MARK_SET:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -