Exemplo n.º 1
0
int source_highlight(struct list_node *node)
{
    int do_color = sources_syntax_on &&
                   (node->language != TOKENIZER_LANGUAGE_UNKNOWN) &&
                   swin_has_colors();

    /* Load the entire file */
    if (!sbcount(node->file_buf.lines))
        load_file_buf(&node->file_buf, node->path);

    /* If we're doing color and we haven't already loaded this file
     * with this language, then load and highlight it.
     */
    if (do_color && (node->file_buf.language != node->language)) {
        node->file_buf.language = node->language;
        highlight_node(node);
    }

    /* Allocate the breakpoints array */
    if (!node->lflags) {
        int count = sbcount(node->file_buf.lines);
        sbsetcount(node->lflags, count);

        memset(node->lflags, 0, sbcount(node->lflags));
    }

    if (node->file_buf.lines)
        return 0;

    return -1;
}
Exemplo n.º 2
0
void highlight(struct list_node *node)
{
    if ( node->language == TOKENIZER_LANGUAGE_UNKNOWN ) {
        /* Just copy the lines from the original buffer if no highlighting
         * is possible */
        int i;
        node->buf.length = node->orig_buf.length;
        node->buf.max_width = node->orig_buf.max_width;
        node->buf.tlines = cgdb_malloc ( sizeof ( char * ) * node->orig_buf.length );
        for ( i = 0; i < node->orig_buf.length; i++ )
            node->buf.tlines[i] = cgdb_strdup ( node->orig_buf.tlines[i] );
    } else
        highlight_node ( node );
}
Exemplo n.º 3
0
void
render_info(BITMAP *bmp)
{
	char buf[256];

	scare_mouse();

	rectfill(bmp, 0, bmp->h - 16, bmp->w/2, bmp->h, bgc);
	rectfill(bmp, bmp->w/3, 0, (int)bmp->w*.66, 10, bgc);

	if (selected_node)
	{
		snprintf(buf, sizeof(buf), "%s: %s (ID: %d   coord: %d,%d)",
		         (selected_node->area?selected_node->area:"(unknown area)"),
		         (selected_node->title?selected_node->title:"(unknown title)"),
		         selected_node->id, selected_node->x, selected_node->y);

		textprintf_centre_ex(bmp, font, bmp->w/2, 2, 0, -1, "%s",
		                     buf);
		hline(bmp, bmp->w/2 - text_length(font, buf)/2, 10,
		      bmp->w/2 + text_length(font, buf)/2, 0);

		highlight_node(selected_node, highlight_color);
	}

	textprintf_ex(bmp, font, 2, (bmp->h - 8) - 2 - text_height(font), 0, -1,
		              "Center: %d,%d", (int)(bmp->w/2.0+xoffset), (int)(bmp->h/2.0+yoffset));
	textprintf_ex(bmp, font, 2, bmp->h - 8, 0, -1,
		              "Mouse: %d,%d", mouse_x+xoffset, mouse_y+yoffset);

	if (last_file)
	{
		snprintf(buf, sizeof(buf), "Most recent file: \"%s\"   (%d nodes total)", last_file, vector_len((vector_t *)nodelist));
		rectfill(bmp, text_length(font, buf), bmp->h - text_height(font), bmp->w, bmp->h, bgc);

		textprintf_right_ex(bmp, font, bmp->w, bmp->h-10, 0, -1, "%s", buf);
	}

	unscare_mouse();
}