]> cgit.babelmonkeys.de Git - jubjub.git/blobdiff - src/gui/cli/JubCLIChatUI.m
Add a zxcv-like CLI frontend
[jubjub.git] / src / gui / cli / JubCLIChatUI.m
diff --git a/src/gui/cli/JubCLIChatUI.m b/src/gui/cli/JubCLIChatUI.m
new file mode 100644 (file)
index 0000000..5803ba7
--- /dev/null
@@ -0,0 +1,37 @@
+#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