mirror of
https://github.com/EnumeratedDev/typer.git
synced 2026-10-31 11:31:48 +00:00
Implement copy and pasting
This commit is contained in:
1 parent
8f85e0991a
commit
0aa819f323
2 files changed
+37
-12
No files matched your search
+9
-2
@@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user