Annotation of Examples/AppKit/Draw/textUndo.subproj/PasteTextChange.m, revision 1.1.1.1

1.1       root        1: #import "textundo.h"
                      2: 
                      3: #define PASTE_OPERATION NXLocalStringFromTable("Operations", "Paste", NULL, "The operation of getting something from the Pasteboard and inserting into the document.")
                      4: 
                      5: @implementation PasteTextChange
                      6: 
                      7: /*
                      8:  * This class calculates how many characters were pasted by looking at
                      9:  * the length of the original selection, and the length of the text object
                     10:  * before the paste. 
                     11:  */
                     12: 
                     13: - initView:aView
                     14: {
                     15:     [super initView:aView name:PASTE_OPERATION];
                     16:     return self;
                     17: }
                     18: 
                     19: - saveBeforeChange
                     20: {
                     21:     NXSelPt start, end;
                     22: 
                     23:     [super saveBeforeChange];
                     24: 
                     25:     [textView getSel:&start :&end];
                     26:     textLength = [textView textLength];
                     27:     selectionStart = start.cp;
                     28:     selectionLength = end.cp - start.cp;
                     29: 
                     30:     return self;
                     31: }
                     32: 
                     33: - saveAfterChange
                     34: {
                     35:     int charsPasted;
                     36: 
                     37:     charsPasted = [textView textLength] - (textLength - selectionLength);
                     38:     newSel = [[TextSelection alloc] initText:textView
                     39:                                       start:selectionStart
                     40:                                         end:selectionStart + charsPasted];
                     41:     [newSel capture];
                     42:     return self;
                     43: }
                     44: 
                     45: @end

unix.superglobalmegacorp.com

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