File:  [NeXTSTEP 3.3 examples] / Examples / AppKit / Draw / textUndo.subproj / PasteTextChange.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:39 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

#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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.