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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// CLIPSTextView.m
// CLIPS
//
// Created by Gary Riley on 3/7/06.
//
#import "CLIPSTextView.h"
@implementation CLIPSTextView
/**************/
/* mouseDown: */
/**************/
- (void) mouseDown: (NSEvent *) theEvent
{
mouseDownDetected = YES;
[super mouseDown: theEvent];
}
/******************/
/* insertNewLine: */
/******************/
- (void) insertNewline: (id) sender
{
NSString *previousLineWhitespaceString;
NSString *previousLineText;
NSScanner *previousLineScanner;
NSRange tempRange;
NSString *theText;
/*============================*/
/* First call the superclass. */
/*============================*/
[super insertNewline: sender];
/*=============================================*/
/* Should new lines be automatically indented? */
/*=============================================*/
//if (! [defaults boolForKey:@"IndentNewLinesAutomatically"]) return;
/*==============================================*/
/* Set a range to the end of the previous line. */
/*==============================================*/
tempRange.location = [self selectedRange].location - 1;
tempRange.length = 0;
/*======================================================*/
/* Use that range to get the text of the previous line. */
/*======================================================*/
theText = [self string];
previousLineText = [theText substringWithRange: [theText lineRangeForRange: tempRange]];
/*==================================================================*/
/* Create a scanner initialized with the text of the previous line. */
/*==================================================================*/
previousLineScanner = [[NSScanner alloc] initWithString: previousLineText];
/*===========================================*/
/* The default set of characters to skip is */
/* the whitespace and newline character set. */
/*===========================================*/
[previousLineScanner setCharactersToBeSkipped: nil];
if ([previousLineScanner scanCharactersFromSet: [NSCharacterSet whitespaceCharacterSet]
intoString: &previousLineWhitespaceString])
{ [self insertText: previousLineWhitespaceString replacementRange: [self selectedRange]]; }
}
/*%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/* Key-Value Coding Methods */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%*/
- (void) setMouseDownDetected: (BOOL) theValue
{
mouseDownDetected = theValue;
}
- (BOOL) mouseDownDetected
{
return mouseDownDetected;
}
@end