Subject: Addition of $n & $c [name/class] for Functions

From: Neil Bird <[email-masked]>
Date: Fri, 23 Jul 1999 11:21:56 +0100

Here's a patch (on top of snap-19990716) for fvwm/functions.c that
incorporates two new 'variables' for Functions (alongside, $w, $d, etc.).

  $n - name of $w
  $c - class name of $w

  This allows, e.g.,

Mouse 0 3       A       Close-All

AddToFunc Close-All  "I" All [$c] Close

  ... to close all windows of the same class as the selected one (e.g, all
Netscape). I personally did it to be able to iconise window sets.

  If you don't like it, bin it. If you do like it, you might conider
putting it in for me! I don't (and likely never will) have CVS access
through my firewall.

-- 
========================- http://www.rdel.co.uk/ -======================
 Neil Bird                   |   This is who we are     The time is near
                             |
 mailto:[email-masked] |        There are 162 days remaining

--- fvwm/functions.c.orig	Sat Jul 10 12:30:19 1999
+++ fvwm/functions.c	Fri Jul 23 10:41:36 1999
@@ -283,6 +283,8 @@
   {
     addto = 1;
   }
+
+  /* Calculate best guess at length of expanded string */
   i=0;
   while(i<l)
     {
@@ -314,11 +316,24 @@
 	      l2 += 16;
 	      i++;
 	      break;
+	    case 'c':
+	      if (tmp_win && tmp_win->class.res_name && tmp_win->class.res_name[0])
+		{
+		  l2 += strlen(tmp_win->class.res_name) + 2;
+		}
+	      break;
+	    case 'n':
+	      if (tmp_win && tmp_win->name && tmp_win->name[0])
+		{
+		  l2 += strlen(tmp_win->name) + 2;
+		}
+	      break;
 	    }
 	}
       i++;
     }
 
+  /* Actually create expanded string */
   i=0;
   out = safemalloc(l2+1);
   j=0;
@@ -341,20 +356,20 @@
 	      n = input[i+1] - '0';
 	      if(arguments[n] != NULL)
 		{
-		  for(k=0;k<strlen(arguments[n]);k++)
+		  for(k=0;arguments[n][k];k++)
 		    out[j++] = arguments[n][k];
 		  i++;
 		}
-            else if (addto == 1)
-        {
-		out[j++] = '$';
-        }
-          else
-        {
-          i++;
-          if (isspace(input[i+1]))
-            i++; /*eliminates extra white space*/
-        }
+	      else if (addto == 1)
+		{
+		  out[j++] = '$';
+		}
+	      else
+		{
+		  i++;
+		  if (isspace(input[i+1]))
+		    i++; /*eliminates extra white space*/
+		}
 	      break;
 	    case 'w':
 	      if(tmp_win)
@@ -377,6 +392,34 @@
 	    case 'y':
 	      sprintf(&out[j], "%d", Scr.Vy);
 	      i++;
+	      break;
+	    case 'c':
+	      if (tmp_win && tmp_win->class.res_name && tmp_win->class.res_name[0])
+		{
+		  out[j++] = '\'';
+		  for(k=0;tmp_win->class.res_name[k];k++)
+		    out[j++] = tmp_win->class.res_name[k];
+		  out[j++] = '\'';
+		  i++;
+		}
+	      else
+		{
+		  out[j++] = '$';
+		}
+	      break;
+	    case 'n':
+	      if (tmp_win && tmp_win->name && tmp_win->name[0])
+		{
+		  out[j++] = '\'';
+		  for(k=0;tmp_win->name[k];k++)
+		    out[j++] = tmp_win->name[k];
+		  out[j++] = '\'';
+		  i++;
+		}
+	      else
+		{
+		  out[j++] = '$';
+		}
 	      break;
 	    case '$':
 	      out[j++] = '$';

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 23 Jul 1999 16:21:11 +0300 (IDT)

> incorporates two new 'variables' for Functions (alongside, $w, $d, etc.).

I have applied the patch, but replaced your $c with $r and added $c:

$c - resource class
$r - resource name

See also a man page.

Regards,
Mikhael.

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]