From ebdf89e4184240a752061c7c8d5450dbca809f39 Mon Sep 17 00:00:00 2001 From: Oliver Kiehl Date: Fri, 10 Jan 2003 21:33:42 +0000 Subject: Added some basic line editing to the EditText widget svn-id: r6393 --- common/str.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'common/str.cpp') diff --git a/common/str.cpp b/common/str.cpp index e8e73a32a2..ffb8c298b0 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -160,6 +160,16 @@ void String::deleteLastChar() { } } +void String::deleteChar(int p) +{ + if (p >= 0 && p < _len) { + ensureCapacity(_len - 1, true); + while (p++ < _len) + _str[p-1] = _str[p]; + _len--; + } +} + void String::clear() { if (_capacity) { @@ -172,6 +182,17 @@ void String::clear() } } +void String::insertChar(char c, int p) +{ + if (p >= 0 && p <= _len) { + ensureCapacity(++_len, true); + for (int i = _len; i > p; i--) { + _str[i] = _str[i-1]; + } + _str[p] = c; + } +} + void String::toLowercase() { if (_str == 0 || _len == 0) -- cgit v1.2.3