std::set<string>& GetComponentsInfo() { static FN_RETURN_TYPE(GetComponentsInfo) sList; if (sList.empty()) { auto& ComponentsList = GetComponentsList(); std::transform(ALL_RANGE(ComponentsList), std::inserter(sList, sList.end()), [](CONST_REFERENCE(ComponentsList) i) { return i(); });
int DialogBuilder::AddTextWrap(const wchar_t *text, bool center, int width) { string str(text); FarFormatText(str, width <= 0 ? ScrX-1-10 : width, str, L"\n", 0); int LineCount = 1 + std::count(ALL_CONST_RANGE(str), L'\n'); std::replace(ALL_RANGE(str), L'\n', L'\0'); const wchar_t *ps = str.data(); for (int i = 0; i < LineCount; ++i, ps += wcslen(ps) + 1) { const auto Text = AddText(ps); Text->Flags = (center ? DIF_CENTERTEXT : 0); } return LineCount; }
static const std::vector<wchar_t> create_alt_sort_table() { std::vector<wchar_t> alt_sort_table(WCHAR_MAX + 1); std::vector<wchar_t> chars(WCHAR_MAX + 1); std::iota(ALL_RANGE(chars), 0); std::sort(chars.begin() + 1, chars.end(), [](wchar_t a, wchar_t b) { return StrCmpNN(&a, 1, &b, 1) < 0; }); int u_beg = 0, u_end = 0xffff; for (int ic=0; ic < 0x10000; ++ic) { if (chars[ic] == L'a') { u_beg = ic; break; } alt_sort_table[chars[ic]] = static_cast<wchar_t>(ic); } for (int ic=0xffff; ic > u_beg; --ic) { if (IsUpper(chars[ic])) { u_end = ic; break; } alt_sort_table[chars[ic]] = static_cast<wchar_t>(ic); } assert(u_beg > 0 && u_beg < u_end && u_end < 0xffff); int cc = u_beg; for (int ic=u_beg; ic <= u_end; ++ic) // uppercase first { if (IsUpper(chars[ic])) alt_sort_table[chars[ic]] = static_cast<wchar_t>(cc++); } for (int ic=u_beg; ic <= u_end; ++ic) // than not uppercase { if (!IsUpper(chars[ic])) alt_sort_table[chars[ic]] = static_cast<wchar_t>(cc++); } assert(cc == u_end+1); return alt_sort_table; }