============================================================================= EditJoinLinesEx()
| 3704 | // EditJoinLinesEx() |
| 3705 | // |
| 3706 | void EditJoinLinesEx ( HWND hwnd ) |
| 3707 | { |
| 3708 | char *pszText; |
| 3709 | char *pszJoin; |
| 3710 | int cchJoin = 0; |
| 3711 | int i; |
| 3712 | int iLine; |
| 3713 | int iCurPos; |
| 3714 | int iAnchorPos; |
| 3715 | int iSelStart; |
| 3716 | int iSelEnd; |
| 3717 | int iSelCount; |
| 3718 | struct TextRange tr; |
| 3719 | int cEOLMode; |
| 3720 | char szEOL[] = "\r\n"; |
| 3721 | int cchEOL = 2; |
| 3722 | BOOL bModified = FALSE; |
| 3723 | if ( SC_SEL_RECTANGLE == SendMessage ( hwnd, SCI_GETSELECTIONMODE, 0, 0 ) ) { |
| 3724 | MsgBox ( MBINFO, IDS_SELRECT ); |
| 3725 | return; |
| 3726 | } |
| 3727 | iCurPos = ( int ) SendMessage ( hwnd, SCI_GETCURRENTPOS, 0, 0 ); |
| 3728 | iAnchorPos = ( int ) SendMessage ( hwnd, SCI_GETANCHOR, 0, 0 ); |
| 3729 | if ( iCurPos == iAnchorPos ) { |
| 3730 | return; |
| 3731 | } else { |
| 3732 | iSelStart = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONSTART, 0, 0 ); |
| 3733 | iSelEnd = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONEND, 0, 0 ); |
| 3734 | } |
| 3735 | iLine = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iSelStart, 0 ); |
| 3736 | iSelStart = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLine, 0 ); |
| 3737 | iSelCount = iSelEnd - iSelStart; |
| 3738 | pszText = LocalAlloc ( LPTR, ( iSelCount ) + 2 ); |
| 3739 | if ( pszText == NULL ) { |
| 3740 | return; |
| 3741 | } |
| 3742 | pszJoin = LocalAlloc ( LPTR, LocalSize ( pszText ) ); |
| 3743 | if ( pszJoin == NULL ) { |
| 3744 | LocalFree ( pszText ); |
| 3745 | return; |
| 3746 | } |
| 3747 | tr.chrg.cpMin = iSelStart; |
| 3748 | tr.chrg.cpMax = iSelEnd; |
| 3749 | tr.lpstrText = pszText; |
| 3750 | SendMessage ( hwnd, SCI_GETTEXTRANGE, 0, ( LPARAM ) &tr ); |
| 3751 | cEOLMode = ( int ) SendMessage ( hwnd, SCI_GETEOLMODE, 0, 0 ); |
| 3752 | if ( cEOLMode == SC_EOL_CR ) { |
| 3753 | cchEOL = 1; |
| 3754 | } else if ( cEOLMode == SC_EOL_LF ) { |
| 3755 | cchEOL = 1; |
| 3756 | szEOL[0] = '\n'; |
| 3757 | } |
| 3758 | cchJoin = 0; |
| 3759 | for ( i = 0; i < iSelCount; i++ ) { |
| 3760 | if ( pszText[i] == '\r' || pszText[i] == '\n' ) { |
| 3761 | if ( pszText[i] == '\r' && pszText[i + 1] == '\n' ) { |
| 3762 | i++; |
| 3763 | } |