/* <<< Start of information >>>                                       */
/* ------------------------------------------------------------------ */
/* This file is part of the xwatch program. Copyright (C) Karel Kubat */
/* 1995. All rights reserved. You are permitted to redistribute this  */
/* package, if you include all unmodified sources and all unmodified  */
/* documentation (including this text). You are NOT permitted to      */
/* distribute files of this package with modifications. See the file  */
/* COPYING for more information. When in doubt, mail me at            */
/* karel@icce.rug.nl.                                                 */
/* ------------------------------------------------------------------ */
/* <<< End of information >>>                                         */

#include "xwatch.h"

static char
    outputbuf [1001];
    
void flushline ()
{
    fl_addto_browser (browser, outputbuf);
    outputbuf [0] = '\0';
}

void addline (char *buf, int colindex)
{
    /* flush lines so far if too long */ 
    if (strlen (outputbuf) + strlen (buf) > linelen)
	flushline ();

    /* add color code if necessary */ 
    if (! outputbuf [0] && colindex != foregr)
	sprintf (outputbuf, "@C%d", colindex);

    /* add delimiting space if no more control codes */ 
    if (*buf != '@')
	strcat (outputbuf, " ");

    /* add to window */ 
    strcat (outputbuf, buf);

    if (outputbuf [strlen (outputbuf) - 1] == '\n')
	flushline ();
}
