void mutt_help (int menu) { char t[_POSIX_PATH_MAX]; char buf[SHORT_STRING]; const char *desc; FILE *f; const struct binding_t *funcs; mutt_mktemp (t, sizeof (t)); funcs = km_get_table (menu); desc = mutt_getnamebyvalue (menu, Menus); if (!desc) desc = _("<UNKNOWN>"); do { if ((f = safe_fopen (t, "w")) == NULL) { mutt_perror (t); return; } dump_menu (f, menu); if (menu != MENU_EDITOR && menu != MENU_PAGER) { fputs (_("\nGeneric bindings:\n\n"), f); dump_menu (f, MENU_GENERIC); } fputs (_("\nUnbound functions:\n\n"), f); if (funcs) dump_unbound (f, funcs, Keymaps[menu], NULL); if (menu != MENU_PAGER) dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]); safe_fclose (&f); snprintf (buf, sizeof (buf), _("Help for %s"), desc); } while (mutt_do_pager (buf, t, M_PAGER_RETWINCH | M_PAGER_MARKER | M_PAGER_NSKIP | M_PAGER_NOWRAP, NULL) == OP_REFORMAT_WINCH); }
/** * dump_all_menus - Dumps all the binds or macros inside every menu * @param buf Output buffer * @param bind If true it's :bind, else :macro */ static void dump_all_menus(struct Buffer *buf, bool bind) { bool empty; for (int i = 0; i < MENU_MAX; i++) { const char *menu_name = mutt_map_get_name(i, Menus); struct Mapping menu = { menu_name, i }; empty = dump_menu(buf, &menu, bind); /* Add a new line for readability between menus. */ if (!empty && (i < (MENU_MAX - 1))) mutt_buffer_addch(buf, '\n'); } }
/** * icmd_bind - Parse 'bind' and 'macro' commands - Implements ::icommand_t */ static enum CommandResult icmd_bind(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err) { FILE *fp_out = NULL; char tempfile[PATH_MAX]; bool dump_all = false, bind = (data == 0); if (!MoreArgs(s)) dump_all = true; else mutt_extract_token(buf, s, 0); if (MoreArgs(s)) { /* More arguments potentially means the user is using the * ::command_t :bind command thus we delegate the task. */ return MUTT_CMD_ERROR; } struct Buffer *filebuf = mutt_buffer_alloc(4096); if (dump_all || (mutt_str_strcasecmp(buf->data, "all") == 0)) { dump_all_menus(filebuf, bind); } else { const int menu_index = mutt_map_get_value(buf->data, Menus); if (menu_index == -1) { mutt_buffer_printf(err, _("%s: no such menu"), buf->data); mutt_buffer_free(&filebuf); return MUTT_CMD_ERROR; } struct Mapping menu = { buf->data, menu_index }; dump_menu(filebuf, &menu, bind); } if (mutt_buffer_is_empty(filebuf)) { mutt_buffer_printf(err, _("%s: no %s for this menu"), dump_all ? "all" : buf->data, bind ? "binds" : "macros"); mutt_buffer_free(&filebuf); return MUTT_CMD_ERROR; } mutt_mktemp(tempfile, sizeof(tempfile)); fp_out = mutt_file_fopen(tempfile, "w"); if (!fp_out) { mutt_buffer_printf(err, _("Could not create temporary file %s"), tempfile); mutt_buffer_free(&filebuf); return MUTT_CMD_ERROR; } fputs(filebuf->data, fp_out); mutt_file_fclose(&fp_out); mutt_buffer_free(&filebuf); struct Pager info = { 0 }; if (mutt_pager((bind) ? "bind" : "macro", tempfile, 0, &info) == -1) { mutt_buffer_printf(err, _("Could not create temporary file %s"), tempfile); return MUTT_CMD_ERROR; } return MUTT_CMD_SUCCESS; }
/* * Main loop */ int main(int argc, char *argv[]) { int c, n = 0; int warm = 0; xeq_init_contexts(); load_statefile(); if (argc > 1) { if (argc == 2) { if (strcmp(argv[1], "commands") == 0) { dump_commands(0); return 0; } if (strcmp(argv[1], "reg") == 0) { dump_registers(); return 0; } if (strcmp(argv[1], "wake") == 0) { warm = 1; goto skipargs; } if (strcmp(argv[1], "opcodes") == 0) { dump_opcodes(stdout, 0); return 0; } if (strcmp(argv[1], "xref") == 0) { dump_opcodes(stdout, 1); return 0; } if (strcmp(argv[1], "constants") == 0) { dump_constants(); return 0; } dump_menu("statistics", "", CATALOGUE_STATS); dump_menu("probability", "", CATALOGUE_PROB); dump_menu("clear", "", CATALOGUE_CLEAR); dump_menu("displ", "", CATALOGUE_DISPL); dump_menu("more", "", CATALOGUE_MORE); dump_menu("modes", "", CATALOGUE_MODE); dump_menu("conversions", "", CATALOGUE_CONV); dump_menu("constants", "# ", CATALOGUE_CONST); } for (c=0; c<65536; c++) { if (isDBL(c) && (c & 0xff)) /* Don't show all multi-word instructions */ continue; n += dumpop(c, argc > 2); } printf("total number of opcodes %d\n", n); printf("\tniladic commands %d\n", NUM_NILADIC); for (n=c=0; c<NUM_MONADIC; c++) { if (monfuncs[c].mondreal != NULL) n++; if (monfuncs[c].mondcmplx != NULL) n++; if (monfuncs[c].monint != NULL) n++; } printf("\tmonadic commands %d with %d functions\n", NUM_MONADIC, n); for (n=c=0; c<NUM_DYADIC; c++) { if (dyfuncs[c].dydreal != NULL) n++; if (dyfuncs[c].dydcmplx != NULL) n++; if (dyfuncs[c].dydint != NULL) n++; } printf("\tdyadic commands %d with %d functions\n", NUM_DYADIC, n); for (n=c=0; c<NUM_TRIADIC; c++) { if (trifuncs[c].trireal != NULL) n++; if (trifuncs[c].triint != NULL) n++; } printf("\ttriadic commands %d with %d functions\n", NUM_TRIADIC, n); printf("\targument commands %d\n", NUM_RARG); printf("\tmultiword commands %d\n", NUM_MULTI); printf("\tspecial commands %d\n", NUM_SPECIAL); printf("\ttotal commands %u\n", dump_commands(1)); return 0; } skipargs: if (!warm) init_34s(); State2.flags = 1; if (setuptty(0) == 0) { display(); JustDisplayed = 0; while ((c = GETCHAR()) != GETCHAR_ERR && c != CH_QUIT) { #ifdef USECURSES if (c == CH_TRACE) { State2.trace = 1 - State2.trace; display(); } else if (c == CH_FLAGS) { State2.flags = 1 - State2.flags; display(); } else if (c == CH_REFRESH) { clear(); display(); } else if (c == CH_ICOUNT) { instruction_count = 0; view_instruction_counter = 1 - view_instruction_counter; display(); } else if (c == CH_PASTE) { paste_raw_x("123.14159265358979323846264338327950"); c = K_UNKNOWN; clear(); display(); } else if (c == CH_COPY) { char buffer[66]; const char *p = fill_buffer_from_raw_x(buffer); printf("%s\n", p); fflush(NULL); sleep(1); c = K_UNKNOWN; } else #endif c=remap(c); if(c != K_UNKNOWN) { process_keycode(c); process_keycode(K_RELEASE); } } setuptty(1); } shutdown(); return 0; }
/* ***************************************************************************** * Function : dump_resources * Syntax : void dump_resources(const resource_t *top) * Input : * top - Top of the resource tree * Output : * nop * Description : Dump the parsed resource-tree to stdout * Remarks : ***************************************************************************** */ void dump_resources(const resource_t *top) { printf("Internal resource-tree dump:\n"); while(top) { printf("Resource: %s\nId: %s\n", get_typename(top), get_nameid_str(top->name)); switch(top->type) { case res_acc: dump_accelerator(top->res.acc); break; case res_bmp: dump_bitmap(top->res.bmp); break; case res_cur: dump_cursor(top->res.cur); break; case res_curg: dump_cursor_group(top->res.curg); break; case res_dlg: dump_dialog(top->res.dlg); break; case res_dlgex: dump_dialogex(top->res.dlgex); break; case res_fnt: dump_font(top->res.fnt); break; case res_icog: dump_icon_group(top->res.icog); break; case res_ico: dump_icon(top->res.ico); break; case res_men: dump_menu(top->res.men); break; case res_menex: dump_menuex(top->res.menex); break; case res_rdt: dump_rcdata(top->res.rdt); break; case res_stt: dump_stringtable(top->res.stt); break; case res_usr: dump_user(top->res.usr); break; case res_msg: dump_messagetable(top->res.msg); break; case res_ver: dump_versioninfo(top->res.ver); break; case res_dlginit: dump_dlginit(top->res.dlgi); break; case res_toolbar: dump_toolbar(top->res.tbt); break; case res_anicur: case res_aniico: dump_ani_curico(top->res.ani); break; default: printf("Report this: Unknown resource type parsed %08x\n", top->type); } printf("\n"); top = top->next; } }