MCPcopy Create free account
hub / github.com/WheretIB/nullc / OnPaste

Method OnPaste

GUI/RichTextarea.cpp:1728–1763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1726}
1727
1728void TextareaData::OnPaste()
1729{
1730 // Remove selection
1731 if(selectionOn)
1732 DeleteSelection();
1733
1734 // Get pasted text
1735 OpenClipboard(areaWnd);
1736 HANDLE clipData = GetClipboardData(CF_TEXT);
1737 if(clipData)
1738 {
1739 // Find line count
1740 unsigned char *str = (unsigned char*)clipData;
1741 unsigned int linesAdded = 0;
1742 do
1743 {
1744 if(*str == '\r')
1745 linesAdded++;
1746 }while(*str++);
1747 history->TakeSnapshot(currLine, HistoryManager::LINES_ADDED, linesAdded);
1748
1749 str = (unsigned char*)clipData;
1750 // Simulate as if the text was written
1751 while(*str)
1752 {
1753 if(*str >= 0x20 || *str == '\t')
1754 InputChar(*str);
1755 else if(*str == '\r')
1756 InputEnter();
1757 str++;
1758 }
1759 }
1760 CloseClipboard();
1761 // Force update on whole window
1762 InvalidateRect(areaWnd, NULL, false);
1763}
1764
1765void TextareaData::OnCharacter(unsigned char ch)
1766{

Callers 1

TextareaProcMethod · 0.80

Calls 1

TakeSnapshotMethod · 0.80

Tested by

no test coverage detected