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-05 20:31:53 +0300
committerGitHub <noreply@github.com>2022-11-05 20:31:53 +0300
commit253a6b140797e035eb9301a1632fed2408a837e2 (patch)
treeed6be316904b5d5ff11b7bfa46e7037fc2ec51d5 /far2l/src/plug
parent89eaed71c674aadda536408638e3416bc7f4c053 (diff)
support full-width/composite characters and true color palette in terminal (#1386)
Added normal support for full-width (CJK etc) and composite (using diacritics) characters. IMPORTANT: WINPORT API changed in binary incompatible way in order to implement this.
Diffstat (limited to 'far2l/src/plug')
-rw-r--r--far2l/src/plug/PluginA.cpp17
-rw-r--r--far2l/src/plug/PluginW.cpp12
-rw-r--r--far2l/src/plug/wrap.cpp8
3 files changed, 34 insertions, 3 deletions
diff --git a/far2l/src/plug/PluginA.cpp b/far2l/src/plug/PluginA.cpp
index e43b500f..610321c3 100644
--- a/far2l/src/plug/PluginA.cpp
+++ b/far2l/src/plug/PluginA.cpp
@@ -333,6 +333,21 @@ static void WINAPI farBackgroundTaskA(const char *Info, BOOL Started)
CtrlObject->Plugins.BackroundTaskFinished(MB2Wide(Info).c_str());
}
+static size_t WINAPI farStrCellsCountA(const char *Str, size_t CharsCount)
+{
+ std::wstring ws;
+ MB2Wide(Str, CharsCount, ws);
+ return StrCellsCount(ws.c_str(), ws.size());
+}
+
+static size_t WINAPI farStrSizeOfCellsA(const char *Str, size_t CharsCount, size_t *CellsCount, BOOL RoundUp)
+{
+ std::wstring ws;
+ MB2Wide(Str, CharsCount, ws);
+ size_t cnt = StrSizeOfCells(ws.c_str(), ws.size(), *CellsCount, RoundUp != FALSE);
+ ws.resize(cnt);
+ return StrWide2MB(ws).size();
+}
static void CreatePluginStartupInfoA(PluginA *pPlugin, oldfar::PluginStartupInfo *PSI, oldfar::FarStandardFunctions *FSF)
{
@@ -384,6 +399,8 @@ static void CreatePluginStartupInfoA(PluginA *pPlugin, oldfar::PluginStartupInfo
StandardFunctions.DisplayNotification = farDisplayNotificationA;
StandardFunctions.DispatchInterThreadCalls = farDispatchInterThreadCallsA;
StandardFunctions.BackgroundTask = farBackgroundTaskA;
+ StandardFunctions.StrCellsCount = farStrCellsCountA;
+ StandardFunctions.StrSizeOfCells = farStrSizeOfCellsA;
}
if (!StartupInfo.StructSize)
diff --git a/far2l/src/plug/PluginW.cpp b/far2l/src/plug/PluginW.cpp
index cde065be..aa0fa9ca 100644
--- a/far2l/src/plug/PluginW.cpp
+++ b/far2l/src/plug/PluginW.cpp
@@ -397,6 +397,16 @@ static void WINAPI farBackgroundTaskW(const wchar_t *Info, BOOL Started)
CtrlObject->Plugins.BackroundTaskFinished(Info);
}
+static size_t WINAPI farStrCellsCount(const wchar_t *Str, size_t CharsCount)
+{
+ return StrCellsCount(Str, CharsCount);
+}
+
+static size_t WINAPI farStrSizeOfCells(const wchar_t *Str, size_t CharsCount, size_t *CellsCount, BOOL RoundUp)
+{
+ return StrSizeOfCells(Str, CharsCount, *CellsCount, RoundUp != FALSE);
+}
+
void CreatePluginStartupInfo(Plugin *pPlugin, PluginStartupInfo *PSI, FarStandardFunctions *FSF)
{
static PluginStartupInfo StartupInfo{};
@@ -459,6 +469,8 @@ void CreatePluginStartupInfo(Plugin *pPlugin, PluginStartupInfo *PSI, FarStandar
StandardFunctions.DisplayNotification = farDisplayNotificationW;
StandardFunctions.DispatchInterThreadCalls = farDispatchInterThreadCallsW;
StandardFunctions.BackgroundTask = farBackgroundTaskW;
+ StandardFunctions.StrCellsCount = farStrCellsCount;
+ StandardFunctions.StrSizeOfCells = farStrSizeOfCells;
}
if (!StartupInfo.StructSize)
diff --git a/far2l/src/plug/wrap.cpp b/far2l/src/plug/wrap.cpp
index aeee159d..e08ef7fb 100644
--- a/far2l/src/plug/wrap.cpp
+++ b/far2l/src/plug/wrap.cpp
@@ -1271,10 +1271,12 @@ void AnsiVBufToUnicode(PCHAR_INFO VBufA, PCHAR_INFO VBuf, size_t Size,bool NoCvt
}
else
{
- AnsiToUnicodeBin(&VBufA[i].Char.AsciiChar,&VBuf[i].Char.UnicodeChar,1);
+ WCHAR wc{};
+ AnsiToUnicodeBin(&VBufA[i].Char.AsciiChar,&wc,1);
+ CI_SET_WCHAR(VBuf[i], wc);
}
- VBuf[i].Attributes = VBufA[i].Attributes;
+ CI_SET_ATTR(VBuf[i], VBufA[i].Attributes);
}
}
}
@@ -4046,7 +4048,7 @@ int WINAPI FarCharTableA(int Command, char *Buffer, int BufferSize)
ErrnoSaver ErSr;
const wchar_t *codePageName = L"";//FormatCodePageName(nCP, cpiex.CodePageName, sizeof(cpiex.CodePageName)/sizeof(wchar_t));
- sTableName<<fmt::Width(5)<<nCP<<BoxSymbols[BS_V1]<<L" "<<codePageName;
+ sTableName<<fmt::Expand(5)<<nCP<<BoxSymbols[BS_V1]<<L" "<<codePageName;
sTableName.strValue().GetCharString(TableSet->TableName, sizeof(TableSet->TableName) - 1, CP_OEMCP);
wchar_t *us=AnsiToUnicodeBin((char*)TableSet->DecodeTable, sizeof(TableSet->DecodeTable), nCP);
WINPORT(CharLowerBuff)(us, sizeof(TableSet->DecodeTable));