static int console_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char UNUSED(bg[3]))
{
	ConsoleLine *cl_iter = (ConsoleLine *)tvc->iter;

	/* annoying hack, to draw the prompt */
	if (tvc->iter_index == 0) {
		const SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
		const ConsoleLine *cl = (ConsoleLine *)sc->history.last;
		const int prompt_len = strlen(sc->prompt);
		const int cursor_loc = cl->cursor + prompt_len;
		const int line_len = cl->len + prompt_len;
		int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN};
		int pen[2];
		xy[1] += tvc->lheight / 6;

		/* account for wrapping */
		if (line_len < tvc->console_width) {
			/* simple case, no wrapping */
			pen[0] = tvc->cwidth * cursor_loc;
			pen[1] = -2;
		}
		else {
			/* wrap */
			pen[0] = tvc->cwidth * (cursor_loc % tvc->console_width);
			pen[1] = -2 + (((line_len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight);
		}

		/* cursor */
		UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, fg);
		glColor3ubv(fg);

		glRecti((xy[0] + pen[0]) - 1,
		        (xy[1] + pen[1]),
		        (xy[0] + pen[0]) + 1,
		        (xy[1] + pen[1] + tvc->lheight)
		        );
	}

	console_line_color(fg, cl_iter->type);

	return TVC_LINE_FG;
}
static int console_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char UNUSED(bg[3]))
{
	ConsoleLine *cl_iter = (ConsoleLine *)tvc->iter;

	/* annoying hack, to draw the prompt */
	if (tvc->iter_index == 0) {
		const SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
		const ConsoleLine *cl = (ConsoleLine *)sc->history.last;
		int offl = 0, offc = 0;
		int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN};
		int pen[2];
		xy[1] += tvc->lheight / 6;

		console_cursor_wrap_offset(sc->prompt, tvc->console_width, &offl, &offc, NULL);
		console_cursor_wrap_offset(cl->line, tvc->console_width, &offl, &offc, cl->line + cl->cursor);
		pen[0] = tvc->cwidth * offc;
		pen[1] = -2 - tvc->lheight * offl;

		console_cursor_wrap_offset(cl->line + cl->cursor, tvc->console_width, &offl, &offc, NULL);
		pen[1] += tvc->lheight * offl;

		/* cursor */
		UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, fg);
		glColor3ubv(fg);

		glRecti((xy[0] + pen[0]) - 1,
		        (xy[1] + pen[1]),
		        (xy[0] + pen[0]) + 1,
		        (xy[1] + pen[1] + tvc->lheight)
		        );
	}

	console_line_color(fg, cl_iter->type);

	return TVC_LINE_FG;
}