From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 19 Jan 2011 03:47:23 -0500 Message-ID: From: Joseph Xu To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Subject: Re: [9fans] assigning acme windows to columns programmatically Topicbox-Message-UUID: 9f2c5dca-ead6-11e9-9d60-3106f5b1d025 Adding this feature turned out to be pretty easy. If anyone else is interested, here's a patch that allows you to write a message of the form "col i\n" to /n/ctl to move window n to the i th column from the left, starting with 0. diff -r ad2f6f64fbc8 src/cmd/acme/xfid.c --- a/src/cmd/acme/xfid.c Wed Jan 12 00:54:22 2011 -0500 +++ b/src/cmd/acme/xfid.c Wed Jan 19 03:39:10 2011 -0500 @@ -780,6 +780,26 @@ if(strncmp(p, "scroll", 6) == 0){ /* turn on automatic scrolling (writes to body only) */ w->noscroll = FALSE; m = 6; + }else + if(strncmp(p, "col ", 4) == 0){ + pp = p+4; + m = 4; + q = memchr(pp, '\n', e-pp); + if(q==nil || q==pp){ + err = Ebadctl; + break; + } + *q = 0; + i = atoi(pp); + if(i < 0 || i >= row.ncol){ + err = Ebadctl; + break; + } + if(row.col[i] != w->col){ + colclose(w->col, w, FALSE); + coladd(row.col[i], w, nil, 0); + } + m += (q+1) - pp; }else{ err = Ebadctl; break;