Fix proper case conversion logic for single and smart single quotes
Changed all instances of TITLECASE to PROPERCASE for consistency. Close #13584
This commit is contained in:
parent
391f4281ef
commit
9b7dff6fa9
|
@ -1880,11 +1880,11 @@ void Notepad_plus::command(int id)
|
|||
break;
|
||||
|
||||
case IDM_EDIT_PROPERCASE_FORCE:
|
||||
_pEditView->convertSelectedTextToNewerCase(TITLECASE_FORCE);
|
||||
_pEditView->convertSelectedTextToNewerCase(PROPERCASE_FORCE);
|
||||
break;
|
||||
|
||||
case IDM_EDIT_PROPERCASE_BLEND:
|
||||
_pEditView->convertSelectedTextToNewerCase(TITLECASE_BLEND);
|
||||
_pEditView->convertSelectedTextToNewerCase(PROPERCASE_BLEND);
|
||||
break;
|
||||
|
||||
case IDM_EDIT_SENTENCECASE_FORCE:
|
||||
|
|
|
@ -182,6 +182,12 @@ int getNbDigits(int aNum, int base)
|
|||
return nbChiffre;
|
||||
}
|
||||
|
||||
bool isCharSingleQuote(__inout wchar_t const c)
|
||||
{
|
||||
if (c == L'\'' || c == L'\u2019' || c == L'\u2018') return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
|
||||
{
|
||||
if (!_SciInit)
|
||||
|
@ -3167,24 +3173,28 @@ void ScintillaEditView::changeCase(__inout wchar_t * const strWToConvert, const
|
|||
}
|
||||
break;
|
||||
} //case LOWERCASE
|
||||
case TITLECASE_FORCE:
|
||||
case TITLECASE_BLEND:
|
||||
case PROPERCASE_FORCE:
|
||||
case PROPERCASE_BLEND:
|
||||
{
|
||||
for (int i = 0; i < nbChars; ++i)
|
||||
{
|
||||
if (::IsCharAlphaW(strWToConvert[i]))
|
||||
{
|
||||
if ((i < 1) ? true : !::IsCharAlphaNumericW(strWToConvert[i - 1]))
|
||||
// Exception for single quote and smart single quote
|
||||
if ((i < 2) ? false :
|
||||
(isCharSingleQuote(strWToConvert[i - 1]) && ::IsCharAlphaNumericW(strWToConvert[i - 2])))
|
||||
{
|
||||
if (caseToConvert == PROPERCASE_FORCE)
|
||||
strWToConvert[i] = (WCHAR)(UINT_PTR)::CharLowerW(reinterpret_cast<LPWSTR>(strWToConvert[i]));
|
||||
}
|
||||
else if ((i < 1) ? true : !::IsCharAlphaNumericW(strWToConvert[i - 1]))
|
||||
strWToConvert[i] = (WCHAR)(UINT_PTR)::CharUpperW(reinterpret_cast<LPWSTR>(strWToConvert[i]));
|
||||
else if (caseToConvert == TITLECASE_FORCE)
|
||||
strWToConvert[i] = (WCHAR)(UINT_PTR)::CharLowerW(reinterpret_cast<LPWSTR>(strWToConvert[i]));
|
||||
//An exception
|
||||
if ((i < 2) ? false : (strWToConvert[i - 1] == L'\'' && ::IsCharAlphaW(strWToConvert[i - 2])))
|
||||
else if (caseToConvert == PROPERCASE_FORCE)
|
||||
strWToConvert[i] = (WCHAR)(UINT_PTR)::CharLowerW(reinterpret_cast<LPWSTR>(strWToConvert[i]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
} //case TITLECASE
|
||||
break;
|
||||
} //case PROPERCASE
|
||||
case SENTENCECASE_FORCE:
|
||||
case SENTENCECASE_BLEND:
|
||||
{
|
||||
|
|
|
@ -97,8 +97,8 @@ enum TextCase : UCHAR
|
|||
{
|
||||
UPPERCASE,
|
||||
LOWERCASE,
|
||||
TITLECASE_FORCE,
|
||||
TITLECASE_BLEND,
|
||||
PROPERCASE_FORCE,
|
||||
PROPERCASE_BLEND,
|
||||
SENTENCECASE_FORCE,
|
||||
SENTENCECASE_BLEND,
|
||||
INVERTCASE,
|
||||
|
|
Loading…
Reference in New Issue