Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 0498732

Browse files
committed
Merge pull request #3778 from livecodefraser/bugfix-16959
Synthesize clipboardData["styledText"] from plain text on the clipboard
2 parents 745aebb + d5153c9 commit 0498732

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

docs/notes/bugfix-16959.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Synthesize clipboardData["styledText"] from plain text on the clipboard
2+

engine/src/clipboard.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ bool MCClipboard::CopyAsLiveCodeStyledText(MCDataRef& r_pickled_text) const
837837
}
838838
}
839839

840-
// Could not grab as either styled text or RTF. One last try with HTML...
840+
// Could not grab as either styled text or RTF. Try with HTML.
841841
MCAutoDataRef t_html;
842842
if (CopyAsData(kMCRawClipboardKnownTypeHTML, &t_html))
843843
{
@@ -850,6 +850,19 @@ bool MCClipboard::CopyAsLiveCodeStyledText(MCDataRef& r_pickled_text) const
850850
}
851851
}
852852

853+
// Finally, try plain text.
854+
MCAutoStringRef t_plain_text;
855+
if (CopyAsText(&t_plain_text))
856+
{
857+
// Convert to LiveCode styled text
858+
MCDataRef t_pickled_text = ConvertTextToStyledText(*t_plain_text);
859+
if (t_pickled_text != NULL)
860+
{
861+
r_pickled_text = t_pickled_text;
862+
return true;
863+
}
864+
}
865+
853866
// There was nothing on the clipboard that could be converted to LiveCode
854867
// styled text.
855868
return false;

0 commit comments

Comments
 (0)