Up Next:
-* Make Fn keys execute nth command in the tags buffer
* check for file changes on save
* check for file changes when window regains focus
* Right click in tags region should search edit region
-* Add keyboard shortcut to highlight the thing under the cursor
* 100% coverage with unit and unit-integration tests
Tomorrow-ish:
+* Make Fn keys execute nth command in the tags buffer
* selecting text should set PRIMARY x11 selection
* Add a SaveAs tag that takes an argument for the filename to save as
* Add a GoTo tag for ctags lookup and line number jump (or right click magic?)
-* Add a ctrl+space shortcut to autocomplete ctag
+* Add keyboard shortcut to highlight the thing under the cursor
* off by one error on scrolling up with wrapped lines
* tab inserts dont coalesce like one would expect
void view_selword(View* view, size_t row, size_t col) {
buf_loglock(&(view->buffer));
- view_setcursor(view, row, col);
+ if (row != SIZE_MAX && col != SIZE_MAX)
+ view_setcursor(view, row, col);
Sel sel = view->selection;
buf_getword(&(view->buffer), risbigword, &(sel));
sel.end++;
static char* ShellCmd[] = { NULL, "-c", NULL, NULL };
static char* SedCmd[] = { "sed", "-e", NULL, NULL };
static char* PickFileCmd[] = { "xfilepick", ".", NULL };
-static char* PickTagCmd[] = { "xtagpick", "tags", NULL, NULL };
+static char* PickTagCmd[] = { "xtagpick", NULL, "tags", NULL, NULL };
static char* OpenCmd[] = { "xedit", NULL, NULL };
static Tag Builtins[];
static int SearchDir = DOWN;
}
static void pick_symbol(char* symbol) {
- PickTagCmd[2] = symbol;
+ PickTagCmd[1] = "fetch";
+ PickTagCmd[3] = symbol;
char* pick = cmdread(PickTagCmd, NULL);
if (pick) {
Buf* buf = win_buf(EDIT);
pick_symbol(NULL);
}
+static void complete(void) {
+ View* view = win_view(FOCUSED);
+ view_selword(view, SIZE_MAX, SIZE_MAX);
+ PickTagCmd[1] = "print";
+ PickTagCmd[3] = view_getstr(view, NULL);
+ char* pick = cmdread(PickTagCmd, NULL);
+ if (pick)
+ view_putstr(view, chomp(pick));
+ free(PickTagCmd[3]);
+}
+
static void goto_ctag(void) {
char* str = view_getctx(win_view(FOCUSED));
if (str) {
{ ModCtrl, 'n', new_win },
{ ModCtrl, '\n', newline },
{ ModCtrl|ModShift, '\n', newline },
+ { ModCtrl, ' ', complete },
{ 0, 0, 0 }
};
#ifndef TEST
int main(int argc, char** argv) {
load_choices();
+ buf_init(&Query);
+ if (argc >= 2) {
+ char* str = argv[1];
+ while (*str)
+ buf_insert(&Query, false, Pos++, *(str++));
+ score();
+ }
if (vec_size(&Choices) > 1) {
- /* initialize the filter edit buffer */
- buf_init(&Query);
/* initialize the display engine */
x11_init(&Config);
x11_dialog("pick", Width, Height);
#!/bin/sh
-TAGFILE="$1"
-TAG="$2"
+ACTION="$1"
+TAGFILE="$2"
+TAG="$3"
usage(){
- echo "Usage: $0 TAGFILE [TAG]"
+ echo "Usage: $0 ACTION TAGFILE [TAG]"
+ echo ""
+ echo "Actions:"
+ echo " fetch - Print the filename and line number of the selcted tag"
+ echo " print - Print the selected tag"
exit 1
}
-if [ "" == "$TAGFILE" ]; then
+if [ "" == "$TAGFILE" ] || [ "" == "$ACTION" ]; then
usage
fi
-if [ "" == "$TAG" ]; then
- TAG=$(cat tags | grep -v '^!' | cut -f1 | uniq | xpick)
- [ "" == "$TAG" ] && exit
-fi
+printtags(){
+ cat "$TAGFILE" | grep -v '^!' | cut -f1 | uniq
+}
+
+print(){
+ printtags | xpick "$TAG"
+}
-awk -v TAG="$TAG" '
-BEGIN { FS = "[\t]+" }
-($1 == TAG) {
- matchstr = $3
- sub(/^\//, "\"", matchstr)
- sub(/\$?\/;"$/, "\"", matchstr)
- gsub(/\*/, "\\*", matchstr)
- print "grep -Hn", matchstr, $2, "| cut -d: -f1,2"
+fetch(){
+ if [ "" == "$TAG" ]; then
+ TAG=$(printtags | xpick)
+ [ "" == "$TAG" ] && exit
+ fi
+ awk -v TAG="$TAG" '
+ BEGIN { FS = "[\t]+" }
+ ($1 == TAG) {
+ matchstr = $3
+ sub(/^\//, "\"", matchstr)
+ sub(/\$?\/;"$/, "\"", matchstr)
+ gsub(/\*/, "\\*", matchstr)
+ print "grep -Hn", matchstr, $2, "| cut -d: -f1,2"
+ }
+ ' "$TAGFILE" | /bin/sh | xpick
}
-' "$TAGFILE" | /bin/sh | xpick
+
+case "$ACTION" in
+ "print") print ;;
+ "fetch") fetch ;;
+ *) usage ;;
+esac
+
+