From: Michael D. Lowis Date: Mon, 1 May 2017 00:32:01 +0000 (-0400) Subject: Added SaveAs tag to allow saving the file with a new name X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=29ed423546ec0e6d9618da8fc0057a4f1d99e459;p=projs%2Ftide.git Added SaveAs tag to allow saving the file with a new name --- diff --git a/TODO.md b/TODO.md index 0e758fe..0aea04e 100644 --- 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: diff --git a/docs/xedit.1 b/docs/xedit.1 index cfeb477..030f337 100644 --- a/docs/xedit.1 +++ b/docs/xedit.1 @@ -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\. . diff --git a/docs/xedit.1.md b/docs/xedit.1.md index 435da89..52fc42f 100644 --- a/docs/xedit.1.md +++ b/docs/xedit.1.md @@ -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 c2e00ea..17ccab1 100644 --- 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 },