============================================================================= EditModifyLines()
| 2495 | // EditModifyLines() |
| 2496 | // |
| 2497 | void EditModifyLines ( HWND hwnd, LPCWSTR pwszPrefix, LPCWSTR pwszAppend ) |
| 2498 | { |
| 2499 | char mszPrefix1[256 * 3] = ""; |
| 2500 | char mszPrefix2[256 * 3] = ""; |
| 2501 | BOOL bPrefixNum = FALSE; |
| 2502 | int iPrefixNum = 0; |
| 2503 | int iPrefixNumWidth = 1; |
| 2504 | char *pszPrefixNumPad = ""; |
| 2505 | char mszAppend1[256 * 3] = ""; |
| 2506 | char mszAppend2[256 * 3] = ""; |
| 2507 | BOOL bAppendNum = FALSE; |
| 2508 | int iAppendNum = 0; |
| 2509 | int iAppendNumWidth = 1; |
| 2510 | char *pszAppendNumPad = ""; |
| 2511 | int mbcp; |
| 2512 | int iSelStart = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONSTART, 0, 0 ); |
| 2513 | int iSelEnd = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONEND, 0, 0 ); |
| 2514 | //if (iSelStart == iSelEnd) { |
| 2515 | // iSelStart = 0; |
| 2516 | // iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); |
| 2517 | //} |
| 2518 | if ( SendMessage ( hwnd, SCI_GETCODEPAGE, 0, 0 ) == SC_CP_UTF8 ) { |
| 2519 | mbcp = CP_UTF8; |
| 2520 | } else { |
| 2521 | mbcp = CP_ACP; |
| 2522 | } |
| 2523 | if ( lstrlen ( pwszPrefix ) ) { |
| 2524 | WideCharToMultiByte ( mbcp, 0, pwszPrefix, -1, mszPrefix1, COUNTOF ( mszPrefix1 ), NULL, NULL ); |
| 2525 | } |
| 2526 | if ( lstrlen ( pwszAppend ) ) { |
| 2527 | WideCharToMultiByte ( mbcp, 0, pwszAppend, -1, mszAppend1, COUNTOF ( mszAppend1 ), NULL, NULL ); |
| 2528 | } |
| 2529 | if ( SC_SEL_RECTANGLE != SendMessage ( hwnd, SCI_GETSELECTIONMODE, 0, 0 ) ) { |
| 2530 | char *p; |
| 2531 | int i; |
| 2532 | int iLine; |
| 2533 | int iLineStart = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iSelStart, 0 ); |
| 2534 | int iLineEnd = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iSelEnd, 0 ); |
| 2535 | //if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)) |
| 2536 | // iLineStart++; |
| 2537 | if ( iSelEnd <= SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLineEnd, 0 ) ) { |
| 2538 | if ( iLineEnd - iLineStart >= 1 ) { |
| 2539 | iLineEnd--; |
| 2540 | } |
| 2541 | } |
| 2542 | if ( lstrlenA ( mszPrefix1 ) ) { |
| 2543 | p = mszPrefix1; |
| 2544 | while ( !bPrefixNum && ( p = StrStrA ( p, "$(" ) ) ) { |
| 2545 | if ( StrCmpNA ( p, "$(I)", CSTRLEN ( "$(I)" ) ) == 0 ) { |
| 2546 | *p = 0; |
| 2547 | StrCpyA ( mszPrefix2, p + CSTRLEN ( "$(I)" ) ); |
| 2548 | bPrefixNum = TRUE; |
| 2549 | iPrefixNum = 0; |
| 2550 | for ( i = iLineEnd - iLineStart; i >= 10; i = i / 10 ) { |
| 2551 | iPrefixNumWidth++; |
| 2552 | } |
| 2553 | pszPrefixNumPad = ""; |
| 2554 | } else if ( StrCmpNA ( p, "$(0I)", CSTRLEN ( "$(0I)" ) ) == 0 ) { |