Le 24 août 2005 à 15:16, Xavier Nicollet a écrit:
> [...]
> There are still some problems: I don't understant the UTMPOK part, same
> for the WindowChanged.
>
> If someone could help me, I guess it would make screen more
> user-friendly.
Ok, I made a new patch, which should take care of the UTMP and
multiusers stuff. It also deals with holes in the windowlist like in
this example:
Num Name Flags
0 bash
1 mutt
2 domaines
-> 3 xavier
9 python
Here, you can move the 'xavier' window up, by pressing 'P' or 'K'. The
'domaines' window will take its place. If you press 'N' or 'J', it
increments its number to 4.
The patch is attached. You can also download it from:
http://nicollet.jeru.org/screen/patch/moveWindows.patch
IMHO, it is ok for testing and inclusion. I can update the documentation
as well.
Cheers,
--
Xavier Nicollet
http://nicollet.jeru.org/
--- screen-4.0.2/process.c 2003-09-18 14:53:54.000000000 +0200
+++ screen-4.0.2.new/process.c 2005-08-27 15:16:41.569724038 +0200
@@ -393,6 +393,18 @@
char *noargs[1];
+#ifdef UTMPOK
+void
+RenewUtmp(p)
+struct win *p;
+{
+ if (p && (p->w_slot != (slot_t) -1) && (p->w_slot != (slot_t) 0 )) {
+ RemoveUtmp(p);
+ SetUtmp(p);
+ }
+}
+#endif
+
void
InitKeytab()
{
@@ -2774,18 +2786,24 @@
#endif
#ifdef UTMPOK
/* exchange the utmp-slots for these windows */
- if ((fore->w_slot != (slot_t) -1) && (fore->w_slot != (slot_t) 0))
+ RenewUtmp(fore);
+ RenewUtmp(p);
+
+/* if ((fore->w_slot != (slot_t) -1) && (fore->w_slot != (slot_t) 0))
{
RemoveUtmp(fore);
SetUtmp(fore);
- }
+ }*/
if (p && (p->w_slot != (slot_t) -1) && (p->w_slot != (slot_t) 0))
{
+
/* XXX: first display wins? */
display = fore->w_layer.l_cvlist ?
fore->w_layer.l_cvlist->c_display : 0;
- RemoveUtmp(p);
+ }
+/* RemoveUtmp(p);
SetUtmp(p);
}
+ */
#endif
WindowChanged(fore, 'n');
--- screen-4.0.2/screen.h 2003-08-22 14:28:43.000000000 +0200
+++ screen-4.0.2.new/screen.h 2005-08-27 15:13:12.578560397 +0200
@@ -293,3 +293,8 @@
*/
#define WLIST_NUM 0
#define WLIST_MRU 1
+
+#ifdef UTMPOK
+/* don't know exactly what it does, but... */
+void RenewUtmp(struct win *p);
+#endif
--- screen-4.0.2/help.c 2003-09-08 16:25:33.000000000 +0200
+++ screen-4.0.2.new/help.c 2005-08-27 15:08:23.162263373 +0200
@@ -37,6 +37,7 @@
extern struct mchar mchar_blank, mchar_so;
extern unsigned char *blank;
extern struct win *wtab[];
+extern int maxwin;
static void PadStr __P((char *, int, int, int));
@@ -895,6 +896,70 @@
return 0;
}
+/* Renumber current window: move its position by offset */
+/* greatly inspired by RC_NUMBER part in process.c */
+static void
+WRenumber(wlistdata, offset)
+struct wlistdata *wlistdata;
+int offset;
+{
+ int pos = wlistdata->pos;
+ int new = pos+offset;
+ int nextpos = WListNext(wlistdata, pos, offset);
+ struct win *firstwin;
+
+ /* my way of asserting
+ XXX find a real way to assert in screen */
+ if ( wtab[pos] == NULL ) {
+ LMsg(0, "WTAB[pos] == NULL BIG PROBLEM !");
+ return;
+ }
+ /* Exit if we are not in the limits */
+ if (new < 0 || new >= maxwin ) { return; }
+ firstwin = wtab[pos];
+
+ wtab[pos] = wtab[new];
+ wtab[new] = firstwin;
+ wtab[new]->w_number = new;
+ if (wtab[pos]) {
+ wtab[pos]->w_number = pos;
+ }
+
+#ifdef MULTIUSER
+ /* exchange the acls for these windows. */
+ AclWinSwap(pos, new);
+#endif
+#ifdef UTMPOK
+ /* TODO put this in a function and in process.c */
+/* struct win *p = wtab[pos]; */
+ // LMsg(0, "UTMPOK !");
+ RenewUtmp(wtab[pos]);
+ RenewUtmp(wtab[new]);
+/* if (p && (p->w_slot != (slot_t) -1) && (p->w_slot != (slot_t) 0
)) {
+ RemoveUtmp(p);
+ SetUtmp(p);
+ }
+ p = wtab[new];
+ if (p && (p->w_slot != (slot_t) -1) && (p->w_slot != (slot_t) 0
)) {
+ RemoveUtmp(p);
+ SetUtmp(p);
+ }
+ */
+#endif
+ /* refresh the screen */
+ if (new == nextpos ) {
+ WListMove(offset, -1);
+ }
+ else {
+ wlistdata->pos = new;
+ if (wlistdata != (struct wlistdata *)flayer->l_data) {
+ LMsg(0, "wlistdata != flayer->l_data");
+ }
+ /* XXX ok, may find a way not to redraw all the screen... */
+ wlistpage();
+ }
+}
+
static void
WListProcess(ppbuf, plen)
char **ppbuf;
@@ -955,6 +1020,18 @@
case 0205: /* end */
WListMove(MAXWIN, -1);
break;
+
+ /* change the order of the windows */
+ /* todo: find shift up / shift down keycodes */
+ case 'N':
+ case 'J':
+ WRenumber(wlistdata, 1);
+ break;
+ case 'P':
+ case 'K':
+ WRenumber(wlistdata, -1);
+ break;
+
case '\r':
case '\n':
case ' ':
_______________________________________________
screen-users mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/screen-users