[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] Slightly smarter split...
From: |
Mike Meyer |
Subject: |
[RP] Slightly smarter split... |
Date: |
Fri Nov 16 07:16:03 2001 |
Here's a patch that lets *split take an argument. It *should* be
independent of the previous patch for numbered frames et. al.
When called interactively without an argument, the split commands *do
not* ask for one - they provide the old behavior. I did this on
purpose, so that nobody who applies the patch will get surprised by
doing a split and being asked for a value that they don't know
anything about.
The behavior I finally settled on is:
"*split part":
part > 0 -> create new frame by taking part pixels from current frame.
part < 0 -> create new frame by taking one part'th from current frame
part missing or = 0 -> you get the old behavior, i.e. "*split -2"
Now I can create some *really* nasty problems to hand to "remove" [weg].
A note on the documentation: While I don't have problems writing
documentation, I don't like writing it for code that nobody else
uses. I'll be more than happy to provide it as soon as I know the
relevant code has been merged into the cvs repository.
<mike
--
Mike Meyer <address@hidden> http://www.mired.org/home/mwm/
Q: How do you make the gods laugh? A: Tell them your plans.
--- actions.c~ Thu Nov 8 05:16:00 2001
+++ actions.c Fri Nov 16 08:15:55 2001
@@ -51,7 +51,7 @@
{"focusprev", cmd_prev_frame, arg_VOID},
{"meta", cmd_meta, arg_STRING},
{"help", cmd_help, arg_VOID},
- {"hsplit", cmd_h_split, arg_VOID},
+ {"hsplit", cmd_h_split, arg_STRING},
{"kill", cmd_kill, arg_VOID},
{"redisplay", cmd_redisplay, arg_VOID},
{"newwm", cmd_newwm, arg_STRING},
@@ -71,12 +71,12 @@
{"select", cmd_select, arg_STRING},
{"selectframe", cmd_selectframe,arg_STRING},
{"source", cmd_source, arg_STRING},
- {"split", cmd_h_split, arg_VOID},
+ {"split", cmd_h_split, arg_STRING},
{"title", cmd_rename, arg_STRING},
{"titleframe", cmd_renameframe,arg_STRING},
{"unbind", cmd_unbind, arg_STRING},
{"version", cmd_version, arg_VOID},
- {"vsplit", cmd_v_split, arg_VOID},
+ {"vsplit", cmd_v_split, arg_STRING},
{"windows", cmd_windows, arg_VOID},
{"frames", cmd_frames, arg_VOID},
{"setenv", cmd_setenv, arg_STRING},
@@ -1358,14 +1358,24 @@
char *
cmd_h_split (int interactive, void *data)
{
- h_split_frame (current_frame());
+ int part;
+
+ if (data == NULL || (part = atoi((char *) data)) == 0)
+ part = -2;
+
+ h_split_frame (current_frame(), part);
return NULL;
}
char *
cmd_v_split (int interactive, void *data)
{
- v_split_frame (current_frame());
+ int part;
+
+ if (data == NULL || (part = atoi((char *) data)) == 0)
+ part = -2;
+
+ v_split_frame (current_frame(), part);
return NULL;
}
--- split.c~ Thu Nov 8 04:35:06 2001
+++ split.c Fri Nov 16 08:15:44 2001
@@ -220,10 +220,11 @@
return most_recent;
}
-/* Splits the frame in 2. if way is 0 then split vertically otherwise
+/* Splits the frame in 2. part is how big a part to split off, way is
+ the direction to split: if 0 then split vertically otherwise
split it horizontally. */
static void
-split_frame (rp_window_frame *frame, int way)
+split_frame (rp_window_frame *frame, int part, int way)
{
rp_window *win;
rp_window_frame *new_frame;
@@ -245,21 +246,25 @@
if (way)
{
+ if (part < 0) part = -frame->height / part;
+
new_frame->x = frame->x;
- new_frame->y = frame->y + frame->height / 2;
+ new_frame->y = frame->y + frame->height - part;
new_frame->width = frame->width;
- new_frame->height = frame->height / 2 + frame->height % 2;
+ new_frame->height = part;
- frame->height /= 2;
+ frame->height -= part;
}
else
{
- new_frame->x = frame->x + frame->width / 2;
+ if (part < 0) part = -frame->width / part;
+
+ new_frame->x = frame->x + frame->width - part;
new_frame->y = frame->y;
- new_frame->width = frame->width / 2 + frame->width % 2;
+ new_frame->width = part;
new_frame->height = frame->height;
- frame->width /= 2;
+ frame->width -= part;
}
win = find_window_for_frame (new_frame, current_window());
@@ -292,16 +297,16 @@
/* Splits the window vertically in 2. */
void
-v_split_frame (rp_window_frame *frame)
+v_split_frame (rp_window_frame *frame, int part)
{
- split_frame (frame, 0);
+ split_frame (frame, part, 0);
}
/* Splits the window horizontally in 2. */
void
-h_split_frame (rp_window_frame *frame)
+h_split_frame (rp_window_frame *frame, int part)
{
- split_frame (frame, 1);
+ split_frame (frame, part, 1);
}
void
--- actions.h~ Thu Nov 8 02:48:52 2001
+++ actions.h Thu Nov 8 02:52:09 2001
@@ -71,6 +71,8 @@
char * cmd_next_frame (int interactive, void *data);
char * cmd_prev (int interactive, void *data);
char * cmd_place (int interactive, void *data);
+char * cmd_push (int interactive, void *data);
+char * cmd_pull (int interactive, void *data);
char * cmd_prev_frame (int interactive, void *data);
char * cmd_windows (int interactive, void *data);
char * cmd_frames (int interactive, void *data);
--- split.h~ Thu Nov 8 04:35:02 2001
+++ split.h Fri Nov 16 07:09:43 2001
@@ -24,8 +24,8 @@
rp_window *set_frames_window (rp_window_frame *frame, rp_window *win);
void maximize_all_windows_in_frame (rp_window_frame *frame);
-void h_split_frame (rp_window_frame *frame);
-void v_split_frame (rp_window_frame *frame);
+void h_split_frame (rp_window_frame *frame, int part);
+void v_split_frame (rp_window_frame *frame, int part);
void remove_all_splits ();
void remove_frame (rp_window_frame *frame);
rp_window *find_window_for_frame (rp_window_frame *frame, rp_window *old);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [RP] Slightly smarter split...,
Mike Meyer <=