diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-01-27 20:11:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-01-27 20:11:26 +0300 |
commit | e525b4bc81dc56749c1cf5df6420ebe9ad6bf6cb (patch) | |
tree | f12f3b5295be46dc2bb62d34ca7501f21b7114f4 | |
parent | bfd5338c20fcd838f711ea5e96b2f37e012dc884 (diff) | |
download | mv-e525b4bc81dc56749c1cf5df6420ebe9ad6bf6cb.tar.gz mv-e525b4bc81dc56749c1cf5df6420ebe9ad6bf6cb.tar.bz2 mv-e525b4bc81dc56749c1cf5df6420ebe9ad6bf6cb.tar.xz mv-e525b4bc81dc56749c1cf5df6420ebe9ad6bf6cb.zip |
Move tabs replace code from browserbox into browserboxtools.
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 18 | ||||
-rw-r--r-- | src/utils/browserboxtools.cpp | 21 | ||||
-rw-r--r-- | src/utils/browserboxtools.h | 2 |
3 files changed, 24 insertions, 17 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index b1793b725..ced262090 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -271,23 +271,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) if (mEnableTabs) { - idx1 = newRow.find("\\t"); - while (idx1 != std::string::npos) - { - const size_t idx2 = newRow.find(';', idx1); - if (idx2 == std::string::npos) - break; - - const unsigned int newSize = CAST_U32( - atoi(newRow.substr( - idx1 + 2, idx2 - idx1 - 2).c_str())); - std::string str = newRow.substr(0, idx1); - while (str.size() < newSize) - str.append(" "); - str.append(newRow.substr(idx2 + 1)); - newRow = str; - idx1 = newRow.find("\\t"); - } + BrowserBoxTools::replaceTabs(newRow); } if (atTop) diff --git a/src/utils/browserboxtools.cpp b/src/utils/browserboxtools.cpp index ff7df8d30..4db092798 100644 --- a/src/utils/browserboxtools.cpp +++ b/src/utils/browserboxtools.cpp @@ -134,3 +134,24 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link) return data; #endif // DYECMD } + +void BrowserBoxTools::replaceTabs(std::string &data) +{ + size_t idx1 = data.find("\\t"); + while (idx1 != std::string::npos) + { + const size_t idx2 = data.find(';', idx1); + if (idx2 == std::string::npos) + break; + + const unsigned int newSize = CAST_U32( + atoi(data.substr( + idx1 + 2, idx2 - idx1 - 2).c_str())); + std::string str = data.substr(0, idx1); + while (str.size() < newSize) + str.append(" "); + str.append(data.substr(idx2 + 1)); + data = str; + idx1 = data.find("\\t"); + } +} diff --git a/src/utils/browserboxtools.h b/src/utils/browserboxtools.h index d35f4bda9..1e267ed2b 100644 --- a/src/utils/browserboxtools.h +++ b/src/utils/browserboxtools.h @@ -32,6 +32,8 @@ namespace BrowserBoxTools void replaceKeys(std::string &data); std::string replaceLinkCommands(const std::string &link); + + void replaceTabs(std::string &data); } // BrowserBoxTools #endif // UTILS_BROWSERBOXTOOLS_H |