-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmix.cpp
More file actions
106 lines (88 loc) · 2.68 KB
/
mix.cpp
File metadata and controls
106 lines (88 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "windows.h"
#include "mix.hpp"
#include "filetagslng.hpp"
#include "DlgBuilder.hpp"
#include "PluginSettings.hpp"
#include "guid.hpp"
const wchar_t *GetMsg(int MsgId) {
return ::Info.GetMsg(&MainGuid,MsgId);
}
int Config(const ConfigureInfo* CInfo) {
const int configMatchIds[] = {
MConfigIncludesFilter,
MConfigEqualsFilter,
};
wchar_t tagMarker[256];
wcsncpy_s(tagMarker, Opt.TagMarker.c_str(), ARRAYSIZE(tagMarker)-1);
PluginDialogBuilder Builder(::Info, MainGuid, ConfigDialogGuid, MConfigTitle, L"Config");
Builder.AddText(MConfigMatch);
Builder.AddRadioButtons(&Opt.ExactMatch, ARRAYSIZE(configMatchIds), configMatchIds);
Builder.AddSeparator();
Builder.AddText(MConfigTagMarker);
Builder.AddEditField(tagMarker, ARRAYSIZE(tagMarker), 20);
Builder.AddSeparator();
Builder.AddCheckbox(MConfigStorePanelMode, &Opt.StorePanelMode);
Builder.AddOKCancel(MOk, MCancel);
if (Builder.ShowDialog()) {
Opt.TagMarker = tagMarker;
PluginSettings settings(MainGuid, ::Info.SettingsControl);
settings.Set(0, OptionExactMatch, Opt.ExactMatch);
settings.Set(0, OptionTagMarker, tagMarker);
settings.Set(0, OptionStorePanelMode, Opt.StorePanelMode);
notifier.notify();
return 1;
}
return 0;
}
std::vector<char> ucs2oem(const std::wstring &s) {
std::vector<char> result;
int sizeRequired = WideCharToMultiByte(CP_OEMCP, 0, s.c_str(), (int)s.size(),
nullptr, 0, nullptr, nullptr);
if (sizeRequired > 0) {
result.resize(sizeRequired);
WideCharToMultiByte(CP_OEMCP, 0, s.c_str(), (int)s.size(),
&(*result.begin()), sizeRequired, nullptr, nullptr);
}
return result;
}
std::vector<char> ucs2utf(const std::wstring &s) {
std::vector<char> result;
int sizeRequired = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), (int)s.size(),
nullptr, 0, nullptr, nullptr);
if (sizeRequired > 0) {
result.resize(sizeRequired);
WideCharToMultiByte(CP_UTF8, 0, s.c_str(), (int)s.size(),
&(*result.begin()), sizeRequired, nullptr, nullptr);
}
return result;
}
std::wstring oem2ucs(const char *buf, size_t nChars) {
std::wstring result;
if (nChars != 0) {
result.resize(nChars);
if (MultiByteToWideChar(CP_OEMCP, 0, buf, (int)nChars,
&(*result.begin()), (int)nChars) == 0)
{
result.clear();
}
}
return result;
}
std::wstring oem2ucs(const std::vector<char> &buf) {
return oem2ucs(&(*buf.begin()), buf.size());
}
std::wstring utf2ucs(const char *buf, size_t nChars) {
std::wstring result;
if (nChars != 0) {
result.resize(nChars);
if (MultiByteToWideChar(CP_UTF8, 0, buf, (int)nChars,
&(*result.begin()), (int)nChars) == 0)
{
result.clear();
}
}
return result;
}
std::wstring utf2ucs(const std::vector<char> &buf) {
return utf2ucs(&(*buf.begin()), buf.size());
}