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

Function EditSetNewEncoding

src/Edit.c:367–402  ·  view source on GitHub ↗

============================================================================= EditSetNewEncoding()

Source from the content-addressed store, hash-verified

365// EditSetNewEncoding()
366//
367BOOL EditSetNewEncoding ( HWND hwnd, int iCurrentEncoding, int iNewEncoding, BOOL bNoUI, BOOL bSetSavePoint )
368{
369 if ( iCurrentEncoding != iNewEncoding ) {
370 if ( ( iCurrentEncoding == CPI_DEFAULT && iNewEncoding == CPI_DEFAULT ) ||
371 ( iCurrentEncoding != CPI_DEFAULT && iNewEncoding != CPI_DEFAULT ) ) {
372 return ( TRUE );
373 }
374 if ( SendMessage ( hwnd, SCI_GETLENGTH, 0, 0 ) == 0 ) {
375 BOOL bIsEmptyUndoHistory =
376 ( SendMessage ( hwnd, SCI_CANUNDO, 0, 0 ) == 0 && SendMessage ( hwnd, SCI_CANREDO, 0, 0 ) == 0 );
377 if ( ( iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT ) &&
378 ( bNoUI || bIsEmptyUndoHistory || InfoBox ( MBYESNO, L"MsgConv2", IDS_ASK_ENCODING2 ) == IDYES ) ) {
379 EditConvertText ( hwnd,
380 ( mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT ) ? iDefaultCodePage : SC_CP_UTF8,
381 ( mEncoding[iNewEncoding].uFlags & NCP_DEFAULT ) ? iDefaultCodePage : SC_CP_UTF8,
382 bSetSavePoint );
383 return ( TRUE );
384 } else {
385 return ( FALSE );
386 }
387 } else if ( ( iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT ) &&
388 ( bNoUI || InfoBox ( MBYESNO, L"MsgConv1", IDS_ASK_ENCODING ) == IDYES ) ) {
389 BeginWaitCursor();
390 EditConvertText ( hwnd,
391 ( mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT ) ? iDefaultCodePage : SC_CP_UTF8,
392 ( mEncoding[iNewEncoding].uFlags & NCP_DEFAULT ) ? iDefaultCodePage : SC_CP_UTF8,
393 FALSE );
394 EndWaitCursor();
395 return ( TRUE );
396 } else {
397 return ( FALSE );
398 }
399 } else {
400 return ( FALSE );
401 }
402}
403
404
405//=============================================================================

Callers 1

MsgCommandFunction · 0.85

Calls 4

InfoBoxFunction · 0.85
EditConvertTextFunction · 0.85
BeginWaitCursorFunction · 0.85
EndWaitCursorFunction · 0.85

Tested by

no test coverage detected