summaryrefslogtreecommitdiff
path: root/appl
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2007-06-08 11:35:27 +0000
committerCharles.Forsyth <devnull@localhost>2007-06-08 11:35:27 +0000
commit9f620229775d41f76096d9039c46ff368fd44d47 (patch)
tree7ef2d6be0ef54b41724916cc89d80951e0815ba0 /appl
parent1f44c82a26ff60e012a2ff697cb036a25c0c7f97 (diff)
20070608-1234
Diffstat (limited to 'appl')
-rw-r--r--appl/cmd/mc.b29
1 files changed, 19 insertions, 10 deletions
diff --git a/appl/cmd/mc.b b/appl/cmd/mc.b
index 631c4cc1..5d8f216e 100644
--- a/appl/cmd/mc.b
+++ b/appl/cmd/mc.b
@@ -10,8 +10,6 @@ include "draw.m";
include "bufio.m";
bufio: Bufio;
Iobuf: import bufio;
-include "env.m";
- env: Env;
include "arg.m";
font: ref Font;
@@ -28,10 +26,7 @@ init(ctxt: ref Draw->Context, argv: list of string)
sys = load Sys Sys->PATH;
if((bufio = load Bufio Bufio->PATH) == nil)
fatal("can't load " + Bufio->PATH);
- if((env = load Env Env->PATH) == nil)
- fatal("can't load " + Env->PATH);
- if((draw = load Draw Draw->PATH) == nil)
- fatal("can't load " + Draw->PATH);
+ draw = load Draw Draw->PATH;
if((arg := load Arg Arg->PATH) == nil)
fatal("can't load " + Arg->PATH);
@@ -120,18 +115,20 @@ nexttab(col: int): int
getwidth(ctxt: ref Draw->Context)
{
- if((wid:=env->getenv("acmewin")) == nil)
+ if(ctxt == nil || draw == nil)
return;
- if((fd:=open("/chan/" + wid + "/ctl", ORDWR)) == nil)
+ if((wid := rf("/env/acmewin")) == nil)
+ return;
+ if((fd := open("/chan/" + wid + "/ctl", ORDWR)) == nil)
return;
buf := array[256] of byte;
- if((n:=read(fd, buf, len buf)) <= 0)
+ if((n := read(fd, buf, len buf)) <= 0)
return;
(nf, f) := tokenize(string buf[:n], " ");
if(nf != 8)
return;
f0 := tl tl tl tl tl f;
- if((font=Font.open(ctxt.display, hd tl f0)) == nil)
+ if((font = Font.open(ctxt.display, hd tl f0)) == nil)
return;
tabwid = int hd tl tl f0;
mintab = font.width("0");
@@ -143,3 +140,15 @@ fatal(s: string)
fprint(fildes(2), "mc: %s: %r\n", s);
raise "fail:"+s;
}
+
+rf(f: string): string
+{
+ fd := sys->open(f, Sys->OREAD);
+ if(fd == nil)
+ return nil;
+ b := array[Sys->NAMEMAX] of byte;
+ n := sys->read(fd, b, len b);
+ if(n < 0)
+ return nil;
+ return string b[0:n];
+}