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 +#include #include #include @@ -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