summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions.c29
-rw-r--r--src/actions.h153
-rw-r--r--src/bar.c246
-rw-r--r--src/bar.h5
-rw-r--r--src/data.h3
-rw-r--r--src/input.c6
-rw-r--r--src/main.c1
-rw-r--r--src/window.c9
8 files changed, 363 insertions, 89 deletions
diff --git a/src/actions.c b/src/actions.c
index 5aa6cd3..456abc1 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -95,7 +95,7 @@ static user_command user_commands[] =
{"fselect", cmd_fselect, arg_VOID},
{"fdump", cmd_fdump, arg_STRING},
{"frestore", cmd_frestore, arg_STRING},
- /*@end (tag required for genrpbindings) */
+ {"verbexec", cmd_verbexec, arg_STRING},
/* Commands to set default behavior. */
{"defbargravity", cmd_defbargravity, arg_STRING},
@@ -115,6 +115,8 @@ static user_command user_commands[] =
{"defbgcolor", cmd_defbgcolor, arg_STRING},
{"defbarpadding", cmd_defbarpadding, arg_STRING},
{"defresizeunit", cmd_defresizeunit, arg_STRING},
+ {"defwrapwinlist", cmd_defwrapwinlist, arg_STRING},
+ /*@end (tag required for genrpbindings) */
/* Commands to help debug ratpoison. */
#ifdef DEBUG
@@ -3105,3 +3107,28 @@ cmd_frestore (int interactively, void *data)
PRINT_DEBUG (("Done.\n"));
return NULL;
}
+
+char *
+cmd_verbexec (int interactive, void *data)
+{
+ char msg[100]="Running ";
+ strncat(msg, data, 100-strlen(msg));
+
+ if(data) cmd_echo(interactive, msg);
+ return cmd_exec(interactive, data);
+}
+
+char *
+cmd_defwrapwinlist (int interactive, void *data)
+{
+ if (data == NULL && !interactive)
+ return xsprintf ("%d", defaults.wrap_window_list);
+
+ if (data == NULL
+ || sscanf (data, "%d", &defaults.wrap_window_list) < 1)
+ {
+ message (" defwrapwinlist: One argument required ");
+ }
+
+ return NULL;
+}
diff --git a/src/actions.h b/src/actions.h
index 84a1d97..cc22f84 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -40,85 +40,88 @@ user_command
int spawn(void *data);
char * command (int interactive, char *data);
-char * cmd_newwm(int interactive, void *which);
-char * cmd_meta (int interactive, void *data);
-char * cmd_abort (int interactive, void *data);
-char * cmd_exec (int interactive, void *data);
-char * cmd_colon (int interactive, void *data);
-char * cmd_kill (int interactive, void *data);
-char * cmd_delete (int interactive, void *data);
-char * cmd_rename (int interactive, void *data);
-char * cmd_select (int interactive, void *data);
-char * cmd_last (int interactive, void *data);
-char * cmd_next (int interactive, void *data);
-char * cmd_next_frame (int interactive, void *data);
-char * cmd_prev (int interactive, void *data);
-char * cmd_prev_frame (int interactive, void *data);
-char * cmd_windows (int interactive, void *data);
-char * cmd_other (int interactive, void *data);
-char * cmd_time (int interactive, void *data);
-char * cmd_version (int interactive, void *data);
-char * cmd_unimplemented (int interactive, void *data);
-char * cmd_bind (int interactive, void* data);
-char * cmd_source (int interactive, void* data);
-char * cmd_redisplay (int interactive, void *data);
-char * cmd_escape (int interactive, void *data);
-char * cmd_echo (int interactive, void *data);
-char * cmd_h_split (int interactive, void *data);
-char * cmd_v_split (int interactive, void *data);
-char * cmd_only (int interactive, void *data);
-char * cmd_remove (int interactive, void *data);
-char * cmd_shrink (int interactive, void *data);
-char * cmd_resize (int interactive, void *data);
-char * cmd_banish (int interactive, void *data);
-char * cmd_curframe (int interactive, void *data);
-char * cmd_help (int interactive, void *data);
-char * cmd_quit(int interactive, void *data);
-char * cmd_number (int interactive, void *data);
-char * cmd_rudeness (int interactive, void *data);
-char * cmd_unbind (int interactive, void *data);
-char * cmd_gravity (int interactive, void *data);
-char * cmd_defwingravity (int interactive, void *data);
-char * cmd_deftransgravity (int interactive, void *data);
-char * cmd_defmaxsizegravity (int interactive, void *data);
-char * cmd_msgwait (int interactive, void *data);
-char * cmd_defbargravity (int interactive, void *data);
-char * cmd_deffont (int interactive, void *data);
-char * cmd_defpadding (int interactive, void *data);
-char * cmd_defborder (int interactive, void *data);
-char * cmd_definputwidth (int interactive, void *data);
-char * cmd_defwaitcursor (int interactive, void *data);
-char * cmd_defwinfmt (int interactive, void *data);
-char * cmd_defwinname (int interactive, void *data);
-char * cmd_deffgcolor (int interactive, void *data);
-char * cmd_defbgcolor (int interactive, void *data);
-char * cmd_defresizeunit (int interactive, void *data);
-char * cmd_setenv (int interactive, void *data);
-char * cmd_getenv (int interactive, void *data);
-char * cmd_chdir (int interactive, void *data);
-char * cmd_unsetenv (int interactive, void *data);
-char * cmd_info (int interactive, void *data);
-char * cmd_lastmsg (int interactive, void *data);
-char * cmd_focusup (int interactive, void *data);
-char * cmd_focusdown (int interactive, void *data);
-char * cmd_focusleft (int interactive, void *data);
-char * cmd_focusright (int interactive, void *data);
-char * cmd_restart (int interactive, void *data);
-char * cmd_startup_message (int interactive, void *data);
-char * cmd_focuslast (int interactive, void *data);
-char * cmd_link (int interactive, void *data);
-char * cmd_defbarpadding (int interactive, void *data);
-char * cmd_license (int interactive, void *data);
-char * cmd_alias (int interactive, void *data);
+char *cmd_abort (int interactive, void *data);
+char *cmd_alias (int interactive, void *data);
+char *cmd_banish (int interactive, void *data);
+char *cmd_bind (int interactive, void* data);
+char *cmd_chdir (int interactive, void *data);
+char *cmd_colon (int interactive, void *data);
+char *cmd_curframe (int interactive, void *data);
char *cmd_defbarborder (int interactive, void *data);
-char *cmd_prevscreen (int interactive, void *data);
+char *cmd_defbargravity (int interactive, void *data);
+char *cmd_defbarpadding (int interactive, void *data);
+char *cmd_defbgcolor (int interactive, void *data);
+char *cmd_defborder (int interactive, void *data);
+char *cmd_deffgcolor (int interactive, void *data);
+char *cmd_deffont (int interactive, void *data);
+char *cmd_definputwidth (int interactive, void *data);
+char *cmd_defmaxsizegravity (int interactive, void *data);
+char *cmd_defpadding (int interactive, void *data);
+char *cmd_defresizeunit (int interactive, void *data);
+char *cmd_deftransgravity (int interactive, void *data);
+char *cmd_defwaitcursor (int interactive, void *data);
+char *cmd_defwinfmt (int interactive, void *data);
+char *cmd_defwingravity (int interactive, void *data);
+char *cmd_defwinname (int interactive, void *data);
+char *cmd_defwrapwinlist (int interactive, void *data);
+char *cmd_delete (int interactive, void *data);
+char *cmd_echo (int interactive, void *data);
+char *cmd_escape (int interactive, void *data);
+char *cmd_exec (int interactive, void *data);
+char *cmd_fdump (int interactively, void *data);
+char *cmd_focusdown (int interactive, void *data);
+char *cmd_focuslast (int interactive, void *data);
+char *cmd_focusleft (int interactive, void *data);
+char *cmd_focusright (int interactive, void *data);
+char *cmd_focusup (int interactive, void *data);
+char *cmd_frestore (int interactively, void *data);
+char *cmd_fselect (int interactive, void *data);
+char *cmd_getenv (int interactive, void *data);
+char *cmd_gravity (int interactive, void *data);
+char *cmd_h_split (int interactive, void *data);
+char *cmd_help (int interactive, void *data);
+char *cmd_info (int interactive, void *data);
+char *cmd_kill (int interactive, void *data);
+char *cmd_last (int interactive, void *data);
+char *cmd_lastmsg (int interactive, void *data);
+char *cmd_license (int interactive, void *data);
+char *cmd_link (int interactive, void *data);
+char *cmd_meta (int interactive, void *data);
+char *cmd_msgwait (int interactive, void *data);
+char *cmd_newwm(int interactive, void *which);
+char *cmd_next (int interactive, void *data);
+char *cmd_next_frame (int interactive, void *data);
char *cmd_nextscreen (int interactive, void *data);
+char *cmd_number (int interactive, void *data);
+char *cmd_only (int interactive, void *data);
+char *cmd_other (int interactive, void *data);
+char *cmd_prev (int interactive, void *data);
+char *cmd_prev_frame (int interactive, void *data);
+char *cmd_prevscreen (int interactive, void *data);
+char *cmd_quit(int interactive, void *data);
+char *cmd_redisplay (int interactive, void *data);
+char *cmd_remove (int interactive, void *data);
+char *cmd_rename (int interactive, void *data);
+char *cmd_resize (int interactive, void *data);
+char *cmd_restart (int interactive, void *data);
+char *cmd_rudeness (int interactive, void *data);
+char *cmd_select (int interactive, void *data);
+char *cmd_setenv (int interactive, void *data);
+char *cmd_shrink (int interactive, void *data);
+char *cmd_source (int interactive, void* data);
+char *cmd_startup_message (int interactive, void *data);
+char *cmd_time (int interactive, void *data);
+char *cmd_tmpwm (int interactive, void *data);
+char *cmd_togglewrapwinlist ();
char *cmd_unalias (int interactive, void *data);
+char *cmd_unbind (int interactive, void *data);
+char *cmd_unimplemented (int interactive, void *data);
+char *cmd_unsetenv (int interactive, void *data);
+char *cmd_v_split (int interactive, void *data);
+char *cmd_verbexec (int interactive, void *data);
+char *cmd_version (int interactive, void *data);
char *cmd_warp(int interactive, void *data);
-char *cmd_tmpwm (int interactive, void *data);
-char *cmd_fselect (int interactive, void *data);
-char *cmd_fdump (int interactively, void *data);
-char *cmd_frestore (int interactively, void *data);
+char *cmd_windows (int interactive, void *data);
void initialize_default_keybindings (void);
void free_keybindings ();
diff --git a/src/bar.c b/src/bar.c
index d363305..cf76fef 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -107,7 +107,7 @@ bar_x (screen_info *s, int width)
}
int
-bar_y (screen_info *s)
+bar_y (screen_info *s, int height)
{
int y = 0;
@@ -121,13 +121,13 @@ bar_y (screen_info *s)
case EastGravity:
case CenterGravity:
case WestGravity:
- y = (s->root_attr.height - (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2)
+ y = (s->root_attr.height - height
- defaults.bar_border_width * 2) / 2;
break;
case SouthEastGravity:
case SouthGravity:
case SouthWestGravity:
- y = (s->root_attr.height - (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2)
+ y = (s->root_attr.height - height
- defaults.bar_border_width * 2);
break;
}
@@ -146,9 +146,19 @@ update_window_names (screen_info *s)
bar_buffer = sbuf_new (0);
- get_window_list (defaults.window_fmt, NULL, bar_buffer, &mark_start, &mark_end);
+ if(!defaults.wrap_window_list)
+ {
+ get_window_list (defaults.window_fmt, NULL, bar_buffer, &mark_start, &mark_end);
+ marked_message (sbuf_get (bar_buffer), mark_start, mark_end);
+ }
+ else
+ {
+ get_window_list (defaults.window_fmt, "\n", bar_buffer, &mark_start, &mark_end);
+ marked_wrapped_message (sbuf_get (bar_buffer), mark_start, mark_end);
+ }
- marked_message (sbuf_get (bar_buffer), mark_start, mark_end);
+
+/* marked_message (sbuf_get (bar_buffer), mark_start, mark_end); */
sbuf_free (bar_buffer);
}
@@ -166,6 +176,230 @@ marked_message_printf (int mark_start, int mark_end, char *fmt, ...)
free (buffer);
}
+int
+count_lines (char* msg, int len)
+{
+ int ret=1;
+ int i=0;
+ for(; i<len; ++i) {
+ if(msg[i]=='\n') ret++;
+ }
+ PRINT_DEBUG(("count_lines: %d\n", ret));
+ return ret;
+}
+
+
+int
+max_line_length (char* msg)
+{
+ int ret=0;
+ int i=0;
+ int j=0;
+ int len=strlen(msg);
+ int current_width=0;
+ char tmp_buf[100];
+
+ for(; i<=len; ++j, ++i) {
+ if(msg[i]=='\n' || msg[i]=='\0') {
+ tmp_buf[j]='\0';
+ current_width = XTextWidth (defaults.font, tmp_buf, strlen (tmp_buf));
+ if(current_width>ret) ret=current_width;
+ j=0;
+ }
+ else tmp_buf[j]=msg[i];
+ }
+ PRINT_DEBUG(("max_line_length: %d\n", ret));
+ return ret;
+}
+
+int
+pos_in_line (char* msg, int pos)
+{
+ int i=pos - 1;
+ int ret=0;
+ if(i>=0) {
+ for(; i<=pos && i>=0; ++ret, --i) if(msg[i]=='\n') break;
+ }
+ PRINT_DEBUG (("pos_in_line(\"%s\", %d) = %d\n", msg, pos, ret));
+ return ret;
+}
+
+int
+line_beginning (char* msg, int pos)
+{
+ int ret=0;
+ int i=pos-1;
+ if(i) {
+ for(; i>=0; --i) {
+ /* PRINT_DEBUG("pos = %d, i = %d, msg[i] = '%c'\n", pos, i, msg[i]); */
+ if (msg[i]=='\n') {
+ ret=i+1;
+ break;
+ }
+ }
+ }
+ PRINT_DEBUG (("line_beginning(\"%s\", %d) = %d\n", msg, pos, ret));
+ return ret;
+
+}
+
+void
+marked_wrapped_message (char *msg, int mark_start, int mark_end)
+{
+ XGCValues lgv;
+ GC lgc;
+ unsigned long mask;
+ screen_info *s = current_screen ();
+ int i=0;
+ int j=0;
+ int num_lines;
+ int line_no=0;
+ char tmp_buf[100];
+
+
+
+ int width = defaults.bar_x_padding * 2 + max_line_length(msg);
+ /* XTextWidth (defaults.font, msg, strlen (msg)); */
+ int line_height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2);
+ int height;
+
+ PRINT_DEBUG (("msg = %s\n", msg));
+ PRINT_DEBUG (("mark_start = %d, mark_end = %d\n", mark_start, mark_end));
+
+
+ num_lines = count_lines(msg, strlen(msg));
+ height = line_height * num_lines;
+
+ /* Map the bar if needed */
+ if (!s->bar_is_raised)
+ {
+ s->bar_is_raised = BAR_IS_MESSAGE;
+ XMapRaised (dpy, s->bar_window);
+ }
+
+ /* Reset the alarm to auto-hide the bar in BAR_TIMEOUT seconds. */
+ alarm (defaults.bar_timeout);
+ alarm_signalled = 0;
+
+ XMoveResizeWindow (dpy, s->bar_window,
+ bar_x (s, width), bar_y (s, height),
+ width,
+ height);
+
+ XRaiseWindow (dpy, s->bar_window);
+ XClearWindow (dpy, s->bar_window);
+ XSync (dpy, False);
+
+ /* if(!defaults.wrap_window_list){
+ XDrawString (dpy, s->bar_window, s->normal_gc,
+ defaults.bar_x_padding,
+ defaults.bar_y_padding + defaults.font->max_bounds.ascent,
+ msg, strlen (msg));
+ } else { */
+ for(i=0; i<=strlen(msg); ++i) {
+ if (msg[i]!='\0' && msg[i]!='\n') {
+ tmp_buf[j]=msg[i];
+ j++;
+ }
+ else {
+ tmp_buf[j]='\0';
+ XDrawString (dpy, s->bar_window, s->normal_gc,
+ defaults.bar_x_padding,
+ defaults.bar_y_padding + defaults.font->max_bounds.ascent
+ + line_no * line_height,
+ tmp_buf, strlen(tmp_buf));
+ j=0;
+ line_no++;
+ }
+ }
+
+
+
+ XSync (dpy, False);
+
+ /* Crop to boundary conditions. */
+ if (mark_start < 0)
+ mark_start = 0;
+
+ if (mark_end < 0)
+ mark_end = 0;
+
+ if (mark_start > strlen (msg))
+ mark_start = strlen (msg);
+
+ if (mark_end > strlen (msg))
+ mark_end = strlen (msg);
+
+ if (mark_start > mark_end+mark_start)
+ {
+ int tmp;
+ tmp = mark_start;
+ mark_start = mark_end;
+ mark_end = tmp;
+ }
+
+ /* xor the string representing the current window */
+ if (mark_end)
+ {
+ int start;
+ int end;
+ int width;
+ int start_line, end_line;
+ int start_pos_in_line, end_pos_in_line;
+ int start_line_beginning, end_line_beginning;
+
+ start_line=count_lines(msg, mark_start);
+ end_line=count_lines(msg, mark_end+mark_start-1);
+
+ start_pos_in_line = pos_in_line(msg, mark_start);
+ end_pos_in_line = pos_in_line(msg, mark_end+mark_start-1);
+
+ start_line_beginning = line_beginning(msg, mark_start);
+ end_line_beginning = line_beginning(msg, mark_end+mark_start-1);
+
+ PRINT_DEBUG (("start_line = %d, end_line = %d\n", start_line, end_line));
+
+ if (mark_start == 0 || start_pos_in_line == 0)
+ start = 0;
+ else
+ start = XTextWidth (defaults.font,
+ &msg[start_line_beginning],
+ start_pos_in_line) + defaults.bar_x_padding;
+
+
+ end = XTextWidth (defaults.font, &msg[end_line_beginning],
+ end_pos_in_line + (msg[end_line_beginning+end_pos_in_line+1] == '\0'?1:0) )
+ + defaults.bar_x_padding * 2;
+
+ if (mark_end != strlen (msg)) end -= defaults.bar_x_padding;
+
+ width = end - start;
+
+ PRINT_DEBUG (("start = %d, end = %d, width = %d\n", start, end, width));
+
+ lgv.foreground = current_screen()->fg_color;
+ lgv.function = GXxor;
+ mask = GCForeground | GCFunction;
+ lgc = XCreateGC(dpy, s->root, mask, &lgv);
+
+ XFillRectangle (dpy, s->bar_window, lgc, start, (start_line-1)*line_height, width, (end_line-start_line+1)*line_height);
+
+ lgv.foreground = s->bg_color;
+ lgc = XCreateGC(dpy, s->root, mask, &lgv);
+
+ XFillRectangle (dpy, s->bar_window, lgc, start, (start_line-1)*line_height, width, (end_line-start_line+1)*line_height);
+ }
+
+ /* Keep a record of the message. */
+ if (last_msg)
+ free (last_msg);
+ last_msg = xstrdup (msg);
+ last_mark_start = mark_start;
+ last_mark_end = mark_end;
+}
+
+
+
void
marked_message (char *msg, int mark_start, int mark_end)
{
@@ -191,7 +425,7 @@ marked_message (char *msg, int mark_start, int mark_end)
alarm_signalled = 0;
XMoveResizeWindow (dpy, s->bar_window,
- bar_x (s, width), bar_y (s),
+ bar_x (s, width), bar_y (s, width),
width,
height);
diff --git a/src/bar.h b/src/bar.h
index 5ec1262..23da5a7 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -25,11 +25,12 @@
void update_window_names (screen_info *s);
int show_bar (screen_info *s);
int hide_bar (screen_info *s);
-int bar_y (screen_info *s);
+int bar_y (screen_info *s, int height);
int bar_x (screen_info *s, int width);
-#define message(msg) marked_message (msg, 0, 0)
+#define message(msg) marked_message ((msg), 0, 0)
void marked_message (char *msg, int hl_start, int hl_end);
+void marked_wrapped_message (char *msg, int hl_start, int hl_end);
void marked_message_printf (int mark_start, int mark_end, char *fmt, ...);
void show_last_message ();
void free_bar ();
diff --git a/src/data.h b/src/data.h
index c7bba0f..6fea19a 100644
--- a/src/data.h
+++ b/src/data.h
@@ -175,6 +175,9 @@ struct rp_defaults
int startup_message;
+ /* A toggle for wrapping the window list. */
+ int wrap_window_list;
+
/* Pointer warping toggle. */
int warp;
};
diff --git a/src/input.c b/src/input.c
index a5d5461..0d788ae 100644
--- a/src/input.c
+++ b/src/input.c
@@ -293,9 +293,10 @@ update_input_window (screen_info *s, char *prompt, char *input, int input_len)
{
int prompt_width = XTextWidth (defaults.font, prompt, strlen (prompt));
int input_width = XTextWidth (defaults.font, input, input_len);
- int width;
+ int width, height;
width = defaults.bar_x_padding * 2 + prompt_width + input_width;
+ height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2);
if (width < defaults.input_window_size + prompt_width)
{
@@ -303,8 +304,7 @@ update_input_window (screen_info *s, char *prompt, char *input, int input_len)
}
XMoveResizeWindow (dpy, s->input_window,
- bar_x (s, width), bar_y (s), width,
- (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2));
+ bar_x (s, width), bar_y (s, height), width, height);
XClearWindow (dpy, s->input_window);
XSync (dpy, False);
diff --git a/src/main.c b/src/main.c
index b34cd6e..bf47559 100644
--- a/src/main.c
+++ b/src/main.c
@@ -482,6 +482,7 @@ init_defaults ()
defaults.win_name = 0;
defaults.startup_message = 1;
defaults.warp = 1;
+ defaults.wrap_window_list = 0;
}
int
diff --git a/src/window.c b/src/window.c
index 37eec0c..0153704 100644
--- a/src/window.c
+++ b/src/window.c
@@ -665,8 +665,13 @@ get_window_list (char *fmt, char *delim, struct sbuf *buffer,
if (delim && w->node.next != &rp_mapped_window)
sbuf_concat (buffer, delim);
- if (w == current_window())
- *mark_end = strlen (sbuf_get (buffer));
+ if (w == current_window()) {
+ if(!defaults.wrap_window_list){
+ *mark_end = strlen (sbuf_get (buffer));
+ } else {
+ *mark_end = strlen (sbuf_get(buffer)) - *mark_start;
+ }
+ }
}
if (!strcmp (sbuf_get (buffer), ""))