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:
Diffstat (limited to 'far2l/src/console/interf.cpp')
-rw-r--r--far2l/src/console/interf.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/far2l/src/console/interf.cpp b/far2l/src/console/interf.cpp
index d4f83422..2cd2503c 100644
--- a/far2l/src/console/interf.cpp
+++ b/far2l/src/console/interf.cpp
@@ -572,24 +572,37 @@ void Text(const WCHAR *Str, size_t Length)
PCHAR_INFO HeapBuffer=nullptr;
PCHAR_INFO BufPtr=StackBuffer;
- if (Length >= StackBufferSize)
+ if (Length * 2 >= StackBufferSize)
{
- HeapBuffer=new CHAR_INFO[Length+1];
+ HeapBuffer=new CHAR_INFO[Length * 2 + 1];
BufPtr=HeapBuffer;
}
- for (size_t i=0; i < Length; i++)
+ int nCells = 0;
+ std::wstring wstr;
+ for (size_t i = 0; i < Length; ++nCells)
{
- BufPtr[i].Char.UnicodeChar=Str[i];
- BufPtr[i].Attributes=CurColor;
+ const size_t nG = StrSizeOfCell(&Str[i], Length - i);
+ if (nG > 1) {
+ wstr.assign(&Str[i], nG);
+ CI_SET_COMPOSITE(BufPtr[nCells], wstr.c_str());
+ } else {
+ CI_SET_WCHAR(BufPtr[nCells], Str[i]);
+ }
+ CI_SET_ATTR(BufPtr[nCells], CurColor);
+ if (IsCharFullWidth(Str[i])) {
+ ++nCells;
+ CI_SET_WCATTR(BufPtr[nCells], 0, CurColor);
+ }
+ i+= nG;
}
- ScrBuf.Write(CurX, CurY, BufPtr, static_cast<int>(Length));
+ ScrBuf.Write(CurX, CurY, BufPtr, nCells);
if(HeapBuffer)
{
delete[] HeapBuffer;
}
- CurX+=static_cast<int>(Length);
+ CurX+= nCells;
}
@@ -1082,7 +1095,7 @@ FARString& HiText2Str(FARString& strDest, const wchar_t *Str)
return strDest;
}
-int HiStrlen(const wchar_t *Str)
+int HiStrCellsCount(const wchar_t *Str)
{
/*
&& = '&'
@@ -1123,8 +1136,11 @@ int HiStrlen(const wchar_t *Str)
}
else
{
+ if (IsCharFullWidth(*Str))
+ Length+= 2;
+ else if (!IsCharXxxfix(*Str))
+ Length+= 1;
Str++;
- Length++;
}
}
}
@@ -1169,8 +1185,11 @@ int HiFindRealPos(const wchar_t *Str, int Pos, BOOL ShowAmp)
}
}
+ if (IsCharFullWidth(*Str))
+ VisPos+= 2;
+ else if (!IsCharXxxfix(*Str))
+ VisPos+= 1;
Str++;
- VisPos++;
RealPos++;
}
}
@@ -1207,6 +1226,9 @@ int HiFindNextVisualPos(const wchar_t *Str, int Pos, int Direct)
return Pos-2;
}
+ if (IsCharFullWidth(Str[Pos - 1]) && Pos > 1)
+ return Pos-2;
+
return Pos-1;
}
else
@@ -1231,7 +1253,7 @@ int HiFindNextVisualPos(const wchar_t *Str, int Pos, int Direct)
}
else
{
- return Pos+1;
+ return IsCharFullWidth(*Str) ? Pos + 2 : Pos + 1;
}
}
}