summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4c04df8)
raw | patch | inline | side by side (parent: 4c04df8)
author | Patrick Hallen <patrick.hallen@rwth-aachen.de> | |
Wed, 11 Feb 2009 19:07:03 +0000 (20:07 +0100) | ||
committer | Patrick Hallen <patrick.hallen@rwth-aachen.de> | |
Wed, 11 Feb 2009 19:07:03 +0000 (20:07 +0100) |
Added a new function which finds a string in a listwindow which begins with
the given characters.
the given characters.
src/list_window.c | patch | blob | history | |
src/list_window.h | patch | blob | history |
diff --git a/src/list_window.c b/src/list_window.c
index 688ae8bd70600ced1c53c0fac83e6144e7143b8d..4cd9a8f6009c241d2ee56700b4f4fbd24b8aeef0 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
return false;
}
+bool
+list_window_jump(struct list_window *lw,
+ list_window_callback_fn_t callback,
+ void *callback_data,
+ const char *str)
+{
+ bool h;
+ unsigned i = 0;
+ const char *label;
+
+ while ((label = callback(i,&h,callback_data))) {
+ if (label && label[0] != '[')
+ {
+ if (str && label && g_ascii_strncasecmp(label, str, strlen(str)) == 0) {
+ lw->selected = i;
+ if(!lw->visual_selection || i > lw->selected_end)
+ lw->selected_end = i;
+ if(!lw->visual_selection || i < lw->selected_start)
+ lw->selected_start = i;
+ return true;
+ }
+ }
+ else if (str && label && g_ascii_strncasecmp(label+1, str, strlen(str)) == 0) {
+ lw->selected = i;
+ if(!lw->visual_selection || i > lw->selected_end)
+ lw->selected_end = i;
+ if(!lw->visual_selection || i < lw->selected_start)
+ lw->selected_start = i;
+ return true;
+ }
+ i++;
+ }
+ return false;
+}
+
/* perform basic list window commands (movement) */
bool
list_window_cmd(struct list_window *lw, unsigned rows, command_t cmd)
diff --git a/src/list_window.h b/src/list_window.h
index e996039a739f4457356614aa634654888437a78a..fd087bbc34457de3a9a8d47980ded9ddabad5a28 100644 (file)
--- a/src/list_window.h
+++ b/src/list_window.h
bool bell_on_wrap,
unsigned rows);
+/* find a string in a list window which begins with the given characters in *str */
+bool
+list_window_jump(struct list_window *lw,
+ list_window_callback_fn_t callback,
+ void *callback_data,
+ const char *str);
+
#endif