]> git.mdlowis.com Git - projs/tide.git/commitdiff
Tweake escape code to remove null char. Added filter to find command in tide-fetch...
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 21 Jul 2017 12:40:07 +0000 (08:40 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 21 Jul 2017 12:40:07 +0000 (08:40 -0400)
TODO.md
inc/edit.h
lib/config.c
lib/pty.c
tcmd
tide-fetch.rb
tide.c

diff --git a/TODO.md b/TODO.md
index de7672539fd222f90a08dc5b83aaa260bfbe6e24..d1d6d326e95afc6a279dcb285fcf7f972a682a19 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -82,6 +82,17 @@ ls
 cat
 cd
 
+# Fetch Rule Syntax
+
+include [FILE]
+set [NAME] [VALUE]
+unset [NAME] [VALUE]
+is [NAME] [VALUE]
+isdir [VALUE]
+isfile [VALUE]
+findfile [VALUE]
+matches [NAME] [REGEX]
+exec [CMD] [ARGS...]
 
 # Syntax Highlighting
 
index 2497411da30a7981cc80511ad91203eabfef0d7d..93f5bc8fd95e1dbc6783a27e4ead331a56e83c6a 100644 (file)
@@ -241,9 +241,9 @@ void pty_send_susp(void);
 /* Configuration Data
  *****************************************************************************/
 enum { /* Configuration Variables */
-    FontString = 0, TagString, WinWidth, WinHeight, LineSpacing, LineNumbers,
-    RulerColumn, EventTimeout, CopyIndent, TrimOnSave, ExpandTabs, TabWidth,
-    ScrollLines, DblClickTime, MaxScanDist, SyntaxEnabled,
+    FontString = 0, EditTagString, CmdTagString, WinWidth, WinHeight,
+    LineSpacing, LineNumbers, RulerColumn, EventTimeout, CopyIndent, TrimOnSave,
+    ExpandTabs, TabWidth, ScrollLines, DblClickTime, MaxScanDist, SyntaxEnabled,
     Color00, Color01, Color02, Color03, Color04, Color05, Color06, Color07,
     Color08, Color09, Color10, Color11, Color12, Color13, Color14, Color15,
 
index 92c18dbaef8bd5776bc72e67a18a44538c330124..c19fffe4f8d409d2f890b66629b6a8ab3622e443 100644 (file)
@@ -14,8 +14,10 @@ struct {
         char* str;
     } value;
 } Options[] = {
-    [TagString] = { "tide.ui.tags", STRING, {
+    [EditTagString] = { "tide.ui.tags.edit", STRING, {
         .str = "Quit Save Undo Redo Cut Copy Paste | Find " } },
+    [CmdTagString] = { "tide.ui.tags.cmd", STRING, {
+        .str = "Quit Undo Redo Cut Copy Paste | Send Find " } },
 
 #ifdef __MACH__
     [FontString] = { "tide.ui.font", STRING, {
index fd1a532402430dc361c45650761df4d3757679cd..2b20d5c3a89c3f197b93988e65bf309d9fb50b45 100644 (file)
--- a/lib/pty.c
+++ b/lib/pty.c
@@ -89,6 +89,8 @@ void pty_send_rune(Rune rune) {
 static void read_escape(char* data, long* i, long n) {
     /* only one escape code supported and that is to change the working dir */
     if (data[*i] != 'P') return;
+    for (long x = *i; x < n && data[x]; x++)
+        if (data[x] == '\a') data[x] = '\0';
     size_t sz = strlen(&data[*i + 1]);
     chdir(&data[*i + 1]);
     *i = *i + 1 + sz;
diff --git a/tcmd b/tcmd
index 6be0131bd2a1bf141e12f16c7d5a6dd5d195dc68..ccf45c27642d5e4955e5e9259684ed0106fad4cc 100755 (executable)
--- a/tcmd
+++ b/tcmd
@@ -7,11 +7,10 @@ export EDITRCFILE="$HOME/.config/edit/editrc"
 export BASH_ENV="$EDITRCFILE"
 export PROMPT_COMMAND='tide_cd "$PWD"'
 
-# Override
-function tide_cd(){ echo -en "\033P$PWD\0"; }
+# Provide a cd function to change tide's working directory manually. This could
+# be aliased or defined to cd but that interferes with some programs like rbenv.
+function tide_cd(){ echo -en "\033P$PWD\a"; }
 export -f tide_cd
-function cd(){ cd "$@" && tide_cd "$@"; }
-export -f cd
 
 edit(){
     [[ -f "$EDITRCFILE" ]] && . "$EDITRCFILE"
index d2f864f03c2b4398716ec92ab1559e7288241a9a..6853908f1ea6fb687eff2619694a70b2c0f70884 100755 (executable)
@@ -38,6 +38,7 @@ end
 
 def open_with(app)
   app = Apps[app] || ENV[app.to_s.upcase]
+  puts "app: " + app
   raise RuleError.new() if not app
   spawn("#{app} #{$item}")
 end
@@ -45,7 +46,7 @@ end
 def find_file(file)
   file = file.gsub(/^~/, ENV["HOME"])
   if not file.match(/^\.?\//)
-    file = `find . -path '*#{file}' -print -quit`.chomp
+    file = `find . -ipath '*/build/*' -prune -o -path '*#{file}' -print -quit`.chomp
   end
   raise RuleError.new() if (file.length == 0 || (not File.exist?(file)))
   file
@@ -53,9 +54,8 @@ end
 
 def mimetype(regex)
   mtype = `file --mime-type #{$item} | cut -d' ' -f2`
-  if not mtype.match(regex) then
-    raise RuleError.new()
-  end
+  raise RuleError.new() if not mtype.match(regex)
+  mtype
 end
 
 # Builtin Rules
diff --git a/tide.c b/tide.c
index b4951fa8d7fa0073e310e9b4126376117d1e7a25..c73eff149a2a0b05fe4d846a7ada1cd51e485658 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -624,8 +624,6 @@ void edit_command(char** cmd) {
     char* shellcmd[] = { ShellCmd[0], NULL };
     win_buf(EDIT)->crlf = 1;
     config_set_int(TabWidth, 8);
-    win_setlinenums(false);
-    win_setruler(0);
     pty_spawn(*cmd ? cmd : shellcmd);
 }
 
@@ -635,12 +633,8 @@ int main(int argc, char** argv) {
     if (!ShellCmd[0]) ShellCmd[0] = getenv("SHELL");
     if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh";
 
-    /* Create the window and enter the event loop */
+    /* create the window */
     win_window("tide", ondiagmsg);
-    char* tags = getenv("EDITTAGS");
-    win_settext(TAGS, (tags ? tags : config_get_str(TagString)));
-    win_setruler(config_get_int(RulerColumn));
-    win_setlinenums(config_get_bool(LineNumbers));
 
     /* open all but the last file in new instances */
     for (argc--, argv++; argc > 1; argc--, argv++) {
@@ -659,6 +653,15 @@ int main(int argc, char** argv) {
     }
 
     /* now create the window and start the event loop */
+    if (!pty_active()) {
+        win_settext(TAGS, config_get_str(EditTagString));
+        win_setruler(config_get_int(RulerColumn));
+        win_setlinenums(config_get_bool(LineNumbers));
+    } else {
+        win_settext(TAGS, config_get_str(CmdTagString));
+        win_setruler(0);
+        win_setlinenums(false);
+    }
     win_setkeys(Bindings, oninput);
     win_loop();
     return 0;