aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/e1/pdj/ConsoleStreamWin32.java
blob: 80f767eb1180ef25e0bb97c99649b3e76a0d783f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.e1.pdj;

import com.cycling74.max.MaxSystem;

/**
 * Win32 has a special stream since it can contains /r/n that will
 * be duplicated in the console
 */
public class ConsoleStreamWin32 extends ConsoleStream {
	protected void send(String message) {
		StringBuffer ret = new StringBuffer();
        
		for (int i=0;i<message.length();i++) {
			char c = message.charAt(i);

			if ( c != '\r' )
				ret.append(c);
		}
        
		message = ret.toString();
		if ( !message.equals("\n") )
			MaxSystem.post("pdj: " + ret.toString());
	}

	public void flush() {
		String msg = buffer.toString();
		if ( msg.endsWith("\n") ) {
			msg = msg.substring(0, msg.length()-1);
		}
		if ( !msg.equals("") )
			send(buffer.toString());
		buffer.reset();
	}
}