mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* editcmd.c (edit_quit_cmd): Rename to ...
(edit_ok_to_exit): ... this. Don't stop dialog - this function is called by the dialog code. * editwidget.c (edit_dialog_callback): Process DLG_VALIDATE event. Don't exit it the user wants to continue editing. * edit.c (edit_execute_cmd): Close the dialog - it will ask user if necessary.
This commit is contained in:
parent
7a5c9a3834
commit
dadbdd25e9
@ -1,5 +1,13 @@
|
||||
2003-07-20 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* editcmd.c (edit_quit_cmd): Rename to ...
|
||||
(edit_ok_to_exit): ... this. Don't stop dialog - this function
|
||||
is called by the dialog code.
|
||||
* editwidget.c (edit_dialog_callback): Process DLG_VALIDATE
|
||||
event. Don't exit it the user wants to continue editing.
|
||||
* edit.c (edit_execute_cmd): Close the dialog - it will ask user
|
||||
if necessary.
|
||||
|
||||
* editcmd.c (edit_quit_cmd): Don't save this command in the undo
|
||||
stack. Don't force any refresh. Don't delete unsaved files, do
|
||||
it ...
|
||||
|
@ -2520,7 +2520,7 @@ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion)
|
||||
break;
|
||||
|
||||
case CK_Exit:
|
||||
edit_quit_cmd (edit);
|
||||
dlg_stop (edit->widget.parent);
|
||||
break;
|
||||
case CK_New:
|
||||
edit_new_cmd (edit);
|
||||
|
@ -198,6 +198,7 @@ int edit_save_as_cmd (WEdit * edit);
|
||||
WEdit *edit_init (WEdit *edit, int lines, int columns,
|
||||
const char *filename, long line);
|
||||
int edit_clean (WEdit * edit);
|
||||
int edit_ok_to_exit (WEdit *edit);
|
||||
int edit_renew (WEdit * edit);
|
||||
int edit_new_cmd (WEdit * edit);
|
||||
int edit_reload (WEdit *edit, const char *filename);
|
||||
@ -205,7 +206,6 @@ int edit_load_cmd (WEdit * edit);
|
||||
void edit_mark_cmd (WEdit * edit, int unmark);
|
||||
void edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2);
|
||||
void edit_push_markers (WEdit * edit);
|
||||
void edit_quit_cmd (WEdit * edit);
|
||||
void edit_replace_cmd (WEdit * edit, int again);
|
||||
void edit_search_cmd (WEdit * edit, int again);
|
||||
void edit_complete_word_cmd (WEdit * edit);
|
||||
|
@ -2049,16 +2049,24 @@ void edit_search_cmd (WEdit * edit, int again)
|
||||
}
|
||||
|
||||
|
||||
/* Real edit only */
|
||||
void edit_quit_cmd (WEdit * edit)
|
||||
/*
|
||||
* Check if it's OK to close the editor. If there are unsaved changes,
|
||||
* ask user. Return 1 if it's OK to exit, 0 to continue editing.
|
||||
*/
|
||||
int
|
||||
edit_ok_to_exit (WEdit *edit)
|
||||
{
|
||||
if (edit->modified) {
|
||||
switch (edit_query_dialog3 (_ ("Quit"), _ (" File was modified, Save with exit? "), _ ("Cancel quit"), _ ("&Yes"), _ ("&No"))) {
|
||||
if (!edit->modified)
|
||||
return 1;
|
||||
|
||||
switch (edit_query_dialog3
|
||||
(_("Quit"), _(" File was modified, Save with exit? "),
|
||||
_("Cancel quit"), _("&Yes"), _("&No"))) {
|
||||
case 1:
|
||||
edit_push_markers (edit);
|
||||
edit_set_markers (edit, 0, 0, 0, 0);
|
||||
if (!edit_save_cmd (edit))
|
||||
return;
|
||||
return 0;
|
||||
break;
|
||||
case 2:
|
||||
if (edit->locked)
|
||||
@ -2066,12 +2074,13 @@ void edit_quit_cmd (WEdit * edit)
|
||||
break;
|
||||
case 0:
|
||||
case -1:
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
dlg_stop (edit->widget.parent);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#define TEMP_BUF_LEN 1024
|
||||
|
||||
/* Return a null terminated length of text. Result must be g_free'd */
|
||||
|
@ -141,12 +141,19 @@ edit_adjust_size (Dlg_head *h)
|
||||
|
||||
/* Callback for the edit dialog */
|
||||
static int
|
||||
edit_dialog_callback (Dlg_head * h, int id, int msg)
|
||||
edit_dialog_callback (Dlg_head *h, int id, int msg)
|
||||
{
|
||||
WEdit *edit;
|
||||
|
||||
switch (msg) {
|
||||
case DLG_RESIZE:
|
||||
edit_adjust_size (h);
|
||||
return MSG_HANDLED;
|
||||
case DLG_VALIDATE:
|
||||
edit = (WEdit *) find_widget_type (h, (callback_fn) edit_callback);
|
||||
if (!edit_ok_to_exit (edit)) {
|
||||
h->running = 1;
|
||||
}
|
||||
}
|
||||
return default_dlg_callback (h, id, msg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user