ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RP] Patch to add number command. As in screen.


From: Martin Samuelsson
Subject: Re: [RP] Patch to add number command. As in screen.
Date: Sun, 28 Jan 2001 16:49:01 +0100
User-agent: Mutt/1.2.5i

Resend-mania!

On Thu, Dec 28, 2000 at 02:11:20PM +0100, Martin Samuelsson wrote:
> I wrote some additional code. It's really ugly, but it works. With this 
> applied it's possible to move a window to another number. Working exactly as 
> in screen.
> 
> Do you like it?
> -- 
> /Martin

> diff -u -r ratpoison-cvs-20001228-1029/src/actions.c 
> ratpoison-cvs-20001228-1029-with-number/src/actions.c
> --- ratpoison-cvs-20001228-1029/src/actions.c Fri Dec 15 20:52:28 2000
> +++ ratpoison-cvs-20001228-1029-with-number/src/actions.c     Thu Dec 28 
> 13:59:38 2000
> @@ -2,6 +2,7 @@
>     keystrokes */
>  
>  #include <unistd.h>
> +#include <string.h>
>  #include <sys/wait.h>
>  #include <X11/keysym.h>
>  
> @@ -126,6 +127,26 @@
>        update_window_names (rp_current_window->scr);
>      }
>  }
> +void
> +renumber_current_window (int newnumber)
> +{
> +  int oldnumber;
> +  rp_window *otherwin;
> +  
> +  if (rp_current_window == NULL) return;
> +
> +  /* Save old number if the new is occupied. */
> +  oldnumber = rp_current_window->number;
> +
> +  /* Find other window with same number and give it old number. */
> +  if ((otherwin = find_window_by_number (newnumber)) != NULL)
> +    otherwin->number = oldnumber;
> +  
> +  rp_current_window->number = newnumber;
> +
> +  /* Update the program bar. */
> +  update_window_names (rp_current_window->scr);
> +}
>  
>  
>  void
> @@ -159,6 +180,8 @@
>  execute_command (void *data)
>  {
>    char cmd[100];
> +  char errormsg[100];
> +  int number;
>  
>    if (rp_current_window)
>      {
> @@ -173,7 +196,23 @@
>  
>    PRINT_DEBUG ("user entered: %s\n", cmd);
>  
> -  spawn (cmd);
> +  /* This code is really ugly. It should be an own function, so that it 
> could be reused when parsing a config file. - cosis */
> +  if(!strncmp(cmd, "number", 6))
> +  {
> +      number = atol(cmd + 7);
> +      renumber_current_window(number);
> +      return;
> +  }
> +  if(!strncmp(cmd, "exec", 4))
> +  {
> +      spawn (cmd + 5);
> +      return;
> +  }
> +
> +  strcpy(errormsg, ": Unknown command '");
> +  strncat(errormsg, cmd, 78);
> +  strcat(errormsg, "'");
> +  display_msg_in_bar (&screens[0], errormsg);
>  }
>  
>  void


-- 
/Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]