static void edit_about (void) { quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_LABEL ("MCEdit " VERSION, NULL), QUICK_SEPARATOR (TRUE), QUICK_LABEL (N_("A user friendly text editor\n" "written for the Midnight Commander."), NULL), QUICK_SEPARATOR (FALSE), QUICK_LABEL (N_("Copyright (C) 1996-2019 the Free Software Foundation"), NULL), QUICK_START_BUTTONS (TRUE, TRUE), QUICK_BUTTON (N_("&OK"), B_ENTER, NULL, NULL), QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 40, N_("About"), "[Internal File Editor]", quick_widgets, NULL, NULL }; quick_widgets[0].pos_flags = WPOS_KEEP_TOP | WPOS_CENTER_HORZ; quick_widgets[2].pos_flags = WPOS_KEEP_TOP | WPOS_CENTER_HORZ; quick_widgets[4].pos_flags = WPOS_KEEP_TOP | WPOS_CENTER_HORZ; (void) quick_dialog (&qdlg); }
int editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text, int xpos, int ypos) { Widget *w = WIDGET (edit); /* dialog size */ int dlg_height = 10; int dlg_width; char tmp[BUF_MEDIUM]; char *repl_from, *repl_to; int retval; if (xpos == -1) xpos = w->x + option_line_state_width + 1; if (ypos == -1) ypos = w->y + w->lines / 2; /* Sometimes menu can hide replaced text. I don't like it */ if ((edit->curs_row >= ypos - 1) && (edit->curs_row <= ypos + dlg_height - 1)) ypos -= dlg_height; dlg_width = WIDGET (w->owner)->cols - xpos - 1; g_snprintf (tmp, sizeof (tmp), "\"%s\"", from_text); repl_from = g_strdup (str_trunc (tmp, dlg_width - 7)); g_snprintf (tmp, sizeof (tmp), "\"%s\"", to_text); repl_to = g_strdup (str_trunc (tmp, dlg_width - 7)); { quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_LABEL (repl_from, NULL), QUICK_LABEL (N_("Replace with:"), NULL), QUICK_LABEL (repl_to, NULL), QUICK_START_BUTTONS (TRUE, TRUE), QUICK_BUTTON (N_("&Replace"), B_ENTER, NULL, NULL), QUICK_BUTTON (N_("A&ll"), B_REPLACE_ALL, NULL, NULL), QUICK_BUTTON (N_("&Skip"), B_SKIP_REPLACE, NULL, NULL), QUICK_BUTTON (N_("&Cancel"), B_CANCEL, NULL, NULL), QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { ypos, xpos, -1, N_("Confirm replace"), NULL, quick_widgets, NULL, NULL }; retval = quick_dialog (&qdlg); } g_free (repl_from); g_free (repl_to); return retval; }
gboolean editcmd_dialog_search_show (WEdit * edit) { char *search_text; size_t num_of_types; gchar **list_of_types; int dialog_result; list_of_types = mc_search_get_types_strings_array (&num_of_types); { quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_LABELED_INPUT (N_("Enter search string:"), input_label_above, INPUT_LAST_TEXT, MC_HISTORY_SHARED_SEARCH, &search_text, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_SEPARATOR (TRUE), QUICK_START_COLUMNS, QUICK_RADIO (num_of_types, (const char **) list_of_types, (int *) &edit_search_options.type, NULL), QUICK_NEXT_COLUMN, QUICK_CHECKBOX (N_("Cas&e sensitive"), &edit_search_options.case_sens, NULL), QUICK_CHECKBOX (N_("&Backwards"), &edit_search_options.backwards, NULL), QUICK_CHECKBOX (N_("In se&lection"), &edit_search_options.only_in_selection, NULL), QUICK_CHECKBOX (N_("&Whole words"), &edit_search_options.whole_words, NULL), #ifdef HAVE_CHARSET QUICK_CHECKBOX (N_("&All charsets"), &edit_search_options.all_codepages, NULL), #endif QUICK_STOP_COLUMNS, QUICK_START_BUTTONS (TRUE, TRUE), QUICK_BUTTON (N_("&OK"), B_ENTER, NULL, NULL), QUICK_BUTTON (N_("&Find all"), B_USER, NULL, NULL), QUICK_BUTTON (N_("&Cancel"), B_CANCEL, NULL, NULL), QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 58, N_("Search"), "[Input Line Keys]", quick_widgets, NULL, NULL }; dialog_result = quick_dialog (&qdlg); } g_strfreev (list_of_types); if ((dialog_result == B_CANCEL) || (search_text == NULL) || (search_text[0] == '\0')) { g_free (search_text); return FALSE; } if (dialog_result == B_USER) search_create_bookmark = TRUE; #ifdef HAVE_CHARSET { GString *tmp; tmp = str_convert_to_input (search_text); if (tmp != NULL) { g_free (search_text); search_text = g_string_free (tmp, FALSE); } } #endif g_free (edit->last_search_string); edit->last_search_string = search_text; mc_search_free (edit->search); #ifdef HAVE_CHARSET edit->search = mc_search_new (edit->last_search_string, cp_source); #else edit->search = mc_search_new (edit->last_search_string, NULL); #endif if (edit->search != NULL) { edit->search->search_type = edit_search_options.type; #ifdef HAVE_CHARSET edit->search->is_all_charsets = edit_search_options.all_codepages; #endif edit->search->is_case_sensitive = edit_search_options.case_sens; edit->search->whole_words = edit_search_options.whole_words; edit->search->search_fn = edit_search_cmd_callback; edit->search->update_fn = edit_search_update_callback; } return (edit->search != NULL); }
char * file_mask_dialog (file_op_context_t * ctx, FileOperation operation, gboolean only_one, const char *format, const void *text, const char *def_text, gboolean * do_bg) { size_t fmd_xlen; vfs_path_t *vpath; int source_easy_patterns = easy_patterns; char fmd_buf[BUF_MEDIUM]; char *dest_dir, *tmp; char *def_text_secure; if (ctx == NULL) return NULL; /* unselect checkbox if target filesystem don't support attributes */ ctx->op_preserve = filegui__check_attrs_on_fs (def_text); ctx->stable_symlinks = FALSE; *do_bg = FALSE; /* filter out a possible password from def_text */ vpath = vfs_path_from_str_flags (def_text, only_one ? VPF_NO_CANON : VPF_NONE); tmp = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_PASSWORD); vfs_path_free (vpath); if (source_easy_patterns) def_text_secure = strutils_glob_escape (tmp); else def_text_secure = strutils_regex_escape (tmp); g_free (tmp); if (only_one) { int format_len, text_len; int max_len; format_len = str_term_width1 (format); text_len = str_term_width1 (text); max_len = COLS - 2 - 6; if (format_len + text_len <= max_len) { fmd_xlen = format_len + text_len + 6; fmd_xlen = max (fmd_xlen, 68); } else { text = str_trunc ((const char *) text, max_len - format_len); fmd_xlen = max_len + 6; } g_snprintf (fmd_buf, sizeof (fmd_buf), format, (const char *) text); } else { fmd_xlen = COLS * 2 / 3; fmd_xlen = max (fmd_xlen, 68); g_snprintf (fmd_buf, sizeof (fmd_buf), format, *(const int *) text); } { char *source_mask, *orig_mask; int val; struct stat buf; quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_LABELED_INPUT (fmd_buf, input_label_above, easy_patterns ? "*" : "^(.*)$", "input-def", &source_mask, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES), QUICK_START_COLUMNS, QUICK_SEPARATOR (FALSE), QUICK_NEXT_COLUMN, QUICK_CHECKBOX (N_("&Using shell patterns"), &source_easy_patterns, NULL), QUICK_STOP_COLUMNS, QUICK_LABELED_INPUT (N_("to:"), input_label_above, def_text_secure, "input2", &dest_dir, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES), QUICK_SEPARATOR (TRUE), QUICK_START_COLUMNS, QUICK_CHECKBOX (N_("Follow &links"), &ctx->follow_links, NULL), QUICK_CHECKBOX (N_("Preserve &attributes"), &ctx->op_preserve, NULL), QUICK_NEXT_COLUMN, QUICK_CHECKBOX (N_("Di&ve into subdir if exists"), &ctx->dive_into_subdirs, NULL), QUICK_CHECKBOX (N_("&Stable symlinks"), &ctx->stable_symlinks, NULL), QUICK_STOP_COLUMNS, QUICK_START_BUTTONS (TRUE, TRUE), QUICK_BUTTON (N_("&OK"), B_ENTER, NULL, NULL), #ifdef ENABLE_BACKGROUND QUICK_BUTTON (N_("&Background"), B_USER, NULL, NULL), #endif /* ENABLE_BACKGROUND */ QUICK_BUTTON (N_("&Cancel"), B_CANCEL, NULL, NULL), QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, fmd_xlen, op_names[operation], "[Mask Copy/Rename]", quick_widgets, NULL, NULL }; ask_file_mask: val = quick_dialog_skip (&qdlg, 4); if (val == B_CANCEL) { g_free (def_text_secure); return NULL; } if (ctx->follow_links) ctx->stat_func = mc_stat; else ctx->stat_func = mc_lstat; if (ctx->op_preserve) { ctx->preserve = TRUE; ctx->umask_kill = 0777777; ctx->preserve_uidgid = (geteuid () == 0); } else { int i2; ctx->preserve = ctx->preserve_uidgid = FALSE; i2 = umask (0); umask (i2); ctx->umask_kill = i2 ^ 0777777; } if ((dest_dir == NULL) || (*dest_dir == '\0')) { g_free (def_text_secure); g_free (source_mask); return dest_dir; } ctx->search_handle = mc_search_new (source_mask, -1, NULL); if (ctx->search_handle == NULL) { message (D_ERROR, MSG_ERROR, _("Invalid source pattern '%s'"), source_mask); g_free (dest_dir); g_free (source_mask); goto ask_file_mask; } g_free (def_text_secure); g_free (source_mask); ctx->search_handle->is_case_sensitive = TRUE; if (source_easy_patterns) ctx->search_handle->search_type = MC_SEARCH_T_GLOB; else ctx->search_handle->search_type = MC_SEARCH_T_REGEX; vpath = vfs_path_from_str (dest_dir); ctx->dest_mask = strrchr (dest_dir, PATH_SEP); if (ctx->dest_mask == NULL) ctx->dest_mask = dest_dir; else ctx->dest_mask++; orig_mask = ctx->dest_mask; if (*ctx->dest_mask == '\0' || (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask) && (!only_one || (mc_stat (vpath, &buf) == 0 && S_ISDIR (buf.st_mode)))) || (ctx->dive_into_subdirs && ((!only_one && !is_wildcarded (ctx->dest_mask)) || (only_one && mc_stat (vpath, &buf) == 0 && S_ISDIR (buf.st_mode))))) ctx->dest_mask = g_strdup ("\\0"); else { ctx->dest_mask = g_strdup (ctx->dest_mask); *orig_mask = '\0'; } if (*dest_dir == '\0') { g_free (dest_dir); dest_dir = g_strdup ("./"); } vfs_path_free (vpath); if (val == B_USER) *do_bg = TRUE; } return dest_dir; }