-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDirtyText.cp
executable file
·71 lines (56 loc) · 1.59 KB
/
CDirtyText.cp
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
// ===========================================================================
// CDirtyText.cp ©1994-1999 Metrowerks Inc. All rights reserved.
// ===========================================================================
//
// Subclass of LTextEditView which keeps track of whether the text is dirty
// or not (i.e. the user has made changes since last save). Since
// LTextEditView (should) follows any user change to the text with a call to
// UserChangedText(), we just need to track that here to set our dirty flag.
// We also must override SetTextPtr and Insert to flag the dirty changes
// as these are usually programatic changes of text, not typically directly
// resulting from a user action (tho they can in your implementations, so
// just call SetDirty() afterwards).
#include "CDirtyText.h"
CDirtyText::CDirtyText(
LStream* inStream)
: LTextEditView(inStream)
{
mIsDirty = false;
}
void
CDirtyText::UserChangedText()
{
if (!mIsDirty) {
SetUpdateCommandStatus(true);
mIsDirty = true;
}
}
void
CDirtyText::SetTextPtr(
Ptr inTextP,
SInt32 inTextLen,
StScrpHandle inStyleH)
{
LTextEditView::SetTextPtr(inTextP, inTextLen, inStyleH);
mIsDirty = false;
}
void
CDirtyText::Insert(
const void* inText,
SInt32 inLength,
StScrpHandle inStyleH,
Boolean inRefresh )
{
try {
LTextEditView::Insert( inText, inLength, inStyleH, inRefresh );
}
catch (...) {
// We failed for some reason, so let's return to short
// circut things
return;
}
UserChangedText();
}
// these are inlined in the header
#pragma mark CDirtyText::IsDirty
#pragma mark CDirtyText::SetDirty