[1167] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r1115 - trunk/owl

daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:13:42 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Fri, 22 Aug 2008 12:22:37 -0400 (EDT)

Author: nelhage
Date: 2008-08-22 12:22:37 -0400 (Fri, 22 Aug 2008)
New Revision: 1115

Modified:
   trunk/owl/commands.c
   trunk/owl/filter.c
   trunk/owl/functions.c
Log:
Implement a getfilter command to get the text of a filter.


Modified: trunk/owl/commands.c
===================================================================
--- trunk/owl/commands.c	2008-08-21 22:20:31 UTC (rev 1114)
+++ trunk/owl/commands.c	2008-08-22 16:22:37 UTC (rev 1115)
@@ -712,6 +712,10 @@
 	      "returns the value of a variable",
 	      "getvar <varname>", ""),
 
+  OWLCMD_ARGS("getfilter", owl_command_getfilter, OWL_CTX_INTERACTIVE,
+	      "returns the definition of a filter",
+	      "getfilter <filtername>", ""),
+
   OWLCMD_ARGS("getstyle", owl_command_getstyle, OWL_CTX_INTERACTIVE,
 	      "returns the name of the style for the current view",
 	      "", ""),
@@ -2460,6 +2464,20 @@
   return owl_strdup(tmpbuff); 
 }
 
+char *owl_command_getfilter(int argc, char **argv, char *buf)
+{
+  owl_filter *f;
+  if (argc != 2) {
+    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
+    return NULL;
+  }
+  f = owl_global_get_filter(&g, argv[1]);
+  if (!f) {
+    return NULL;
+  }
+  return owl_filter_print(f);
+}
+
 char *owl_command_search(int argc, char **argv, char *buff)
 {
   int direction;

Modified: trunk/owl/filter.c
===================================================================
--- trunk/owl/filter.c	2008-08-21 22:20:31 UTC (rev 1114)
+++ trunk/owl/filter.c	2008-08-22 16:22:37 UTC (rev 1115)
@@ -213,10 +213,8 @@
 
 char* owl_filter_print(owl_filter *f)
 {
-  GString *out = g_string_new(owl_filter_get_name(f));
+  GString *out = g_string_new("");
 
-  g_string_append(out, ": ");
-
   if (f->fgcolor!=OWL_COLOR_DEFAULT) {
     g_string_append(out, "-c ");
     if (f->fgcolor < 8) {
@@ -255,6 +253,8 @@
   buffb = owl_filter_print(b);
 
   ret = !strcmp(buffa, buffb);
+  ret = ret && !strcmp(owl_filter_get_name(a),
+                       owl_filter_get_name(b));
 
   owl_free(buffa);
   owl_free(buffb);

Modified: trunk/owl/functions.c
===================================================================
--- trunk/owl/functions.c	2008-08-21 22:20:31 UTC (rev 1114)
+++ trunk/owl/functions.c	2008-08-22 16:22:37 UTC (rev 1115)
@@ -2523,16 +2523,18 @@
 void owl_function_show_filter(char *name)
 {
   owl_filter *f;
-  char *buff;
+  char *buff, *tmp;
 
   f=owl_global_get_filter(&g, name);
   if (!f) {
     owl_function_error("There is no filter named %s", name);
     return;
   }
-  buff = owl_filter_print(f);
+  tmp = owl_filter_print(f);
+  buff = owl_sprintf("%s: %s", owl_filter_get_name(f), tmp);
   owl_function_popless_text(buff);
   owl_free(buff);
+  owl_free(tmp);
 }
 
 void owl_function_show_zpunts()


home help back first fref pref prev next nref lref last post