diff mcabber/src/screen.c @ 370:dd9e2eb52916

Add /buffer search_{backward,forward}
author Mikael Berthe <mikael@lilotux.net>
date Sun, 24 Jul 2005 22:56:42 +0100
parents 499170ed71c9
children af2f8ddf6a1b
line wrap: on
line diff
--- a/mcabber/src/screen.c	Sun Jul 24 22:31:31 2005 +0100
+++ b/mcabber/src/screen.c	Sun Jul 24 22:56:42 2005 +0100
@@ -1005,6 +1005,40 @@
   doupdate();
 }
 
+//  scr_BufferSearch(direction, text)
+// Jump to the next line containing text
+// (backward search if direction == -1, forward if topbottom == 1)
+void scr_BufferSearch(int direction, const char *text)
+{
+  window_entry_t *win_entry;
+  GList *current_line, *search_res;
+
+  // Get win_entry
+  if (!current_buddy) return;
+  win_entry  = scr_SearchWindow(CURRENT_JID);
+  if (!win_entry) return;
+
+  if (win_entry->top)
+    current_line = win_entry->top;
+  else
+    current_line = g_list_last(win_entry->hbuf);
+
+  search_res = hbuf_search(current_line, direction, text);
+
+  if (search_res) {
+    win_entry->cleared = FALSE;
+    win_entry->top = search_res;
+
+    // Refresh the window
+    scr_UpdateWindow(win_entry);
+
+    // Finished :)
+    update_panels();
+    doupdate();
+  } else
+    scr_LogPrint("Search string not found");
+}
+
 //  scr_LogPrint(...)
 // Display a message in the log window.
 void scr_LogPrint(const char *fmt, ...)