]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added SaveAs tag to allow saving the file with a new name
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 1 May 2017 00:32:01 +0000 (20:32 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 1 May 2017 00:32:01 +0000 (20:32 -0400)
TODO.md
docs/xedit.1
docs/xedit.1.md
xedit.c

diff --git a/TODO.md b/TODO.md
index 0e758fe3711ee83420b5b56c9b7665fb092a2f1e..0aea04ec4f9098cea757eeff5f75a2f5850d99ce 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,24 +2,22 @@
 
 Up Next:
 
-* fix crash on saving read-only file
-* Run commands in the background and don't block the main thread.
+* refactor x11.c and win.c
+* Add a GoTo tag for ctags lookup and line number jump (or right click magic?)
+* Add keyboard shortcut to highlight the thing under the cursor
 * Make Fn keys execute nth command in the tags buffer
-
+* Run commands in the background and don't block the main thread.
 * check for file changes on save
 * check for file changes when window regains focus
 * 100% coverage with unit and unit-integration tests
-* Add a SaveAs tag that takes an argument for the filename to save as
-* Add a GoTo tag for ctags lookup and line number jump (or right click magic?) 
-* Add keyboard shortcut to highlight the thing under the cursor
 * right click to fetch file or line
 * Status line should omit characters from beginning of path to make file path fit
 
 Straight-up Bugs:
 
+* fix crash on saving read-only file
+* fix crash on save to file that can't be created
 * tab inserts dont coalesce like one would expect
-* off by one error on scrolling up with wrapped lines
-* Ctrl+u with a selection clears to bol *before* selected text
 
 The Future:
 
index cfeb477c16ccb9aebf9598cf336504f687ecbfe9..030f3377abc26c8b8ce6c8c43e7e51f17cd7a0a8 100644 (file)
@@ -228,7 +228,7 @@ Copy the selection to the X11 CLIPBOARD selection\.
 Toggle the line\-ending style for the buffers contents between LF and CRLF
 .
 .TP
-\fBFind\fR
+\fBFind [term]\fR
 Find the next occurrence of the selected text\.
 .
 .TP
@@ -252,6 +252,10 @@ Redo the last undone change\.
 Save the contents of the buffer to disk\.
 .
 .TP
+\fBSaveAs [path]\fR
+Save the contents of the buffer to disk\. If a path argument is provided, the buffer will be saved to the new path\.
+.
+.TP
 \fBTabs\fR
 Toggle the expand tabs featuer on or off\.
 .
index 435da89665636c821fdaa7ba63e7ff37d3e7040a..52fc42fc61b6c40e041f472089f6ee5f7005c16c 100644 (file)
@@ -217,7 +217,7 @@ search operation to be applied in the opposite direction of the previous.
     Copy the selection to the X11 CLIPBOARD selection.
 * `Eol`:
     Toggle the line-ending style for the buffers contents between LF and CRLF
-* `Find`:
+* `Find [term]`:
     Find the next occurrence of the selected text.
 * `Indent`:
     Toggle the autoindent feature on or off.
@@ -229,6 +229,9 @@ search operation to be applied in the opposite direction of the previous.
     Redo the last undone change.
 * `Save`:
     Save the contents of the buffer to disk.
+* `SaveAs [path]`:
+    Save the contents of the buffer to disk. If a path argument is provided, the 
+    buffer will be saved to the new path.
 * `Tabs`:
     Toggle the expand tabs featuer on or off.
 * `Undo`:
diff --git a/xedit.c b/xedit.c
index c2e00eafdb4bbee377d0bc58fb9f273a09aefeb7..17ccab1368c16ce314b9b86fc66c1ffb805e3762 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -287,6 +287,15 @@ static void redo(void) {
     view_redo(win_view(FOCUSED));
 }
 
+static void tag_save(char* arg) {
+    if (arg) {
+        char* path = win_buf(EDIT)->path;
+        win_buf(EDIT)->path = stringdup(arg);
+        buf_save(win_buf(EDIT));
+        free(path);
+    }
+}
+
 static void tag_undo(void) {
     view_undo(win_view(EDIT));
 }
@@ -437,6 +446,7 @@ static void newline(void) {
 static Tag Builtins[] = {
     { .tag = "Quit",   .action.noarg = quit     },
     { .tag = "Save",   .action.noarg = save     },
+    { .tag = "SaveAs", .action.arg   = tag_save },
     { .tag = "Cut",    .action.noarg = cut      },
     { .tag = "Copy",   .action.noarg = copy     },
     { .tag = "Paste",  .action.noarg = paste    },