unit MultiSkelEdit; interface uses TransSkel, MultiSkelGlobals; procedure EditWindInit; procedure EditWindEditMenu (item: Integer); implementation const undo = 1; cut = 3; copy = 4; paste = 5; clear = 6; var teEdit: TEHandle; procedure Mouse (pt: Point; t: LongInt; mods: Integer); begin TEClick(pt, Boolean(BitAnd(mods, shiftKey) <> 0), teEdit); end; procedure Key (c: char; code: Integer; mods: Integer); begin TEKey(c, teEdit); end; procedure Update (resized: Boolean); var r: Rect; begin r := editWind^.portRect; EraseRect(r); r.left := r.left + 4; r.bottom := r.bottom - 2; r.top := r.top + 2; r.right := r.right - 19; if (resized) then begin teEdit^^.destRect.right := r.right; teEdit^^.viewRect := r; TECalText(teEdit); end; DrawGrowBox(editWind); TEUpdate(r, teEdit); end; procedure Activate (active: Boolean); begin DrawGrowBox(editWind); if (active) then begin TEActivate(teEdit); DisableItem(editMenu, undo); end else begin TEDeactivate(teEdit); EnableItem(editMenu, undo); end; end; procedure Clobber; begin TEDispose(teEdit); DisposeWindow(editWind); end; procedure Idle; begin TEIdle(teEdit); end; procedure EditWindInit; var r: Rect; str: Str255; ignore: Boolean; begin if (SkelQuery(skelQHasColorQD) <> 0) then editWind := GetNewCWindow(editWindRes, nil, WindowPtr(-1)) else editWind := GetNewWindow(editWindRes, nil, WindowPtr(-1)); if (editWind = nil) then exit(EditWindInit); ignore := SkelWindow(editWind, @Mouse, @Key, @Update, @Activate, nil, @Clobber, @Idle, true); TextFont(0); TextSize(0); r := editWind^.portRect; r.left := r.left + 4; r.bottom := r.bottom - 2; r.top := r.top + 2; r.right := r.right - 19; teEdit := TENew(r, r); str := 'This is the text editing window.X'; str[length(str)] := chr(13); { make last char (X) a carriage return } TEInsert(Ptr(LongInt(@str) + 1), LongInt(length(str)), teEdit); end; procedure EditWindEditMenu (item: Integer); var ignore: OSErr; begin case item of cut: begin TECut(teEdit); ignore := ZeroScrap; ignore := TEToScrap; end; copy: begin TECopy(teEdit); ignore := ZeroScrap; ignore := TEToScrap; end; paste: begin ignore := TEFromScrap; TEPaste(teEdit); end; clear: begin TEDelete(teEdit); end; end; end; end.