summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrustable-code <krauter.simon@arcor.de>2017-09-15 11:19:40 +0200
committertrustable-code <krauter.simon@arcor.de>2017-09-15 11:19:40 +0200
commit9074c9020cdc2ad0c6d94447e0af93024f539dc8 (patch)
tree02cc6532d44a2bcafc51f03d3d6621781ee741c4
parentbec4fa49d7edf31611df1797815791044859926a (diff)
downloadNiGui-9074c9020cdc2ad0c6d94447e0af93024f539dc8.tar.gz
NiGui-9074c9020cdc2ad0c6d94447e0af93024f539dc8.zip
Fix: Use runeSubStr instead of substr for Unicode compatibility
-rwxr-xr-xsrc/nigui.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nigui.nim b/src/nigui.nim
index a6b3b0a..a62348c 100755
--- a/src/nigui.nim
+++ b/src/nigui.nim
@@ -887,6 +887,7 @@ import math
import os
import strutils
import times
+import unicode
# ----------------------------------------------------------------------------------------
@@ -2293,12 +2294,12 @@ method `selectionEnd=`(textBox: TextBox, selectionEnd: int) = discard
# has to be implemented by NativeTextBox
method selectedText(textBox: TextBox): string =
- result = textBox.text.substr(textBox.selectionStart, textBox.selectionEnd - 1)
+ result = textBox.text.runeSubStr(textBox.selectionStart, textBox.selectionEnd - textBox.selectionStart)
method `selectedText=`(textBox: TextBox, text: string) =
let oldCursorPos = textBox.cursorPos
let oldText = textBox.text
- textBox.text = oldText.substr(0, textBox.selectionStart - 1) & text & oldText.substr(textBox.selectionEnd)
+ textBox.text = oldText.runeSubStr(0, textBox.selectionStart) & text & oldText.runeSubStr(textBox.selectionEnd)
textBox.cursorPos = oldCursorPos