From e525b4bc81dc56749c1cf5df6420ebe9ad6bf6cb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 27 Jan 2017 20:11:26 +0300 Subject: Move tabs replace code from browserbox into browserboxtools. --- src/utils/browserboxtools.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/utils/browserboxtools.cpp') 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"); + } +} -- cgit v1.2.3-70-g09d2