Fix action icons in the log dialog being clipped on High-DPI displays
[TortoiseGit.git] / ext / scintilla / src / CaseFolder.cxx
blob3cf429e1d270420116ac600ed7b685ec3163b507
1 // Scintilla source code edit control
2 /** @file CaseFolder.cxx
3 ** Classes for case folding.
4 **/
5 // Copyright 1998-2013 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #include <stdexcept>
9 #include <vector>
10 #include <algorithm>
12 #include "CaseFolder.h"
13 #include "CaseConvert.h"
14 #include "UniConversion.h"
16 #ifdef SCI_NAMESPACE
17 using namespace Scintilla;
18 #endif
20 CaseFolder::~CaseFolder() {
23 CaseFolderTable::CaseFolderTable() {
24 for (size_t iChar=0; iChar<sizeof(mapping); iChar++) {
25 mapping[iChar] = static_cast<char>(iChar);
29 CaseFolderTable::~CaseFolderTable() {
32 size_t CaseFolderTable::Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) {
33 if (lenMixed > sizeFolded) {
34 return 0;
35 } else {
36 for (size_t i=0; i<lenMixed; i++) {
37 folded[i] = mapping[static_cast<unsigned char>(mixed[i])];
39 return lenMixed;
43 void CaseFolderTable::SetTranslation(char ch, char chTranslation) {
44 mapping[static_cast<unsigned char>(ch)] = chTranslation;
47 void CaseFolderTable::StandardASCII() {
48 for (size_t iChar=0; iChar<sizeof(mapping); iChar++) {
49 if (iChar >= 'A' && iChar <= 'Z') {
50 mapping[iChar] = static_cast<char>(iChar - 'A' + 'a');
51 } else {
52 mapping[iChar] = static_cast<char>(iChar);
57 CaseFolderUnicode::CaseFolderUnicode() {
58 StandardASCII();
59 converter = ConverterFor(CaseConversionFold);
62 size_t CaseFolderUnicode::Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) {
63 if ((lenMixed == 1) && (sizeFolded > 0)) {
64 folded[0] = mapping[static_cast<unsigned char>(mixed[0])];
65 return 1;
66 } else {
67 return converter->CaseConvertString(folded, sizeFolded, mixed, lenMixed);