📄 menu.c
字号:
d->items[7].data = (void *)&ts->block_cursor; d->items[8].type = D_CHECKBOX; d->items[8].gid = 0; d->items[8].dlen = sizeof(int); d->items[8].data = (void *)&ts->col; d->items[9].type = D_BUTTON; d->items[9].gid = B_ENTER; d->items[9].fn = ok_dialog; d->items[9].text = TEXT(T_OK); d->items[10].type = D_BUTTON; d->items[10].gid = B_ESC; d->items[10].fn = cancel_dialog; d->items[10].text = TEXT(T_CANCEL); d->items[11].type = D_END; do_dialog(term, d, getml(d, NULL));}unsigned char *http_labels[] = { TEXT(T_USE_HTTP_10), TEXT(T_ALLOW_SERVER_BLACKLIST), TEXT(T_BROKEN_302_REDIRECT), TEXT(T_NO_KEEPALIVE_AFTER_POST_REQUEST), TEXT(T_DO_NOT_SEND_ACCEPT_CHARSET) };int dlg_http_options(struct dialog_data *dlg, struct dialog_item_data *di){ struct http_bugs *bugs = (struct http_bugs *)di->cdata; struct dialog *d; d = mem_alloc(sizeof(struct dialog) + 8 * sizeof(struct dialog_item)); memset(d, 0, sizeof(struct dialog) + 8 * sizeof(struct dialog_item)); d->title = TEXT(T_HTTP_BUG_WORKAROUNDS); d->fn = checkbox_list_fn; d->udata = http_labels; d->items[0].type = D_CHECKBOX; d->items[0].gid = 0; d->items[0].dlen = sizeof(int); d->items[0].data = (void *)&bugs->http10; d->items[1].type = D_CHECKBOX; d->items[1].gid = 0; d->items[1].dlen = sizeof(int); d->items[1].data = (void *)&bugs->allow_blacklist; d->items[2].type = D_CHECKBOX; d->items[2].gid = 0; d->items[2].dlen = sizeof(int); d->items[2].data = (void *)&bugs->bug_302_redirect; d->items[3].type = D_CHECKBOX; d->items[3].gid = 0; d->items[3].dlen = sizeof(int); d->items[3].data = (void *)&bugs->bug_post_no_keepalive; d->items[4].type = D_CHECKBOX; d->items[4].gid = 0; d->items[4].dlen = sizeof(int); d->items[4].data = (void *)&bugs->no_accept_charset; d->items[5].type = D_BUTTON; d->items[5].gid = B_ENTER; d->items[5].fn = ok_dialog; d->items[5].text = TEXT(T_OK); d->items[6].type = D_BUTTON; d->items[6].gid = B_ESC; d->items[6].fn = cancel_dialog; d->items[6].text = TEXT(T_CANCEL); d->items[7].type = D_END; do_dialog(dlg->win->term, d, getml(d, NULL)); return 0;}unsigned char *ftp_texts[] = { TEXT(T_PASSWORD_FOR_ANONYMOUS_LOGIN), TEXT(T_USE_PASSIVE_FTP), TEXT(T_USE_FAST_FTP), TEXT(T_SET_TYPE_OF_SERVICE), NULL };void ftpopt_fn(struct dialog_data *dlg){ struct terminal *term = dlg->win->term; int max = 0, min = 0; int w, rw; int y = 0; max_text_width(term, ftp_texts[0], &max); min_text_width(term, ftp_texts[0], &min); checkboxes_width(term, ftp_texts + 1, &max, max_text_width); checkboxes_width(term, ftp_texts + 1, &min, min_text_width); max_buttons_width(term, dlg->items + dlg->n - 2, 2, &max); min_buttons_width(term, dlg->items + dlg->n - 2, 2, &min); w = term->x * 9 / 10 - 2 * DIALOG_LB; if (w > max) w = max; if (w < min) w = min; if (w > term->x - 2 * DIALOG_LB) w = term->x - 2 * DIALOG_LB; if (w < 5) w = 5; rw = 0; dlg_format_text(NULL, term, ftp_texts[0], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT); y += 1; dlg_format_checkboxes(NULL, term, dlg->items + 1, dlg->n - 3, 0, &y, w, &rw, ftp_texts + 1); y += 1; dlg_format_buttons(NULL, term, dlg->items + dlg->n - 2, 2, 0, &y, w, &rw, AL_CENTER); w = rw; dlg->xw = rw + 2 * DIALOG_LB; dlg->yw = y + 2 * DIALOG_TB; center_dlg(dlg); draw_dlg(dlg); y = dlg->y + DIALOG_TB; dlg_format_text(term, term, ftp_texts[0], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT); dlg_format_field(term, term, dlg->items, dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT); y += 1; dlg_format_checkboxes(term, term, dlg->items + 1, dlg->n - 3, dlg->x + DIALOG_LB, &y, w, NULL, ftp_texts + 1); y += 1; dlg_format_buttons(term, term, dlg->items + dlg->n - 2, 2, dlg->x + DIALOG_LB, &y, w, &rw, AL_CENTER);}int dlg_ftp_options(struct dialog_data *dlg, struct dialog_item_data *di){ int a; struct ftp_options *ftp_options = (struct ftp_options *)di->cdata; struct dialog *d; d = mem_alloc(sizeof(struct dialog) + 7 * sizeof(struct dialog_item)); memset(d, 0, sizeof(struct dialog) + 7 * sizeof(struct dialog_item)); d->title = TEXT(T_FTP_OPTIONS); d->fn = ftpopt_fn; d->items[0].type = D_FIELD; d->items[0].dlen = MAX_STR_LEN; d->items[0].data = ftp_options->anon_pass; d->items[1].type = D_CHECKBOX; d->items[1].dlen = sizeof(int); d->items[1].data = (void*)&ftp_options->passive_ftp; d->items[1].gid = 0; d->items[2].type = D_CHECKBOX; d->items[2].dlen = sizeof(int); d->items[2].data = (void*)&ftp_options->fast_ftp;#ifdef HAVE_IPTOS d->items[3].type = D_CHECKBOX; d->items[3].dlen = sizeof(int); d->items[3].data = (void*)&ftp_options->set_tos; a = 4;#else a = 3;#endif d->items[a].type = D_BUTTON; d->items[a].gid = B_ENTER; d->items[a].fn = ok_dialog; d->items[a].text = TEXT(T_OK); a++; d->items[a].type = D_BUTTON; d->items[a].gid = B_ESC; d->items[a].fn = cancel_dialog; d->items[a].text = TEXT(T_CANCEL); a++; d->items[a].type = D_END; do_dialog(dlg->win->term, d, getml(d, NULL)); return 0;}unsigned char max_c_str[3];unsigned char max_cth_str[3];unsigned char max_t_str[3];unsigned char time_str[5];unsigned char unrtime_str[5];void refresh_net(void *xxx){ /*abort_all_connections();*/ max_connections = atoi(max_c_str); max_connections_to_host = atoi(max_cth_str); max_tries = atoi(max_t_str); receive_timeout = atoi(time_str); unrestartable_receive_timeout = atoi(unrtime_str); register_bottom_half(check_queue, NULL);}unsigned char *net_msg[] = { TEXT(T_HTTP_PROXY__HOST_PORT), TEXT(T_FTP_PROXY__HOST_PORT), TEXT(T_MAX_CONNECTIONS), TEXT(T_MAX_CONNECTIONS_TO_ONE_HOST), TEXT(T_RETRIES), TEXT(T_RECEIVE_TIMEOUT_SEC), TEXT(T_TIMEOUT_WHEN_UNRESTARTABLE), TEXT(T_ASYNC_DNS_LOOKUP), TEXT(T_SET_TIME_OF_DOWNLOADED_FILES), "", "",};void netopt_fn(struct dialog_data *dlg){ struct terminal *term = dlg->win->term; int max = 0, min = 0; int w, rw; int y = -1; max_text_width(term, net_msg[0], &max); min_text_width(term, net_msg[0], &min); max_text_width(term, net_msg[1], &max); min_text_width(term, net_msg[1], &min); max_group_width(term, net_msg + 2, dlg->items + 2, 9, &max); min_group_width(term, net_msg + 2, dlg->items + 2, 9, &min); max_buttons_width(term, dlg->items + 11, 2, &max); min_buttons_width(term, dlg->items + 11, 2, &min); w = dlg->win->term->x * 9 / 10 - 2 * DIALOG_LB; if (w > max) w = max; if (w < min) w = min; if (w > dlg->win->term->x - 2 * DIALOG_LB) w = dlg->win->term->x - 2 * DIALOG_LB; if (w < 1) w = 1; rw = 0; dlg_format_text(NULL, term, net_msg[0], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT); y += 2; dlg_format_text(NULL, term, net_msg[1], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT); y += 2; dlg_format_group(NULL, term, net_msg + 2, dlg->items + 2, 9, 0, &y, w, &rw); y++; dlg_format_buttons(NULL, term, dlg->items + 11, 2, 0, &y, w, &rw, AL_CENTER); w = rw; dlg->xw = w + 2 * DIALOG_LB; dlg->yw = y + 2 * DIALOG_TB; center_dlg(dlg); draw_dlg(dlg); y = dlg->y + DIALOG_TB; dlg_format_text(term, term, net_msg[0], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT); dlg_format_field(term, term, &dlg->items[0], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT); y++; dlg_format_text(term, term, net_msg[1], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT); dlg_format_field(term, term, &dlg->items[1], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT); y++; dlg_format_group(term, term, net_msg + 2, &dlg->items[2], 9, dlg->x + DIALOG_LB, &y, w, NULL); y++; dlg_format_buttons(term, term, &dlg->items[11], 2, dlg->x + DIALOG_LB, &y, w, NULL, AL_CENTER);}void net_options(struct terminal *term, void *xxx, void *yyy){ struct dialog *d; snprint(max_c_str, 3, max_connections); snprint(max_cth_str, 3, max_connections_to_host); snprint(max_t_str, 3, max_tries); snprint(time_str, 5, receive_timeout); snprint(unrtime_str, 5, unrestartable_receive_timeout); d = mem_alloc(sizeof(struct dialog) + 14 * sizeof(struct dialog_item)); memset(d, 0, sizeof(struct dialog) + 14 * sizeof(struct dialog_item)); d->title = TEXT(T_NETWORK_OPTIONS); d->fn = netopt_fn; d->refresh = (void (*)(void *))refresh_net; d->items[0].type = D_FIELD; d->items[0].dlen = MAX_STR_LEN; d->items[0].data = http_proxy; d->items[1].type = D_FIELD; d->items[1].dlen = MAX_STR_LEN; d->items[1].data = ftp_proxy; d->items[2].type = D_FIELD; d->items[2].data = max_c_str; d->items[2].dlen = 3; d->items[2].fn = check_number; d->items[2].gid = 1; d->items[2].gnum = 99; d->items[3].type = D_FIELD; d->items[3].data = max_cth_str; d->items[3].dlen = 3; d->items[3].fn = check_number; d->items[3].gid = 1; d->items[3].gnum = 99; d->items[4].type = D_FIELD; d->items[4].data = max_t_str; d->items[4].dlen = 3; d->items[4].fn = check_number; d->items[4].gid = 0; d->items[4].gnum = 16; d->items[5].type = D_FIELD; d->items[5].data = time_str; d->items[5].dlen = 5; d->items[5].fn = check_number; d->items[5].gid = 1; d->items[5].gnum = 1800; d->items[6].type = D_FIELD; d->items[6].data = unrtime_str; d->items[6].dlen = 5; d->items[6].fn = check_number; d->items[6].gid = 1; d->items[6].gnum = 1800; d->items[7].type = D_CHECKBOX; d->items[7].data = (unsigned char *)&async_lookup; d->items[7].dlen = sizeof(int); d->items[8].type = D_CHECKBOX; d->items[8].data = (unsigned char *)&download_utime; d->items[8].dlen = sizeof(int); d->items[9].type = D_BUTTON; d->items[9].gid = 0; d->items[9].fn = dlg_http_options; d->items[9].text = TEXT(T_HTTP_OPTIONS); d->items[9].data = (unsigned char *)&http_bugs; d->items[9].dlen = sizeof(struct http_bugs); d->items[10].type = D_BUTTON; d->items[10].gid = 0; d->items[10].fn = dlg_ftp_options; d->items[10].text = TEXT(T_FTP_OPTIONS); d->items[10].data = (unsigned char *)&ftp_options; d->items[10].dlen = sizeof(struct ftp_options); d->items[11].type = D_BUTTON; d->items[11].gid = B_ENTER; d->items[11].fn = ok_dialog; d->items[11].text = TEXT(T_OK); d->items[12].type = D_BUTTON; d->items[12].gid = B_ESC; d->items[12].fn = cancel_dialog; d->items[12].text = TEXT(T_CANCEL); d->items[13].type = D_END; do_dialog(term, d, getml(d, NULL));}unsigned char *prg_msg[] = { TEXT(T_MAILTO_PROG), TEXT(T_TELNET_PROG), TEXT(T_TN3270_PROG), TEXT(T_MMS_PROG), ""};void netprog_fn(struct dialog_data *dlg){ struct terminal *term = dlg->win->term; int max = 0, min = 0; int w, rw; int y = -1; max_text_width(term, prg_msg[0], &max); min_text_width(term, prg_msg[0], &min); max_text_width(term, prg_msg[1], &max); min_text_width(term, prg_msg[1], &min); max_text_width(term, prg_msg[2], &max); min_text_width(term, prg_msg[2], &min); max_text_width(term, prg_msg[3], &max); min_text_width(term, prg_msg[3], &min); max_buttons_width(term, dlg->items + 4, 2, &max); min_buttons_width(term, dlg->items + 4, 2, &min); w = dlg->win->term->x * 9 / 10 - 2 * DIALOG_LB; if (w > max) w = max; if (w < min) w = min; if (w > dlg->win->term->x - 2 * DIALOG_LB) w = dlg->win->term->x - 2 * DIALOG_LB; if (w < 1) w = 1; rw = 0; dlg_format_text(NULL, term, prg_msg[0], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT); y += 2; dlg_format_text(NULL, term, prg_msg[1], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT); y += 2; dlg_format_text(NULL, term, prg_msg[2], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT); y += 2; dlg_format_text(NULL, term, prg_msg[3], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT); y += 2; dlg_format_buttons(NULL, term, dlg->items + 4, 2, 0, &y, w, &rw, AL_CENTER); w = rw; dlg->xw = w + 2 * DIALOG_LB; dlg->yw = y + 2 * DIALOG_TB; center_dlg(dlg); draw_dlg(dlg); y = dlg->y + DIALOG_TB; dlg_format_text(term, term, prg_msg[0], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT); dlg_format_field(term, term, &dlg->items[0], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT); y++; dlg_format_text(term, term, prg_msg[1], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT); dlg_format_field(term, term, &dlg->items[1], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT); y++; dlg_format_text(term, term, prg_msg[2], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT); dlg_format_field(term, term, &dlg->items[2], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT); y++; dlg_format_text(term, term, prg_msg[3], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT); dlg_format_field(term, term, &dlg->items[3], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT); y++; dlg_format_buttons(term, term, &dlg->items[4], 2, dlg->x + DIALOG_LB, &y, w, NULL, AL_CENTER);}void net_programs(struct terminal *term, void *xxx, void *yyy){ struct dialog *d; d = mem_alloc(sizeof(struct dialog) + 7 * sizeof(struct dialog_item)); memset(d, 0, sizeof(struct dialog) + 7 * sizeof(struct dialog_item)); d->title = TEXT(T_MAIL_AND_TELNET_PROGRAMS); d->fn = netprog_fn; d->items[0].type = D_FIELD; d->items[0].dlen = MAX_STR_LEN; d->items[0].data = get_prog(&mailto_prog); d->items[1].type = D_FIELD; d->items[1].dlen = MAX_STR_LEN; d->items[1].data = get_prog(&telnet_prog); d->items[2].type = D_FIELD; d->items[2].dlen = MAX_STR_LEN; d->items[2].data = get_prog(&tn3270_prog); d->items[3].type = D_FIELD; d->items[3].dlen = MAX_STR_LEN; d->items[3].data = get_prog(&mms_prog); d->items[4].type = D_BUTTON; d->items[4].gid = B_ENTER; d->items[4].fn = ok_dialog; d->items[4].text = TEXT(T_OK); d->items[5].type = D_BUTTON; d->items[5].gid = B_ESC; d->items[5].fn = cancel_dialog; d->items[5].text = TEXT(T_CANCEL); d->items[6].type = D_END; do_dialog(term, d, getml(d, NULL));}/*void net_opt_ask(struct terminal *term, void *xxx, void *yyy){ if (list_empty(downloads)) { net_options(term, xxx, yyy); return; } msg_box(term, NULL, _("Network options"), AL_CENTER, _("Warning: configuring network will terminate all running downloads. Do you really want to configure network?"), term, 2, _("Yes"), (void (*)(void *))net_options, B_ENTER, _("No"), NULL, B_ESC);}*/unsigned char mc_str[8];unsigned char doc_str[4];void cache_refresh(void *xxx){ memory_cache_size = atoi(mc_str) * 1024; max_format_cache_entries = atoi(doc_str); count_format_cache(); shrink_memory(0);}unsigned char *cache_texts[] = { TEXT(T_MEMORY_CACHE_SIZE__KB), TEXT(T_NUMBER_OF_FORMATTED_DOCUMENTS) };void cache_opt(struct terminal *term, void *xxx, void *yyy){ struct dialog *d; snprint(mc_str, 8, memory_cache_size / 1024); snprint(doc_str, 4, max_format_cache_entries); d = mem_alloc(sizeof(struct dialog) + 5 * sizeof(struct dialog_item)); memset(d, 0, sizeof(struct dialog) + 5 * sizeof(struct dialog_item)); d->title = TEXT(T_CACHE_OPTIONS); d->fn = group_fn; d->udata = cache_texts; d->refresh = (void (*)(void *))cache_refresh; d->items[0].type = D_FIELD; d->items[0].dlen = 8; d->items[0].data = mc_str; d->items[0].fn = check_number; d->items[0].gid = 0; d->items[0].gnum = MAXINT; d->items[1].type = D_FIELD; d->items[1].dlen = 4; d->items[1].data = doc_str;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -