1
0
forked from aniani/vim

patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe

Problem:    A lot of code is shared between vim.exe and gvim.exe.
Solution:   Optionally put the shared code in vim.dll. (Ken Takata,
            closes #4287)
This commit is contained in:
Bram Moolenaar
2019-04-28 19:46:49 +02:00
parent ab4cece605
commit afde13b62b
42 changed files with 1202 additions and 468 deletions

View File

@@ -2314,75 +2314,6 @@ sm_client_check_changed_any(GnomeClient *client UNUSED,
gnome_interaction_key_return(key, shutdown_cancelled);
}
/*
* Generate a script that can be used to restore the current editing session.
* Save the value of v:this_session before running :mksession in order to make
* automagic session save fully transparent. Return TRUE on success.
*/
static int
write_session_file(char_u *filename)
{
char_u *escaped_filename;
char *mksession_cmdline;
unsigned int save_ssop_flags;
int failed;
/*
* Build an ex command line to create a script that restores the current
* session if executed. Escape the filename to avoid nasty surprises.
*/
escaped_filename = vim_strsave_escaped(filename, escape_chars);
if (escaped_filename == NULL)
return FALSE;
mksession_cmdline = g_strconcat("mksession ", (char *)escaped_filename,
NULL);
vim_free(escaped_filename);
/*
* Use a reasonable hardcoded set of 'sessionoptions' flags to avoid
* unpredictable effects when the session is saved automatically. Also,
* we definitely need SSOP_GLOBALS to be able to restore v:this_session.
* Don't use SSOP_BUFFERS to prevent the buffer list from becoming
* enormously large if the GNOME session feature is used regularly.
*/
save_ssop_flags = ssop_flags;
ssop_flags = (SSOP_BLANK|SSOP_CURDIR|SSOP_FOLDS|SSOP_GLOBALS
|SSOP_HELP|SSOP_OPTIONS|SSOP_WINSIZE|SSOP_TABPAGES);
do_cmdline_cmd((char_u *)"let Save_VV_this_session = v:this_session");
failed = (do_cmdline_cmd((char_u *)mksession_cmdline) == FAIL);
do_cmdline_cmd((char_u *)"let v:this_session = Save_VV_this_session");
do_unlet((char_u *)"Save_VV_this_session", TRUE);
ssop_flags = save_ssop_flags;
g_free(mksession_cmdline);
/*
* Reopen the file and append a command to restore v:this_session,
* as if this save never happened. This is to avoid conflicts with
* the user's own sessions. FIXME: It's probably less hackish to add
* a "stealth" flag to 'sessionoptions' -- gotta ask Bram.
*/
if (!failed)
{
FILE *fd;
fd = open_exfile(filename, TRUE, APPENDBIN);
failed = (fd == NULL
|| put_line(fd, "let v:this_session = Save_VV_this_session") == FAIL
|| put_line(fd, "unlet Save_VV_this_session") == FAIL);
if (fd != NULL && fclose(fd) != 0)
failed = TRUE;
if (failed)
mch_remove(filename);
}
return !failed;
}
/*
* "save_yourself" signal handler. Initiate an interaction to ask the user
* for confirmation if necessary. Save the current editing session and tell