MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / EditWrapToColumn

Function EditWrapToColumn

src/Edit.c:3530–3699  ·  view source on GitHub ↗

============================================================================= EditWrapToColumn()

Source from the content-addressed store, hash-verified

3528// EditWrapToColumn()
3529//
3530void EditWrapToColumn ( HWND hwnd, int nColumn/*,int nTabWidth*/ )
3531{
3532 char *pszText;
3533 LPWSTR pszTextW;
3534 int cchTextW;
3535 int iTextW;
3536 LPWSTR pszConvW;
3537 int cchConvW;
3538 int cchConvM;
3539 int iLineLength;
3540 int iLine;
3541 int iCurPos;
3542 int iAnchorPos;
3543 int iSelStart;
3544 int iSelEnd;
3545 int iSelCount;
3546 UINT cpEdit;
3547 struct TextRange tr;
3548 int cEOLMode;
3549 WCHAR wszEOL[] = L"\r\n";
3550 int cchEOL = 2;
3551 BOOL bModified = FALSE;
3552 if ( SC_SEL_RECTANGLE == SendMessage ( hwnd, SCI_GETSELECTIONMODE, 0, 0 ) ) {
3553 MsgBox ( MBINFO, IDS_SELRECT );
3554 return;
3555 }
3556 iCurPos = ( int ) SendMessage ( hwnd, SCI_GETCURRENTPOS, 0, 0 );
3557 iAnchorPos = ( int ) SendMessage ( hwnd, SCI_GETANCHOR, 0, 0 );
3558 if ( iCurPos == iAnchorPos ) /*{
3559 iSelStart = 0;
3560 iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
3561 }*/
3562 {
3563 return;
3564 } else {
3565 iSelStart = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONSTART, 0, 0 );
3566 iSelEnd = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONEND, 0, 0 );
3567 }
3568 iLine = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iSelStart, 0 );
3569 iSelStart = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLine, 0 );
3570 iSelCount = iSelEnd - iSelStart;
3571 pszText = GlobalAlloc ( GPTR, ( iSelCount ) + 2 );
3572 if ( pszText == NULL ) {
3573 return;
3574 }
3575 pszTextW = GlobalAlloc ( GPTR, ( iSelCount * 2 ) + 2 );
3576 if ( pszTextW == NULL ) {
3577 GlobalFree ( pszText );
3578 return;
3579 }
3580 tr.chrg.cpMin = iSelStart;
3581 tr.chrg.cpMax = iSelEnd;
3582 tr.lpstrText = pszText;
3583 SendMessage ( hwnd, SCI_GETTEXTRANGE, 0, ( LPARAM ) &tr );
3584 cpEdit = ( UINT ) SendMessage ( hwnd, SCI_GETCODEPAGE, 0, 0 );
3585 cchTextW = MultiByteToWideChar ( cpEdit, 0, pszText, iSelCount, pszTextW, ( int ) GlobalSize ( pszTextW ) / sizeof ( WCHAR ) );
3586 GlobalFree ( pszText );
3587 pszConvW = GlobalAlloc ( GPTR, cchTextW * sizeof ( WCHAR ) * 3 + 2 );

Callers 1

MsgCommandFunction · 0.85

Calls 1

MsgBoxFunction · 0.85

Tested by

no test coverage detected