summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-04-15 21:25:10 +0000
committersabetts <sabetts>2001-04-15 21:25:10 +0000
commitb87be52b56c7f62294c49c40a49c766b958d0809 (patch)
tree34a8eb4bae8f1ad42990457715156fe1378264f7
parent58b76fc72cd88e4a6a45b12f97810e63c75e97d6 (diff)
downloadratpoison-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
-rw-r--r--ChangeLog15
-rw-r--r--src/actions.c59
-rw-r--r--src/actions.h1
-rw-r--r--src/list.c20
-rw-r--r--src/list.h2
-rw-r--r--src/messages.h1
-rw-r--r--src/number.c6
-rw-r--r--src/number.h1
8 files changed, 99 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index ab3ede6..6eb8c67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,21 @@
2001-04-15 shawn <sabetts@diggin.lamenet.tmp>
+ * 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
+
* src/actions.c (cmd_clock): remove newline from date string.
+ (cmd_rename): passes current_screen() to update_window_names.
+ (cmd_number): new function
* src/messages.h (MESSAGE_WELCOME): new define
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
diff --git a/src/actions.h b/src/actions.h
index e0b2cb8..19b5c02 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -72,6 +72,7 @@ void cmd_banish (void *data);
void cmd_curframe (void *data);
void cmd_help (void *data);
void cmd_quit(void *data);
+void cmd_number (void *data);
/* void cmd_xterm (void *data); */
diff --git a/src/list.c b/src/list.c
index 34517b2..750221e 100644
--- a/src/list.c
+++ b/src/list.c
@@ -439,3 +439,23 @@ goto_window (rp_window *win)
set_active_window (win);
}
}
+
+void
+print_window_information (rp_window *win)
+{
+ char number[3];
+ char *str;
+
+ snprintf (number, 3, "%d", win->number);
+
+ /* There is a bit of extra memory being allocated from the
+ formatting tags in MESSAGE_WINDOW_INFORMATION, but it is not a
+ couple bytes. */
+ str = xmalloc (strlen (number) + strlen (win->name) + strlen (MESSAGE_WINDOW_INFORMATION) + 1);
+
+ sprintf (str, MESSAGE_WINDOW_INFORMATION, number, win->name);
+ message (str);
+ free (str);
+
+ return;
+}
diff --git a/src/list.h b/src/list.h
index 2ad0b47..8a97f92 100644
--- a/src/list.h
+++ b/src/list.h
@@ -50,4 +50,6 @@ void append_to_list (rp_window *win, rp_window *sentinel);
void insert_into_list (rp_window *win, rp_window *sentinel);
void remove_from_list (rp_window *win);
+void print_window_information (rp_window *win);
+
#endif /* ! _RATPOISON_LIST_H */
diff --git a/src/messages.h b/src/messages.h
index 0d8cbe6..23ffe3d 100644
--- a/src/messages.h
+++ b/src/messages.h
@@ -27,6 +27,7 @@
#define MESSAGE_NO_OTHER_WINDOW " No other window "
#define MESSAGE_NO_MANAGED_WINDOWS " No managed windows "
#define MESSAGE_UNKNOWN_COMMAND ": unknown command "
+#define MESSAGE_WINDOW_INFORMATION "This is window %s (%s)."
#define MESSAGE_PROMPT_SWITCH_TO_WINDOW " Switch to window: "
#define MESSAGE_PROMPT_NEW_WINDOW_NAME " Set window's title to: "
diff --git a/src/number.c b/src/number.c
index 0e33e21..8676d9d 100644
--- a/src/number.c
+++ b/src/number.c
@@ -69,8 +69,8 @@ find_empty_cell ()
return num_taken-1;
}
-static int
-add_to_list (int n)
+int
+add_window_number (int n)
{
if (number_is_taken (n)) return 0; /* failed. */
@@ -88,7 +88,7 @@ get_unique_window_number ()
/* look for a unique number, and add it to the list of taken
numbers. */
i = 0;
- while (!add_to_list (i)) i++;
+ while (!add_window_number (i)) i++;
return i;
}
diff --git a/src/number.h b/src/number.h
index 1a489b1..aea0945 100644
--- a/src/number.h
+++ b/src/number.h
@@ -24,6 +24,7 @@
int get_unique_window_number ();
void return_window_number (int n);
+int add_window_number (int n);
void init_numbers ();
#endif /* ! _RATPOISON_NUMBER_H */