Implement the modification bit of the .swp file, put it in the correct actual

location (pos 1007).



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4551 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2013-01-03 03:36:20 +00:00
parent 21f73f902f
commit d70c7f3c14
3 changed files with 15 additions and 10 deletions

View File

@ -1,9 +1,8 @@
2012-12-31 Chris Allegretta <chrisa@asty.org>
* src/*: Introduce (basic) vim-style file locks. Does not allow vim to recover
our files, and doesn't yet support setting the file as modified; just lets a
vim user know we're editing a file. Commands line "-G" or "--locking", nanorc
option "locking". New functions src/files.c:do_lockfile(), write_lockfile(),
and delete_lockfile().
our changes, and just lets a vim user know we're editing a file. Commands line "-G"
or "--locking", nanorc option "locking". New functions
src/files.c:do_lockfile(), write_lockfile(), and delete_lockfile().
2012-02-05 Chris Allegretta <chrisa@asty.org>
* src/*: Fix overlapping strings highlighting each other. new variables in edit_draw

View File

@ -182,8 +182,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
bytes 28-44 - username of who created the lock
bytes 68-100 - hostname of where the lock was created
bytes 108-876 - filename the lock is for
byte 1018 - 0x55 if file is modified
(TODO: set if 'modified' == TRUE)
byte 1007 - 0x55 if file is modified
Looks like VIM also stores undo state in this file so we're
gonna have to figure out how to slap a 'OMG don't use recover
@ -200,6 +199,8 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
strncpy(&lockdata[28], mypwuid->pw_name, 16);
strncpy(&lockdata[68], myhostname, 31);
strncpy(&lockdata[108], origfilename, 768);
if (modified == TRUE)
lockdata[1007] = 0x55;
wroteamt = fwrite(lockdata, sizeof(char), lockdatalen, filestream);
if (wroteamt < lockdatalen) {

View File

@ -2259,11 +2259,16 @@ void set_modified(void)
openfile->modified = TRUE;
titlebar(NULL);
#ifndef NANO_TINY
if (ISSET(LOCKING) && openfile->lock_filename == NULL)
/* Translators: Try to keep this at most 80 characters. */
statusbar(_("Warning: Modifying a file which is not locked, check directory permission?"));
if (ISSET(LOCKING)) {
if (openfile->lock_filename == NULL) {
/* Translators: Try to keep this at most 80 characters. */
statusbar(_("Warning: Modifying a file which is not locked, check directory permission?"));
} else {
write_lockfile(openfile->lock_filename,
get_full_path(openfile->filename), TRUE);
}
}
#endif
}
}