Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!osf.org!meeks From: meeks@osf.org (W. Scott Meeks) Newsgroups: comp.windows.x.motif Subject: Re: XmText and arbitrary text additions Message-ID: <9007111848.AA21638@osf.osf.org> Date: 11 Jul 90 18:48:30 GMT References: <9007111555.AA05383@osf.osf.org> Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 33 Al's solution was good, but it completely clears the log when MAX_LOG_SIZE is reached. To have something more like what xterm does, you need to just dump the oldest material in the log that doesn't fit anymore. Here's some example code: #define MAX_LOG_SIZE 4000 static log_size = 0; void add_to_log(str) char *str; { int len = strlen(str); if (log_size+len < MAX_LOG_SIZE) { XmTextReplace (log, log_size, log_size, str); log_size += len; } else { diff = (log_size + len) - MAX_LOG_SIZE; XmTextReplace (log, 0, diff, ""); XmTextReplace (log, MAX_LOG_SIZE - len, MAX_LOG_SIZE - len, str); log_size=MAX_LOG_SIZE; } } W. Scott Meeks Open Software Foundation meeks@osf.org (617) 621-7229