]> cgit.babelmonkeys.de Git - jubjub.git/blob - src/gui/cli/JubCLIChatUI.m
Add a zxcv-like CLI frontend
[jubjub.git] / src / gui / cli / JubCLIChatUI.m
1 #import "JubCLIChatUI.h"
2 #import "JubCLIColor.h"
3
4 @implementation JubCLIChatUI
5 - initWithTitle: (OFString*)title
6      closeBlock: (jub_close_block_t)closeBlock
7       sendBlock: (jub_send_block_t)sendBlock
8 {
9         self = [super init];
10
11         @try {
12                 _sendBlock = [sendBlock copy];
13         } @catch (id e) {
14                 [self release];
15                 @throw e;
16         }
17
18         return self;
19 }
20
21 - (void)dealloc
22 {
23         [_sendBlock release];
24         [super dealloc];
25 }
26
27 - (void)addMessage: (OFString*)text
28             sender: (OFString*)sender
29 {
30         [of_stdout writeFormat: BOLD("%@:") @" %@\n", sender, text];
31 }
32
33 - (void)send: (OFString*)text
34 {
35         _sendBlock(text);
36 }
37 @end