MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / EditEncloseSelectionDlgProc

Function EditEncloseSelectionDlgProc

src/Edit.c:5682–5754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5680
5681
5682INT_PTR CALLBACK EditEncloseSelectionDlgProc ( HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam )
5683{
5684 const WCHAR* _left_braces = L"<{([";
5685 const WCHAR* _right_braces = L">})]";
5686 const WCHAR* _special_symbs = L"`~!@#%^*-_+=|\\/:;\"',.?";
5687 static PENCLOSESELDATA pdata;
5688 switch (umsg) {
5689 case WM_INITDIALOG: {
5690 pdata = (PENCLOSESELDATA)lParam;
5691 SendDlgItemMessage(hwnd, 100, EM_LIMITTEXT, 255, 0);
5692 SetDlgItemTextW(hwnd, 100, pdata->pwsz1);
5693 SendDlgItemMessage(hwnd, 101, EM_LIMITTEXT, 255, 0);
5694 SetDlgItemTextW(hwnd, 101, pdata->pwsz2);
5695 CenterDlgInParent(hwnd);
5696 }
5697 return TRUE;
5698 case WM_COMMAND:
5699 switch (LOWORD(wParam)) {
5700 case 100: {
5701 if (HIWORD(wParam) == EN_CHANGE) {
5702 WCHAR wcIns[256], wcBuf[256];
5703 WCHAR* br;
5704 BOOL brackets;
5705 int bCount;
5706 //
5707 GetDlgItemTextW(hwnd, 100, wcBuf, 255);
5708 //
5709 *wcIns = L'\0';
5710 bCount = 0;
5711 brackets = TRUE;
5712 if (!*wcBuf){
5713 bCount = -1;
5714 }
5715 else{
5716 while (br = StrChr(_left_braces, *(wcBuf + bCount))){
5717 wcIns[bCount++] = _right_braces[br - _left_braces];
5718 }
5719 wcIns[bCount] = '\0';
5720 }
5721 //
5722 if (0 == bCount){
5723 br = StrChr(_special_symbs, *(wcBuf ));
5724 while (br && *br == *(wcBuf + bCount)){
5725 wcIns[bCount++] = *br;
5726 brackets = FALSE;
5727 }
5728 wcIns[bCount] = '\0';
5729 }
5730
5731 //
5732 if (bCount){
5733 if (brackets){
5734 HL_inplace_rev(wcIns);
5735 }
5736 SetDlgItemTextW(hwnd, 101, wcIns);
5737 }
5738 }
5739 }

Callers

nothing calls this directly

Calls 2

CenterDlgInParentFunction · 0.85
HL_inplace_revFunction · 0.85

Tested by

no test coverage detected