-
Notifications
You must be signed in to change notification settings - Fork 1
/
LogTextView.m
46 lines (29 loc) · 834 Bytes
/
LogTextView.m
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
35
36
37
38
39
40
41
42
43
44
45
46
//
// NSLogTextView.m
// DynamixelMonitor
//
// Created by Slavik on 11/3/13.
// Copyright (c) 2013 LUCS. All rights reserved.
//
#import "LogTextView.h"
@implementation LogTextView
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
[self _setup];
return self;
}
- (void)_setup {
self.backgroundColor = [NSColor colorWithWhite:0.1 alpha:1];
self.textColor = [NSColor lightGrayColor];
}
-(void)log:(NSString*)string {
NSLog(@"jslog: %@", string);
NSTextStorage* mstr = [self textStorage];
NSUInteger p = [mstr length];
[self setEditable:YES];
[self setSelectedRange:NSMakeRange(p, p)];
[self insertText: @"\n"];
[self insertText:string replacementRange:NSMakeRange(p, p)];
[self setEditable:NO];
}
@end