Support more folding icon styles: arrows, +/- and no lines
[geany-mirror.git] / tagmanager / nestlevel.c
blob1dde656173dc83dc7d3703b04d239b4bcf72fc4d
1 /*
2 * $Id$
4 * Copyright (c) 1999-2002, Darren Hiebert
5 * Copyright 2009-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This source code is released for free distribution under the terms of the
8 * GNU General Public License.
10 * Defines external interface to scope nesting levels for tags.
14 * INCLUDE FILES
16 #include "general.h" /* must always come first */
18 #include "main.h"
19 #include "nestlevel.h"
22 * FUNCTION DEFINITIONS
25 extern NestingLevels *nestingLevelsNew(void)
27 NestingLevels *nls = xCalloc (1, NestingLevels);
28 return nls;
31 extern void nestingLevelsFree(NestingLevels *nls)
33 int i;
34 for (i = 0; i < nls->allocated; i++)
35 vStringDelete(nls->levels[i].name);
36 if (nls->levels) eFree(nls->levels);
37 eFree(nls);
40 extern void nestingLevelsPush(NestingLevels *nls,
41 const vString *name, int type)
43 NestingLevel *nl = NULL;
45 if (nls->n >= nls->allocated)
47 nls->allocated++;
48 nls->levels = xRealloc(nls->levels,
49 nls->allocated, NestingLevel);
50 nls->levels[nls->n].name = vStringNew();
52 nl = &nls->levels[nls->n];
53 nls->n++;
55 vStringCopy(nl->name, name);
56 nl->type = type;
59 extern void nestingLevelsPop(NestingLevels *nls)
61 const NestingLevel *nl = nestingLevelsGetCurrent(nls);
63 Assert (nl != NULL);
64 vStringClear(nl->name);
65 nls->n--;
68 extern NestingLevel *nestingLevelsGetCurrent(NestingLevels *nls)
70 Assert (nls != NULL);
72 if (nls->n < 1)
73 return NULL;
75 return &nls->levels[nls->n - 1];
78 /* vi:set tabstop=4 shiftwidth=4: */