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

Function EditInsertTagDlgProc

src/Edit.c:5788–5994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5786
5787
5788INT_PTR CALLBACK EditInsertTagDlgProc ( HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam )
5789{
5790 //
5791 const WCHAR* _left_braces = L"<{([";
5792 const WCHAR* _right_braces = L">})]";
5793 static PTAGSDATA pdata;
5794 switch (umsg) {
5795 case WM_INITDIALOG: {
5796 WCHAR end[0xff] = L"</";
5797 INT len = lstrlen(hl_last_html_tag);
5798 pdata = (PTAGSDATA)lParam;
5799 SendDlgItemMessage(hwnd, 100, EM_LIMITTEXT, 254, 0);
5800 SetDlgItemTextW(hwnd, 100, hl_last_html_tag);
5801 SendDlgItemMessage(hwnd, 101, EM_LIMITTEXT, 255, 0);
5802 SetDlgItemTextW(hwnd, 101, hl_last_html_end_tag);
5803 //
5804 SetFocus(GetDlgItem(hwnd, 100));
5805#if 0
5806 if (len > 2 &&
5807 StrChr(_left_braces, hl_last_html_tag[0]) &&
5808 StrChr(_right_braces, hl_last_html_tag[len-1])
5809 ) {
5810 PostMessage(GetDlgItem(hwnd, 100), EM_SETSEL, 1, lstrlen(hl_last_html_tag) - 1);
5811 }
5812 else {
5813 PostMessage(GetDlgItem(hwnd, 100), EM_SETSEL, 0, lstrlen(hl_last_html_tag));
5814 }
5815#else
5816 {
5817 int k = 0;
5818 while (1)
5819 {
5820 if (len > k * 2 + 1 &&
5821 StrChr(_left_braces, hl_last_html_tag[k]) &&
5822 StrChr(_right_braces, hl_last_html_tag[len - k - 1])) {
5823 ++k;
5824 }
5825 else{
5826 break;
5827 }
5828 }
5829 if (k){
5830 PostMessage(GetDlgItem(hwnd, 100), EM_SETSEL, k, len - k );
5831 }
5832 else {
5833 PostMessage(GetDlgItem(hwnd, 100), EM_SETSEL, 0, len);
5834 }
5835 }
5836#endif
5837 CenterDlgInParent(hwnd);
5838 }
5839 return FALSE;
5840 case WM_COMMAND:
5841 switch (LOWORD(wParam)) {
5842 case 100: {
5843 if (HIWORD(wParam) == EN_CHANGE) {
5844 WCHAR wchBuf[256];
5845 WCHAR wchIns[256];

Callers

nothing calls this directly

Calls 2

CenterDlgInParentFunction · 0.85
HL_WTraceFunction · 0.85

Tested by

no test coverage detected