INT_PTR WINAPI ConEmuAbout::aboutProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { INT_PTR lRc = 0; if (DonateBtns_Process(hDlg, messg, wParam, lParam, lRc) || EditIconHint_Process(hDlg, messg, wParam, lParam, lRc)) { SetWindowLongPtr(hDlg, DWLP_MSGRESULT, lRc); return TRUE; } PatchMsgBoxIcon(hDlg, messg, wParam, lParam); switch (messg) { case WM_INITDIALOG: { gpConEmu->OnOurDialogOpened(); mh_AboutDlg = hDlg; DonateBtns_Add(hDlg, pIconCtrl, IDOK); if (mp_DpiAware) { mp_DpiAware->Attach(hDlg, ghWnd, CDynDialog::GetDlgClass(hDlg)); } RECT rect = {}; if (GetWindowRect(hDlg, &rect)) { CDpiAware::GetCenteredRect(ghWnd, rect); MoveWindowRect(hDlg, rect); } if ((ghOpWnd && IsWindow(ghOpWnd)) || (WS_EX_TOPMOST & GetWindowLongPtr(ghWnd, GWL_EXSTYLE))) { SetWindowPos(hDlg, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE); } LPCWSTR pszActivePage = (LPCWSTR)lParam; wchar_t* pszTitle = lstrmerge(gpConEmu->GetDefaultTitle(), L" About"); if (pszTitle) { SetWindowText(hDlg, pszTitle); SafeFree(pszTitle); } if (hClassIcon) { SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hClassIcon); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)CreateNullIcon()); SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)hClassIcon); } SetDlgItemText(hDlg, stConEmuAbout, pAboutTitle); SetDlgItemText(hDlg, stConEmuUrl, gsHomePage); EditIconHint_Set(hDlg, GetDlgItem(hDlg, tAboutSearch), true, L"Search", false, UM_SEARCH, IDOK); EditIconHint_Subclass(hDlg); wchar_t* pszLabel = GetDlgItemTextPtr(hDlg, stConEmuVersion); if (pszLabel) { wchar_t* pszSet = NULL; if (gpUpd) { wchar_t* pszVerInfo = gpUpd->GetCurVerInfo(); if (pszVerInfo) { pszSet = lstrmerge(pszLabel, L" ", pszVerInfo); free(pszVerInfo); } } if (!pszSet) { pszSet = lstrmerge(pszLabel, L" ", L"Please check for updates manually"); } if (pszSet) { SetDlgItemText(hDlg, stConEmuVersion, pszSet); free(pszSet); } free(pszLabel); } HWND hTab = GetDlgItem(hDlg, tbAboutTabs); INT_PTR nPage = -1; for (size_t i = 0; i < countof(Pages); i++) { TCITEM tie = {}; tie.mask = TCIF_TEXT; tie.pszText = (LPWSTR)Pages[i].Title; TabCtrl_InsertItem(hTab, i, &tie); if (pszActivePage && (lstrcmpi(pszActivePage, Pages[i].Title) == 0)) nPage = i; } if (nPage >= 0) { TabSelected(hDlg, nPage); TabCtrl_SetCurSel(hTab, (int)nPage); } else if (!pszActivePage) { TabSelected(hDlg, 0); } else { _ASSERTE(pszActivePage==NULL && "Unknown page name?"); } SetFocus(hTab); return FALSE; } case WM_CTLCOLORSTATIC: if (GetWindowLongPtr((HWND)lParam, GWLP_ID) == stConEmuUrl) { SetTextColor((HDC)wParam, GetSysColor(COLOR_HOTLIGHT)); HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)hBrush; } else { SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)hBrush; } break; case WM_SETCURSOR: { if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == stConEmuUrl) { SetCursor(LoadCursor(NULL, IDC_HAND)); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE); return TRUE; } return FALSE; } break; case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: case IDCLOSE: aboutProc(hDlg, WM_CLOSE, 0, 0); return 1; case stConEmuUrl: ConEmuAbout::OnInfo_HomePage(); return 1; } // BN_CLICKED break; case EN_SETFOCUS: switch (LOWORD(wParam)) { case tAboutText: { // Do not autosel all text HWND hEdit = (HWND)lParam; DWORD nStart = 0, nEnd = 0; SendMessage(hEdit, EM_GETSEL, (WPARAM)&nStart, (LPARAM)&nEnd); if (nStart != nEnd) { SendMessage(hEdit, EM_SETSEL, nTextSelStart, nTextSelEnd); } } break; } } // switch (HIWORD(wParam)) break; case WM_NOTIFY: { LPNMHDR nmhdr = (LPNMHDR)lParam; if ((nmhdr->code == TCN_SELCHANGE) && (nmhdr->idFrom == tbAboutTabs)) { int iPage = TabCtrl_GetCurSel(nmhdr->hwndFrom); if ((iPage >= 0) && (iPage < (int)countof(Pages))) TabSelected(hDlg, iPage); } break; } case UM_SEARCH: searchProc(hDlg, (HWND)lParam, false); break; case UM_EDIT_KILL_FOCUS: SendMessage((HWND)lParam, EM_GETSEL, (WPARAM)&nTextSelStart, (LPARAM)&nTextSelEnd); break; case WM_CLOSE: //if (ghWnd == NULL) gpConEmu->OnOurDialogClosed(); if (mp_DpiAware) mp_DpiAware->Detach(); EndDialog(hDlg, IDOK); //else // DestroyWindow(hDlg); break; case WM_DESTROY: mh_AboutDlg = NULL; break; default: if (mp_DpiAware && mp_DpiAware->ProcessDpiMessages(hDlg, messg, wParam, lParam)) { return TRUE; } } return FALSE; }
void ConEmuAbout::searchProc(HWND hDlg, HWND hSearch, bool bReentr) { HWND hEdit = GetDlgItem(hDlg, tAboutText); wchar_t* pszPart = GetDlgItemTextPtr(hSearch, 0); wchar_t* pszText = GetDlgItemTextPtr(hEdit, 0); bool bRetry = false; if (pszPart && *pszPart && pszText && *pszText) { LPCWSTR pszFrom = pszText; DWORD nStart = 0, nEnd = 0; SendMessage(hEdit, EM_GETSEL, (WPARAM)&nStart, (LPARAM)&nEnd); size_t cchMax = wcslen(pszText); size_t cchFrom = max(nStart,nEnd); if (cchMax > cchFrom) pszFrom += cchFrom; LPCWSTR pszFind = StrStrI(pszFrom, pszPart); if (!pszFind && bReentr && (pszFrom != pszText)) pszFind = StrStrI(pszText, pszPart); if (pszFind) { const wchar_t szBrkChars[] = L"()[]<>{}:;,.-=\\/ \t\r\n"; LPCWSTR pszEnd = wcspbrk(pszFind, szBrkChars); INT_PTR nPartLen = wcslen(pszPart); if (!pszEnd || ((pszEnd - pszFind) > max(nPartLen,60))) pszEnd = pszFind + nPartLen; while ((pszFind > pszFrom) && !wcschr(szBrkChars, *(pszFind-1))) pszFind--; //SetFocus(hEdit); nTextSelStart = (DWORD)(pszEnd-pszText); nTextSelEnd = (DWORD)(pszFind-pszText); SendMessage(hEdit, EM_SETSEL, nTextSelStart, nTextSelEnd); SendMessage(hEdit, EM_SCROLLCARET, 0, 0); } else if (!bReentr) { HWND hTab = GetDlgItem(hDlg, tbAboutTabs); int iPage = TabCtrl_GetCurSel(hTab); int iFound = -1; for (int s = 0; (iFound == -1) && (s <= 1); s++) { int iFrom = (s == 0) ? (iPage+1) : 0; int iTo = (s == 0) ? (int)countof(Pages) : (iPage-1); for (int i = iFrom; i < iTo; i++) { if (StrStrI(Pages[i].Title, pszPart) || StrStrI(Pages[i].Text, pszPart)) { iFound = i; break; } } } if (iFound >= 0) { TabSelected(hDlg, iFound); TabCtrl_SetCurSel(hTab, iFound); //SetFocus(hEdit); bRetry = true; } } } SafeFree(pszPart); SafeFree(pszText); if (bRetry) { searchProc(hDlg, hSearch, true); } }
void breakKey(string str) { int index=0; string command; string name; string tt; string s; name.clear(); //Reading the command name for(int i=0;i<(int)str.length();i++) { if(str[i]==' ') { index=i; break; } command.push_back(str[i]); } if(command.compare("store")==0) { nextisget=0; for(int i=index+1;i<(int)str.length();i++) { if(str[i]==' ') { index=i; break; } name.push_back(str[i]); } for(int i=index+1;i<(int)str.length();i++) { if(str[i]==' ') { index=i; break; } tt.push_back(str[i]); } //Splitting all the strings for(int i=index+1;i<(int)str.length();i++) { if(str[i]=='='||str[i]==' ') { std::transform(s.begin(),s.end(),s.begin(),::tolower); keywords.push_back(s); s.clear(); continue; } if(str[i]!='\"') s.push_back(str[i]); else { if(i==((int)str.length()-1)) { std::transform(s.begin(),s.end(),s.begin(),::tolower); keywords.push_back(s); s.clear(); } } } store(name,atoi(tt.c_str()),keywords); //display(); } else if(command.compare("search")==0) { localsearchbuffer.clear(); string type; string content; vector<string> v; vector<searchresponse> j; vector<string> fd; vector<string> md; /*---------Reading the type of the file---------------*/ for(int i=index+1;i<(int)str.length();i++) { if(str[i]=='=') { index=i; break; } type.push_back(str[i]); } /*----------------------------------------------------*/ for(int i=index+1;i<(int)str.length();i++) { content.push_back(str[i]); } if(type.compare("filename")==0) { v.push_back(content); j=searchProc(v,0); search(0,v); } if(type.compare("sha1hash")==0) { char ab[40]; string snd; reassign(ab,content); unsigned char shg[20]; stripIndex(ab,shg); snd=assign(shg); v.push_back(snd); j=searchProc(v,1); search(1,v); } if(type.compare("keywords")==0) { int nospace=1; for(int i=index+1;i<(int)str.length();i++) { if(str[i]=='\"'&&i==(index+1)) continue; if(str[i]==' '||str[i]=='\"') { v.push_back(s); s.clear(); nospace=0; continue; } s.push_back(str[i]); } if(nospace) { v.push_back(s); } j=searchProc(v,2); search(2,v); /*for(int i=0;i<(int)v.size();i++) cout<<v[i]<<endl;*/ } for(int i=0;i<(int)j.size();i++) { md.push_back(j[i].fileid); fd.push_back(j[i].mdata); } searchResponse(md,fd); int sid=1; while(search_flag) { pthread_mutex_lock(&globalbufferlock); if(globalsearchbuffer.size()==0) { pthread_mutex_unlock(&globalbufferlock); //cout<<"sleeping"<<endl; sleep(1); continue; } for(int i=0;i<(int)globalsearchbuffer.size();i++) { localsearchbuffer.push_back(globalsearchbuffer[i]); displaySearchResponse(globalsearchbuffer[i],sid); sid++; } globalsearchbuffer.clear(); pthread_mutex_unlock(&globalbufferlock); } search_flag=1; nextisget=1; } else if(command.compare("get")==0) { if(nextisget) { string no; int ino; int extfile_flag=0; getres gs; getExtFile.clear(); /*---------Reading the type of the file---------------*/ for(int i=index+1;i<(int)str.length();i++) { if(str[i]==' ') { index=i; extfile_flag=1; break; } no.push_back(str[i]); } /*----------------------------------------------------*/ string nameoffile; if(extfile_flag==1) { for(int i=index+1;i<(int)str.length();i++) { nameoffile.push_back(str[i]); } } ino=atoi(no.c_str()); if(localsearchbuffer.size()!=0) { gs=localsearchbuffer[ino-1]; } if(extfile_flag) { getExtFile.assign(nameoffile); //cout<<nameoffile<<"Sdsd"<<endl; if(fileExistsInCurr(nameoffile)) { string dec; cout<<"THE FILE EXISTS...SHOULD WE OVERWRITE THE FILE(yes/no)\n"; cin>>dec; bug=1; if(dec[0]=='y'||dec[0]=='Y') { //cout<<"he is asking us to rewrite the file"; get_UI(gs.fileid,gs.sha1); } else { cout<<"FILE RETRY FAILED\n"; } } else { //cout<<"Calling get"<<endl; get_UI(gs.fileid,gs.sha1); } } else { getExtFile.assign(gs.filename); if(fileExistsInCurr(gs.filename)) { string dec; cout<<"THE FILE EXISTS...SHOULD WE OVERWRITE THE FILE(yes/no)"; cin>>dec; bug=1; if(dec[0]=='y'||dec[0]=='Y') { get_UI(gs.fileid,gs.sha1); } else { cout<<"RETRY FAILED"<<endl; } } else {