]> git.mdlowis.com Git - projs/tide.git/commitdiff
added : shortcut for executing sed commands on selection
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 1 Dec 2016 21:20:42 +0000 (16:20 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 1 Dec 2016 21:20:42 +0000 (16:20 -0500)
libedit/exec.c
xedit.c

index 403b7ddf86a76689484ee1cdda83015d25d7bf04..be0ee21dc4e1f5b75e636c885a2abbe0d1842fd4 100644 (file)
@@ -87,7 +87,7 @@ void cmdwrite(char** cmd, char* text, char** err) {
         perror("failed to execute");
         return;
     }
-    if (write(proc.in, text, strlen(text)) < 0) {
+    if (text && write(proc.in, text, strlen(text)) < 0) {
         perror("failed to write");
         return;
     }
@@ -102,7 +102,7 @@ char* cmdwriteread(char** cmd, char* text, char** err) {
         perror("failed to execute");
         return NULL;
     }
-    if (write(proc.in, text, strlen(text)) < 0) {
+    if (text && write(proc.in, text, strlen(text)) < 0) {
         perror("failed to write");
         return NULL;
     }
diff --git a/xedit.c b/xedit.c
index 793c0883a407882519de8ebfc1a5d79105981547..5426b2016b92e0a8386cbf4a59adbdbaad9d6dbf 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -160,6 +160,7 @@ static char* PasteCmd[] = { "xsel", "-bo", NULL };
 static char* ShellCmd[] = { "/bin/sh", "-c", NULL, NULL };
 static char* PickFileCmd[] = { "xfilepick", ".", NULL };
 static char* OpenCmd[] = { "xedit", NULL, NULL };
+static char* SedCmd[] = { "sed", "-e", NULL, NULL };
 
 /* Main Routine
  *****************************************************************************/
@@ -523,7 +524,7 @@ static void tag_exec(Tag* tag, char* arg) {
 
 static void cmd_exec(char* cmd) {
     char op = '\0';
-    if (*cmd == '!' || *cmd == '<' || *cmd == '|' || *cmd == '>')
+    if (*cmd == ':' || *cmd == '!' || *cmd == '<' || *cmd == '|' || *cmd == '>')
         op = *cmd, cmd++;
     ShellCmd[2] = cmd;
     /* execute the command */
@@ -531,11 +532,14 @@ static void cmd_exec(char* cmd) {
     enum RegionId dest = EDIT;
     input = view_getstr(getview(EDIT), NULL);
     if (op == '!') {
-        printf("null: '%s'\n", cmd);
+        cmdrun(ShellCmd, NULL);
     } else if (op == '>') {
         cmdwrite(ShellCmd, input, &error);
     } else if (op == '|') {
         output = cmdwriteread(ShellCmd, input, &error);
+    } else if (op == ':') {
+        SedCmd[2] = cmd;
+        output = cmdwriteread(SedCmd, input, &error);
     } else {
         if (op != '<') dest = Focused;
         output = cmdread(ShellCmd, &error);
@@ -630,11 +634,3 @@ static enum RegionId getregion(size_t x, size_t y) {
     }
     return NREGIONS;
 }
-
-#if 0
-void move_pointer(size_t x, size_t y) {
-    x = (x * Fonts.base.width)  + (Fonts.base.width / 2);
-    y = ((y+1) * Fonts.base.height) + (Fonts.base.height / 2);
-    x11_warp_mouse(x,y);
-}
-#endif