#import "JubCLIChatUI.h"
#import "JubCLIColor.h"

@implementation JubCLIChatUI
- initWithTitle: (OFString*)title
     closeBlock: (jub_close_block_t)closeBlock
      sendBlock: (jub_send_block_t)sendBlock
{
	self = [super init];

	@try {
		_sendBlock = [sendBlock copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_sendBlock release];
	[super dealloc];
}

- (void)addMessage: (OFString*)text
	    sender: (OFString*)sender
{
	[of_stdout writeFormat: BOLD("%@:") @" %@\n", sender, text];
}

- (void)send: (OFString*)text
{
	_sendBlock(text);
}
@end
