Skip to content

Commit 42ae59b

Browse files
committed
Add Adv. Option fo slugify separator
1 parent b4e9501 commit 42ae59b

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

AdvGeneral.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ END_MESSAGE_MAP()
138138
#define SETTING_DISABLE_FRIENDS 87
139139
#define SETTING_IGNORE_FALSE_COPIES_DEALY 88
140140
#define SETTING_REFRESH_VIEW_AFTER_PASTE 89
141+
#define SETTING_SLUGIFY_SEPARATOR 90
141142

142143

143144
BOOL CAdvGeneral::OnInitDialog()
@@ -254,6 +255,8 @@ BOOL CAdvGeneral::OnInitDialog()
254255
AddTrueFalse(pGroupTest, _T("Show text for first ten copy hot keys"), CGetSetOptions::GetShowTextForFirstTenHotKeys(), SETTING_TEXT_FIRST_TEN);
255256
AddTrueFalse(pGroupTest, _T("Show thumbnails(for CF_DIB types) (could increase memory usage and display speed)"), CGetSetOptions::GetDrawThumbnail(), SETTING_DRAW_THUMBNAILS);
256257

258+
pGroupTest->AddSubItem(new CMFCPropertyGridProperty(_T("Slugify Separator (default: -)"), CGetSetOptions::GetSlugifySeparator(), _T(""), SETTING_SLUGIFY_SEPARATOR));
259+
257260
pGroupTest->AddSubItem(new CMFCPropertyGridProperty(_T("Text lines per clip"), CGetSetOptions::GetLinesPerRow(), _T(""), SETTING_LINES_PER_ROW));
258261

259262
pGroupTest->AddSubItem(new CMFCPropertyGridProperty(_T("Tooltip display time(ms) max of 32000 (-1 default (5 seconds), 0 to turn off)"), g_Opt.m_tooltipTimeout, _T(""), SETTING_TOOLTIP_TIMEOUT));
@@ -760,6 +763,12 @@ void CAdvGeneral::OnBnClickedOk()
760763
CGetSetOptions::SetDefaultCutString(pNewValue->bstrVal);
761764
}
762765
break;
766+
case SETTING_SLUGIFY_SEPARATOR:
767+
if (wcscmp(pNewValue->bstrVal, pOrigValue->bstrVal) != 0)
768+
{
769+
CGetSetOptions::SetSlugifySeparator(pNewValue->bstrVal);
770+
}
771+
break;
763772
case SETTING_REVERT_TO_TOP_LEVEL_GROUP:
764773
if (wcscmp(pNewValue->bstrVal, pOrigValue->bstrVal) != 0)
765774
{

DittoSetup/BuildDitto.bld

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ DittoSetup*]]></ExclExt>
316316
".\Ditto\Language\French.xml" "Language\French.xml"
317317
".\Ditto\Language\Greek.xml" "Language\Greek.xml"
318318
".\Ditto\Language\Hebrew.xml" "Language\Hebrew.xml"
319-
".\Ditto\Language\italiano.xml" "Language\italiano.xml"
319+
".\Ditto\Language\Italian.xml" "Language\Italian.xml"
320320
".\Ditto\Language\Japanese.xml" "Language\Japanese.xml"
321321
".\Ditto\Language\Korean.xml" "Language\Korean.xml"
322322
".\Ditto\Language\Persian.xml" "Language\Persian.xml"

OleClipSource.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ void COleClipSource::Slugify(CClip &clip)
13581358
//free the old text we are going to replace it below with an upper case version
13591359
unicodeTextFormat->Free();
13601360

1361-
CString newString = slugify(cs.GetString()).c_str();
1361+
CString newString = slugify(cs.GetString(), CGetSetOptions::GetSlugifySeparator().GetString()).c_str();
13621362

13631363
long len = newString.GetLength();
13641364
HGLOBAL hGlobal = NewGlobalP(newString.GetBuffer(), ((len + 1) * sizeof(wchar_t)));

Options.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -2961,4 +2961,16 @@ void CGetSetOptions::SetRefreshViewAfterPasting(BOOL val)
29612961
{
29622962
m_refreshViewAfterPasting = val;
29632963
SetProfileLong("RefreshViewAfterPasting", val);
2964-
}
2964+
}
2965+
2966+
2967+
CString CGetSetOptions::GetSlugifySeparator()
2968+
{
2969+
return GetProfileString("SlugifySeparator", _T("-"));
2970+
}
2971+
2972+
void CGetSetOptions::SetSlugifySeparator(CString val)
2973+
{
2974+
SetProfileString("SlugifySeparator", val);
2975+
}
2976+

Options.h

+3
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ class CGetSetOptions
669669
static BOOL m_refreshViewAfterPasting;
670670
static BOOL GetRefreshViewAfterPasting();
671671
static void SetRefreshViewAfterPasting(BOOL val);
672+
673+
static CString GetSlugifySeparator();
674+
static void SetSlugifySeparator(CString val);
672675
};
673676

674677
// global for easy access and for initialization of fast access variables

Slugify.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ std::wstring trim(const std::wstring &s)
2929
}
3030

3131
// SLUGIFY
32-
std::wstring slugify(std::wstring input)
32+
std::wstring slugify(std::wstring input, std::wstring separator)
3333
{
3434
std::unordered_map<std::wstring, std::wstring> charMap{
3535
// latin
@@ -117,9 +117,11 @@ std::wstring slugify(std::wstring input)
117117

118118
trim(input);
119119

120-
//replace spaces with hyphens
121-
std::wregex e3(_T("[-\\s]+"));
122-
input = std::regex_replace(input, e3, _T("-"));
120+
auto replaceSpacesAndSep = _T("[") + separator + _T("\\s]+");
121+
122+
//replace spaces with separator
123+
std::wregex e3(replaceSpacesAndSep);
124+
input = std::regex_replace(input, e3, separator);
123125

124126
return input;
125127
};

0 commit comments

Comments
 (0)