Esempio n. 1
0
static void	print_cases(int tx, int ty, int c)
{
    if (c == 0)
        put_color(tx, ty, 53, " ");
    else
        put_color(tx, ty, c, " ");
}
Esempio n. 2
0
QString TextParser::parse(const char *msg)
{
    Buffer b;
    b.pack(msg, strlen(msg));
    for (;;) {
        string part;
        if (!b.scan("\x1B\x5B", part))
            break;
        addText(part.c_str(), part.length());

        if (!b.scan("m", part))
            break;
        if (part.empty())
            continue;
        if (part[0] == 'x') {
            unsigned code = atol(part.c_str() + 1);
            switch (code) {
            case 1:
            case 2:
            case 4:
                setState(code, false);
                break;
            }
            continue;
        }
        if (part[0] == '#') {
            put_color(strtoul(part.c_str() + 1, NULL, 16));
            continue;
        }
        unsigned code = atol(part.c_str());
        switch (code) {
        case 1:
        case 2:
        case 4:
            setState(code, true);
            break;
        default:
            if ((code >= 30) && (code < 40))
                put_color(esc_colors[code - 30]);
        }
    }
    addText(b.data(b.readPos()), b.writePos() - b.readPos());
    while (!m_tags.empty()) {
        m_text += m_tags.top().close_tag();
        m_tags.pop();
    }
    string s;
    if (!m_text.isEmpty())
        s = m_text.local8Bit();
    return m_text;
}
Esempio n. 3
0
static void	*draw_worker(void *p)
{
	t_data_thread	*dt;

	dt = (t_data_thread *)p;
	pthread_mutex_lock(&dt->frac_mutex);
	dt->f->p.y = 0;
	while (dt->f->p.x < dt->end)
	{
		while (dt->f->p.y < HEIGHT)
		{
			chose_frac(dt->f);
			while ((dt->f->z_r * dt->f->z_r) + (SQRT(dt->f->z_i)) <
					4 && dt->f->i < dt->f->iter_max)
			{
				dt->f->tmp = dt->f->z_r;
				choose_z(dt->f);
				dt->f->i++;
			}
			put_color(dt->f, dt->img);
			dt->f->p.y++;
		}
		dt->f->p.y = 0;
		dt->f->p.x++;
	}
	pthread_mutex_unlock(&dt->frac_mutex);
	return (NULL);
}
Esempio n. 4
0
/* print_with_color():
 */
void
print_with_color(const Char *filename, size_t len, Char suffix)
{
    if (color_context_lsmF &&
	(haderr ? (didfds ? is2atty : isdiagatty) :
	 (didfds ? is1atty : isoutatty))) {
	print_color(filename, len, suffix);
	xprintf("%S", filename);
	if (0 < variables[VEnd].color.len)
	    put_color(&variables[VEnd].color);
	else {
	    put_color(&variables[VLeft].color);
	    put_color(&variables[VNormal].color);
	    put_color(&variables[VRight].color);
	}
    }
    else
	xprintf("%S", filename);
    xputwchar(suffix);
}
Esempio n. 5
0
/* print_color():
 */
static void
print_color(const Char *fname, size_t len, Char suffix)
{
    size_t  i;
    char   *filename = short2str(fname);
    char   *last = filename + len;
    Str	   *color = &variables[VFile].color;

    switch (suffix) {
    case '>':			/* File is a symbolic link pointing to
				 * a directory */
	color = &variables[VDir].color;
	break;
    case '+':			/* File is a hidden directory [aix] or
				 * context dependent [hpux] */
    case ':':			/* File is network special [hpux] */
	break;
    default:
	for (i = 0; i < nvariables; i++)
	    if (variables[i].suffix != NOS &&
		(Char)variables[i].suffix == suffix) {
		color = &variables[i].color;
		break;
	    }
	if (i == nvariables) {
	    for (i = 0; i < nextensions; i++)
		if (len >= extensions[i].extension.len
		    && strncmp(last - extensions[i].extension.len,
			       extensions[i].extension.s,
			       extensions[i].extension.len) == 0) {
		  color = &extensions[i].color;
		break;
	    }
	}
	break;
    }

    put_color(&variables[VLeft].color);
    put_color(color);
    put_color(&variables[VRight].color);
}