mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-21 08:27:13 +01:00
Bug 2699 - Cannot edit labels with emoji in them correctly.
Fixed on Windows 10. Probably still broken on mac and linux.
This commit is contained in:
@@ -936,6 +936,11 @@ int LabelTrackView::FindCursorPosition(wxCoord xPos)
|
|||||||
const int length = title.length();
|
const int length = title.length();
|
||||||
while (!finished && (charIndex < length + 1))
|
while (!finished && (charIndex < length + 1))
|
||||||
{
|
{
|
||||||
|
int unichar = (int)title.at( charIndex-1 );
|
||||||
|
if( (0xDC00 <= unichar) && (unichar <= 0xDFFF)){
|
||||||
|
charIndex++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
subString = title.Left(charIndex);
|
subString = title.Left(charIndex);
|
||||||
// Get the width of substring
|
// Get the width of substring
|
||||||
dc.GetTextExtent(subString, &partWidth, NULL);
|
dc.GetTextExtent(subString, &partWidth, NULL);
|
||||||
@@ -1460,6 +1465,9 @@ bool LabelTrackView::DoKeyDown(
|
|||||||
if ( HasSelection( project ) ) {
|
if ( HasSelection( project ) ) {
|
||||||
auto labelStruct = mLabels[mSelIndex];
|
auto labelStruct = mLabels[mSelIndex];
|
||||||
auto &title = labelStruct.title;
|
auto &title = labelStruct.title;
|
||||||
|
wxUniChar wchar;
|
||||||
|
bool more=true;
|
||||||
|
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
|
|
||||||
case WXK_BACK:
|
case WXK_BACK:
|
||||||
@@ -1474,11 +1482,15 @@ bool LabelTrackView::DoKeyDown(
|
|||||||
RemoveSelectedText();
|
RemoveSelectedText();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// DELETE one letter
|
// DELETE one codepoint leftwards
|
||||||
if (mCurrentCursorPos > 0) {
|
while ((mCurrentCursorPos > 0) && more) {
|
||||||
|
wchar = title.at( mCurrentCursorPos-1 );
|
||||||
title.erase(mCurrentCursorPos-1, 1);
|
title.erase(mCurrentCursorPos-1, 1);
|
||||||
mCurrentCursorPos--;
|
mCurrentCursorPos--;
|
||||||
|
if( ((int)wchar > 0xDFFF) || ((int)wchar <0xDC00)){
|
||||||
pTrack->SetLabel(mSelIndex, labelStruct);
|
pTrack->SetLabel(mSelIndex, labelStruct);
|
||||||
|
more = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1505,10 +1517,14 @@ bool LabelTrackView::DoKeyDown(
|
|||||||
RemoveSelectedText();
|
RemoveSelectedText();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// DELETE one letter
|
// DELETE one codepoint rightwards
|
||||||
if (mCurrentCursorPos < len) {
|
while ((mCurrentCursorPos < len) && more) {
|
||||||
|
wchar = title.at( mCurrentCursorPos );
|
||||||
title.erase(mCurrentCursorPos, 1);
|
title.erase(mCurrentCursorPos, 1);
|
||||||
|
if( ((int)wchar > 0xDBFF) || ((int)wchar <0xD800)){
|
||||||
pTrack->SetLabel(mSelIndex, labelStruct);
|
pTrack->SetLabel(mSelIndex, labelStruct);
|
||||||
|
more = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1545,7 +1561,10 @@ bool LabelTrackView::DoKeyDown(
|
|||||||
case WXK_LEFT:
|
case WXK_LEFT:
|
||||||
case WXK_NUMPAD_LEFT:
|
case WXK_NUMPAD_LEFT:
|
||||||
// Moving cursor left
|
// Moving cursor left
|
||||||
if (mCurrentCursorPos > 0) {
|
while ((mCurrentCursorPos > 0) && more) {
|
||||||
|
wchar = title.at( mCurrentCursorPos-1 );
|
||||||
|
more = !( ((int)wchar > 0xDFFF) || ((int)wchar <0xDC00));
|
||||||
|
|
||||||
mCurrentCursorPos--;
|
mCurrentCursorPos--;
|
||||||
if (mods == wxMOD_SHIFT)
|
if (mods == wxMOD_SHIFT)
|
||||||
;
|
;
|
||||||
@@ -1558,7 +1577,10 @@ bool LabelTrackView::DoKeyDown(
|
|||||||
case WXK_RIGHT:
|
case WXK_RIGHT:
|
||||||
case WXK_NUMPAD_RIGHT:
|
case WXK_NUMPAD_RIGHT:
|
||||||
// Moving cursor right
|
// Moving cursor right
|
||||||
if (mCurrentCursorPos < (int)title.length()) {
|
while ((mCurrentCursorPos < (int)title.length())&& more) {
|
||||||
|
wchar = title.at( mCurrentCursorPos );
|
||||||
|
more = !( ((int)wchar > 0xDBFF) || ((int)wchar <0xD800));
|
||||||
|
|
||||||
mCurrentCursorPos++;
|
mCurrentCursorPos++;
|
||||||
if (mods == wxMOD_SHIFT)
|
if (mods == wxMOD_SHIFT)
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user