conbuffer_t con;
-#define CON_LINES_IDX(i) CONBUFFER_LINES_IDX(&con, i)
-#define CON_LINES_UNIDX(i) CONBUFFER_LINES_UNIDX(&con, i)
-#define CON_LINES_LAST CONBUFFER_LINES_LAST(&con)
#define CON_LINES(i) CONBUFFER_LINES(&con, i)
-#define CON_LINES_PRED(i) CONBUFFER_LINES_PRED(&con, i)
-#define CON_LINES_SUCC(i) CONBUFFER_LINES_SUCC(&con, i)
-#define CON_LINES_FIRST CONBUFFER_LINES_FIRST(&con)
+#define CON_LINES_LAST CONBUFFER_LINES_LAST(&con)
#define CON_LINES_COUNT CONBUFFER_LINES_COUNT(&con)
cvar_t con_notifytime = {CVAR_SAVE, "con_notifytime","3", "how long notify lines last, in seconds"};
int i;
if(buf->lines_count >= 1)
{
- double diff = cl.time - (buf->lines + CONBUFFER_LINES_LAST(buf))->addtime;
+ double diff = cl.time - CONBUFFER_LINES_LAST(buf).addtime;
if(diff < 0)
{
for(i = 0; i < buf->lines_count; ++i)
if(buf->lines_count == 0)
return;
--buf->lines_count;
- buf->lines_first = CONBUFFER_LINES_IDX(buf, 1);
+ buf->lines_first = (buf->lines_first) % buf->maxlines;
}
/*
else
{
char *firstline_start = buf->lines[buf->lines_first].start;
- char *lastline_onepastend = buf->lines[CONBUFFER_LINES_LAST(buf)].start + buf->lines[CONBUFFER_LINES_LAST(buf)].len;
+ char *lastline_onepastend = CONBUFFER_LINES_LAST(buf).start + CONBUFFER_LINES_LAST(buf).len;
// the buffer is cyclic, so we first have two cases...
if(firstline_start < lastline_onepastend) // buffer is contiguous
{
//fprintf(stderr, "Now have %d lines (%d -> %d).\n", buf->lines_count, buf->lines_first, CON_LINES_LAST);
- p = buf->lines + CONBUFFER_LINES_LAST(buf);
+ p = &CONBUFFER_LINES_LAST(buf);
p->start = putpos;
p->len = len;
p->addtime = cl.time;
{
float width = vid_conwidth.value;
con_text_info_t ti;
+ con_lineinfo_t *li = &CON_LINES(lineno);
//if(con.lines[lineno].mask & CON_MASK_LOADEDHISTORY)
// return 0;
ti.fontsize = con_textsize.value;
ti.font = FONT_CONSOLE;
- return COM_Wordwrap(con.lines[lineno].start, con.lines[lineno].len, 0, width, Con_WordWidthFunc, &ti, Con_CountLineFunc, NULL);
- // FIXME uses con in a non abstracted way
+ return COM_Wordwrap(li->start, li->len, 0, width, Con_WordWidthFunc, &ti, Con_CountLineFunc, NULL);
}
/*
*/
int Con_LineHeight(int i)
{
- int h = con.lines[i].height;
+ con_lineinfo_t *li = &CON_LINES(i);
+ int h = li->height;
if(h != -1)
return h;
- return con.lines[i].height = Con_MeasureConsoleLine(i);
- // FIXME uses con in a non abstracted way
+ return li->height = Con_MeasureConsoleLine(i);
}
/*
{
float width = vid_conwidth.value;
con_text_info_t ti;
+ con_lineinfo_t *li = &CON_LINES(lineno);
//if(con.lines[lineno].mask & CON_MASK_LOADEDHISTORY)
// return 0;
ti.ymax = ymax;
ti.width = width;
- return COM_Wordwrap(con.lines[lineno].start, con.lines[lineno].len, 0, width, Con_WordWidthFunc, &ti, Con_DisplayLineFunc, &ti);
- // FIXME uses con in a non abstracted way
+ return COM_Wordwrap(li->start, li->len, 0, width, Con_WordWidthFunc, &ti, Con_DisplayLineFunc, &ti);
}
/*
void Con_LastVisibleLine(int *last, int *limitlast)
{
int lines_seen = 0;
- int ic;
+ int i;
if(con_backscroll < 0)
con_backscroll = 0;
// now count until we saw con_backscroll actual lines
- for(ic = 0; ic < CON_LINES_COUNT; ++ic)
+ for(i = CON_LINES_COUNT - 1; i >= 0; --i)
{
- int i = CON_LINES_IDX(CON_LINES_COUNT - 1 - ic);
int h = Con_LineHeight(i);
// line is the last visible line?
y = ymax - con_textsize.value;
if(limitlast)
- y += (con.lines[last].height - limitlast) * con_textsize.value;
+ y += (CON_LINES(last).height - limitlast) * con_textsize.value;
// FIXME uses con in a non abstracted way
i = last;
for(;;)
{
y -= Con_DrawConsoleLine(y, i, 0, ymax) * con_textsize.value;
- if(i == con.lines_first)
- // FIXME uses con in a non abstracted way
+ if(i == 0)
break; // top of console buffer
if(y < 0)
break; // top of console window
limitlast = 0;
- i = CON_LINES_PRED(i);
+ --i;
}
}
}
conbuffer_t;
-#define CONBUFFER_LINES_IDX(buf, i) (((buf)->lines_first + (i)) % (buf)->maxlines)
-#define CONBUFFER_LINES_UNIDX(buf, i) (((i) - (buf)->lines_first + (buf)->maxlines) % (buf)->maxlines)
-#define CONBUFFER_LINES_LAST(buf) CONBUFFER_LINES_IDX(buf, (buf)->lines_count - 1)
-#define CONBUFFER_LINES(buf, i) (buf)->lines[CONBUFFER_LINES_IDX(buf, i)]
-#define CONBUFFER_LINES_PRED(buf, i) (((i) + (buf)->maxlines - 1) % (buf)->maxlines)
-#define CONBUFFER_LINES_SUCC(buf, i) (((i) + 1) % (buf)->maxlines)
-#define CONBUFFER_LINES_FIRST(buf) ((buf)->lines_first)
+#define CONBUFFER_LINES(buf, i) (buf)->lines[((buf)->lines_first + (i)) % (buf)->maxlines]
#define CONBUFFER_LINES_COUNT(buf) ((buf)->lines_count)
+#define CONBUFFER_LINES_LAST(buf) CONBUFFER_LINES(buf, CONBUFFER_LINES_COUNT(buf) - 1)
void ConBuffer_Init(conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool);
void ConBuffer_Clear (conbuffer_t *buf);