Implement copy and pasting

This commit is contained in:
2025-06-08 21:13:51 +03:00
parent 8f85e0991a
commit 0aa819f323
2 changed files with 37 additions and 12 deletions
+9 -2
View File
@@ -72,10 +72,17 @@ func (buffer *Buffer) GetSelectedText() string {
start := buffer.Selection.selectionStart
end := buffer.Selection.selectionEnd
if start >= len(buffer.Contents) {
start = len(buffer.Contents) - 1
}
if end >= len(buffer.Contents) {
end = len(buffer.Contents) - 1
}
if start <= end {
return buffer.Contents[buffer.Selection.selectionStart : buffer.Selection.selectionEnd+1]
return buffer.Contents[start : end+1]
} else {
return buffer.Contents[buffer.Selection.selectionEnd : buffer.Selection.selectionStart+1]
return buffer.Contents[end : start+1]
}
}