screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vertical split


From: bill
Subject: Re: vertical split
Date: Sun, 18 Dec 2005 21:31:06 +0000
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929)

Michael Schroeder wrote:

On Sun, Dec 18, 2005 at 05:28:07PM +0000, bill wrote:
Here's a patch that does the vertical split.  It doesn't put any delimiter
between the windows, which can be disconcerting, since when you
first create the new region (^A V), absolutely nothing noticeable
happens.  But if you ^A-tab you'll be in the new region, and a
next will make something show up.  This was
a diff against 4.0.3, which I gather from Michael's comment may
be the wrong thing to diff against.

Hey, that's the easy part. If it was that easy it would have been
in screen reight away. You have to add resizing, stacking and the
like. Just habe a look at vim.

(And please don't use EXIT_FAILURE/EXIT_SUCCESS, we're all using
unix here. I much prefer 0/-1)

Cheers,
 Michael.

Here's a patch against 4.0.2 that includes resizing for 'Q'. That's the easiest resize of course, but I don't yet see that the others will be that difficult to do. I'm hoping to get some time to look at it this week. I have a really mundane question, though... Is there an easier way to do these patches? I'm maintaining my developmental directory, in which I've made massive formatting changes and notes and comments, etc, where I dig around and figure out how things work, and I don't want to make diffs against that, since there are huge amounts of white space, &c changes. When I've got code that does work, I get 2 fresh copies of the original source, make the changes in one (I'm trying to maintain the style of the surrounding code, and apologize when I get it wrong; except that I prefer using functional declarations with types in the parameter list...if no one objects I'd prefer to continue doing that), and then do a diff -u in the common parent directory. It feels like I end up doing more work than I need to do. I'm more accustomed to accessing a repository directly, and any pointers on doing this would be highly
appreciated.

Also, this patch is against the original 4.0.2, rather than an incremental
patch against the vert_split_diff that I put out earlier this evening. Is that the right way to go? or should I send incremental patches? The more I get into this code, the more I like it. It's a very nice design.

diff -u screen-4.0.2/comm.c my-screen-4.0.2/comm.c
--- screen-4.0.2/comm.c 2003-09-08 15:25:08.000000000 +0100
+++ my-screen-4.0.2/comm.c      2005-12-18 21:09:16.169541392 +0000
@@ -309,6 +309,7 @@
   { "vbellwait",       ARGS_1 },
   { "verbose",         ARGS_01 },
   { "version",         ARGS_0 },
+  { "vert_split",              NEED_DISPLAY|ARGS_0 },
   { "wall",            NEED_DISPLAY|ARGS_1},
   { "width",           ARGS_0123 },
   { "windowlist",      NEED_DISPLAY|ARGS_012 },
diff -u screen-4.0.2/display.c my-screen-4.0.2/display.c
--- screen-4.0.2/display.c      2003-12-05 13:45:41.000000000 +0000
+++ my-screen-4.0.2/display.c   2005-12-18 21:10:40.756682192 +0000
@@ -592,10 +592,13 @@
     {
       if (cv == mycv)
         {
-         cv->c_ys = 0;
-         cv->c_ye = D_height - 1 - (D_has_hstatus == HSTATUS_LASTLINE) - 
captionalways;
-         cv->c_yoff = 0;
-         cvpp = &cv->c_next;
+         cv->c_xs         = 0;
+         cv->c_xe         = D_width-1;
+         cv->c_xoff       = 0;
+         cv->c_ys         = 0;
+         cv->c_ye         = D_height - 1 - (D_has_hstatus == HSTATUS_LASTLINE) 
- captionalways;
+         cv->c_yoff       = 0;
+         cvpp             = &cv->c_next;
         }
       else
         {
@@ -3920,3 +3923,83 @@
 }
 
 #endif
+
+int
+AddVerticalCanvas()
+{   /*! \brief Add a new canvas with a vertical split.
+    */
+
+    int             canvas_count;  /* Canvasses with same y offset. */
+    struct canvas  *cv;            /* Index into D_cvlist. */
+    int             x_start;       /* Start position of a canvas. */
+
+    /* Count the canvasses that have the same horizontal position as
+    the canvas with the focus. */
+    for (cv = D_cvlist, canvas_count = 0; cv; cv = cv->c_next) {
+        if (cv -> c_ys == D_forecv -> c_ys)
+            canvas_count++;
+    }
+    canvas_count++;
+
+    debug2("canvas_count = %d, width = %d\n", canvas_count, D_width);
+
+    /* Return EXIT_FAILURE if the screen isn't wide enough to split. */
+    if (D_width / canvas_count <= 1)
+        return -1; 
+
+    ASSERT(D_forecv);
+
+    /* Allocate a new canvas. */
+    debug("initializing new canvas\n");
+    if ((cv = (struct canvas *) calloc(1, sizeof *cv)) == 0)
+        return -1;
+
+    /* Insert the new canvas after the current foreground. */
+    cv -> c_next = D_forecv->c_next;
+    D_forecv -> c_next = cv;
+
+    cv -> c_xs               = D_forecv -> c_xs;
+    cv -> c_xe               = D_forecv -> c_xe;
+    cv -> c_ys               = D_forecv -> c_ys;
+    cv -> c_ye               = D_forecv -> c_ye;
+    cv -> c_xoff             = D_forecv -> c_xoff;
+    cv -> c_yoff             = D_forecv -> c_yoff;
+    cv -> c_display          = display;
+    cv -> c_vplist           = 0;
+    cv -> c_captev.type      = EV_TIMEOUT;
+    cv -> c_captev.data      = (char *) cv;
+    cv -> c_captev.handler   = cv_winid_fn;
+
+    cv -> c_blank.l_cvlist   = cv;
+    cv -> c_blank.l_width    = cv->c_xe - cv->c_xs + 1;
+    cv -> c_blank.l_height   = cv->c_ye - cv->c_ys + 1;
+    cv -> c_blank.l_x        = cv->c_blank.l_y = 0;
+    cv -> c_blank.l_layfn    = &BlankLf;
+    cv -> c_blank.l_data     = 0;
+    cv -> c_blank.l_next     = 0;
+    cv -> c_blank.l_bottom   = &cv->c_blank;
+    cv -> c_blank.l_blocking = 0;
+    cv -> c_layer            = &cv->c_blank;
+    cv -> c_lnext            = 0;
+
+    /* Reset the width of each region. */
+    x_start = 0;
+    for (cv = D_cvlist; cv; cv = cv->c_next) {
+        if (cv -> c_ys == D_forecv -> c_ys) {
+            int this_width; /* new width of cv */
+
+            this_width = D_width / canvas_count - 1;
+            cv -> c_xs = x_start;
+            cv -> c_xe = x_start + this_width - 1;
+            cv -> c_xoff = x_start;
+            x_start += this_width + 1;
+            debug3(" c_xs = %d, x_xe = %d, xoff = %d\n",
+                cv -> c_xs, cv -> c_xe, cv-> c_xoff);
+        }
+    }
+
+    RethinkDisplayViewports();
+    ResizeLayersToCanvases();
+    return 0;
+}
+
Common subdirectories: screen-4.0.2/doc and my-screen-4.0.2/doc
Common subdirectories: screen-4.0.2/etc and my-screen-4.0.2/etc
diff -u screen-4.0.2/process.c my-screen-4.0.2/process.c
--- screen-4.0.2/process.c      2003-09-18 13:53:54.000000000 +0100
+++ my-screen-4.0.2/process.c   2005-12-18 21:08:33.476031792 +0000
@@ -548,6 +548,7 @@
   ktab['B'].nr = RC_POW_BREAK;
   ktab['_'].nr = RC_SILENCE;
   ktab['S'].nr = RC_SPLIT;
+  ktab['V'].nr = RC_VERT_SPLIT;
   ktab['Q'].nr = RC_ONLY;
   ktab['X'].nr = RC_REMOVE;
   ktab['F'].nr = RC_FIT;
@@ -3648,6 +3649,10 @@
         Msg(0, "%s", s);
       break;
 #endif /* MULTIUSER */
+    case RC_VERT_SPLIT:
+        AddVerticalCanvas();
+        Activate(-1);
+        break;
     case RC_SPLIT:
       AddCanvas();
       Activate(-1);
Common subdirectories: screen-4.0.2/terminfo and my-screen-4.0.2/terminfo
Common subdirectories: screen-4.0.2/utf8encodings and 
my-screen-4.0.2/utf8encodings

reply via email to

[Prev in Thread] Current Thread [Next in Thread]