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

Function EditSpacesToTabs

src/Edit.c:2191–2316  ·  view source on GitHub ↗

============================================================================= EditSpacesToTabs()

Source from the content-addressed store, hash-verified

2189// EditSpacesToTabs()
2190//
2191void EditSpacesToTabs ( HWND hwnd, int nTabWidth, BOOL bOnlyIndentingWS )
2192{
2193 char *pszText;
2194 LPWSTR pszTextW;
2195 int cchTextW;
2196 int iTextW;
2197 LPWSTR pszConvW;
2198 int cchConvW;
2199 int cchConvM;
2200 int i, j, t;
2201 int iLine;
2202 int iCurPos;
2203 int iAnchorPos;
2204 int iSelStart;
2205 int iSelEnd;
2206 int iSelCount;
2207 UINT cpEdit;
2208 struct TextRange tr;
2209 WCHAR space[256];
2210 BOOL bIsLineStart = TRUE;
2211 BOOL bModified = FALSE;
2212 if ( SC_SEL_RECTANGLE == SendMessage ( hwnd, SCI_GETSELECTIONMODE, 0, 0 ) ) {
2213 MsgBox ( MBINFO, IDS_SELRECT );
2214 return;
2215 }
2216 iCurPos = ( int ) SendMessage ( hwnd, SCI_GETCURRENTPOS, 0, 0 );
2217 iAnchorPos = ( int ) SendMessage ( hwnd, SCI_GETANCHOR, 0, 0 );
2218 if ( iCurPos == iAnchorPos ) /*{
2219 iSelStart = 0;
2220 iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0);
2221 }*/
2222 {
2223 return;
2224 } else {
2225 iSelStart = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONSTART, 0, 0 );
2226 iSelEnd = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONEND, 0, 0 );
2227 }
2228 iLine = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iSelStart, 0 );
2229 iSelStart = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLine, 0 );
2230 iSelCount = iSelEnd - iSelStart;
2231 pszText = GlobalAlloc ( GPTR, ( iSelCount ) + 2 );
2232 if ( pszText == NULL ) {
2233 return;
2234 }
2235 pszTextW = GlobalAlloc ( GPTR, ( iSelCount * 2 ) + 2 );
2236 if ( pszTextW == NULL ) {
2237 GlobalFree ( pszText );
2238 return;
2239 }
2240 tr.chrg.cpMin = iSelStart;
2241 tr.chrg.cpMax = iSelEnd;
2242 tr.lpstrText = pszText;
2243 SendMessage ( hwnd, SCI_GETTEXTRANGE, 0, ( LPARAM ) &tr );
2244 cpEdit = ( UINT ) SendMessage ( hwnd, SCI_GETCODEPAGE, 0, 0 );
2245 cchTextW = MultiByteToWideChar ( cpEdit, 0, pszText, iSelCount, pszTextW, ( int ) GlobalSize ( pszTextW ) / sizeof ( WCHAR ) );
2246 GlobalFree ( pszText );
2247 pszConvW = GlobalAlloc ( GPTR, cchTextW * sizeof ( WCHAR ) + 2 );
2248 if ( pszConvW == NULL ) {

Callers 1

MsgCommandFunction · 0.85

Calls 1

MsgBoxFunction · 0.85

Tested by

no test coverage detected