From 9763857d8857a14f2a20c05e5ed552ca47bba3d8 Mon Sep 17 00:00:00 2001 From: Peter Teichman Date: Mon, 9 Nov 2009 12:35:00 -0500 Subject: Support a PID variable during screenrc evaluation. This evaluates to the current SCREEN process id. --- src/process.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index fa3d06c..1875ad8 100644 --- a/src/process.c +++ b/src/process.c @@ -4596,6 +4596,8 @@ int bufl, *argl; sprintf(xbuf, "%d", display ? D_width : -1); else if (!strcmp(ps, "LINES")) sprintf(xbuf, "%d", display ? D_height : -1); + else if (!strcmp(ps, "PID")) + sprintf(xbuf, "%d", getpid()); else v = getenv(ps); } -- cgit v1.2.1 From 0456cfb8bd0fe25c3f78cc15a6f10688eb51aa83 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Mon, 9 Nov 2009 12:45:33 -0500 Subject: Support 'STY' variable to show the session name. --- src/process.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 1875ad8..970b276 100644 --- a/src/process.c +++ b/src/process.c @@ -4598,6 +4598,8 @@ int bufl, *argl; sprintf(xbuf, "%d", display ? D_height : -1); else if (!strcmp(ps, "PID")) sprintf(xbuf, "%d", getpid()); + else if (!strcmp(ps, "STY")) + v = SockName; else v = getenv(ps); } -- cgit v1.2.1 From 1048d3fce2f4fb52eeab0e30466c62925aafcd86 Mon Sep 17 00:00:00 2001 From: Steve Kemp and Gabriel Date: Tue, 10 Nov 2009 10:22:19 -0500 Subject: unbindall command This command will unbind *all* bindings. This can be useful when screen is used solely for its detaching abilities, such as when letting a console application run as a daemon. If, for some reason, it is necessary to bind commands after this, there is always '-X'. Fixes #27745. --- src/process.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 970b276..7553471 100644 --- a/src/process.c +++ b/src/process.c @@ -1398,6 +1398,15 @@ int key; Msg(0, "zmodem mode is %s", zmodes[zmodem_mode]); break; #endif + case RC_UNBINDALL: + { + register unsigned int i; + + for (i = 0; i < sizeof(ktab)/sizeof(*ktab); i++) + ClearAction(&ktab[i]); + Msg(0, "Unbound all keys." ); + break; + } case RC_ZOMBIE: { if (!(s = *args)) -- cgit v1.2.1 From fe5ff3987224b31ca0f9fe9950b661870ec174d8 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Wed, 11 Nov 2009 16:46:40 -0500 Subject: Refactor some code. --- src/process.c | 134 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 75 insertions(+), 59 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 7553471..219a432 100644 --- a/src/process.c +++ b/src/process.c @@ -162,7 +162,6 @@ static void ResizeFin __P((char *, int, char *)); static struct action *FindKtab __P((char *, int)); static void SelectFin __P((char *, int, char *)); static void SelectLayoutFin __P((char *, int, char *)); -static struct canvas *FindCanvas __P((int, int)); extern struct layer *flayer; @@ -3942,63 +3941,37 @@ int key; LaySetCursor(); break; case RC_FOCUS: - if (!*args || !strcmp(*args, "next")) - D_forecv = D_forecv->c_next ? D_forecv->c_next : D_cvlist; - else if (!strcmp(*args, "prev")) - { - struct canvas *cv; - for (cv = D_cvlist; cv->c_next && cv->c_next != D_forecv; cv = cv->c_next) - ; - D_forecv = cv; - } - else if (!strcmp(*args, "top")) - D_forecv = D_cvlist; - else if (!strcmp(*args, "bottom")) - { - struct canvas *cv; - for (cv = D_cvlist; cv->c_next; cv = cv->c_next) - ; - D_forecv = cv; - } - else if (!strcmp(*args, "up")) - D_forecv = FindCanvas(D_forecv->c_xs, D_forecv->c_ys - 1); - else if (!strcmp(*args, "down")) - D_forecv = FindCanvas(D_forecv->c_xs, D_forecv->c_ye + 2); - else if (!strcmp(*args, "left")) - D_forecv = FindCanvas(D_forecv->c_xs - 1, D_forecv->c_ys); - else if (!strcmp(*args, "right")) - D_forecv = FindCanvas(D_forecv->c_xe + 1, D_forecv->c_ys); - else - { - Msg(0, "%s: usage: focus [next|prev|up|down|left|right|top|bottom]", rc_name); - break; - } - if ((focusminwidth && (focusminwidth < 0 || D_forecv->c_xe - D_forecv->c_xs + 1 < focusminwidth)) || - (focusminheight && (focusminheight < 0 || D_forecv->c_ye - D_forecv->c_ys + 1 < focusminheight))) - { - ResizeCanvas(&D_canvas); - RecreateCanvasChain(); - RethinkDisplayViewports(); - ResizeLayersToCanvases(); /* redisplays */ - } - fore = D_fore = Layer2Window(D_forecv->c_layer); - if (D_other == fore) - D_other = 0; - flayer = D_forecv->c_layer; -#ifdef RXVT_OSC - if (D_xtermosc[2] || D_xtermosc[3]) - { - Activate(-1); - break; - } -#endif - RefreshHStatus(); -#ifdef RXVT_OSC - RefreshXtermOSC(); -#endif - flayer = D_forecv->c_layer; - CV_CALL(D_forecv, LayRestore();LaySetCursor()); - WindowChanged(0, 'F'); + { + struct canvas *cv = 0; + if (!*args || !strcmp(*args, "next")) + cv = D_forecv->c_next ? D_forecv->c_next : D_cvlist; + else if (!strcmp(*args, "prev")) + { + for (cv = D_cvlist; cv->c_next && cv->c_next != D_forecv; cv = cv->c_next) + ; + } + else if (!strcmp(*args, "top")) + cv = D_cvlist; + else if (!strcmp(*args, "bottom")) + { + for (cv = D_cvlist; cv->c_next; cv = cv->c_next) + ; + } + else if (!strcmp(*args, "up")) + cv = FindCanvas(D_forecv->c_xs, D_forecv->c_ys - 1); + else if (!strcmp(*args, "down")) + cv = FindCanvas(D_forecv->c_xs, D_forecv->c_ye + 2); + else if (!strcmp(*args, "left")) + cv = FindCanvas(D_forecv->c_xs - 1, D_forecv->c_ys); + else if (!strcmp(*args, "right")) + cv = FindCanvas(D_forecv->c_xe + 1, D_forecv->c_ys); + else + { + Msg(0, "%s: usage: focus [next|prev|up|down|left|right|top|bottom]", rc_name); + break; + } + SetForeCanvas(display, cv); + } break; case RC_RESIZE: i = 0; @@ -6790,7 +6763,7 @@ int percent; return done; } -static struct canvas * +struct canvas * FindCanvas(x, y) int x, y; { @@ -7022,6 +6995,49 @@ char *data; buf[len] = '\034'; } +void +SetForeCanvas(d, cv) +struct display *d; +struct canvas *cv; +{ + struct display *odisplay = display; + if (d->d_forecv == cv) + return; + + display = d; + D_forecv = cv; + if ((focusminwidth && (focusminwidth < 0 || D_forecv->c_xe - D_forecv->c_xs + 1 < focusminwidth)) || + (focusminheight && (focusminheight < 0 || D_forecv->c_ye - D_forecv->c_ys + 1 < focusminheight))) + { + ResizeCanvas(&D_canvas); + RecreateCanvasChain(); + RethinkDisplayViewports(); + ResizeLayersToCanvases(); /* redisplays */ + } + fore = D_fore = Layer2Window(D_forecv->c_layer); + if (D_other == fore) + D_other = 0; + flayer = D_forecv->c_layer; +#ifdef RXVT_OSC + if (D_xtermosc[2] || D_xtermosc[3]) + { + Activate(-1); + } + else +#endif + { + RefreshHStatus(); +#ifdef RXVT_OSC + RefreshXtermOSC(); +#endif + flayer = D_forecv->c_layer; + CV_CALL(D_forecv, LayRestore();LaySetCursor()); + WindowChanged(0, 'F'); + } + + display = odisplay; +} + #ifdef RXVT_OSC void RefreshXtermOSC() -- cgit v1.2.1 From ca20b068fd39f8f9ca0c67353bc2b87141d0d290 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Thu, 12 Nov 2009 12:49:52 -0500 Subject: Add support for mouse tracking. Mouse tracking can be turned on/off using 'mousetrack' command. With mouse-tracking turned on, it is possible to switch to a region ('focus') using mouse-clicks. --- src/process.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 219a432..8136fd5 100644 --- a/src/process.c +++ b/src/process.c @@ -75,6 +75,7 @@ extern char *printcmd; extern int default_startup; extern int defobuflimit; extern int defnonblock; +extern int defmousetrack; extern int ZombieKey_destroy; extern int ZombieKey_resurrect; extern int ZombieKey_onerror; @@ -2727,6 +2728,22 @@ int key; if (ParseOnOff(act, &n) == 0) nwin_default.monitor = (n == 0) ? MON_OFF : MON_ON; break; + case RC_DEFMOUSETRACK: + if (ParseOnOff(act, &n) == 0) + defmousetrack = (n == 0) ? 0 : 1000; + break; + case RC_MOUSETRACK: + if (!args[0]) + { + Msg(0, "Mouse tracking for this display is turned %s", D_mousetrack ? "on" : "off"); + } + else if (ParseOnOff(act, &n) == 0) + { + D_mousetrack = n == 0 ? 0 : 1000; + if (D_fore) + MouseMode(D_fore->w_mouse); + } + break; case RC_DEFSILENCE: if (ParseOnOff(act, &n) == 0) nwin_default.silence = (n == 0) ? SILENCE_OFF : SILENCE_ON; -- cgit v1.2.1 From 827243a5521df50824f0371f24a67692d11fe101 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Thu, 12 Nov 2009 13:42:55 -0500 Subject: Start refactoring. The Screen code at this stage is somewhat complicated to start working on. So refactor some code so it's easier to manage and hack. Also, the plan is to eventually add some documentation, possibly in the header files showing their usage. --- src/process.c | 163 +--------------------------------------------------------- 1 file changed, 1 insertion(+), 162 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 8136fd5..fda3a8e 100644 --- a/src/process.c +++ b/src/process.c @@ -49,6 +49,7 @@ #include "screen.h" #include "extern.h" #include "logfile.h" +#include "canvas.h" extern struct comm comms[]; extern char *rc_name; @@ -5006,118 +5007,6 @@ int n; Activate(fore->w_norefresh); } - -void -SetCanvasWindow(cv, wi) -struct canvas *cv; -struct win *wi; -{ - struct win *p = 0, **pp; - struct layer *l; - struct canvas *cvp, **cvpp; - - l = cv->c_layer; - display = cv->c_display; - - if (l) - { - /* remove old layer */ - for (cvpp = &l->l_cvlist; (cvp = *cvpp); cvpp = &cvp->c_lnext) - if (cvp == cv) - break; - ASSERT(cvp); - *cvpp = cvp->c_lnext; - - p = Layer2Window(l); - l = cv->c_layer; - cv->c_layer = 0; - - if (p && cv == D_forecv) - { -#ifdef MULTIUSER - ReleaseAutoWritelock(display, p); -#endif - if (p->w_silence) - { - SetTimeout(&p->w_silenceev, p->w_silencewait * 1000); - evenq(&p->w_silenceev); - } - D_other = fore; - D_fore = 0; - } - if (l->l_cvlist == 0 && (p == 0 || l != p->w_savelayer)) - KillLayerChain(l); - } - - /* find right layer to display on canvas */ - if (wi && wi->w_type != W_TYPE_GROUP) - { - l = &wi->w_layer; - if (wi->w_savelayer && (wi->w_blocked || wi->w_savelayer->l_cvlist == 0)) - l = wi->w_savelayer; - } - else - { - l = &cv->c_blank; - if (wi) - l->l_data = (char *)wi; - else - l->l_data = 0; - } - - /* add our canvas to the layer's canvaslist */ - ASSERT(l->l_cvlist != cv); - cv->c_lnext = l->l_cvlist; - l->l_cvlist = cv; - cv->c_layer = l; - cv->c_xoff = cv->c_xs; - cv->c_yoff = cv->c_ys; - RethinkViewportOffsets(cv); - - if (flayer == 0) - flayer = l; - - if (wi && wi->w_type == W_TYPE_GROUP) - { - /* auto-start windowlist on groups */ - struct display *d = display; - struct layer *oldflayer = flayer; - flayer = l; - display_wlist(0, 0, wi); - flayer = oldflayer; - display = d; - } - - if (wi && D_other == wi) - D_other = wi->w_next; /* Might be 0, but that's OK. */ - if (cv == D_forecv) - { - D_fore = wi; - fore = D_fore; /* XXX ? */ - if (wi) - { -#ifdef MULTIUSER - ObtainAutoWritelock(display, wi); -#endif - /* - * Place the window at the head of the most-recently-used list - */ - if (windows != wi) - { - for (pp = &windows; (p = *pp); pp = &p->w_next) - if (p == wi) - break; - ASSERT(p); - *pp = p->w_next; - p->w_next = windows; - windows = p; - WListLinkChanged(); - } - } - } -} - - /* * SetForeWindow changes the window in the input focus of the display. * Puts window wi in canvas display->d_forecv. @@ -6780,56 +6669,6 @@ int percent; return done; } -struct canvas * -FindCanvas(x, y) -int x, y; -{ - struct canvas *cv, *mcv = 0; - int m, mm = 0; - - for (cv = D_cvlist; cv; cv = cv->c_next) - { - /* ye + 1 because of caption line */ - if (x >= cv->c_xs && x <= cv->c_xe && y >= cv->c_ys && y <= cv->c_ye + 1) - return cv; - if (cv == D_forecv) - continue; - m = 0; - if (x >= D_forecv->c_xs && x <= D_forecv->c_xe) - { - if (x < cv->c_xs || x > cv->c_xe) - continue; - if (y < D_forecv->c_ys && y < cv->c_ys) - continue; - if (y > D_forecv->c_ye + 1 && y > cv->c_ye + 1) - continue; - if (y < cv->c_ys) - m = cv->c_ys - y; - if (y > cv->c_ye + 1) - m = y - (cv->c_ye + 1); - } - if (y >= D_forecv->c_ys && y <= D_forecv->c_ye + 1) - { - if (y < cv->c_ys || y > cv->c_ye + 1) - continue; - if (x < D_forecv->c_xs && x < cv->c_xs) - continue; - if (x > D_forecv->c_xe && x > cv->c_xe) - continue; - if (x < cv->c_xs) - m = cv->c_xs - x; - if (x > cv->c_xe) - m = x - cv->c_xe; - } - if (m && (!mm || m < mm)) - { - mcv = cv; - mm = m; - } - } - return mcv ? mcv : D_forecv; -} - static void ResizeRegions(arg, flags) char *arg; -- cgit v1.2.1 From 36983385404db06b71744d9d42fbdd6d1c105bc2 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Thu, 12 Nov 2009 14:24:12 -0500 Subject: Refactor 'layout' and 'viewport' --- src/process.c | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index fda3a8e..27877c2 100644 --- a/src/process.c +++ b/src/process.c @@ -49,7 +49,8 @@ #include "screen.h" #include "extern.h" #include "logfile.h" -#include "canvas.h" +#include "layout.h" +#include "viewport.h" extern struct comm comms[]; extern char *rc_name; @@ -5135,36 +5136,6 @@ MoreWindows() return 0; } -static void -UpdateLayoutCanvas(cv, wi) -struct canvas *cv; -struct win *wi; -{ - for (; cv; cv = cv->c_slnext) - { - if (cv->c_layer && Layer2Window(cv->c_layer) == wi) - { - /* A simplistic version of SetCanvasWindow(cv, 0) */ - struct layer *l = cv->c_layer; - cv->c_layer = 0; - if (l->l_cvlist == 0 && (wi == 0 || l != wi->w_savelayer)) - KillLayerChain(l); - l = &cv->c_blank; - l->l_data = 0; - if (l->l_cvlist != cv) - { - cv->c_lnext = l->l_cvlist; - l->l_cvlist = cv; - } - cv->c_layer = l; - /* Do not end here. Multiple canvases can have the same window */ - } - - if (cv->c_slperp) - UpdateLayoutCanvas(cv->c_slperp, wi); - } -} - void KillWindow(wi) struct win *wi; -- cgit v1.2.1 From 2199ead34441dd5291ffecb737b9ff4e7ae47f0d Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Sat, 5 Dec 2009 21:53:52 -0500 Subject: Revamp the display list. Revamp the display list (in works). The future changes are expected to add full mouse control, and perhaps some other utility functions (e.g. detaching a display, changing permissions perhaps? etc.) --- src/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 27877c2..8788ea8 100644 --- a/src/process.c +++ b/src/process.c @@ -6338,7 +6338,7 @@ int i; fore = D_fore; act = 0; #ifdef COPY_PASTE - if (InMark() || InInput() || InWList()) + if (flayer && flayer->l_mode == 1) act = i < KMAP_KEYS+KMAP_AKEYS ? &mmtab[i] : &kmap_exts[i - (KMAP_KEYS+KMAP_AKEYS)].mm; #endif if ((!act || act->nr == RC_ILLEGAL) && !D_mapdefault) -- cgit v1.2.1 From 0dc3a24b7bd949dc2c1709416b580828baea5b5f Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Fri, 11 Dec 2009 17:29:48 -0500 Subject: New 'dump' subcommand for 'layout'. This command will write a series of screen commands that can later be used to recreate the current layout. I think this will be pretty useful. Users like to create a layout interactively, and use it again for the next session etc. --- src/process.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 8788ea8..2874e7e 100644 --- a/src/process.c +++ b/src/process.c @@ -4367,6 +4367,15 @@ int key; if (lay) RemoveLayout(lay); } + else if (!strcmp(args[0], "dump")) + { + if (!display) + Msg(0, "Must have a display for 'layout dump'."); + else if (!LayoutDumpCanvas(&D_canvas, args[1] ? args[1] : "layout-dump")) + Msg(errno, "Error dumping layout."); + else + Msg(0, "Layout dumped to \"%s\"", args[1] ? args[1] : "layout-dump"); + } else Msg(0, "unknown layout subcommand"); break; -- cgit v1.2.1 From 1e4fb57b49754618dc147f397a8a72483fd6c419 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Tue, 15 Dec 2009 12:59:18 -0500 Subject: Allow adding visual notification in caption string. '%P' in caption string will set '%?' to true if the current region is in copy/paste mode. So, if you want to simply change the color etc. of your caption, prepend '%?%P%{XXX}%?' to your caption and you're set ('XXX' stands for the usual attribute/color modifier). If, on the other hand, you want to change the caption string in copy mode, change your caption string to '%?%PCaption for copy mode%:Your usual caption%?'. --- src/process.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 2874e7e..0e835f0 100644 --- a/src/process.c +++ b/src/process.c @@ -2231,6 +2231,7 @@ int key; break; } MarkRoutine(); + WindowChanged(fore, 'P'); break; case RC_HISTORY: { -- cgit v1.2.1 From 52efeb8dfc40be5d5ba36253a1dc3af514d0b226 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Sat, 19 Dec 2009 14:23:27 -0500 Subject: Allow no argument to blankerprg. Without any argument, blankerprg will show the command that would be executed on 'blanker'. To unset, use an empty string, i.e. "blankerprg ''". --- src/process.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 0e835f0..76785e1 100644 --- a/src/process.c +++ b/src/process.c @@ -4088,6 +4088,21 @@ int key; break; #ifdef BLANKER_PRG case RC_BLANKERPRG: + if (!args[0]) + { + if (blankerprg) + { + char path[MAXPATHLEN]; + char *p = path, **pp; + for (pp = blankerprg; *pp; pp++) + p += snprintf(p, sizeof(path) - (p - path) - 1, "%s ", *pp); + *(p - 1) = '\0'; + Msg(0, "blankerprg: %s", path); + } + else + Msg(0, "No blankerprg set."); + break; + } if (blankerprg) { char **pp; -- cgit v1.2.1 From 4b778782ce398747f080b7b7ffd8a2e26c3b0a88 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Sun, 20 Dec 2009 00:14:15 -0500 Subject: Allow 'at' command for windows without a display. For window-context, 'at' commands can work without any existing display. So allow for that. If the command specified for 'at' requires a display, then that will still fail, as it should. But for some commands, just an existing window is enough. Fixes savannah bug #26996. --- src/process.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 76785e1..70bb4fa 100644 --- a/src/process.c +++ b/src/process.c @@ -1451,12 +1451,14 @@ int key; break; case RC_AT: /* where this AT command comes from: */ + if (!user) + break; #ifdef MULTIUSER - s = SaveStr(D_user->u_name); + s = SaveStr(user->u_name); /* DO NOT RETURN FROM HERE WITHOUT RESETTING THIS: */ - EffectiveAclUser = D_user; + EffectiveAclUser = user; #else - s = SaveStr(D_usertty); + s = SaveStr(display ? D_usertty : user->u_name); #endif n = strlen(args[0]); if (n) n--; @@ -1473,14 +1475,22 @@ int key; struct acluser *u; if (!n) - u = D_user; + u = user; else - for (u = users; u; u = u->u_next) - { - debug3("strncmp('%s', '%s', %d)\n", *args, u->u_name, n); - if (!strncmp(*args, u->u_name, n)) + { + for (u = users; u; u = u->u_next) + { + debug3("strncmp('%s', '%s', %d)\n", *args, u->u_name, n); + if (!strncmp(*args, u->u_name, n)) + break; + } + if (!u) + { + args[0][n] = '\0'; + Msg(0, "Did not find any user matching '%s'", args[0]); break; - } + } + } debug1("at all displays of user %s\n", u->u_name); for (display = displays; display; display = nd) { @@ -1539,7 +1549,7 @@ int key; struct win *nw; int ch; - n++; + n++; ch = args[0][n]; args[0][n] = '\0'; if (!*args[0] || (i = WindowByNumber(args[0])) < 0) -- cgit v1.2.1 From f33e5cdecb7bf3b6ae8e4a5c0ca394dd5a06a416 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Tue, 26 Jan 2010 15:15:24 -0500 Subject: Increase the max-window limit. The limit can be increased using the 'maxwin' command. There is still an upper-limit of 2048 windows. --- src/process.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 70bb4fa..b67afd5 100644 --- a/src/process.c +++ b/src/process.c @@ -186,7 +186,7 @@ extern int nethackflag; #endif -struct win *wtab[MAXWIN]; /* window table, should be dynamic */ +extern struct win **wtab; #ifdef MULTIUSER extern char *multi; @@ -586,7 +586,7 @@ InitKeytab() args[1] = NULL; SaveAction(ktab + '-', RC_SELECT, args, 0); } - for (i = 0; i < ((MAXWIN < 10) ? MAXWIN : 10); i++) + for (i = 0; i < ((maxwin < 10) ? maxwin : 10); i++) { char *args[2], arg1[10]; args[0] = arg1; @@ -991,7 +991,7 @@ struct paster *pa; int FindCommnr(str) -char *str; +const char *str; { int x, m, l = 0, r = RC_LAST; while (l <= r) @@ -1588,7 +1588,7 @@ int key; Msg(0, "%s: at '%s': no such window.\n", rc_name, args[0]); break; } - else if (i < MAXWIN && (fore = wtab[i])) + else if (i < maxwin && (fore = wtab[i])) { args[0][n] = ch; /* must restore string in case of bind */ debug2("AT window %d (%s)\n", fore->w_number, fore->w_title); @@ -4054,14 +4054,25 @@ int key; Msg(0, "Will %sdo alternate screen switching", use_altscreen ? "" : "not "); break; case RC_MAXWIN: + if (!args[0]) + { + Msg(0, "maximum windows allowed: %d", maxwin); + break; + } if (ParseNum(act, &n)) break; if (n < 1) Msg(0, "illegal maxwin number specified"); - else if (n > maxwin) - Msg(0, "may only decrease maxwin number"); + else if (n > 2048) + Msg(0, "maximum 2048 windows allowed"); + else if (n > maxwin && windows) + Msg(0, "may increase maxwin only when there's no window"); else - maxwin = n; + { + if (!windows) + wtab = realloc(wtab, n * sizeof(struct win)); + maxwin = n; + } break; case RC_BACKTICK: if (ParseBase(act, *args, &n, 10, "decimal")) @@ -4435,10 +4446,11 @@ char **argv; int *argl; { struct action act; + const char *cmd = *argv; - if ((act.nr = FindCommnr(*argv)) == RC_ILLEGAL) + if ((act.nr = FindCommnr(cmd)) == RC_ILLEGAL) { - Msg(0, "%s: unknown command '%s'", rc_name, *argv); + Msg(0, "%s: unknown command '%s'", rc_name, cmd); return; } act.args = argv + 1; @@ -4907,7 +4919,7 @@ char *str; int i; struct win *p; - if ((i = WindowByNumber(str)) < 0 || i >= MAXWIN) + if ((i = WindowByNumber(str)) < 0 || i >= maxwin) { if ((p = WindowByName(str))) return p->w_number; @@ -5012,7 +5024,7 @@ int n; struct win *p; debug1("SwitchWindow %d\n", n); - if (n < 0 || n >= MAXWIN) + if (n < 0 || n >= maxwin) { ShowWindows(-1); return; @@ -5116,12 +5128,12 @@ static int NextWindow() { register struct win **pp; - int n = fore ? fore->w_number : MAXWIN; + int n = fore ? fore->w_number : maxwin; struct win *group = fore ? fore->w_group : 0; for (pp = fore ? wtab + n + 1 : wtab; pp != wtab + n; pp++) { - if (pp == wtab + MAXWIN) + if (pp == wtab + maxwin) pp = wtab; if (*pp) { @@ -5144,7 +5156,7 @@ PreviousWindow() for (pp = wtab + n - 1; pp != wtab + n; pp--) { if (pp == wtab - 1) - pp = wtab + MAXWIN - 1; + pp = wtab + maxwin - 1; if (*pp) { if (!fore || group == (*pp)->w_group) @@ -5284,7 +5296,7 @@ int where; *s = 0; return ss; } - for (pp = ((flags & 4) && where >= 0) ? wtab + where + 1: wtab; pp < wtab + MAXWIN; pp++) + for (pp = ((flags & 4) && where >= 0) ? wtab + where + 1: wtab; pp < wtab + maxwin; pp++) { int rend = -1; if (pp - wtab == where && ss == buf) @@ -5921,7 +5933,7 @@ char *fn, **av; if (*buf != '\0') nwin.aka = buf; num = atoi(*av); - if (num < 0 || num > MAXWIN - 1) + if (num < 0 || num > maxwin - 1) { Msg(0, "%s: illegal screen number %d.", fn, num); num = 0; -- cgit v1.2.1 From f3415774783781be919cd0452d401bbbe396c879 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Mon, 8 Feb 2010 21:19:24 -0500 Subject: Fix escape-# to select windows this time. --- src/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index b67afd5..0bb3603 100644 --- a/src/process.c +++ b/src/process.c @@ -586,7 +586,7 @@ InitKeytab() args[1] = NULL; SaveAction(ktab + '-', RC_SELECT, args, 0); } - for (i = 0; i < ((maxwin < 10) ? maxwin : 10); i++) + for (i = 0; i < ((maxwin && maxwin < 10) ? maxwin : 10); i++) { char *args[2], arg1[10]; args[0] = arg1; -- cgit v1.2.1 From b040667633ecccb582426536936f07c8e005c87b Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Fri, 12 Feb 2010 16:26:16 -0500 Subject: Put in some flags to suppress messages from commands. A command name can be prefixed by '@' to suppress the error messages, and by '-' to suppress the normal messages. The flags are currently parsed, but not acted upon. --- src/process.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 0bb3603..42da498 100644 --- a/src/process.c +++ b/src/process.c @@ -695,6 +695,7 @@ int create; kp->ktab[i].nr = RC_ILLEGAL; kp->ktab[i].args = noargs; kp->ktab[i].argl = 0; + kp->ktab[i].quiet = 0; } kp->next = 0; *kpp = kp; @@ -4448,6 +4449,18 @@ int *argl; struct action act; const char *cmd = *argv; + act.quiet = 0; + if (*cmd == '@') /* Suppress error */ + { + act.quiet |= 0x01; + cmd++; + } + if (*cmd == '-') /* Suppress normal message */ + { + act.quiet |= 0x02; + cmd++; + } + if ((act.nr = FindCommnr(cmd)) == RC_ILLEGAL) { Msg(0, "%s: unknown command '%s'", rc_name, cmd); @@ -6125,6 +6138,7 @@ char *data; act.nr = *(int *)data; act.args = noargs; act.argl = 0; + act.quiet = 0; DoAction(&act, -1); } -- cgit v1.2.1 From 9756ae6fb21fb6421e543173115059d36358c692 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Fri, 12 Feb 2010 16:38:38 -0500 Subject: Get rid of compile-time warnings. --- src/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 42da498..128b0e2 100644 --- a/src/process.c +++ b/src/process.c @@ -26,6 +26,8 @@ **************************************************************** */ +#include "config.h" + #include #include #include @@ -39,8 +41,6 @@ #endif -#include "config.h" - /* for solaris 2.1, Unixware (SVR4.2) and possibly others: */ #ifdef HAVE_STROPTS_H # include -- cgit v1.2.1