Plan 9 from Bell Labs’s /usr/web/sources/contrib/nemo/octopus/port/mero/omprowcol.b

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


implement Pimpl;
include "sys.m";
	sys: Sys;
	sprint, fprint: import sys;
include "styx.m";
include "styxservers.m";
	Styxserver: import Styxservers;
include "daytime.m";
include "dat.m";
	dat: Dat;
	mnt, evc, Qdir, debug, appl, slash: import dat;
include "string.m";
	str: String;
	splitl: import str;
include "names.m";
	names: Names;
	dirname: import names;
include "error.m";
	err: Error;
	checkload, panic, stderr: import err;
include "tbl.m";
	tbl: Tbl;
	Table: import tbl;
include "mpanel.m";
	Atag, Amax, Panel, Repl, Tappl, Trepl: import Panels;

Aorder, Arow, Aspace: con Amax + iota;

init(d: Dat): list of string
{
	dat = d;
	sys = dat->sys;
	err = dat->err;
	str = dat->str;
	names = dat->names;
	return list of {"row:", "col:"};
}

pinit(p: ref Panel)
{
	p.container = 1;
}

rinit(p: ref Panel, r: ref Repl)
{
	(t, nil) := splitl(p.name, ":");
	rowcol: string;
	case t {
	"row" =>
		rowcol = "row";
	* =>
		rowcol = "col";
	}
	r.attrs[Atag] = "tag";
	attrs := array[] of { "order", rowcol , "space 0"};
	nattrs := array[len r.attrs + len attrs] of string;
	nattrs[0:] = r.attrs;
	nattrs[len r.attrs:] = attrs;
	r.attrs = nattrs;
}

newdata(nil: ref Panels->Panel): string
{
	return "not to a container";
}

space(p: ref Panels->Panel, r: ref Panels->Repl, ctl: list of string): (int, string)
{
	n := int hd tl ctl;
	if (n < 0)
		return (0, "negative space");
	if (r.id == 0){
		r.attrs[Aspace] = sprint("space %d", n);
		for (rn := 0; rn < len p.repl; rn++)
			if ((pr := p.repl[rn]) != nil)
				pr.attrs[Aspace] = r.attrs[Aspace];
		return (1, nil);
	} else
		return (0, "only allowed in application tree");
}

rowcol(p: ref Panels->Panel, r: ref Panels->Repl, ctl: list of string): (int, string)
{
	r.attrs[Arow] = hd ctl;
	if (r.id == 0){
		for (rn := 0; rn < len p.repl; rn++)
			if ((pr := p.repl[rn]) != nil)
				pr.attrs[Arow] = r.attrs[Arow];
		return (1, nil);
	} else
		return (0, nil);
}

ctl(p: ref Panels->Panel, r: ref Panels->Repl, ctl: list of string): (int, string)
{
	case hd ctl {
	"space" =>
		if (len ctl != 2)
			return (0, "1 argument needed");
		return space(p, r, ctl);
	"row" or "col" =>
		if (len ctl != 3)
			return (0, "3 arguments needed");
		return rowcol(p, r, ctl);
	* =>
		# order is handled by the tree, not by us.
		return (0, "not mine");
	}
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].