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 18:01:27 +0300
committerelfmz <fenix1905@tut.by>2022-11-06 18:01:27 +0300
commitc42eba333cf725e615cc01fbb105817aba0389c2 (patch)
tree96b067b67941d759a95ca2462d9036278739090c
parent2132a5070d45ec4b547b81182338adf68a9daeb7 (diff)
minor/cosmetic
-rw-r--r--README.md11
-rw-r--r--far2l/src/base/FARString.cpp12
2 files changed, 13 insertions, 10 deletions
diff --git a/README.md b/README.md
index b1e34c77..055a1f13 100644
--- a/README.md
+++ b/README.md
@@ -209,6 +209,7 @@ While FAR internally is UTF16 (because WinPort contains UTF16-related stuff), na
Inspect all printf format strings: unlike Windows, in Linux both wide and multibyte printf-like functions have the same multibyte and wide specifiers. This means that %s is always multibyte while %ls is always wide. So, any %s used in wide-printf-s or %ws used in any printf should be replaced with %ls.
Update from 27aug: now it's possible by defining WINPORT_DIRECT to avoid renaming used Windows API and also to avoid changing format strings as swprintf will be intercepted by a compatibility wrapper.
+
Update from 03/11/22: far2l's console emulator capable to correctly render full-width and combining characters as well as 24 bit colors. This caused following deviation of console-simulation functions behavior comparing to original Win32 API counterparts:
* CHAR_INFO's Char::UnicodeChar field extended to 64 bit length to be able to associate sequence of multiple WCHARs with single cell.
* Writing to console full-width character causes two cells to be used: first will get given character code in UnicodeChar field but next one will have UnicodeChar set to zero.
@@ -237,17 +238,17 @@ Shows (depending on settings - always or if far2l in background) system shell-wi
far2l supports calling APIs from different threads by marshalling API calls from non-main threads into main one and dispatching them on main thread at certain known-safe points inside of dialog processing loops. DispatchInterThreadCalls() allows plugin to explicitly dispatch such calls and plugin must use it periodically in case it blocks main thread with some non-UI activity that may wait for other threads.
* `void BackgroundTask(const wchar_t *Info, BOOL Started);`
-If plugin implements tasks running in background it may invoke this function to indicate about pending task in left-top corner.
+If plugin implements tasks running in background it may invoke this function to indicate about pending task in left-top corner.
Info is a short description of task or just its owner and must be same string when invoked with Started TRUE or FALSE.
* `size_t StrCellsCount(const wchar_t *Str, size_t CharsCount);`
Returns count of console cells which will be used to display given string of CharsCount characters.
* `size_t StrSizeOfCells(const wchar_t *Str, size_t CharsCount, size_t *CellsCount, BOOL RoundUp);`
-Returns count of characters which will be used to fill up to CellsCount cells from given string of CharsCount characters.
-RoundUp argument tells what to do with full-width characters that crossed by CellsCount.
-On return CellsCount contains cells count that will be filled by returned characters count, that:
- Can be smaller than initial value if string has too few characters to fill all CellsCount cells or if RoundUp was set to FALSE and last character would then overflow wanted amount.
+Returns count of characters which will be used to fill up to CellsCount cells from given string of CharsCount characters.
+RoundUp argument tells what to do with full-width characters that crossed by CellsCount.
+On return CellsCount contains cells count that will be filled by returned characters count, that:
+ Can be smaller than initial value if string has too few characters to fill all CellsCount cells or if RoundUp was set to FALSE and last character would then overflow wanted amount.
Can be larger by one than initial value if RoundUp was set to TRUE and last full-width character crossed initial value specified in *CellsCount.
* `TruncStr and TruncPathStr`
diff --git a/far2l/src/base/FARString.cpp b/far2l/src/base/FARString.cpp
index cacaaabb..7dc12c82 100644
--- a/far2l/src/base/FARString.cpp
+++ b/far2l/src/base/FARString.cpp
@@ -302,11 +302,13 @@ FARString& FARString::Append(wchar_t Ch, size_t Count)
FARString& FARString::Insert(size_t Pos, wchar_t Ch, size_t Count)
{
- size_t nNewLength = m_pContent->GetLength() + Count;
- PrepareForModify(nNewLength);
- wmemmove(m_pContent->GetData() + Count, m_pContent->GetData(), m_pContent->GetLength());
- wmemset(m_pContent->GetData(), Ch, Count);
- m_pContent->SetLength(nNewLength);
+ if (LIKELY(Pos <= m_pContent->GetLength())) {
+ size_t nNewLength = m_pContent->GetLength() + Count;
+ PrepareForModify(nNewLength);
+ wmemmove(m_pContent->GetData() + Pos + Count, m_pContent->GetData() + Pos, m_pContent->GetLength() - Pos);
+ wmemset(m_pContent->GetData() + Pos, Ch, Count);
+ m_pContent->SetLength(nNewLength);
+ }
return *this;
}