summaryrefslogtreecommitdiff
path: root/MLKListenerController.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-28 16:26:07 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-28 16:26:07 +0200
commit3a5710bf7cb85da4ba6a327d6149db46e6bed82e (patch)
treefd63fdf8063ed5230e43785c64bd1990c42875a3 /MLKListenerController.m
parent5afdd34ed00ed1de76b90a884e5b04bd699dc0af (diff)
Eliminate MLKStream, introduce MLKBinaryStream and MLKCharacterStream.
Diffstat (limited to 'MLKListenerController.m')
-rw-r--r--MLKListenerController.m62
1 files changed, 40 insertions, 22 deletions
diff --git a/MLKListenerController.m b/MLKListenerController.m
index 696b08f..28e556b 100644
--- a/MLKListenerController.m
+++ b/MLKListenerController.m
@@ -22,27 +22,12 @@
#import "MLKPackage.h"
#import "MLKReader.h"
#import "util.h"
+#import "special-symbols.h"
@implementation MLKListenerController
-- (id)init
++ (void)initialize
{
- self = [super init];
-
- ostream = [[NSOutputStream alloc] initToMemory];
- lispStream = [[MLKStream alloc] initWithOutputStream:ostream];
- [ostream setDelegate:self];
- [ostream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
- [ostream open];
-
- return self;
-}
-
-- (void)dealloc
-{
- [ostream close];
- LDESTROY (ostream);
- LDESTROY (lispStream);
- [super dealloc];
+ ensure_symbols();
}
- (IBAction)submit:(id)sender
@@ -51,7 +36,8 @@
NSDictionary *attrs;
NSString *input = [inputField stringValue];
MLKPackage *package;
-
+ MLKDynamicContext *newctx;
+
[submitButton setEnabled:NO];
NS_DURING
@@ -99,13 +85,33 @@
[statusText setStringValue:@"Compiling and executing."];
NS_DURING
{
+ NSDictionary *vars = [NSDictionary dictionaryWithObjectsAndKeys:
+ self, QUERY_IO,
+ self, ERROR_OUTPUT,
+ self, STANDARD_OUTPUT,
+ self, TERMINAL_IO,
+ self, TRACE_OUTPUT,
+ self, DEBUG_IO,
+ nil];
+ MLKDynamicContext *ctx = [MLKDynamicContext currentContext];
+ newctx = [[MLKDynamicContext alloc] initWithParent:ctx
+ variables:vars
+ handlers:nil
+ restarts:nil
+ catchTags:nil
+ activeHandlerEnvironment:nil];
+ [newctx pushContext];
+
// ...
}
NS_HANDLER
{
// ...
}
- NS_ENDHANDLER
+ NS_ENDHANDLER;
+
+ [MLKDynamicContext popContext];
+ LDESTROY (newctx);
[statusText setStringValue:@"Ready."];
[text beginEditing];
@@ -123,8 +129,20 @@
[submitButton setEnabled:YES];
}
-- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)event
+- (void)writeChar:(unichar)ch
+{
+ [self writeString:[NSString stringWithFormat:@"%C", ch]];
+}
+
+- (void)writeString:(NSString *)string
{
- NSLog (@"Heya!");
+ NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSColor brownColor],
+ NSForegroundColorAttributeName,
+ nil];
+ NSAttributedString *output =
+ LAUTORELEASE ([[NSAttributedString alloc] initWithString:string
+ attributes:attrs]);
+ [[outputTextView textStorage] appendAttributedString:output];
}
@end