console/libgnt/gntutils.c

Mon, 14 Aug 2006 02:16:58 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Mon, 14 Aug 2006 02:16:58 +0000
changeset 14169
90d1d4697e23
parent 14122
daf2aaa61829
child 14373
609c902d20f5
permissions
-rw-r--r--

[gaim-migrate @ 16741]
Show little scroll-arrows for trees and textviews when appropriate.

#include "gntutils.h"

void gnt_util_get_text_bound(const char *text, int *width, int *height)
{
	const char *s = text, *last;
	int count = 1, max = 0;
	int len;

	/* XXX: ew ... everyone look away */
	last = s;
	if (s)
	{
		while (*s)
		{
			if (*s == '\n' || *s == '\r')
			{
				count++;
				len = g_utf8_pointer_to_offset(last, s);
				if (max < len)
					max = len;
				last = s + 1;
			}
			s++;
		}

		len = g_utf8_pointer_to_offset(last, s);
		if (max < len)
			max = len;
	}

	if (height)
		*height = count;
	if (width)
		*width = max + (count > 1);
}

mercurial