9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Joseph Xu <josephzxu@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] assigning acme windows to columns programmatically
Date: Wed, 19 Jan 2011 03:47:23 -0500	[thread overview]
Message-ID: <AANLkTi=0_wcSNYOqsz6SFqr9vBHEOB1JLxg+LaO=dvB0@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=sDw86dmqaw4K8UYU1vFxdVfO4scxdxkSM5k1N@mail.gmail.com>

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;



  reply	other threads:[~2011-01-19  8:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-17  8:04 Joseph Xu
2011-01-18  9:43 ` Sergey Zhilkin
2011-01-18 19:20 ` Arvindh Rajesh Tamilmani
2011-01-19  8:47   ` Joseph Xu [this message]
2011-01-19  8:49     ` Joseph Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTi=0_wcSNYOqsz6SFqr9vBHEOB1JLxg+LaO=dvB0@mail.gmail.com' \
    --to=josephzxu@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).