From 5dee954413c553513d65039f0e594d01e3b227ea Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 13 Jul 2013 15:53:07 +0300 Subject: Add support for tabulation to fixed browserbox rows. Command: /tN; where N is number or characters in line. Example: "test\t10;line" will be converted into "test line" --- src/gui/widgets/browserbox.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/gui/widgets/browserbox.cpp') diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 50072c5d2..190e79e10 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -69,6 +69,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const unsigned int mode, mProcessVersion(false), mEnableImages(false), mEnableKeys(false), + mEnableTabs(false), mPadding(0), mNewLinePadding(15), mBackgroundColor(getThemeColor(Theme::BACKGROUND)), @@ -229,6 +230,26 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) if (mProcessVersion) newRow = replaceAll(newRow, "%VER%", SMALL_VERSION); + 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 int newSize = 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"); + } + } + if (atTop) { mTextRows.push_front(newRow); -- cgit v1.2.3-60-g2f50