============================================================================= EditMoveUp()
| 2321 | // EditMoveUp() |
| 2322 | // |
| 2323 | void EditMoveUp ( HWND hwnd ) |
| 2324 | { |
| 2325 | int iCurPos = ( int ) SendMessage ( hwnd, SCI_GETCURRENTPOS, 0, 0 ); |
| 2326 | int iAnchorPos = ( int ) SendMessage ( hwnd, SCI_GETANCHOR, 0, 0 ); |
| 2327 | int iCurLine = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iCurPos, 0 ); |
| 2328 | int iAnchorLine = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iAnchorPos, 0 ); |
| 2329 | if ( iCurLine == iAnchorLine ) { |
| 2330 | int iLineCurPos = iCurPos - ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iCurLine, 0 ); |
| 2331 | int iLineAnchorPos = iAnchorPos - ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iAnchorLine, 0 ); |
| 2332 | if ( iCurLine > 0 ) { |
| 2333 | SendMessage ( hwnd, SCI_BEGINUNDOACTION, 0, 0 ); |
| 2334 | SendMessage ( hwnd, SCI_LINETRANSPOSE, 0, 0 ); |
| 2335 | SendMessage ( hwnd, SCI_SETSEL, |
| 2336 | ( WPARAM ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iAnchorLine - 1, 0 ) + iLineAnchorPos, |
| 2337 | ( LPARAM ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iCurLine - 1, 0 ) + iLineCurPos ); |
| 2338 | SendMessage ( hwnd, SCI_CHOOSECARETX, 0, 0 ); |
| 2339 | SendMessage ( hwnd, SCI_ENDUNDOACTION, 0, 0 ); |
| 2340 | } |
| 2341 | } else if ( SC_SEL_RECTANGLE != SendMessage ( hwnd, SCI_GETSELECTIONMODE, 0, 0 ) ) { |
| 2342 | int iLineSrc = min ( iCurLine, iAnchorLine ) - 1; |
| 2343 | if ( iLineSrc >= 0 ) { |
| 2344 | DWORD cLine; |
| 2345 | char *pLine; |
| 2346 | int iLineSrcStart; |
| 2347 | int iLineSrcEnd; |
| 2348 | int iLineDest; |
| 2349 | int iLineDestStart; |
| 2350 | cLine = ( int ) SendMessage ( hwnd, SCI_GETLINE, ( WPARAM ) iLineSrc, 0 ); |
| 2351 | pLine = LocalAlloc ( LPTR, cLine + 1 ); |
| 2352 | SendMessage ( hwnd, SCI_GETLINE, ( WPARAM ) iLineSrc, ( LPARAM ) pLine ); |
| 2353 | iLineSrcStart = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineSrc, 0 ); |
| 2354 | iLineSrcEnd = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineSrc + 1, 0 ); |
| 2355 | iLineDest = max ( iCurLine, iAnchorLine ); |
| 2356 | if ( max ( iCurPos, iAnchorPos ) <= SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineDest, 0 ) ) { |
| 2357 | if ( iLineDest >= 1 ) { |
| 2358 | iLineDest--; |
| 2359 | } |
| 2360 | } |
| 2361 | SendMessage ( hwnd, SCI_BEGINUNDOACTION, 0, 0 ); |
| 2362 | SendMessage ( hwnd, SCI_SETTARGETSTART, ( WPARAM ) iLineSrcStart, 0 ); |
| 2363 | SendMessage ( hwnd, SCI_SETTARGETEND, ( WPARAM ) iLineSrcEnd, 0 ); |
| 2364 | SendMessage ( hwnd, SCI_REPLACETARGET, 0, ( LPARAM ) "" ); |
| 2365 | iLineDestStart = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineDest, 0 ); |
| 2366 | SendMessage ( hwnd, SCI_INSERTTEXT, ( WPARAM ) iLineDestStart, ( LPARAM ) pLine ); |
| 2367 | LocalFree ( pLine ); |
| 2368 | if ( iLineDest == SendMessage ( hwnd, SCI_GETLINECOUNT, 0, 0 ) - 1 ) { |
| 2369 | char chaEOL[] = "\r\n"; |
| 2370 | int iEOLMode = ( int ) SendMessage ( hwnd, SCI_GETEOLMODE, 0, 0 ); |
| 2371 | if ( iEOLMode == SC_EOL_CR ) { |
| 2372 | chaEOL[1] = 0; |
| 2373 | } else if ( iEOLMode == SC_EOL_LF ) { |
| 2374 | chaEOL[0] = '\n'; |
| 2375 | chaEOL[1] = 0; |
| 2376 | } |
| 2377 | SendMessage ( hwnd, SCI_INSERTTEXT, ( WPARAM ) iLineDestStart, ( LPARAM ) chaEOL ); |
| 2378 | SendMessage ( hwnd, SCI_SETTARGETSTART, ( WPARAM ) |
| 2379 | SendMessage ( hwnd, SCI_GETLINEENDPOSITION, ( WPARAM ) iLineDest, 0 ), 0 ); |
| 2380 | SendMessage ( hwnd, SCI_SETTARGETEND, ( WPARAM ) |