Example #1
0
void
pageclose(Page *p)
{
	Page *c, *nc;

	if(p == selpage)
		selpage = nil;
	pageabort(p);
	closeimages(p);
	urlfree(p->url);
	p->url = nil;
	if(p->doc){
		freedocinfo(p->doc);
		p->doc = nil;
	}
	layfree(p->lay);
	p->lay = nil;
	freeitems(p->items);
	p->items = nil;
	for(c=p->child; c!=nil; c=nc){
		nc = c->next;
		pageclose(c);
		free(c);
	}
	p->child = nil;
	closerunestr(&p->title);
	closerunestr(&p->refresh.rs);
	p->refresh.t = 0;
	p->pos = ZP;
	p->top = ZP;
	p->bot = ZP;
	p->loading = p->aborting = FALSE;
}
Example #2
0
void
freeurlwin(URLwin *u)
{
	freeitems(u->items);
	u->items = nil;
	freedocinfo(u->docinfo);
	u->docinfo = nil;
	free(u);
}
Example #3
0
static
void
fixtext1(Item **list)
{
    Itext *text, *ntext;
    Item *it, *prev;
    Rune *s, *s1, *s2;
    int n;

    if(*list == nil)
        return;

    prev = nil;
    for(it=*list; it!=nil; it=prev->next) {
        if(it->tag!=Itexttag || forceitem(it))
            goto Continue;

        text = (Itext *)it;
        s = text->s;
        while(*s && isspacerune(*s))
            s++;
        if(!*s) {
            if(prev == nil)
                prev = *list = it->next;
            else
                prev->next = it->next;

            it->next = nil;
            freeitems(it);
            if(prev == nil)
                return;
            continue;
        }
        n = 0;
        while(s[n] && !isspacerune(s[n]))
            n++;

        if(!s[n])
            goto Continue;

        s1 = runemalloc(n+1);
        s1 = runemove(s1, s, n);
        s1[n] = L'\0';
        s += n;

        while(*s && isspacerune(*s))
            s++;

        if(*s) {
            n = runestrlen(s);
            s2 = runemalloc(n+1);
            runemove(s2, s, n);
            s2[n] = L'\0';
            ntext = emalloc(sizeof(Itext));
            ntext->s = s2;
            ntext->ascent = text->ascent;
            ntext->anchorid = text->anchorid;
            ntext->state = text->state&~(IFbrk|IFbrksp|IFnobrk|IFcleft|IFcright);
            ntext->tag = text->tag;
            ntext->fnt = text->fnt;
            ntext->fg = text->fg;
            ntext->ul = text->ul;
            ntext->next = (Item *)text->next;
            text->next = (Item *)ntext;
        }
        free(text->s);
        text->s = s1;
Continue:
        prev = it;
    }
}