]> git.mdlowis.com Git - projs/tide.git/commitdiff
added logic to populate buffer from stdin
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 20 May 2019 17:11:56 +0000 (13:11 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 20 May 2019 17:11:56 +0000 (13:11 -0400)
TODO.md
inc/edit.h
src/lib/job.c
src/tide.c

diff --git a/TODO.md b/TODO.md
index e0df5b952ca667692c6c8ad4f688e25c6eda9466..06bae82a2d05cebf48a38c8c0ca892982d9bc8b3 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -4,8 +4,8 @@
 
 ## STAGING
 
-* tide: ability to populate scratch buffer from stdin
 * tfetch: read rules from rcfile in home and curr dir
+* tfetch: ls results instead of pcmanfm on right click directory
 * tide: gap buffer does not handle UTF-8 currently
 
 ## BACKLOG
index 9394b523403e5f87ef946ce484db43e0be2c8a37..bb7512048b20a3f8198562e5fa5cd9d9d6c86afc 100644 (file)
@@ -180,6 +180,7 @@ bool job_poll(int ms);
 void job_spawn(int fd, jobfn_t readfn, jobfn_t writefn, void* data);
 void job_start(char** cmd, char* data, size_t ndata, View* dest);
 int job_run(char** cmd);
+void job_readfd(int fd, View* view);
 
 /* Common Shortcuts
  *****************************************************************************/
index 12ff10504ca9e0d3d9980f52b4fab287af6cadf6..5f4ed42551bcec4900f99131ca8343cfbd3dff90 100644 (file)
@@ -173,3 +173,9 @@ int job_run(char** cmd) {
     } while (!WIFEXITED(status) && !WIFSIGNALED(status));
     return WEXITSTATUS(status);
 }
+
+void job_readfd(int fd, View* view) {
+    struct PipeData* pipedata = calloc(1, sizeof(struct PipeData));
+    pipedata->dest = view;
+    job_spawn(fd, pipe_read, NULL, pipedata);
+}
index 473c89b4043a2bc06582b16ff18387699a7e13da..10399b0bca4d696a5825815b1214423d4009c571 100644 (file)
@@ -294,6 +294,7 @@ void win_quit(void) {
         } else {
             if (fork()) exit(0); /* fork into background if we still have selection */
         }
+
     }
     before = X.now;
 }
@@ -667,10 +668,14 @@ int main(int argc, char** argv) {
     if (*argv) {
         char* path = realpath(*argv, NULL);
         if (!path) path = strdup(*argv); /* if file doesnt exist, use the original name */
-        view_init(win_view(EDIT), path);
-        win_setln(line_num);
-        win_title(path);
-        win_prop_set("FILE", "file", path);
+        if (!strcmp("-", path)) {
+            job_readfd(STDIN_FILENO, win_view(EDIT));
+        } else {
+            view_init(win_view(EDIT), path);
+            win_setln(line_num);
+            win_title(path);
+            win_prop_set("FILE", "file", path);
+        }
         free(path);
     }