commit - 7c1452c14b890849b898f0c935faf35d1042f71c
commit + 8f4ed63441b6c8e9c29c4db32ad615a1657aa1ac
blob - d021edb38b3de98ca191df743d097a9c3e818eec
blob + e4a29913017c957f0d4f8e06cdd86094f3999c58
--- tog/tog.c
+++ tog/tog.c
#define TOG_SEARCH_FORWARD 1
#define TOG_SEARCH_BACKWARD 2
int search_next_done;
+#define TOG_SEARCH_HAVE_MORE 1
+#define TOG_SEARCH_NO_MORE 2
regex_t regex;
};
*new = NULL;
*dead = NULL;
*focus = NULL;
+
+ /* Clear "no more matches" indicator. */
+ if (view->search_next_done == TOG_SEARCH_NO_MORE)
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
if (view->searching && !view->search_next_done) {
errcode = pthread_mutex_unlock(&tog_mutex);
break;
case 'N':
case 'n':
- if (view->search_next && view->searching) {
+ if (view->search_next) {
view->searching = (ch == 'n' ?
TOG_SEARCH_FORWARD : TOG_SEARCH_BACKWARD);
view->search_next_done = 0;
if (err)
break;
if (have_match)
- *search_next_done = 1;
+ *search_next_done = TOG_SEARCH_HAVE_MORE;
}
errcode = pthread_mutex_unlock(&tog_mutex);
if (commits_needed == 0)
halfdelay(10); /* disable fast refresh */
- if (asprintf(&ncommits_str, " [%d/%d] %s",
- entry ? entry->idx + 1 : 0, commits->ncommits,
- commits_needed > 0 ?
- (view->searching && view->search_next_done == 0
- ? "searching..." : "loading... ") :
- (refs_str ? refs_str : "")) == -1) {
- err = got_error_from_errno("asprintf");
- goto done;
+ if (commits_needed > 0) {
+ if (asprintf(&ncommits_str, " [%d/%d] %s",
+ entry ? entry->idx + 1 : 0, commits->ncommits,
+ view->searching ? "searching..." : "loading...") == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
+ } else {
+ if (asprintf(&ncommits_str, " [%d/%d] %s",
+ entry ? entry->idx + 1 : 0, commits->ncommits,
+ view->search_next_done == TOG_SEARCH_NO_MORE ?
+ "no more matches" : (refs_str ? refs_str : "")) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
}
if (path && strcmp(path, "/") != 0) {
struct tog_log_view_state *s = &view->state.log;
struct commit_queue_entry *entry;
- if (!view->searching) {
- view->search_next_done = 1;
- return NULL;
- }
-
if (s->search_entry) {
int errcode, ch;
errcode = pthread_mutex_unlock(&tog_mutex);
return got_error_set_errno(errcode,
"pthread_mutex_lock");
if (ch == KEY_BACKSPACE) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
return NULL;
}
if (view->searching == TOG_SEARCH_FORWARD)
commit_queue_head, entry);
} else if (s->matched_entry) {
if (view->searching == TOG_SEARCH_FORWARD)
- entry = TAILQ_NEXT(s->selected_entry, entry);
+ entry = TAILQ_NEXT(s->matched_entry, entry);
else
- entry = TAILQ_PREV(s->selected_entry,
+ entry = TAILQ_PREV(s->matched_entry,
commit_queue_head, entry);
} else {
if (view->searching == TOG_SEARCH_FORWARD)
if (entry == NULL) {
if (s->thread_args.log_complete ||
view->searching == TOG_SEARCH_BACKWARD) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_NO_MORE;
+ s->search_entry = NULL;
return NULL;
}
/*
if (err)
break;
if (have_match) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
s->matched_entry = entry;
break;
}
int lineno;
if (!view->searching) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
return NULL;
}
if (lineno <= 0 || lineno > s->nlines) {
if (s->matched_line == 0) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
free(line);
break;
}
free(line);
line = parse_next_line(s->f, &len);
if (line && match_line(line, &view->regex)) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
s->matched_line = lineno;
free(line);
break;
int lineno;
if (!view->searching) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
return NULL;
}
if (lineno <= 0 || lineno > s->blame.nlines) {
if (s->matched_line == 0) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
free(line);
break;
}
free(line);
line = parse_next_line(s->blame.f, &len);
if (line && match_line(line, &view->regex)) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
s->matched_line = lineno;
free(line);
break;
struct got_tree_entry *te = NULL;
if (!view->searching) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
return NULL;
}
while (1) {
if (te == NULL) {
if (s->matched_entry == NULL) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
return NULL;
}
if (view->searching == TOG_SEARCH_FORWARD)
}
if (match_tree_entry(te, &view->regex)) {
- view->search_next_done = 1;
+ view->search_next_done = TOG_SEARCH_HAVE_MORE;
s->matched_entry = te;
break;
}