mkdir -p $(PREFIX)/bin
cp -f tide $(PREFIX)/bin
cp -f tide-hl.rb $(PREFIX)/bin
+ cp -f tide-fetch.rb $(PREFIX)/bin
cp -f pick $(PREFIX)/bin
cp -f xcpd $(PREFIX)/bin
cp -f pickfile $(PREFIX)/bin
uninstall:
rm -f $(PREFIX)/bin/tide
rm -f $(PREFIX)/bin/tide-hl.rb
+ rm -f $(PREFIX)/bin/tide-fetch.rb
rm -f $(PREFIX)/bin/pick
rm -f $(PREFIX)/bin/xcpd
rm -f $(PREFIX)/bin/pickfile
void view_byrune(View* view, int move, bool extsel);
void view_byword(View* view, int move, bool extsel);
void view_byline(View* view, int move, bool extsel);
-char* view_fetch(View* view, size_t row, size_t col);
+char* view_fetch(View* view, size_t row, size_t col, bool (*isword)(Rune));
bool view_findstr(View* view, int dir, char* str);
void view_insert(View* view, bool indent, Rune rune);
void view_delete(View* view, int dir, bool byword);
*****************************************************************************/
bool exec_reap(void);
void exec_job(char** cmd, char* data, size_t ndata, View* dest);
-void exec_cmd(char** cmd, char* text, char** out, char** err);
+int exec_cmd(char** cmd, char* text, char** out, char** err);
int exec_spawn(char** cmd, int* in, int* out);
/* Pseudo-Terminal Handling
}
}
-void exec_cmd(char** cmd, char* text, char** out, char** err) {
+int exec_cmd(char** cmd, char* text, char** out, char** err) {
Proc proc;
if (execute(cmd, &proc) < 0) {
perror("failed to execute");
- return;
+ return -1;
}
/* send the input to stdin of the command */
if (text && write(proc.in, text, strlen(text)) < 0) {
perror("failed to write");
- return;
+ return -1;
}
close(proc.in);
/* read the stderr of the command */
if (out) *out = fdgets(proc.out);
close(proc.out);
/* wait for the process to finish */
- waitpid(proc.pid, NULL, 0);
+ int status;
+ waitpid(proc.pid, &status, 0);
+ return status;
}
int exec_spawn(char** cmd, int* in, int* out) {
Rcvr* rcvr = data;
Job* job = rcvr->job;
View* view = rcvr->view;
- Buf* buf = &(rcvr->view->buffer);
Sel sel = view->selection;
if (fd >= 0) {
}
bool risfile(Rune r) {
- return (risword(r) || r == '/' || r == '.');
+ return (risword(r) || r == '/' || r == '.' || r == ':');
}
bool riscmd(Rune r) {
return num_selected(view->selection);
}
-char* view_fetch(View* view, size_t row, size_t col) {
+char* view_fetch(View* view, size_t row, size_t col, bool (*isword)(Rune)) {
char* str = NULL;
size_t off = getoffset(view, row, col);
if (off != SIZE_MAX) {
if (in_selection(view->selection, off)) {
sel = view->selection;
} else {
- buf_getword(&(view->buffer), riscmd, &sel);
+ buf_getword(&(view->buffer), isword, &sel);
sel.end++;
}
str = view_getstr(view, &sel);
#!/usr/bin/env ruby
if not ARGV[0] then
- $stderr.puts "Usage: tide-hl [FILE]"
+ $stderr.puts "Usage: tide-hl.rb [FILE]"
exit 1
end
language "Ruby" do
keywords = Set.new %w[
- if not then else elsif end def do exit nil
+ if not then else elsif end def do exit nil begin rescue raise pass class
goto break return continue case default switch while for
]
/* Open a new instance of the editor */
char* OpenCmd[] = { "tide", NULL, NULL };
+/* Try to fetch the text with tide-fetch */
+char* FetchCmd[] = { "tide-fetch.rb", NULL, NULL };
+
/* Tag/Cmd Execution
******************************************************************************/
static Tag* tag_lookup(char* cmd) {
if (win_btnpressed(MouseLeft)) {
cut();
} else {
- char* str = view_fetch(win_view(id), row, col);
+ char* str = view_fetch(win_view(id), row, col, riscmd);
if (str) exec(str);
free(str);
}
if (win_btnpressed(MouseLeft)) {
paste();
} else {
- SearchDir *= (x11_keymodsset(ModShift) ? -1 : +1);
- free(SearchTerm);
- SearchTerm = view_fetch(win_view(id), row, col);
- if (view_findstr(win_view(EDIT), SearchDir, SearchTerm)) {
- win_setregion(EDIT);
- win_warpptr(EDIT);
+ char* text = view_fetch(win_view(id), row, col, risfile);
+ FetchCmd[1] = text;
+ if (exec_cmd(FetchCmd, NULL, NULL, NULL) != 0) {
+ SearchDir *= (x11_keymodsset(ModShift) ? -1 : +1);
+ free(SearchTerm);
+ SearchTerm = view_fetch(win_view(id), row, col, risfile);
+ if (view_findstr(win_view(EDIT), SearchDir, SearchTerm)) {
+ win_setregion(EDIT);
+ win_warpptr(EDIT);
+ }
+ } else {
+ free(text);
}
}
}