ftp.nice.ch/pub/next/science/mathematics/HippoDraw.2.0.s.tar.gz#/HippoDraw/Hippo.bproj/Draw.subproj/textUndo.subproj/PasteTextChange.m

This is PasteTextChange.m in view mode; [Download] [Up]

#import "textundo.h"

#define PASTE_OPERATION NXLocalStringFromTable("Operations", "Paste", NULL, "The operation of getting something from the Pasteboard and inserting into the document.")

@implementation PasteTextChange

/*
 * This class calculates how many characters were pasted by looking at
 * the length of the original selection, and the length of the text object
 * before the paste. 
 */

- initView:aView
{
    [super initView:aView name:PASTE_OPERATION];
    return self;
}

- saveBeforeChange
{
    NXSelPt start, end;

    [super saveBeforeChange];

    [textView getSel:&start :&end];
    textLength = [textView textLength];
    selectionStart = start.cp;
    selectionLength = end.cp - start.cp;

    return self;
}

- saveAfterChange
{
    int charsPasted;

    charsPasted = [textView textLength] - (textLength - selectionLength);
    newSel = [[TextSelection alloc] initText:textView
	                               start:selectionStart
	                                 end:selectionStart + charsPasted];
    [newSel capture];
    return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.