]> git.mdlowis.com Git - projs/tide.git/commitdiff
cleaned up logic for quit with unsaved changes
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 30 Nov 2016 00:17:06 +0000 (19:17 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 30 Nov 2016 00:17:06 +0000 (19:17 -0500)
xedit.c
xpick [new file with mode: 0755]

diff --git a/xedit.c b/xedit.c
index b2acfe4e8be9aa9ea079d20e5f7f7eeacb6c3e77..a89cd2fdd6e207647a30fa6951b0241355ce7f20 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -413,16 +413,14 @@ static void change_focus(void) {
 }
 
 static void quit(void) {
-    static uint64_t num_clicks = 0;
-    static uint64_t prevtime = 0;
+    static uint64_t before = 0;
     uint64_t now = getmillis();
-    num_clicks = (now - prevtime < 250 ? num_clicks+1 : 1);
-    prevtime = now;
-    if (!getbuf(EDIT)->modified || num_clicks >= 2)
+    if (!getbuf(EDIT)->modified || (now-before) <= 250)
         exit(0);
     else
         view_append(getview(TAGS),
             "File is modified. Double click Quit tag or press Ctrl+Q twice to discard changes.");
+    before = now;
 }
 
 static void save(void) {
diff --git a/xpick b/xpick
new file mode 100755 (executable)
index 0000000..a0917fb
Binary files /dev/null and b/xpick differ