This file is indexed.

/usr/share/nickle/nichrome-box.5c is in cairo-5c 1.4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
/*
 * Copyright © 2008 Keith Packard
 *
 * This library is free software; you can redistribute it and/or
 * modify it either under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation
 * (the "LGPL") or, at your option, under the terms of the Mozilla
 * Public License Version 1.1 (the "MPL"). If you do not alter this
 * notice, a recipient may use your version of this file under either
 * the MPL or the LGPL.
 *
 * You should have received a copy of the LGPL along with this library
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * You should have received a copy of the MPL along with this library
 * in the file COPYING-MPL-1.1
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
 * the specific language governing rights and limitations.
 *
 * The Original Code is the cairo graphics library.
 *
 * The Initial Developer of the Original Code is Keith Packard
 *
 * Contributor(s):
 *      Keith Packard <keithp@keithp.com>
 */
autoload Nichrome;

extend namespace Nichrome {
    public namespace Box {

	protected typedef enum { horizontal, vertical } dir_t;

	public typedef box_t;

	protected typedef contained_t + struct {
	} glue_t;

	protected exception unknown_contained (&box_t box,
					       &contained_t contained);

	/*
	 * Each item in the layout has a natural size and stretch factor
	 */
	protected typedef struct {
	    real	natural_width;
	    real	natural_height;
	    real	stretch_width;
	    real	stretch_height;
	} layout_t;

	typedef void (&contained_t item, &layout_t layout) query_t;

	typedef void (&contained_t  item,
		      layout_t	    layout,
		      rect_t	    geometry) configure_t;

	protected typedef struct {
	    &contained_t    contained;
	    layout_t	    layout;
	    query_t	    query;
	    configure_t	    configure;
	} item_t;

	public typedef container_t + contained_t + struct {
	    dir_t	    dir;
	    item_t[...]	    items;
	} box_t;

	container_t no_container;

	/*
	 * contained layout has changed, get the new layout
	 * and notify our container that our layout has also
	 * changed
	 */
	void box_resize (&box_t box, &contained_t contained) {
	    for (int i = 0; i < dim (box.items); i++) {
		&item_t	item = &box.items[i];
		if (&item.contained == &contained) {
		    if (!is_uninit (&item.query))
			item.query (&item.contained, &item.layout);
		    break;
		}
	    }
	    if (&box.container == &no_container)
		box.nichrome.resize = true;
	    else
		box.container.resize (&box.container, &box);
	}

	/*
	 * Construct a new box, computing the layout of the inserted items
	 */
	protected *box_t new (dir_t dir, item_t items...) {
	    &box_t  box = &(box_t) {
		container = &no_container,
		resize = box_resize,
		dir = dir,
		items = items
	    };
	    for (int i = 0; i < dim (items); i++)
	    {
		&item_t	item = &box.items[i];
		&item.contained.container = &box;
		if (!is_uninit (&item.query))
		    item.query (&item.contained, &item.layout);
	    }
	    return &box;
	}

	/*
	 * Allow stretch to be specified as one or two numbers
	 */
	void get_stretches (&real[*] stretch,
			    &real stretch_width,
			    &real stretch_height) {
	    switch (dim (stretch)) {
	    case 0:
		stretch_width = stretch_height = 1;
		break;
	    case 1:
		stretch_width = stretch_height = stretch[0];
		break;
	    default:
		stretch_width = stretch[0];
		stretch_height= stretch[1];
		break;
	    }
	}

	/*
	 * Handle containeds inside of boxes
	 */

	/* find the natural bounding box of a contained */
	rect_t contained_rect (&contained_t contained) {
	    cairo_t cr = cairo (&contained.nichrome);
	    contained.natural (cr, &contained);
	    rect_t r = fill_extents (cr);
	    Cairo::destroy (cr);
	    return r;
	}

	/*
	 * Widget layout follows natural size
	 */
	void contained_query (&contained_t contained, &layout_t layout) {
	    rect_t  natural = contained_rect (&contained);
	    layout.natural_width = natural.width;
	    layout.natural_height = natural.height;
	}

	/*
	 * Set the geometry of the contained
	 */
	void contained_configure (&contained_t contained,
				  layout_t layout,
				  rect_t geometry)
	{
	    contained.configure (&contained, geometry);
	}

	/*
	 * Construct a new contained item for a box
	 */
	protected item_t contained_item (&contained_t contained, real stretch...)
	{
	    get_stretches (&stretch,
			   &(real stretch_width), &(real stretch_height));
	    return (item_t) {
		layout = {
		    stretch_width = stretch_width,
		    stretch_height = stretch_height
		},
		query = contained_query,
		configure = contained_configure,
		contained = &contained
	    };
	}
	protected item_t widget_item (&contained_t contained, real stretch...){
	    return contained_item (&contained, stretch...);
	}

	/*
	 * Boxes inside of boxes
	 */

	/*
	 * Compute the layout for this box by
	 * walking through the items in the box
	 */
	protected void query (&box_t box, &layout_t layout) {
	    layout.natural_width = 0;
	    layout.natural_height = 0;
	    if (box.dir == dir_t.horizontal) {
		layout.stretch_width = 0;
		layout.stretch_height = 10000;
	    } else {
		layout.stretch_width = 10000;
		layout.stretch_height = 0;
	    }

	    for (int i = 0; i < dim (box.items); i++)
	    {
		&layout_t child = &box.items[i].layout;

		if (box.dir == dir_t.horizontal) {
		    layout.natural_width += child.natural_width;
		    layout.stretch_width += child.stretch_width;
		    if (child.natural_height > layout.natural_height)
			layout.natural_height = child.natural_height;
		    if (child.stretch_height < layout.stretch_height)
			layout.stretch_height = child.stretch_height;
		} else {
		    layout.natural_height += child.natural_height;
		    layout.stretch_height += child.stretch_height;
		    if (child.natural_width > layout.natural_width)
			layout.natural_width = child.natural_width;
		    if (child.stretch_width < layout.stretch_width)
			layout.stretch_width = child.stretch_width;
		}
	    }
	}

	/*
	 * Configure a box
	 */
	protected void configure (&box_t box, layout_t layout, rect_t geometry) {
	    real    actual;
	    real    stretch;
	    real    pref;
	    real    pos;

	    if (box.dir == dir_t.horizontal) {
		stretch = layout.stretch_width;
		actual = geometry.width;
		pref = layout.natural_width;
		pos = geometry.x;
	    } else {
		stretch = layout.stretch_height;
		actual = geometry.height;
		pref = layout.natural_height;
		pos = geometry.y;
	    }
	    if (stretch == 0) stretch = 1;

	    real delta = (real delta_remain) = actual - pref;

	    for (int i = 0; i < dim (box.items); i++) {
		&item_t	    item = &box.items[i];
		&layout_t   child_layout = &item.layout;
		real	    delta_this;

		if (i == dim (box.items) - 1)
		    delta_this = delta_remain;
		else {
		    real stretch_this;

		    if (box.dir == dir_t.horizontal)
			stretch_this = child_layout.stretch_width;
		    else
			stretch_this = child_layout.stretch_height;
		    delta_this = delta * stretch_this / stretch;
		}
		if (delta_remain < 0) {
		    if (delta_this < delta_remain)
			delta_this = delta_remain;
		} else {
		    if (delta_this > delta_remain)
			delta_this = delta_remain;
		}
		delta_remain -= delta_this;

		rect_t child_geometry;

		if (box.dir == dir_t.horizontal) {
		    child_geometry = (rect_t) {
			x = pos,
			y = geometry.y,
			width = child_layout.natural_width + delta_this,
			height = geometry.height
		    };
		    pos = pos + child_geometry.width;
		} else {
		    child_geometry = (rect_t) {
			x = geometry.x,
			y = pos,
			width = geometry.width,
			height = child_layout.natural_height + delta_this,
		    };
		    pos = pos + child_geometry.height;
		}

		if (!is_uninit (&item.configure))
		    item.configure (&item.contained,
				    child_layout, child_geometry);
	    }
	}

	protected item_t box_item (&box_t box)
	{
	    return (item_t) {
		contained = &box,
		query = query,
		configure = configure,
	    };
	}

	/*
	 * Glue in boxes
	 */

	/* 
	 * Once the glue is placed in a box, reset the perpendicular
	 * layout values to effectively ignore the glue in that
	 * direction
	 */
	void glue_query (&glue_t glue, &layout_t layout) {
	    &box_t  box = &glue.container;
	    if (box.dir == dir_t.horizontal) {
		layout.natural_height = 0;
		layout.stretch_height = 10000;
	    } else {
		layout.natural_width = 0;
		layout.stretch_width = 10000;
	    }
	}

	/*
	 * Allow applications to specify size and stretch, just stretch
	 * or neither
	 */
	void get_glue (&real[*] param, &real size, &real stretch) {
	    switch (dim (param)) {
	    case 0:
		size = 0;
		stretch = 1;
		break;
	    case 1:
		size = 0;
		stretch = param[0];
		break;
	    default:
		size = param[0];
		stretch = param[1];
		break;
	    }
	}

	protected item_t glue_item (real param...)
	{
	    get_glue (&param, &(real size), &(real stretch));
	    return (item_t) {
		contained = &(glue_t) { },
		layout = {
		    natural_width = size,
		    natural_height = size,
		    stretch_width = stretch,
		    stretch_height = stretch
		},
		query = glue_query,
	    };
	}

	/*
	 * Add an arbitrary item to a box, filling
	 * in the layout
	 */
	protected void add_item (&box_t box, item_t item)
	{
	    &item_t new = &box.items[dim(box.items)];

	    new = item;
	    &new.contained.container = &box;
	    if (!is_uninit (&new.query))
		new.query (&new.contained, &new.layout);
	    box.resize (&box, &new.contained);
	}

	protected void add_contained (&box_t box,
				&contained_t contained,
				real stretch_width,
				real stretch_height)
	{
	    add_item (&box,
		      contained_item (&contained, stretch_width, stretch_height));
	}

	protected void add_box (&box_t box,
			     &box_t add)
	{
	    add_item (&box, box_item (&add));
	}

	protected void add_glue (&box_t box,
			      real param ...)
	{
	    get_glue (&param, &(real size), &(real stretch));
	    add_item (&box, glue_item (size, stretch));
	}
    }

    /*
     * When the top level geometry manager is a box,
     * set the nichrome configure function to relayout
     * the box
     */
    void configure (&nichrome_t nichrome, &Box::box_t box)
    {
	cairo_t cr = cairo (&nichrome);

	rect_t	geometry = {
	    x = 0,
	    y = 0,
	    width = width (cr),
	    height = height (cr)
	};
	Cairo::destroy (cr);

	/*
	 * Get box preferred size
	 */
	Box::layout_t	layout;
	Box::query (&box, &layout);

	/*
	 * Layout box
	 */
	Box::configure (&box, layout, geometry);
    }

    public void set_box (&nichrome_t nichrome, &Box::box_t box)
    {
	&box.nichrome = &nichrome;
	Nichrome::configure (&nichrome, &box);
	nichrome.configure = void func (&nichrome_t nichrome) {
	    Nichrome::configure (&nichrome, &box);
	};
    }
}