diff options
author | Oliver Kiehl | 2003-01-10 21:33:42 +0000 |
---|---|---|
committer | Oliver Kiehl | 2003-01-10 21:33:42 +0000 |
commit | ebdf89e4184240a752061c7c8d5450dbca809f39 (patch) | |
tree | 6fe9fe552feb98eccfe2c2b7a4d7945e560daf26 /common | |
parent | 23a02b712a83ddd4759dd9158dc470f7f3742dfc (diff) | |
download | scummvm-rg350-ebdf89e4184240a752061c7c8d5450dbca809f39.tar.gz scummvm-rg350-ebdf89e4184240a752061c7c8d5450dbca809f39.tar.bz2 scummvm-rg350-ebdf89e4184240a752061c7c8d5450dbca809f39.zip |
Added some basic line editing to the EditText widget
svn-id: r6393
Diffstat (limited to 'common')
-rw-r--r-- | common/str.cpp | 21 | ||||
-rw-r--r-- | common/str.h | 2 |
2 files changed, 23 insertions, 0 deletions
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) diff --git a/common/str.h b/common/str.h index 4c2a985d46..8ff84c3b5d 100644 --- a/common/str.h +++ b/common/str.h @@ -110,7 +110,9 @@ public: } void deleteLastChar(); + void deleteChar(int p); void clear(); + void insertChar(char c, int p); void toLowercase(); void toUppercase(); |