about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authoranselm@anselm1 <unknown>2008-05-19 20:07:12 +0100
committeranselm@anselm1 <unknown>2008-05-19 20:07:12 +0100
commit822101dd5bceadb12351dd5f9084d7745b10ec92 (patch)
treec9ed3b1c3181b4be933c826834688fc510365393
parent6bdef73a4f0c2a96f8984ddc10b55f1d753ab5fe (diff)
downloaddwm-822101dd5bceadb12351dd5f9084d7745b10ec92.tar.gz
merged tile.c again into dwm.c
-rw-r--r--config.def.h4
-rw-r--r--dwm.c101
-rw-r--r--tile.c102
3 files changed, 101 insertions, 106 deletions
diff --git a/config.def.h b/config.def.h
index 0619a9e..63c8c06 100644
--- a/config.def.h
+++ b/config.def.h
@@ -25,12 +25,10 @@ Rule rules[] = {
 double mfact           = 0.55;
 Bool resizehints       = True;     /* False means respect size hints in tiled resizals */
 
-#include "tile.c"
-
 Layout layouts[] = {
 	/* symbol     arrange  geom */
 	{ "[]=",      tile,    updatetilegeom }, /* first entry is default */
-	{ "><>",      NULL,                   }, /* no layout function means floating behavior */
+	{ "><>",      NULL,    NULL           }, /* no layout function means floating behavior */
 };
 
 /* key definitions */
diff --git a/dwm.c b/dwm.c
index 16e04b0..235940e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -53,7 +53,6 @@
 #define MOUSEMASK       (BUTTONMASK|PointerMotionMask)
 
 /* enums */
-enum { BarTop, BarBot, BarOff, BarLast };               /* bar appearance */
 enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
 enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
 enum { NetSupported, NetWMName, NetLast };              /* EWMH atoms */
@@ -165,11 +164,14 @@ void restack(void);
 void run(void);
 void scan(void);
 void setclientstate(Client *c, long state);
+void setmfact(const char *arg);
 void setup(void);
 void spawn(const char *arg);
 void tag(const char *arg);
 unsigned int textnw(const char *text, unsigned int len);
 unsigned int textw(const char *text);
+void tile(void);
+void tileresize(Client *c, int x, int y, int w, int h);
 void togglebar(const char *arg);
 void togglefloating(const char *arg);
 void togglelayout(const char *arg);
@@ -181,6 +183,7 @@ void unmapnotify(XEvent *e);
 void updatebar(void);
 void updategeom(void);
 void updatesizehints(Client *c);
+void updatetilegeom(void);
 void updatetitle(Client *c);
 void updatewmhints(Client *c);
 void view(const char *arg);
@@ -194,6 +197,7 @@ void zoom(const char *arg);
 char stext[256];
 int screen, sx, sy, sw, sh;
 int bx, by, bw, bh, blw, wx, wy, ww, wh;
+int mx, my, mw, mh, tx, ty, tw, th;
 int seltags = 0;
 int (*xerrorxlib)(Display *, XErrorEvent *);
 unsigned int numlockmask = 0;
@@ -1333,6 +1337,24 @@ setclientstate(Client *c, long state) {
 }
 
 void
+setmfact(const char *arg) {
+	double d;
+
+	if(!arg || lt->arrange != tile)
+		return;
+	else {
+		d = strtod(arg, NULL);
+		if(arg[0] == '-' || arg[0] == '+')
+			d += mfact;
+		if(d < 0.1 || d > 0.9)
+			return;
+		mfact = d;
+	}
+	updatetilegeom();
+	arrange();
+}
+
+void
 setup(void) {
 	unsigned int i, w;
 	XSetWindowAttributes wa;
@@ -1467,6 +1489,53 @@ textw(const char *text) {
 }
 
 void
+tile(void) {
+	int x, y, h, w;
+	unsigned int i, n;
+	Client *c;
+
+	for(n = 0, c = nextunfloating(clients); c; c = nextunfloating(c->next), n++);
+	if(n == 0)
+		return;
+
+	/* master */
+	c = nextunfloating(clients);
+
+	if(n == 1)
+		tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
+	else
+		tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
+
+	if(--n == 0)
+		return;
+
+	/* tile stack */
+	x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw;
+	y = ty;
+	w = (tx > c->x + c->w) ? wx + ww - x : tw;
+	h = th / n;
+	if(h < bh)
+		h = th;
+
+	for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) {
+		if(i + 1 == n) /* remainder */
+			tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
+		else
+			tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
+		if(h != th)
+			y = c->y + c->h + 2 * c->bw;
+	}
+}
+
+void
+tileresize(Client *c, int x, int y, int w, int h) {
+	resize(c, x, y, w, h, resizehints);
+	if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
+		/* client doesn't accept size constraints */
+		resize(c, x, y, w, h, False);
+}
+
+void
 togglebar(const char *arg) {
 	showbar = !showbar;
 	updategeom();
@@ -1668,6 +1737,21 @@ updatesizehints(Client *c) {
 }
 
 void
+updatetilegeom(void) {
+	/* master area geometry */
+	mx = wx;
+	my = wy;
+	mw = mfact * ww;
+	mh = wh;
+
+	/* tile area geometry */
+	tx = mx + mw;
+	ty = wy;
+	tw = ww - mw;
+	th = wh;
+}
+
+void
 updatetitle(Client *c) {
 	if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
 		gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
@@ -1733,6 +1817,21 @@ xerrorstart(Display *dpy, XErrorEvent *ee) {
 	return -1;
 }
 
+void
+zoom(const char *arg) {
+	Client *c = sel;
+
+	if(c == nextunfloating(clients))
+		if(!c || !(c = nextunfloating(c->next)))
+			return;
+	if(lt->arrange == tile && !sel->isfloating) {
+		detach(c);
+		attach(c);
+		focus(c);
+	}
+	arrange();
+}
+
 int
 main(int argc, char *argv[]) {
 	if(argc == 2 && !strcmp("-v", argv[1]))
diff --git a/tile.c b/tile.c
deleted file mode 100644
index 8269676..0000000
--- a/tile.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-int bx, by, bw, bh, blw, mx, my, mw, mh, tx, ty, tw, th, wx, wy, ww, wh;
-
-void setmfact(const char *arg);
-void tile(void);
-void tileresize(Client *c, int x, int y, int w, int h);
-void updatetilegeom(void);
-
-void
-setmfact(const char *arg) {
-	double d;
-
-	if(!arg || lt->arrange != tile)
-		return;
-	else {
-		d = strtod(arg, NULL);
-		if(arg[0] == '-' || arg[0] == '+')
-			d += mfact;
-		if(d < 0.1 || d > 0.9)
-			return;
-		mfact = d;
-	}
-	updatetilegeom();
-	arrange();
-}
-
-void
-tile(void) {
-	int x, y, h, w;
-	unsigned int i, n;
-	Client *c;
-
-	for(n = 0, c = nextunfloating(clients); c; c = nextunfloating(c->next), n++);
-	if(n == 0)
-		return;
-
-	/* master */
-	c = nextunfloating(clients);
-
-	if(n == 1)
-		tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
-	else
-		tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
-
-	if(--n == 0)
-		return;
-
-	/* tile stack */
-	x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw;
-	y = ty;
-	w = (tx > c->x + c->w) ? wx + ww - x : tw;
-	h = th / n;
-	if(h < bh)
-		h = th;
-
-	for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) {
-		if(i + 1 == n) /* remainder */
-			tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
-		else
-			tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
-		if(h != th)
-			y = c->y + c->h + 2 * c->bw;
-	}
-}
-
-void
-tileresize(Client *c, int x, int y, int w, int h) {
-	resize(c, x, y, w, h, resizehints);
-	if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
-		/* client doesn't accept size constraints */
-		resize(c, x, y, w, h, False);
-}
-
-void
-zoom(const char *arg) {
-	Client *c = sel;
-
-	if(c == nextunfloating(clients))
-		if(!c || !(c = nextunfloating(c->next)))
-			return;
-	if(lt->arrange == tile && !sel->isfloating) {
-		detach(c);
-		attach(c);
-		focus(c);
-	}
-	arrange();
-}
-
-void
-updatetilegeom(void) {
-	/* master area geometry */
-	mx = wx;
-	my = wy;
-	mw = mfact * ww;
-	mh = wh;
-
-	/* tile area geometry */
-	tx = mx + mw;
-	ty = wy;
-	tw = ww - mw;
-	th = wh;
-}
#fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - edit/010-warnings.mu</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v1">
<meta name="syntax" content="none">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 1.05em; }
.muRecipe { color: #ff8700; }
.muData { color: #ffff00; }
.Special { color: #ff6060; }
.muScenario { color: #00af00; }
.Comment { color: #9090ff; }
.Constant { color: #00a0a0; }
.SalientComment { color: #00ffff; }
.Delimiter { color: #a04060; }
.muControl { color: #c0a020; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="SalientComment">## handling malformed programs</span>

<span class="muData">container</span> programming-environment-data [
  recipe-warnings:address:array:character
]

<span class="Comment"># copy code from recipe editor, persist, load into mu, save any warnings</span>
<span class="muRecipe">recipe!</span> update-recipes [
  <span class="Constant">local-scope</span>
  env:address:programming-environment-data<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  recipes:address:editor-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span>
  in:address:array:character<span class="Special"> &lt;- </span>editor-contents recipes
  save <span class="Constant">[recipes.mu]</span>, in
  recipe-warnings:address:address:array:character<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">recipe-warnings:offset</span>
  *recipe-warnings<span class="Special"> &lt;- </span>reload in
  <span class="Comment"># if recipe editor has errors, stop</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> *recipe-warnings
    status:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[errors found]</span>
    update-status screen, status, <span class="Constant">1/red</span>
    <span class="muControl">reply</span> <span class="Constant">1/errors-found</span>, env/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>
  <span class="Delimiter">}</span>
  <span class="muControl">reply</span> <span class="Constant">0/no-errors-found</span>, env/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>
]

<span class="muRecipe">before</span> <span class="Constant">&lt;render-components-end&gt;</span> [
  trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render status]</span>
  recipe-warnings:address:array:character<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipe-warnings:offset</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> recipe-warnings
    status:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[errors found]</span>
    update-status screen, status, <span class="Constant">1/red</span>
  <span class="Delimiter">}</span>
]

<span class="muRecipe">before</span> <span class="Constant">&lt;render-recipe-components-end&gt;</span> [
  <span class="Delimiter">{</span>
    recipe-warnings:address:array:character<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipe-warnings:offset</span>
    <span class="muControl">break-unless</span> recipe-warnings
    row, screen<span class="Special"> &lt;- </span>render-string screen, recipe-warnings, left, right, <span class="Constant">1/red</span>, row
  <span class="Delimiter">}</span>
]

<span class="muData">container</span> sandbox-data [
  warnings:address:array:character
]

<span class="muRecipe">recipe!</span> update-sandbox [
  <span class="Constant">local-scope</span>
  sandbox:address:sandbox-data<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  data:address:array:character<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span>
  response:address:address:array:character<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">response:offset</span>
  warnings:address:address:array:character<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">warnings:offset</span>
  trace:address:address:array:character<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">trace:offset</span>
  fake-screen:address:address:screen<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">screen:offset</span>
  *response, *warnings, *fake-screen, *trace, completed?:boolean<span class="Special"> &lt;- </span>run-interactive data
  <span class="Delimiter">{</span>
    <span class="muControl">break-if</span> *warnings
    <span class="muControl">break-if</span> completed?:boolean
    *warnings<span class="Special"> &lt;- </span>new <span class="Constant">[took too long!</span>
<span class="Constant">]</span>
  <span class="Delimiter">}</span>
]

<span class="muRecipe">after</span> <span class="Constant">&lt;render-sandbox-results&gt;</span> [
  <span class="Delimiter">{</span>
    sandbox-warnings:address:array:character<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">warnings:offset</span>
    <span class="muControl">break-unless</span> sandbox-warnings
    *response-starting-row<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># no response</span>
    row, screen<span class="Special"> &lt;- </span>render-string screen, sandbox-warnings, left, right, <span class="Constant">1/red</span>, row
    <span class="muControl">jump</span> <span class="Constant">+render-sandbox-end:label</span>
  <span class="Delimiter">}</span>
]

<span class="muScenario">scenario</span> run-shows-warnings-in-get [
  $close-trace  <span class="Comment"># trace too long</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
<span class="Constant">recipe foo [</span>
<span class="Constant">  get 123:number, foo:offset</span>
<span class="Constant">]</span>]
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  screen-should-contain [
   <span class="Constant"> .  errors found                                                                   run (F4)           .</span>
   <span class="Constant"> .                                                  ┊foo                                              .</span>
   <span class="Constant"> .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .  get 123:number, foo:offset                      ┊                                                 .</span>
   <span class="Constant"> .]                                                 ┊                                                 .</span>
   <span class="Constant"> .unknown element foo in container number           ┊                                                 .</span>
   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
  screen-should-contain-in-color <span class="Constant">1/red</span>, [
   <span class="Constant"> .  errors found                                                                                      .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .unknown element foo in container number                                                             .</span>
   <span class="Constant"> .                                                                                                    .</span>
  ]
]

<span class="muScenario">scenario</span> run-shows-missing-type-warnings [
  $close-trace  <span class="Comment"># trace too long</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
<span class="Constant">recipe foo [</span>
<span class="Constant">  x &lt;- copy 0</span>
<span class="Constant">]</span>]
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  screen-should-contain [
   <span class="Constant"> .  errors found                                                                   run (F4)           .</span>
   <span class="Constant"> .                                                  ┊foo                                              .</span>
   <span class="Constant"> .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .  x &lt;- copy 0                                     ┊                                                 .</span>
   <span class="Constant"> .]                                                 ┊                                                 .</span>
   <span class="Constant"> .missing type in 'x &lt;- copy 0'                     ┊                                                 .</span>
   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
]

<span class="muScenario">scenario</span> run-shows-unbalanced-bracket-warnings [
  $close-trace  <span class="Comment"># trace too long</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span>
  <span class="Comment"># recipe is incomplete (unbalanced '[')</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
<span class="Constant">recipe foo «</span>
<span class="Constant">  x &lt;- copy 0</span>
<span class="Constant">]</span>
  string-replace <span class="Constant">1</span>:address:array:character, <span class="Constant">171/«</span>, <span class="Constant">91</span>  <span class="Comment"># '['</span>
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  screen-should-contain [
   <span class="Constant"> .  errors found                                                                   run (F4)           .</span>
   <span class="Constant"> .                                                  ┊foo                                              .</span>
   <span class="Constant"> .recipe foo \\\[                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .  x &lt;- copy 0                                     ┊                                                 .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
   <span class="Constant"> .9: unbalanced '\\\[' for recipe                      ┊                                                 .</span>
   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
]

<span class="muScenario">scenario</span> run-shows-get-on-non-container-warnings [
  $close-trace  <span class="Comment"># trace too long</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
<span class="Constant">recipe foo [</span>
<span class="Constant">  x:address:point &lt;- new point:type</span>
<span class="Constant">  get x:address:point, 1:offset</span>
<span class="Constant">]</span>]
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  screen-should-contain [
   <span class="Constant"> .                                                                                 run (F4)           .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
   <span class="Constant"> .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .  x:address:point &lt;- new point:type               ┊                                                x.</span>
   <span class="Constant"> .  get x:address:point, 1:offset                   ┊foo                                              .</span>
   <span class="Constant"> .]                                                 ┊foo: first ingredient of 'get' should be a conta↩.</span>
   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊iner, but got x:address:point                    .</span>
   <span class="Constant"> .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
]

<span class="muScenario">scenario</span> run-shows-non-literal-get-argument-warnings [
  $close-trace  <span class="Comment"># trace too long</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
<span class="Constant">recipe foo [</span>
<span class="Constant">  x:number &lt;- copy 0</span>
<span class="Constant">  y:address:point &lt;- new point:type</span>
<span class="Constant">  get *y:address:point, x:number</span>
<span class="Constant">]</span>]
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  screen-should-contain [
   <span class="Constant"> .  errors found                                                                   run (F4)           .</span>
   <span class="Constant"> .                                                  ┊foo                                              .</span>
   <span class="Constant"> .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .  x:number &lt;- copy 0                              ┊                                                 .</span>
   <span class="Constant"> .  y:address:point &lt;- new point:type               ┊                                                 .</span>
   <span class="Constant"> .  get *y:address:point, x:number                  ┊                                                 .</span>
   <span class="Constant"> .]                                                 ┊                                                 .</span>
   <span class="Constant"> .foo: expected ingredient 1 of 'get' to have type ↩┊                                                 .</span>
   <span class="Constant"> .'offset'; got x:number                            ┊                                                 .</span>
   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
]

<span class="muScenario">scenario</span> run-shows-warnings-everytime [
  $close-trace  <span class="Comment"># trace too long</span>
  <span class="Comment"># try to run a file with an error</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
<span class="Constant">recipe foo [</span>
<span class="Constant">  x:number &lt;- copy y:number</span>
<span class="Constant">]</span>]
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  screen-should-contain [
   <span class="Constant"> .  errors found                                                                   run (F4)           .</span>
   <span class="Constant"> .                                                  ┊foo                                              .</span>
   <span class="Constant"> .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .  x:number &lt;- copy y:number                       ┊                                                 .</span>
   <span class="Constant"> .]                                                 ┊                                                 .</span>
   <span class="Constant"> .use before set: y in foo                          ┊                                                 .</span>
   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
  <span class="Comment"># rerun the file, check for the same error</span>
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  screen-should-contain [
   <span class="Constant"> .  errors found                                                                   run (F4)           .</span>
   <span class="Constant"> .                                                  ┊foo                                              .</span>
   <span class="Constant"> .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .  x:number &lt;- copy y:number                       ┊                                                 .</span>
   <span class="Constant"> .]                                                 ┊                                                 .</span>
   <span class="Constant"> .use before set: y in foo                          ┊                                                 .</span>
   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
]

<span class="muScenario">scenario</span> run-instruction-and-print-warnings [
  $close-trace  <span class="Comment"># trace too long</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span>
  <span class="Comment"># left editor is empty</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
  <span class="Comment"># right editor contains an illegal instruction</span>
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[get 1234:number, foo:offset]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  <span class="Comment"># run the code in the editors</span>
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  <span class="Comment"># check that screen prints error message in red</span>
  screen-should-contain [
   <span class="Constant"> .                                                                                 run (F4)           .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .                                                  ┊                                                x.</span>
   <span class="Constant"> .                                                  ┊get 1234:number, foo:offset                      .</span>
   <span class="Constant"> .                                                  ┊unknown element foo in container number          .</span>
   <span class="Constant"> .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
  screen-should-contain-in-color <span class="Constant">7/white</span>, [
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                   get 1234:number, foo:offset                      .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
  ]
  screen-should-contain-in-color <span class="Constant">1/red</span>, [
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                   unknown element foo in container number          .</span>
   <span class="Constant"> .                                                                                                    .</span>
  ]
  screen-should-contain-in-color <span class="Constant">245/grey</span>, [
   <span class="Constant"> .                                                                                                    .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .                                                  ┊                                                x.</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
   <span class="Constant"> .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
]

<span class="muScenario">scenario</span> run-instruction-and-print-warnings-only-once [
  $close-trace  <span class="Comment"># trace too long</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span>
  <span class="Comment"># left editor is empty</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
  <span class="Comment"># right editor contains an illegal instruction</span>
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[get 1234:number, foo:offset]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  <span class="Comment"># run the code in the editors multiple times</span>
  assume-console [
    press F4
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  <span class="Comment"># check that screen prints error message just once</span>
  screen-should-contain [
   <span class="Constant"> .                                                                                 run (F4)           .</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .                                                  ┊                                                x.</span>
   <span class="Constant"> .                                                  ┊get 1234:number, foo:offset                      .</span>
   <span class="Constant"> .                                                  ┊unknown element foo in container number          .</span>
   <span class="Constant"> .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
]

<span class="muScenario">scenario</span> sandbox-can-handle-infinite-loop [
  $close-trace  <span class="Comment"># trace too long</span>
  assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span>
  <span class="Comment"># left editor is empty</span>
  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[recipe foo [</span>
<span class="Constant">  {</span>
<span class="Constant">    loop</span>
<span class="Constant">  }</span>
<span class="Constant">]</span>]
  <span class="Comment"># right editor contains an instruction</span>
  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
  <span class="Comment"># run the sandbox</span>
  assume-console [
    press F4
  ]
  run [
    event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data
  ]
  screen-should-contain [
   <span class="Constant"> .                                                                                 run (F4)           .</span>
   <span class="Constant"> .recipe foo [                                      ┊                                                 .</span>
   <span class="Constant"> .  {                                               ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .    loop                                          ┊                                                x.</span>
   <span class="Constant"> .  }                                               ┊foo                                              .</span>
   <span class="Constant"> .]                                                 ┊took too long!                                   .</span>
<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
   <span class="Constant"> .                                                  ┊                                                 .</span>
  ]
]
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->