diff options
author | sabetts <sabetts> | 2001-04-15 21:25:10 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2001-04-15 21:25:10 +0000 |
commit | b87be52b56c7f62294c49c40a49c766b958d0809 (patch) | |
tree | 34a8eb4bae8f1ad42990457715156fe1378264f7 /src/actions.c | |
parent | 58b76fc72cd88e4a6a45b12f97810e63c75e97d6 (diff) | |
download | ratpoison-b87be52b56c7f62294c49c40a49c766b958d0809.zip |
* src/number.h (add_window_number): new prototype
* src/number.c (add_window_number): renamed from
add_to_list. Dependant code updated.
* src/messages.h (MESSAGE_WINDOW_INFORMATION): new define
* src/list.h (print_window_information): new prototype
* src/list.c (print_window_information): new function
* src/actions.h (cmd_number): new prototype
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/src/actions.c b/src/actions.c index f65c9f4..a9ed3d7 100644 --- a/src/actions.c +++ b/src/actions.c @@ -168,13 +168,13 @@ user_command user_commands[] = {"curframe", cmd_curframe, arg_VOID}, {"help", cmd_help, arg_VOID}, {"quit", cmd_quit, arg_VOID}, + {"number", cmd_number, arg_STRING}, /* the following screen commands may or may not be able to be implemented. See the screen documentation for what should be emulated with these commands */ {"stuff", cmd_unimplemented, arg_VOID}, - {"number", cmd_unimplemented, arg_VOID}, {"hardcopy", cmd_unimplemented, arg_VOID}, {"lastmsg", cmd_unimplemented, arg_VOID}, {"license", cmd_unimplemented, arg_VOID}, @@ -523,7 +523,7 @@ cmd_rename (void *data) current_window()->named = 1; /* Update the program bar. */ - update_window_names (current_window()->scr); + update_window_names (current_screen()); } free (winname); @@ -702,7 +702,7 @@ cmd_quit(void *data) /* Show the current time on the bar. Thanks to Martin Samuelsson <cosis@lysator.liu.se> for the patch. Thanks to Jonathan Walther - <djw@lineo.com> for making it pretty. */ + <krooger@debian.org> for making it pretty. */ void cmd_clock (void *data) { @@ -718,6 +718,59 @@ cmd_clock (void *data) free (msg); } +/* Assign a new number to a window ala screen's number command. Thanks + to Martin Samuelsson <cosis@lysator.liu.se> for the original + patch. */ +void +cmd_number (void *data) +{ + int old_number, new_number; + rp_window *other_win; + char *str; + + if (current_window() == NULL) return; + + if (data == NULL) + { + print_window_information (current_window()); + return; + } + else + { + str = strdup ((char *) data); + } + + if ((new_number = string_to_window_number (str)) >= 0) + { + /* Find other window with same number and give it old number. */ + other_win = find_window_number (new_number); + if (other_win != NULL) + { + old_number = current_window()->number; + other_win->number = old_number; + + /* Resort the the window in the list */ + remove_from_list (other_win); + insert_into_list (other_win, rp_mapped_window_sentinel); + } + else + { + return_window_number (current_window()->number); + } + + current_window()->number = new_number; + add_window_number (new_number); + + /* resort the the window in the list */ + remove_from_list (current_window()); + insert_into_list (current_window(), rp_mapped_window_sentinel); + + /* Update the window list. */ + update_window_names (current_screen()); + } + + free (str); +} /* Toggle the display of the program bar */ void |