From 2f733f92abd3f33c7a4d649e5609d10edf531e80 Mon Sep 17 00:00:00 2001
From: Mooffie <mooffie@gmail.com>
Date: Wed, 1 Jul 2015 11:12:42 +0300
Subject: [PATCH] Use INPUT_LAST_TEXT for input_dialog() instead of static
vars.
---
src/diffviewer/ydiff.c | 13 +++++++------
src/editor/editcmd.c | 49 ++++++++++++++++++-------------------------------
2 files changed, 25 insertions(+), 37 deletions(-)
diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c
index 8cba2ad..ceef3e5 100644
a
|
b
|
dview_edit (WDiff * dview, diff_place_t ord) |
2913 | 2913 | static void |
2914 | 2914 | dview_goto_cmd (WDiff * dview, diff_place_t ord) |
2915 | 2915 | { |
| 2916 | static gboolean first_run = TRUE; |
| 2917 | |
2916 | 2918 | /* *INDENT-OFF* */ |
2917 | 2919 | static const char *title[2] = { |
2918 | 2920 | N_("Goto line (left)"), |
2919 | 2921 | N_("Goto line (right)") |
2920 | 2922 | }; |
2921 | 2923 | /* *INDENT-ON* */ |
2922 | | static char prev[256]; |
2923 | | /* XXX some statics here, to be remembered between runs */ |
2924 | 2924 | |
2925 | 2925 | int newline; |
2926 | 2926 | char *input; |
2927 | 2927 | |
2928 | 2928 | input = |
2929 | | input_dialog (_(title[ord]), _("Enter line:"), MC_HISTORY_YDIFF_GOTO_LINE, prev, |
2930 | | INPUT_COMPLETE_NONE); |
| 2929 | input_dialog (_(title[ord]), _("Enter line:"), MC_HISTORY_YDIFF_GOTO_LINE, |
| 2930 | first_run ? NULL : INPUT_LAST_TEXT, INPUT_COMPLETE_NONE); |
2931 | 2931 | if (input != NULL) |
2932 | 2932 | { |
2933 | 2933 | const char *s = input; |
… |
… |
dview_goto_cmd (WDiff * dview, diff_place_t ord) |
2948 | 2948 | } |
2949 | 2949 | } |
2950 | 2950 | dview->skip_rows = dview->search.last_accessed_num_line = (ssize_t) i; |
2951 | | g_snprintf (prev, sizeof (prev), "%d", newline); |
2952 | 2951 | } |
2953 | 2952 | g_free (input); |
2954 | 2953 | } |
| 2954 | |
| 2955 | first_run = FALSE; |
2955 | 2956 | } |
2956 | 2957 | |
2957 | 2958 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
dview_execute_cmd (WDiff * dview, unsigned long command) |
3211 | 3212 | find_prev_hunk (dview->a[DIFF_LEFT], dview->skip_rows); |
3212 | 3213 | break; |
3213 | 3214 | case CK_Goto: |
3214 | | dview_goto_cmd (dview, TRUE); |
| 3215 | dview_goto_cmd (dview, DIFF_RIGHT); |
3215 | 3216 | break; |
3216 | 3217 | case CK_Edit: |
3217 | 3218 | dview_edit (dview, dview->ord); |
diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c
index ea9f49f..8572470 100644
a
|
b
|
edit_paste_from_X_buf_cmd (WEdit * edit) |
3028 | 3028 | void |
3029 | 3029 | edit_goto_cmd (WEdit * edit) |
3030 | 3030 | { |
| 3031 | static gboolean first_run = TRUE; |
| 3032 | |
3031 | 3033 | char *f; |
3032 | | static long line = 0; /* line as typed, saved as default */ |
3033 | 3034 | long l; |
3034 | 3035 | char *error; |
3035 | | char s[32]; |
3036 | 3036 | |
3037 | | g_snprintf (s, sizeof (s), "%ld", line); |
3038 | | f = input_dialog (_("Goto line"), _("Enter line:"), MC_HISTORY_EDIT_GOTO_LINE, line ? s : "", |
3039 | | INPUT_COMPLETE_NONE); |
| 3037 | f = input_dialog (_("Goto line"), _("Enter line:"), MC_HISTORY_EDIT_GOTO_LINE, |
| 3038 | first_run ? NULL : INPUT_LAST_TEXT, INPUT_COMPLETE_NONE); |
3040 | 3039 | if (!f) |
3041 | 3040 | return; |
3042 | 3041 | |
… |
… |
edit_goto_cmd (WEdit * edit) |
3053 | 3052 | return; |
3054 | 3053 | } |
3055 | 3054 | |
3056 | | line = l; |
3057 | 3055 | if (l < 0) |
3058 | 3056 | l = edit->buffer.lines + l + 2; |
3059 | 3057 | edit_move_display (edit, l - WIDGET (edit)->lines / 2 - 1); |
3060 | 3058 | edit_move_to_line (edit, l - 1); |
3061 | 3059 | edit->force |= REDRAW_COMPLETELY; |
3062 | 3060 | g_free (f); |
| 3061 | |
| 3062 | first_run = FALSE; |
3063 | 3063 | } |
3064 | 3064 | |
3065 | 3065 | |
… |
… |
edit_insert_file_cmd (WEdit * edit) |
3140 | 3140 | int |
3141 | 3141 | edit_sort_cmd (WEdit * edit) |
3142 | 3142 | { |
3143 | | static char *old = 0; |
3144 | 3143 | char *exp, *tmp, *tmp_edit_block_name, *tmp_edit_temp_name; |
3145 | 3144 | off_t start_mark, end_mark; |
3146 | 3145 | int e; |
… |
… |
edit_sort_cmd (WEdit * edit) |
3157 | 3156 | |
3158 | 3157 | exp = input_dialog (_("Run sort"), |
3159 | 3158 | _("Enter sort options (see manpage) separated by whitespace:"), |
3160 | | MC_HISTORY_EDIT_SORT, (old != NULL) ? old : "", INPUT_COMPLETE_NONE); |
| 3159 | MC_HISTORY_EDIT_SORT, INPUT_LAST_TEXT, INPUT_COMPLETE_NONE); |
3161 | 3160 | |
3162 | 3161 | if (!exp) |
3163 | 3162 | return 1; |
3164 | | g_free (old); |
3165 | | old = exp; |
3166 | 3163 | tmp_edit_block_name = mc_config_get_full_path (EDIT_BLOCK_FILE); |
3167 | 3164 | tmp_edit_temp_name = mc_config_get_full_path (EDIT_TEMP_FILE); |
3168 | 3165 | tmp = |
… |
… |
edit_block_process_cmd (WEdit * edit, int macro_number) |
3276 | 3273 | void |
3277 | 3274 | edit_mail_dialog (WEdit * edit) |
3278 | 3275 | { |
3279 | | char *tmail_to = NULL; |
3280 | | char *tmail_subject = NULL; |
3281 | | char *tmail_cc = NULL; |
3282 | | |
3283 | | static char *mail_cc_last = 0; |
3284 | | static char *mail_subject_last = 0; |
3285 | | static char *mail_to_last = 0; |
3286 | | |
| 3276 | char *mail_to, *mail_subject, *mail_cc; |
3287 | 3277 | |
3288 | 3278 | quick_widget_t quick_widgets[] = { |
3289 | 3279 | /* *INDENT-OFF* */ |
3290 | 3280 | QUICK_LABEL (N_("mail -s <subject> -c <cc> <to>"), NULL), |
3291 | 3281 | QUICK_LABELED_INPUT (N_("To"), input_label_above, |
3292 | | mail_to_last != NULL ? mail_to_last : "", "mail-dlg-input-3", |
3293 | | &tmail_to, NULL, FALSE, FALSE, INPUT_COMPLETE_USERNAMES), |
| 3282 | INPUT_LAST_TEXT, "mail-dlg-input-3", |
| 3283 | &mail_to, NULL, FALSE, FALSE, INPUT_COMPLETE_USERNAMES), |
3294 | 3284 | QUICK_LABELED_INPUT (N_("Subject"), input_label_above, |
3295 | | mail_subject_last != NULL ? mail_subject_last : "", "mail-dlg-input-2", |
3296 | | &tmail_subject, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), |
| 3285 | INPUT_LAST_TEXT, "mail-dlg-input-2", |
| 3286 | &mail_subject, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), |
3297 | 3287 | QUICK_LABELED_INPUT (N_("Copies to"), input_label_above, |
3298 | | mail_cc_last != NULL ? mail_cc_last : "", "mail-dlg-input", |
3299 | | &tmail_cc, NULL, FALSE, FALSE, INPUT_COMPLETE_USERNAMES), |
| 3288 | INPUT_LAST_TEXT, "mail-dlg-input", |
| 3289 | &mail_cc, NULL, FALSE, FALSE, INPUT_COMPLETE_USERNAMES), |
3300 | 3290 | QUICK_BUTTONS_OK_CANCEL, |
3301 | 3291 | QUICK_END |
3302 | 3292 | /* *INDENT-ON* */ |
… |
… |
edit_mail_dialog (WEdit * edit) |
3310 | 3300 | |
3311 | 3301 | if (quick_dialog (&qdlg) != B_CANCEL) |
3312 | 3302 | { |
3313 | | g_free (mail_cc_last); |
3314 | | g_free (mail_subject_last); |
3315 | | g_free (mail_to_last); |
3316 | | mail_cc_last = tmail_cc; |
3317 | | mail_subject_last = tmail_subject; |
3318 | | mail_to_last = tmail_to; |
3319 | | pipe_mail (&edit->buffer, mail_to_last, mail_subject_last, mail_cc_last); |
| 3303 | pipe_mail (&edit->buffer, mail_to, mail_subject, mail_cc); |
| 3304 | g_free (mail_to); |
| 3305 | g_free (mail_subject); |
| 3306 | g_free (mail_cc); |
3320 | 3307 | } |
3321 | 3308 | } |
3322 | 3309 | |