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
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
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) {
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
-
}
}