summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 12f47b8)
raw | patch | inline | side by side (parent: 12f47b8)
author | Patrick Hallen <patrick.hallen@rwth-aachen.de> | |
Sat, 28 Mar 2009 18:03:51 +0000 (19:03 +0100) | ||
committer | Patrick Hallen <patrick.hallen@rwth-aachen.de> | |
Sat, 28 Mar 2009 18:03:51 +0000 (19:03 +0100) |
Commit b36fbc3ed8b9ceed41 broke the usecase of jumping
directly to the first entry which begins with a certain letter.
This patch adds a new option, which enables the old behaviour,
which searches for the beginning of a string and not for the first
occurence.
directly to the first entry which begins with a certain letter.
This patch adds a new option, which enables the old behaviour,
which searches for the beginning of a string and not for the first
occurence.
src/conf.c | patch | blob | history | |
src/list_window.c | patch | blob | history | |
src/match.c | patch | blob | history | |
src/match.h | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history |
diff --git a/src/conf.c b/src/conf.c
index 478d468c4823f3d82692ccffdba60e9c12e15595..09fa45fe19d57b638ea3031cbba874471038b196 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#define CONF_VISIBLE_BITRATE "visible-bitrate"
#define CONF_WELCOME_SCREEN_LIST "welcome-screen-list"
#define CONF_DISPLAY_TIME "display-time"
+#define CONF_JUMP_PREFIX_ONLY "jump-prefix-only"
static bool
str2bool(char *str)
{}
#else
options.display_time = str2bool(value);
+#endif
+ else if (!strcasecmp(CONF_JUMP_PREFIX_ONLY, name))
+#ifdef NCMPC_MINI
+ {}
+#else
+ options.jump_prefix_only = str2bool(value);
#endif
else
match_found = false;
diff --git a/src/list_window.c b/src/list_window.c
index 40f2e14250196106735632d483ce1c2633d87580..347c54b4d440fc0f3b704e3ba730d472c37e5b4e 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
const char *label;
while ((label = callback(i,&h,callback_data))) {
- if (label && label[0] != '[')
+ if (label && label[0] == '[')
+ label++;
+#ifndef NCMPC_MINI
+ if (str && label &&
+ ((options.jump_prefix_only && g_ascii_strncasecmp(label, str, strlen(str)) == 0) ||
+ (!options.jump_prefix_only && match_line(label, str))) )
+#else
+ if (str && label && g_ascii_strncasecmp(label, str, strlen(str)) == 0)
+#endif
{
- if (str && label && find_occurence(label, str, strlen(str)) == 0) {
- lw->selected = i;
- if(!lw->range_selection || i > lw->selected_end)
- lw->selected_end = i;
- if(!lw->range_selection || i < lw->selected_start)
- lw->selected_start = i;
- return true;
- }
+ lw->selected = i;
+ if(!lw->range_selection || i > lw->selected_end)
+ lw->selected_end = i;
+ if(!lw->range_selection || i < lw->selected_start)
+ lw->selected_start = i;
+ return true;
}
- else if (str && label && find_occurence(label+1, str, strlen(str)) == 0) {
- lw->selected = i;
- if(!lw->range_selection || i > lw->selected_end)
- lw->selected_end = i;
- if(!lw->range_selection || i < lw->selected_start)
- lw->selected_start = i;
- return true;
- }
i++;
}
return false;
diff --git a/src/match.c b/src/match.c
index 313c76e686dde0c563c71b0ad762b6980027d2fc..bd5250373348943e376a96e551663ce9862dca41 100644 (file)
--- a/src/match.c
+++ b/src/match.c
return ret;
}
-
-int
-find_occurence(const char *str_orig, const char *str_occur, const int str_occur_len)
-{
- const int str_orig_len = strlen (str_orig);
- int i, j;
-
- if (str_occur_len > str_orig_len)
- return -1;
-
- for (i = 0; i < str_orig_len; i++) {
- if ((i + str_occur_len) > str_orig_len)
- return -1;
-
- for (j = 0; j < str_occur_len; j++) {
- if (tolower (str_occur[j]) != tolower (str_orig[i+j]))
- break;
-
- if (j == str_occur_len - 1)
- return 0;
- }
- }
-
- return -1;
-}
-
diff --git a/src/match.h b/src/match.h
index 4362cce8a22769c5489156a20310f7ff35e362d3..fed7207ecb99ca9747cebe5474a4b4338ffa94b1 100644 (file)
--- a/src/match.h
+++ b/src/match.h
{
return strstr(line, needle) != NULL;
}
-
-static inline int
-find_occurence(const char *str_orig, const char *str_occur, const int str_occur_len)
-{
- return g_ascii_strncasecmp(str_orig, str_occur, str_occur_len);
-}
-
#else
/**
bool
match_line(const char *line, const char *needle);
-int
-find_occurence(const char *str_orig, const char *str_occur, const int str_occur_len);
-
#endif
#endif
diff --git a/src/options.c b/src/options.c
index dd7ba532c68aa1346141dc4f44bf9a944180fdf8..44840548eb1c734521d5d1a1b3d8a0426b24d1a6 100644 (file)
--- a/src/options.c
+++ b/src/options.c
.scroll = DEFAULT_SCROLL,
.welcome_screen_list = true,
.display_time = true,
+ .jump_prefix_only = true,
#endif
};
diff --git a/src/options.h b/src/options.h
index dbd5a43ce93a1199be5765034b7eefa22f9c3150..bccd0b22b4fab2217cf1c37bb6c0bf35beaf80b7 100644 (file)
--- a/src/options.h
+++ b/src/options.h
bool visible_bitrate;
bool welcome_screen_list;
bool display_time;
+ bool jump_prefix_only;
#endif
} options_t;