From: Michael D. Lowis Date: Fri, 21 Jul 2017 12:40:07 +0000 (-0400) Subject: Tweake escape code to remove null char. Added filter to find command in tide-fetch... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=50b205bede4221e667aa16dee5dc8e24a0c61b82;p=projs%2Ftide.git Tweake escape code to remove null char. Added filter to find command in tide-fetch. Added separate tags settings for edit mode and command mode --- diff --git a/TODO.md b/TODO.md index de76725..d1d6d32 100644 --- 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 diff --git a/inc/edit.h b/inc/edit.h index 2497411..93f5bc8 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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, diff --git a/lib/config.c b/lib/config.c index 92c18db..c19fffe 100644 --- a/lib/config.c +++ b/lib/config.c @@ -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, { diff --git a/lib/pty.c b/lib/pty.c index fd1a532..2b20d5c 100644 --- 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 6be0131..ccf45c2 100755 --- 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" diff --git a/tide-fetch.rb b/tide-fetch.rb index d2f864f..6853908 100755 --- a/tide-fetch.rb +++ b/tide-fetch.rb @@ -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 b4951fa..c73eff1 100644 --- 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;