Esempio n. 1
0
static inline void
format_this (unsigned char *t, off_t size, long indent, gboolean utf8)
{
    off_t q = 0, ww;

    strip_newlines (t, size);
    ww = option_word_wrap_line_length * FONT_MEAN_WIDTH - indent;
    if (ww < FONT_MEAN_WIDTH * 2)
        ww = FONT_MEAN_WIDTH * 2;

    while (TRUE)
    {
        off_t p;

        q = line_pixel_length (t, q, ww, utf8);
        if (q > size)
            break;
        if (t[q] == '\n')
            break;
        p = word_start (t, q, size);
        if (p == -1)
            q = next_word_start (t, q, size);   /* Return the end of the word if the beginning
                                                   of the word is at the beginning of a line
                                                   (i.e. a very long word) */
        else
            q = p;
        if (q == -1)            /* end of paragraph */
            break;
        if (q != 0)
            t[q - 1] = '\n';
    }
}
Esempio n. 2
0
/* replaces ' ' with '\n' to properly format a paragraph */
static void format_this (unsigned char *t, int size, int indent)
{
    int q = 0, ww;
    strip_newlines (t, size);
    ww = option_word_wrap_line_length * FONT_MEAN_WIDTH - indent;
    if (ww < FONT_MEAN_WIDTH * 2)
	ww = FONT_MEAN_WIDTH * 2;
    for (;;) {
	int p;
	q = line_pixel_length (t, q, ww);
	if (q > size)
	    break;
	if (t[q] == '\n')
	    break;
	p = word_start (t, q, size);
	if (p == -1)
	    q = next_word_start (t, q, size);	/* Return the end of the word if the beginning
						   of the word is at the beginning of a line
						   (i.e. a very long word) */
	else
	    q = p;
	if (q == -1)	/* end of paragraph */
	    break;
	if (q)
	    t[q - 1] = '\n';
    }
}
Esempio n. 3
0
bool
ok_name(const char *name)
{
    return (name
            && *name
            && *name != LOOKUP_TOKEN
            && *name != REGISTERED_TOKEN
            && *name != NUMBER_TOKEN && !index(name, ARG_DELIMITER)
/*	    && !index(name, AND_TOKEN) */
            && !index(name, OR_TOKEN)
            && !index(name, '^')
            && !index(name, '\r')
            && !index(name, '\n')
            && !word_start(name, NOT_TOKEN)
            && string_compare(name, "me")
/*	    && string_compare(name, "home") */
            && string_compare(name, "here"));
}
Esempio n. 4
0
int
ok_name(const char *name)
{
	return (name
			&& *name
			&& *name != LOOKUP_TOKEN
			&& *name != REGISTERED_TOKEN
			&& *name != NUMBER_TOKEN
			&& !index(name, ARG_DELIMITER)
			&& !index(name, AND_TOKEN)
			&& !index(name, OR_TOKEN)
			&& !index(name, '\r')
			&& !index(name, ESCAPE_CHAR)
			&& !word_start(name, NOT_TOKEN)
			&& string_compare(name, "me")
			&& string_compare(name, "home")
			&& string_compare(name, "here")
			&& (
				!*tp_reserved_names ||
				!equalstr((char*)tp_reserved_names, (char*)name)
			));
}