From 9074c9020cdc2ad0c6d94447e0af93024f539dc8 Mon Sep 17 00:00:00 2001 From: trustable-code Date: Fri, 15 Sep 2017 11:19:40 +0200 Subject: Fix: Use runeSubStr instead of substr for Unicode compatibility --- src/nigui.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit v1.2.3