2259 |
2259 |
2260 deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2260 deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2261 "delete all text from startLine/startCol to endLine/endCol - |
2261 "delete all text from startLine/startCol to endLine/endCol - |
2262 joining lines if nescessary" |
2262 joining lines if nescessary" |
2263 |
2263 |
2264 |line lineSize| |
2264 |line newLine lineSize nMore| |
2265 |
2265 |
2266 self checkModificationsAllowed ifFalse:[ ^ self]. |
2266 self checkModificationsAllowed ifFalse:[ ^ self]. |
2267 list isNil ifTrue:[^ self]. |
2267 list isNil ifTrue:[^ self]. |
2268 startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
2268 startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
2269 |
2269 |
2297 "/ must add blanks, if startCol lies behond end of startLine |
2297 "/ must add blanks, if startCol lies behond end of startLine |
2298 |
2298 |
2299 line := list at:startLine. |
2299 line := list at:startLine. |
2300 lineSize := line size. |
2300 lineSize := line size. |
2301 (startCol > lineSize) ifTrue:[ |
2301 (startCol > lineSize) ifTrue:[ |
|
2302 newLine := line. |
2302 line isNil ifTrue:[ |
2303 line isNil ifTrue:[ |
2303 line := String new:(startCol - 1) |
2304 newLine := String new:(startCol - 1) |
2304 ] ifFalse:[ |
2305 ] ifFalse:[ |
2305 line := line , (line species new:(startCol - 1 - lineSize)) |
2306 nMore := startCol - 1 - lineSize. |
|
2307 nMore > 0 ifTrue:[ |
|
2308 newLine := line , (line species new:nMore) |
|
2309 ] |
2306 ]. |
2310 ]. |
2307 list at:startLine put:line. |
2311 newLine ~~ line ifTrue:[ |
|
2312 list at:startLine put:newLine. |
|
2313 ]. |
2308 "/ TODO: remember old maxwidth of linerange, |
2314 "/ TODO: remember old maxwidth of linerange, |
2309 "/ only clear widthOfWidestLine, if this max |
2315 "/ only clear widthOfWidestLine, if this max |
2310 "/ length was (one of) the longest. |
2316 "/ length was (one of) the longest. |
2311 "/ avoids slow delete with huge texts. |
2317 "/ avoids slow delete with huge texts. |
2312 widthOfWidestLine := nil. "/ i.e. unknown |
2318 widthOfWidestLine := nil. "/ i.e. unknown |
2313 self textChanged. |
2319 self textChanged. |
2314 ] |
2320 ] |
2315 ]. |
2321 ]. |
2316 |
2322 |
2317 "/ merge the left rest of 1st line with right rest of last line into one |
2323 "/ merge the left rest of 1st line with right rest of last line into one |
2318 self mergeLine:startLine |
2324 self mergeLine:startLine removeBlanks:false |
2319 |
2325 |
2320 "Modified: / 10.11.1998 / 23:52:59 / cg" |
2326 "Modified: / 10.11.1998 / 23:52:59 / cg" |
2321 ! |
2327 ! |
2322 |
2328 |
2323 deleteFromLine:startLineNr toLine:endLineNr |
2329 deleteFromLine:startLineNr toLine:endLineNr |
3590 !EditTextView methodsFor:'menu actions'! |
3596 !EditTextView methodsFor:'menu actions'! |
3591 |
3597 |
3592 cut |
3598 cut |
3593 "cut selection into copybuffer" |
3599 "cut selection into copybuffer" |
3594 |
3600 |
3595 |line col history sel| |
3601 |line col history sel s| |
3596 |
3602 |
3597 (self checkModificationsAllowed) ifFalse:[ |
3603 (self checkModificationsAllowed) ifFalse:[ |
3598 self flash. |
3604 self flash. |
3599 ^ self |
3605 ^ self |
3600 ]. |
3606 ]. |
3601 |
3607 |
3602 sel := self selection. |
3608 sel := self selection. |
3603 sel notNil ifTrue:[ |
3609 sel notNil ifTrue:[ |
3604 lastString := sel asStringWithCRs. |
3610 lastString := s := sel asStringWithCRs. |
3605 line := selectionStartLine. |
3611 line := selectionStartLine. |
3606 col := selectionStartCol. |
3612 col := selectionStartCol. |
3607 undoAction := [self insertString:lastString atLine:line col:col]. |
3613 undoAction := [ self cursorLine:line col:col. |
|
3614 self insertLines:(Array with:s) withCR:false. |
|
3615 ]. |
3608 |
3616 |
3609 " |
3617 " |
3610 remember in CopyBuffer |
3618 remember in CopyBuffer |
3611 " |
3619 " |
3612 self setTextSelection:lastString. |
3620 self setTextSelection:lastString. |
3750 ] |
3761 ] |
3751 ]. |
3762 ]. |
3752 (nLines := s size) == 0 ifTrue:[^ self]. |
3763 (nLines := s size) == 0 ifTrue:[^ self]. |
3753 (nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
3764 (nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
3754 |
3765 |
3755 startLine := cursorLine. |
3766 startLine := l1 := cursorLine. |
3756 startCol := cursorCol. |
3767 startCol := c1 := cursorCol. |
3757 self insertLines:(s withTabsExpanded) withCR:false. |
3768 self insertLines:(s withTabsExpanded) withCR:false. |
3758 self selectFromLine:startLine col:startCol |
3769 l2 := cursorLine. |
3759 toLine:cursorLine col:(cursorCol - 1). |
3770 c2 := (cursorCol - 1). |
|
3771 self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
3760 typeOfSelection := #paste. |
3772 typeOfSelection := #paste. |
3761 undoAction := [self cut]. |
3773 undoAction := [ self unselect. |
|
3774 self deleteFromLine:l1 col:c1 toLine:l2 col:c2. |
|
3775 self cursorLine:l1 col:c1. |
|
3776 ]. |
3762 ] |
3777 ] |
3763 |
3778 |
3764 "Modified: / 14.2.1996 / 11:14:14 / stefan" |
3779 "Modified: / 14.2.1996 / 11:14:14 / stefan" |
3765 "Modified: / 12.6.1998 / 22:12:00 / cg" |
3780 "Modified: / 12.6.1998 / 22:12:00 / cg" |
3766 ! |
3781 ! |