============================================================================= EditMoveDown()
| 2402 | // EditMoveDown() |
| 2403 | // |
| 2404 | void EditMoveDown ( HWND hwnd ) |
| 2405 | { |
| 2406 | int iCurPos = ( int ) SendMessage ( hwnd, SCI_GETCURRENTPOS, 0, 0 ); |
| 2407 | int iAnchorPos = ( int ) SendMessage ( hwnd, SCI_GETANCHOR, 0, 0 ); |
| 2408 | int iCurLine = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iCurPos, 0 ); |
| 2409 | int iAnchorLine = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iAnchorPos, 0 ); |
| 2410 | if ( iCurLine == iAnchorLine ) { |
| 2411 | int iLineCurPos = iCurPos - ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iCurLine, 0 ); |
| 2412 | int iLineAnchorPos = iAnchorPos - ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iAnchorLine, 0 ); |
| 2413 | if ( iCurLine < SendMessage ( hwnd, SCI_GETLINECOUNT, 0, 0 ) - 1 ) { |
| 2414 | SendMessage ( hwnd, SCI_BEGINUNDOACTION, 0, 0 ); |
| 2415 | SendMessage ( hwnd, SCI_GOTOLINE, ( WPARAM ) iCurLine + 1, 0 ); |
| 2416 | SendMessage ( hwnd, SCI_LINETRANSPOSE, 0, 0 ); |
| 2417 | SendMessage ( hwnd, SCI_SETSEL, |
| 2418 | ( WPARAM ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iAnchorLine + 1, 0 ) + iLineAnchorPos, |
| 2419 | ( LPARAM ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iCurLine + 1, 0 ) + iLineCurPos ); |
| 2420 | SendMessage ( hwnd, SCI_CHOOSECARETX, 0, 0 ); |
| 2421 | SendMessage ( hwnd, SCI_ENDUNDOACTION, 0, 0 ); |
| 2422 | } |
| 2423 | } else if ( SC_SEL_RECTANGLE != SendMessage ( hwnd, SCI_GETSELECTIONMODE, 0, 0 ) ) { |
| 2424 | int iLineSrc = max ( iCurLine, iAnchorLine ) + 1; |
| 2425 | if ( max ( iCurPos, iAnchorPos ) <= SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineSrc - 1, 0 ) ) { |
| 2426 | if ( iLineSrc >= 1 ) { |
| 2427 | iLineSrc--; |
| 2428 | } |
| 2429 | } |
| 2430 | if ( iLineSrc <= SendMessage ( hwnd, SCI_GETLINECOUNT, 0, 0 ) - 1 ) { |
| 2431 | DWORD cLine; |
| 2432 | char *pLine; |
| 2433 | int iLineSrcStart; |
| 2434 | int iLineSrcEnd; |
| 2435 | int iLineDest; |
| 2436 | int iLineDestStart; |
| 2437 | BOOL bLastLine = ( iLineSrc == SendMessage ( hwnd, SCI_GETLINECOUNT, 0, 0 ) - 1 ); |
| 2438 | if ( bLastLine && |
| 2439 | ( SendMessage ( hwnd, SCI_GETLINEENDPOSITION, ( WPARAM ) iLineSrc, 0 ) - |
| 2440 | SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineSrc, 0 ) == 0 ) && |
| 2441 | ( SendMessage ( hwnd, SCI_GETLINEENDPOSITION, ( WPARAM ) iLineSrc - 1, 0 ) - |
| 2442 | SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineSrc - 1, 0 ) == 0 ) ) { |
| 2443 | return; |
| 2444 | } |
| 2445 | if ( bLastLine ) { |
| 2446 | char chaEOL[] = "\r\n"; |
| 2447 | int iEOLMode = ( int ) SendMessage ( hwnd, SCI_GETEOLMODE, 0, 0 ); |
| 2448 | if ( iEOLMode == SC_EOL_CR ) { |
| 2449 | chaEOL[1] = 0; |
| 2450 | } else if ( iEOLMode == SC_EOL_LF ) { |
| 2451 | chaEOL[0] = '\n'; |
| 2452 | chaEOL[1] = 0; |
| 2453 | } |
| 2454 | SendMessage ( hwnd, SCI_APPENDTEXT, ( WPARAM ) lstrlenA ( chaEOL ), ( LPARAM ) chaEOL ); |
| 2455 | } |
| 2456 | cLine = ( int ) SendMessage ( hwnd, SCI_GETLINE, ( WPARAM ) iLineSrc, 0 ); |
| 2457 | pLine = LocalAlloc ( LPTR, cLine + 3 ); |
| 2458 | SendMessage ( hwnd, SCI_GETLINE, ( WPARAM ) iLineSrc, ( LPARAM ) pLine ); |
| 2459 | iLineSrcStart = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineSrc, 0 ); |
| 2460 | iLineSrcEnd = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineSrc + 1, 0 ); |
| 2461 | iLineDest = min ( iCurLine, iAnchorLine ); |