* [9fans] assigning acme windows to columns programmatically
@ 2011-01-17 8:04 Joseph Xu
2011-01-18 9:43 ` Sergey Zhilkin
2011-01-18 19:20 ` Arvindh Rajesh Tamilmani
0 siblings, 2 replies; 5+ messages in thread
From: Joseph Xu @ 2011-01-17 8:04 UTC (permalink / raw)
To: 9fans
Hi:
In acme, is it possible to move an existing window into a specific
column using its control file interface? I have a script that spawns
several windows every run and I'm getting tired of manually
rearranging the windows every time.
Joseph
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] assigning acme windows to columns programmatically
2011-01-17 8:04 [9fans] assigning acme windows to columns programmatically Joseph Xu
@ 2011-01-18 9:43 ` Sergey Zhilkin
2011-01-18 19:20 ` Arvindh Rajesh Tamilmani
1 sibling, 0 replies; 5+ messages in thread
From: Sergey Zhilkin @ 2011-01-18 9:43 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Its impossible without modification.
On Mon, Jan 17, 2011 at 11:04 AM, Joseph Xu <josephzxu@gmail.com> wrote:
> Hi:
>
> In acme, is it possible to move an existing window into a specific
> column using its control file interface? I have a script that spawns
> several windows every run and I'm getting tired of manually
> rearranging the windows every time.
>
> Joseph
>
>
--
С наилучшими пожеланиями
Жилкин Сергей
With best regards
Zhilkin Sergey
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] assigning acme windows to columns programmatically
2011-01-17 8:04 [9fans] assigning acme windows to columns programmatically Joseph Xu
2011-01-18 9:43 ` Sergey Zhilkin
@ 2011-01-18 19:20 ` Arvindh Rajesh Tamilmani
2011-01-19 8:47 ` Joseph Xu
1 sibling, 1 reply; 5+ messages in thread
From: Arvindh Rajesh Tamilmani @ 2011-01-18 19:20 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
the inferno sh script below shows a rather terrible way to
open a file in a given acme column.
arvindh
#!/dis/sh
load std expr string
usage := 'usage: bcol colnum file'
fn xcmd{
(cwin cmd) := $*
q0 := `{wc -c </mnt/acme/$cwin/tag}
q1 := ${expr $q0 ${len $"cmd} +}
echo -n $cmd > /mnt/acme/$cwin/tag
echo Mx$q0 $q1 > /mnt/acme/$cwin/event
}
if{! ~ $#* 2}{
echo $usage >[1=2]
raise fail:usage
}
(col file) := $*
(d0 d1) := /tmp/bcol ^ (0 1) ^ .${pid}
(cwin _) := `{cat /mnt/acme/new/ctl}
xcmd $cwin (Dump $d0)
{sed 4q $d0
echo f^${padr 11 $col}^' 0 0 0 0 '
echo ' 0 0 0 0 0 ' ^
$file ^
' Del Snarf | Look '
} > $d1
xcmd $cwin (Load $d1)
rm $d0 $d1
echo delete > /mnt/acme/$cwin/ctl
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] assigning acme windows to columns programmatically
2011-01-18 19:20 ` Arvindh Rajesh Tamilmani
@ 2011-01-19 8:47 ` Joseph Xu
2011-01-19 8:49 ` Joseph Xu
0 siblings, 1 reply; 5+ messages in thread
From: Joseph Xu @ 2011-01-19 8:47 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] assigning acme windows to columns programmatically
2011-01-19 8:47 ` Joseph Xu
@ 2011-01-19 8:49 ` Joseph Xu
0 siblings, 0 replies; 5+ messages in thread
From: Joseph Xu @ 2011-01-19 8:49 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
[-- Attachment #1: Type: text/plain, Size: 75 bytes --]
Sorry, pretty sure gmail screwed up that inline patch. Attaching instead.
[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 735 bytes --]
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;
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-19 8:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-17 8:04 [9fans] assigning acme windows to columns programmatically Joseph Xu
2011-01-18 9:43 ` Sergey Zhilkin
2011-01-18 19:20 ` Arvindh Rajesh Tamilmani
2011-01-19 8:47 ` Joseph Xu
2011-01-19 8:49 ` Joseph Xu
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).