Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/elfmz/far2l.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelfmz <fenix1905@tut.by>2022-11-06 15:42:07 +0300
committerelfmz <fenix1905@tut.by>2022-11-06 15:42:10 +0300
commit2132a5070d45ec4b547b81182338adf68a9daeb7 (patch)
treeddff746b84170607c90b17b9114fed7cc4c1fa6d /far2l/src/mix
parentdd90814dd17bdc802bf1711cab22bac385498eed (diff)
Location menu: use center-truncate for 2nd and 4rd columns (touch #1379)
Diffstat (limited to 'far2l/src/mix')
-rw-r--r--far2l/src/mix/format.cpp16
-rw-r--r--far2l/src/mix/strmix.cpp16
-rw-r--r--far2l/src/mix/strmix.hpp2
3 files changed, 17 insertions, 17 deletions
diff --git a/far2l/src/mix/format.cpp b/far2l/src/mix/format.cpp
index 2a36f985..653ac059 100644
--- a/far2l/src/mix/format.cpp
+++ b/far2l/src/mix/format.cpp
@@ -80,18 +80,14 @@ void BaseFormat::Put(LPCWSTR Data, size_t Length)
FARString OutStr(Data, Length);
- size_t Count = _Cells ? OutStr.CellsCount() : OutStr.GetLength();
+ const size_t Count = _Cells ? OutStr.CellsCount() : OutStr.GetLength();
- if (_Align == fmt::A_RIGHT)
+ if (_Expand > Count)
{
- for(;Count < _Expand; ++Count)
- {
- OutStr.Insert(0, _FillChar);
- }
- }
- else if (_Expand > Count)
- {
- OutStr.Append(_FillChar, _Expand - Count);
+ if (_Align == fmt::A_RIGHT)
+ OutStr.Insert(0, _FillChar, _Expand - Count);
+ else
+ OutStr.Append(_FillChar, _Expand - Count);
}
Commit(OutStr);
diff --git a/far2l/src/mix/strmix.cpp b/far2l/src/mix/strmix.cpp
index 4e1434ac..a5a8fbed 100644
--- a/far2l/src/mix/strmix.cpp
+++ b/far2l/src/mix/strmix.cpp
@@ -447,18 +447,22 @@ FARString& CenterStr(const wchar_t *Src, FARString &strDest, int Length)
return strDest;
}
-FARString FixedSizeStr(FARString str, size_t Length, bool RAlign)
+FARString FixedSizeStr(FARString str, size_t Cells, bool RAlign, bool TruncateCenter)
{
- if (str.CellsCount() > Length)
+ const size_t InitialStrCells = str.CellsCount();
+ if (InitialStrCells > Cells)
{
- TruncStr(str, Length);
+ if (TruncateCenter)
+ TruncStrFromCenter(str, Cells);
+ else
+ TruncStr(str, Cells);
}
- else while (str.CellsCount() < Length)
+ else if (InitialStrCells < Cells)
{
if (RAlign)
- str.Insert(0, L" ", 1);
+ str.Insert(0, L' ', Cells - InitialStrCells);
else
- str.Append(L" ", 1);
+ str.Append(L' ', Cells - InitialStrCells);
}
return str;
}
diff --git a/far2l/src/mix/strmix.hpp b/far2l/src/mix/strmix.hpp
index 3905f3ef..fa7f26cc 100644
--- a/far2l/src/mix/strmix.hpp
+++ b/far2l/src/mix/strmix.hpp
@@ -115,7 +115,7 @@ BOOL IsCaseMixed(const FARString &strStr);
BOOL IsCaseLower(const FARString &strStr);
FARString& CenterStr(const wchar_t *Src, FARString &strDest,int Length);
-FARString FixedSizeStr(FARString str, size_t Length, bool RAlign);
+FARString FixedSizeStr(FARString str, size_t Cells, bool RAlign, bool TruncateCenter);
void Transform(FARString &strBuffer,const wchar_t *ConvStr,wchar_t TransformType);