keymap files: unification of Fxx keys: move to lower case.
[midnight-commander.git] / src / editor / editcmd_dialogs.c
blob767f466596c69980da05bfa23c163f16cc46be41
1 /*
2 Editor dialogs for high level editing commands
4 Copyright (C) 2009 The Free Software Foundation, Inc.
6 Written by:
7 Slava Zanko <slavazanko@gmail.com>, 2009.
9 This file is part of the Midnight Commander.
11 The Midnight Commander is free software; you can redistribute it
12 and/or modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version.
16 The Midnight Commander is distributed in the hope that it will be
17 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
18 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 MA 02110-1301, USA.
27 #include <config.h>
29 #include "lib/global.h"
30 #include "lib/tty/tty.h"
31 #include "lib/skin.h" /* INPUT_COLOR */
32 #include "lib/tty/key.h"
33 #include "lib/search.h"
34 #include "lib/strutil.h"
35 #include "lib/widget.h"
36 #include "lib/charsets.h"
38 #include "src/main.h"
39 #include "src/history.h"
41 #include "src/editor/edit-widget.h"
42 #include "src/editor/etags.h"
43 #include "src/editor/editcmd_dialogs.h"
45 /*** global variables ****************************************************************************/
47 edit_search_options_t edit_search_options = {
48 .type = MC_SEARCH_T_NORMAL,
49 .case_sens = FALSE,
50 .backwards = FALSE,
51 .only_in_selection = FALSE,
52 .whole_words = FALSE,
53 .all_codepages = FALSE
56 /*** file scope macro definitions ****************************************************************/
58 #define SEARCH_DLG_WIDTH 58
59 #define SEARCH_DLG_MIN_HEIGHT 13
60 #define SEARCH_DLG_HEIGHT_SUPPLY 3
62 #define REPLACE_DLG_WIDTH 58
63 #define REPLACE_DLG_MIN_HEIGHT 17
64 #define REPLACE_DLG_HEIGHT_SUPPLY 5
66 /*** file scope type declarations ****************************************************************/
68 /*** file scope variables ************************************************************************/
70 /*** file scope functions ************************************************************************/
71 /* --------------------------------------------------------------------------------------------- */
73 static cb_ret_t
74 editcmd_dialog_raw_key_query_cb (struct Dlg_head *h, Widget * sender,
75 dlg_msg_t msg, int parm, void *data)
77 switch (msg)
79 case DLG_KEY:
80 h->ret_value = parm;
81 dlg_stop (h);
82 return MSG_HANDLED;
83 default:
84 return default_dlg_callback (h, sender, msg, parm, data);
88 /* --------------------------------------------------------------------------------------------- */
89 /*** public functions ****************************************************************************/
90 /* --------------------------------------------------------------------------------------------- */
92 void
93 editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const char *replace_default,
94 /*@out@ */ char **search_text, /*@out@ */ char **replace_text)
96 if ((search_default == NULL) || (*search_default == '\0'))
97 search_default = INPUT_LAST_TEXT;
100 size_t num_of_types;
101 gchar **list_of_types = mc_search_get_types_strings_array (&num_of_types);
102 int REPLACE_DLG_HEIGHT = REPLACE_DLG_MIN_HEIGHT + num_of_types - REPLACE_DLG_HEIGHT_SUPPLY;
104 QuickWidget quick_widgets[] = {
105 /* 0 */ QUICK_BUTTON (6, 10, 13, REPLACE_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
106 /* 1 */ QUICK_BUTTON (2, 10, 13, REPLACE_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
107 #ifdef HAVE_CHARSET
108 /* 2 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 11, REPLACE_DLG_HEIGHT,
109 N_("All charsets"),
110 &edit_search_options.all_codepages),
111 #endif
112 /* 3 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 10, REPLACE_DLG_HEIGHT,
113 N_("&Whole words"),
114 &edit_search_options.whole_words),
115 /* 4 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 9, REPLACE_DLG_HEIGHT,
116 N_("In se&lection"),
117 &edit_search_options.only_in_selection),
118 /* 5 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 8, REPLACE_DLG_HEIGHT, N_("&Backwards"),
119 &edit_search_options.backwards),
120 /* 6 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT,
121 N_("Case &sensitive"),
122 &edit_search_options.case_sens),
123 /* 7 */ QUICK_RADIO (3, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT,
124 num_of_types, (const char **) list_of_types,
125 (int *) &edit_search_options.type),
126 /* 8 */ QUICK_LABEL (3, REPLACE_DLG_WIDTH, 4, REPLACE_DLG_HEIGHT,
127 N_("Enter replacement string:")),
128 /* 9 */ QUICK_INPUT (3, REPLACE_DLG_WIDTH, 5, REPLACE_DLG_HEIGHT,
129 replace_default, REPLACE_DLG_WIDTH - 6, 0, "replace",
130 replace_text),
131 /* 10 */ QUICK_LABEL (3, REPLACE_DLG_WIDTH, 2, REPLACE_DLG_HEIGHT,
132 N_("Enter search string:")),
133 /* 11 */ QUICK_INPUT (3, REPLACE_DLG_WIDTH, 3, REPLACE_DLG_HEIGHT,
134 search_default, REPLACE_DLG_WIDTH - 6, 0,
135 MC_HISTORY_SHARED_SEARCH, search_text),
136 QUICK_END
139 QuickDialog Quick_input = {
140 REPLACE_DLG_WIDTH, REPLACE_DLG_HEIGHT, -1, -1, N_("Replace"),
141 "[Input Line Keys]", quick_widgets, NULL, FALSE
144 if (quick_dialog (&Quick_input) != B_CANCEL)
146 edit->replace_mode = 0;
148 else
150 *replace_text = NULL;
151 *search_text = NULL;
154 g_strfreev (list_of_types);
158 /* --------------------------------------------------------------------------------------------- */
160 gboolean
161 editcmd_dialog_search_show (WEdit * edit)
163 char *search_text;
165 size_t num_of_types;
166 gchar **list_of_types = mc_search_get_types_strings_array (&num_of_types);
167 int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + num_of_types - SEARCH_DLG_HEIGHT_SUPPLY;
168 size_t i;
170 int dialog_result;
172 QuickWidget quick_widgets[] = {
173 /* 0 */
174 QUICK_BUTTON (6, 10, 11, SEARCH_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
175 /* 1 */
176 QUICK_BUTTON (4, 10, 11, SEARCH_DLG_HEIGHT, N_("&Find all"), B_USER, NULL),
177 /* 2 */
178 QUICK_BUTTON (2, 10, 11, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
179 #ifdef HAVE_CHARSET
180 /* 3 */
181 QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 9, SEARCH_DLG_HEIGHT, N_("All charsets"),
182 &edit_search_options.all_codepages),
183 #endif
184 /* 4 */
185 QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT, N_("&Whole words"),
186 &edit_search_options.whole_words),
187 /* 5 */
188 QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("In se&lection"),
189 &edit_search_options.only_in_selection),
190 /* 6 */
191 QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"),
192 &edit_search_options.backwards),
193 /* 7 */
194 QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("Case &sensitive"),
195 &edit_search_options.case_sens),
196 /* 8 */
197 QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
198 num_of_types, (const char **) list_of_types,
199 (int *) &edit_search_options.type),
200 /* 9 */
201 QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
202 INPUT_LAST_TEXT, SEARCH_DLG_WIDTH - 6, 0,
203 MC_HISTORY_SHARED_SEARCH, &search_text),
204 /* 10 */
205 QUICK_LABEL (3, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_("Enter search string:")),
206 QUICK_END
209 #ifdef HAVE_CHARSET
210 size_t last_checkbox = 7;
211 #else
212 size_t last_checkbox = 6;
213 #endif
215 QuickDialog Quick_input = {
216 SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"),
217 "[Input Line Keys]", quick_widgets, NULL, TRUE
220 #ifdef ENABLE_NLS
221 char **list_of_types_nls;
223 /* header title */
224 Quick_input.title = _(Quick_input.title);
225 /* buttons */
226 for (i = 0; i < 3; i++)
227 quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text);
228 /* checkboxes */
229 for (i = 3; i <= last_checkbox; i++)
230 quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text);
231 /* label */
232 quick_widgets[10].u.label.text = _(quick_widgets[10].u.label.text);
234 /* radiobuttons */
235 /* create copy of radio items to avoid memory leak */
236 list_of_types_nls = g_new0 (char *, num_of_types + 1);
237 for (i = 0; i < num_of_types; i++)
238 list_of_types_nls[i] = g_strdup (_(list_of_types[i]));
239 g_strfreev (list_of_types);
240 list_of_types = list_of_types_nls;
241 quick_widgets[last_checkbox + 1].u.radio.items = (const char **) list_of_types;
242 #endif
244 /* calculate widget coordinates */
246 int len = 0;
247 int dlg_width;
248 gchar **radio = list_of_types;
249 int b0_len, b1_len, b2_len;
250 const int button_gap = 2;
252 /* length of radiobuttons */
253 while (*radio != NULL)
255 len = max (len, str_term_width1 (*radio));
256 radio++;
258 /* length of checkboxes */
259 for (i = 3; i <= last_checkbox; i++)
260 len = max (len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4);
262 /* preliminary dialog width */
263 dlg_width = max (len * 2, str_term_width1 (Quick_input.title)) + 4;
265 /* length of buttons */
266 b0_len = str_term_width1 (quick_widgets[0].u.button.text) + 3;
267 b1_len = str_term_width1 (quick_widgets[1].u.button.text) + 3;
268 b2_len = str_term_width1 (quick_widgets[2].u.button.text) + 5; /* default button */
269 len = b0_len + b1_len + b2_len + button_gap * 2;
271 /* dialog width */
272 Quick_input.xlen = max (SEARCH_DLG_WIDTH, max (dlg_width, len + 6));
274 /* correct widget coordinates */
275 for (i = 0; i < sizeof (quick_widgets) / sizeof (quick_widgets[0]); i++)
276 quick_widgets[i].x_divisions = Quick_input.xlen;
278 /* checkbox positions */
279 for (i = 3; i <= last_checkbox; i++)
280 quick_widgets[i].relative_x = Quick_input.xlen / 2 + 2;
281 /* input length */
282 quick_widgets[last_checkbox + 2].u.input.len = Quick_input.xlen - 6;
283 /* button positions */
284 quick_widgets[2].relative_x = Quick_input.xlen / 2 - len / 2;
285 quick_widgets[1].relative_x = quick_widgets[2].relative_x + b2_len + button_gap;
286 quick_widgets[0].relative_x = quick_widgets[1].relative_x + b1_len + button_gap;
289 dialog_result = quick_dialog (&Quick_input);
291 g_strfreev (list_of_types);
293 if ((dialog_result == B_CANCEL) || (search_text == NULL) || (search_text[0] == '\0'))
295 g_free (search_text);
296 return FALSE;
299 if (dialog_result == B_USER)
300 search_create_bookmark = TRUE;
302 #ifdef HAVE_CHARSET
304 GString *tmp;
306 tmp = str_convert_to_input (search_text);
307 if (tmp != NULL)
309 g_free (search_text);
310 search_text = g_string_free (tmp, FALSE);
313 #endif
315 g_free (edit->last_search_string);
316 edit->last_search_string = search_text;
317 mc_search_free (edit->search);
319 edit->search = mc_search_new (edit->last_search_string, -1);
320 if (edit->search != NULL)
322 edit->search->search_type = edit_search_options.type;
323 edit->search->is_all_charsets = edit_search_options.all_codepages;
324 edit->search->is_case_sensitive = edit_search_options.case_sens;
325 edit->search->whole_words = edit_search_options.whole_words;
326 edit->search->search_fn = edit_search_cmd_callback;
329 return (edit->search != NULL);
332 /* --------------------------------------------------------------------------------------------- */
333 /* gets a raw key from the keyboard. Passing cancel = 1 draws
334 a cancel button thus allowing c-c etc. Alternatively, cancel = 0
335 will return the next key pressed. ctrl-a (=B_CANCEL), ctrl-g, ctrl-c,
336 and Esc are cannot returned */
339 editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel)
341 int w = str_term_width1 (query) + 7;
343 struct Dlg_head *raw_dlg =
344 create_dlg (TRUE, 0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
345 NULL, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
346 add_widget (raw_dlg, input_new (3 - cancel, w - 5, input_get_default_colors (),
347 2, "", 0, INPUT_COMPLETE_DEFAULT));
348 add_widget (raw_dlg, label_new (3 - cancel, 2, query));
349 if (cancel)
350 add_widget (raw_dlg, button_new (4, w / 2 - 5, B_CANCEL, NORMAL_BUTTON, _("Cancel"), 0));
351 w = run_dlg (raw_dlg);
352 destroy_dlg (raw_dlg);
354 return (cancel && (w == ESC_CHAR || w == B_CANCEL)) ? 0 : w;
357 /* --------------------------------------------------------------------------------------------- */
358 /* let the user select its preferred completion */
360 void
361 editcmd_dialog_completion_show (WEdit * edit, int max_len, int word_len,
362 struct selection *compl, int num_compl)
365 int start_x, start_y, offset, i;
366 char *curr = NULL;
367 Dlg_head *compl_dlg;
368 WListbox *compl_list;
369 int compl_dlg_h; /* completion dialog height */
370 int compl_dlg_w; /* completion dialog width */
372 /* calculate the dialog metrics */
373 compl_dlg_h = num_compl + 2;
374 compl_dlg_w = max_len + 4;
375 start_x = edit->curs_col + edit->start_col - (compl_dlg_w / 2) +
376 EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
377 start_y = edit->curs_row + EDIT_TEXT_VERTICAL_OFFSET + 1;
379 if (start_x < 0)
380 start_x = 0;
381 if (compl_dlg_w > COLS)
382 compl_dlg_w = COLS;
383 if (compl_dlg_h > LINES - 2)
384 compl_dlg_h = LINES - 2;
386 offset = start_x + compl_dlg_w - COLS;
387 if (offset > 0)
388 start_x -= offset;
389 offset = start_y + compl_dlg_h - LINES;
390 if (offset > 0)
391 start_y -= (offset + 1);
393 /* create the dialog */
394 compl_dlg =
395 create_dlg (TRUE, start_y, start_x, compl_dlg_h, compl_dlg_w,
396 dialog_colors, NULL, "[Completion]", NULL, DLG_COMPACT);
398 /* create the listbox */
399 compl_list = listbox_new (1, 1, compl_dlg_h - 2, compl_dlg_w - 2, FALSE, NULL);
401 /* add the dialog */
402 add_widget (compl_dlg, compl_list);
404 /* fill the listbox with the completions */
405 for (i = num_compl - 1; i >= 0; i--) /* reverse order */
406 listbox_add_item (compl_list, LISTBOX_APPEND_AT_END, 0, (char *) compl[i].text, NULL);
408 /* pop up the dialog and apply the choosen completion */
409 if (run_dlg (compl_dlg) == B_ENTER)
411 listbox_get_current (compl_list, &curr, NULL);
412 if (curr)
414 #ifdef HAVE_CHARSET
415 GString *temp, *temp2;
416 temp = g_string_new ("");
417 for (curr += word_len; *curr; curr++)
418 g_string_append_c (temp, *curr);
420 temp2 = str_convert_to_input (temp->str);
422 if (temp2 && temp2->len)
424 g_string_free (temp, TRUE);
425 temp = temp2;
427 else
428 g_string_free (temp2, TRUE);
429 for (curr = temp->str; *curr; curr++)
430 edit_insert (edit, *curr);
431 g_string_free (temp, TRUE);
432 #else
433 for (curr += word_len; *curr; curr++)
434 edit_insert (edit, *curr);
435 #endif
439 /* destroy dialog before return */
440 destroy_dlg (compl_dlg);
443 /* --------------------------------------------------------------------------------------------- */
444 /* let the user select where function definition */
446 void
447 editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_len, int word_len,
448 etags_hash_t * def_hash, int num_lines)
451 int start_x, start_y, offset, i;
452 char *curr = NULL;
453 etags_hash_t *curr_def = NULL;
454 Dlg_head *def_dlg;
455 WListbox *def_list;
456 int def_dlg_h; /* dialog height */
457 int def_dlg_w; /* dialog width */
458 char *label_def = NULL;
460 (void) word_len;
461 /* calculate the dialog metrics */
462 def_dlg_h = num_lines + 2;
463 def_dlg_w = max_len + 4;
464 start_x = edit->curs_col + edit->start_col - (def_dlg_w / 2) +
465 EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
466 start_y = edit->curs_row + EDIT_TEXT_VERTICAL_OFFSET + 1;
468 if (start_x < 0)
469 start_x = 0;
470 if (def_dlg_w > COLS)
471 def_dlg_w = COLS;
472 if (def_dlg_h > LINES - 2)
473 def_dlg_h = LINES - 2;
475 offset = start_x + def_dlg_w - COLS;
476 if (offset > 0)
477 start_x -= offset;
478 offset = start_y + def_dlg_h - LINES;
479 if (offset > 0)
480 start_y -= (offset + 1);
482 /* create the dialog */
483 def_dlg = create_dlg (TRUE, start_y, start_x, def_dlg_h, def_dlg_w,
484 dialog_colors, NULL, "[Definitions]", match_expr, DLG_COMPACT);
486 /* create the listbox */
487 def_list = listbox_new (1, 1, def_dlg_h - 2, def_dlg_w - 2, FALSE, NULL);
489 /* add the dialog */
490 add_widget (def_dlg, def_list);
492 /* fill the listbox with the completions */
493 for (i = 0; i < num_lines; i++)
495 label_def =
496 g_strdup_printf ("%s -> %s:%ld", def_hash[i].short_define, def_hash[i].filename,
497 def_hash[i].line);
498 listbox_add_item (def_list, LISTBOX_APPEND_AT_END, 0, label_def, &def_hash[i]);
499 g_free (label_def);
502 /* pop up the dialog and apply the choosen completion */
503 if (run_dlg (def_dlg) == B_ENTER)
505 char *tmp_curr_def = (char *) curr_def;
506 int do_moveto = 0;
508 listbox_get_current (def_list, &curr, (void **) &tmp_curr_def);
509 curr_def = (etags_hash_t *) tmp_curr_def;
510 if (edit->modified)
512 if (!edit_query_dialog2
513 (_("Warning"),
514 _("Current text was modified without a file save.\n"
515 "Continue discards these changes."), _("C&ontinue"), _("&Cancel")))
517 edit->force |= REDRAW_COMPLETELY;
518 do_moveto = 1;
521 else
523 do_moveto = 1;
526 if (curr && do_moveto)
528 if (edit_stack_iterator + 1 < MAX_HISTORY_MOVETO)
530 g_free (edit_history_moveto[edit_stack_iterator].filename);
531 if (edit->dir)
533 edit_history_moveto[edit_stack_iterator].filename =
534 g_strdup_printf ("%s/%s", edit->dir, edit->filename);
536 else
538 edit_history_moveto[edit_stack_iterator].filename = g_strdup (edit->filename);
540 edit_history_moveto[edit_stack_iterator].line = edit->start_line +
541 edit->curs_row + 1;
542 edit_stack_iterator++;
543 g_free (edit_history_moveto[edit_stack_iterator].filename);
544 edit_history_moveto[edit_stack_iterator].filename =
545 g_strdup ((char *) curr_def->fullpath);
546 edit_history_moveto[edit_stack_iterator].line = curr_def->line;
547 edit_reload_line (edit, edit_history_moveto[edit_stack_iterator].filename,
548 edit_history_moveto[edit_stack_iterator].line);
553 /* clear definition hash */
554 for (i = 0; i < MAX_DEFINITIONS; i++)
556 g_free (def_hash[i].filename);
559 /* destroy dialog before return */
560 destroy_dlg (def_dlg);
563 /* --------------------------------------------------------------------------------------------- */
566 editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text, int xpos,
567 int ypos)
569 /* dialog sizes */
570 int dlg_height = 9;
571 int dlg_width = 8;
573 int retval;
574 int i;
575 int btn_pos;
577 char *repl_from, *repl_to;
578 char tmp[BUF_MEDIUM];
580 QuickWidget quick_widgets[] = {
581 /* 0 */ QUICK_BUTTON (44, dlg_width, 6, dlg_height, N_("&Cancel"), B_CANCEL, NULL),
582 /* 1 */ QUICK_BUTTON (29, dlg_width, 6, dlg_height, N_("&Skip"), B_SKIP_REPLACE, NULL),
583 /* 2 */ QUICK_BUTTON (21, dlg_width, 6, dlg_height, N_("A&ll"), B_REPLACE_ALL, NULL),
584 /* 3 */ QUICK_BUTTON (4, dlg_width, 6, dlg_height, N_("&Replace"), B_ENTER, NULL),
585 /* 4 */ QUICK_LABEL (3, dlg_width, 2, dlg_height, NULL),
586 /* 5 */ QUICK_LABEL (3, dlg_width, 3, dlg_height, N_("Replace with:")),
587 /* 6 */ QUICK_LABEL (3, dlg_width, 4, dlg_height, NULL),
588 QUICK_END
591 #ifdef ENABLE_NLS
592 for (i = 0; i < 4; i++)
593 quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text);
594 #endif
596 /* calculate button positions */
597 btn_pos = 4;
599 for (i = 3; i > -1; i--)
601 quick_widgets[i].relative_x = btn_pos;
602 btn_pos += str_term_width1 (quick_widgets[i].u.button.text) + 5;
603 if (i == 3) /* default button */
604 btn_pos += 2;
607 dlg_width = btn_pos + 2;
609 /* correct widget coordinates */
610 for (i = 0; i < 7; i++)
611 quick_widgets[i].x_divisions = dlg_width;
613 g_snprintf (tmp, sizeof (tmp), "\"%s\"", from_text);
614 repl_from = g_strdup (str_fit_to_term (tmp, dlg_width - 7, J_LEFT));
616 g_snprintf (tmp, sizeof (tmp), "\"%s\"", to_text);
617 repl_to = g_strdup (str_fit_to_term (tmp, dlg_width - 7, J_LEFT));
619 quick_widgets[4].u.label.text = repl_from;
620 quick_widgets[6].u.label.text = repl_to;
622 if (xpos == -1)
623 xpos = (edit->widget.cols - dlg_width) / 2;
625 if (ypos == -1)
626 ypos = edit->widget.lines * 2 / 3;
629 QuickDialog Quick_input = {
630 dlg_width, dlg_height, 0, 0, N_("Confirm replace"),
631 "[Input Line Keys]", quick_widgets, NULL, FALSE
634 /* Sometimes menu can hide replaced text. I don't like it */
635 if ((edit->curs_row >= ypos - 1) && (edit->curs_row <= ypos + dlg_height - 1))
636 ypos -= dlg_height;
638 Quick_input.ypos = ypos;
639 Quick_input.xpos = xpos;
641 retval = quick_dialog (&Quick_input);
642 g_free (repl_from);
643 g_free (repl_to);
645 return retval;
649 /* --------------------------------------------------------------------------------------------- */