KeyObject& PerconaFTIterator::Key(bool clone_str) { if (m_key.GetType() > 0) { if (clone_str && m_key.GetKey().IsCStr()) { m_key.CloneStringPart(); } return m_key; } Slice key = RawKey(); Buffer kbuf(const_cast<char*>(key.data()), 0, key.size()); m_key.Decode(kbuf, clone_str); m_key.SetNameSpace(m_ns); return m_key; }
void PerconaFTIterator::Del() { RawKey(); CHECK_EXPR(m_db->del(m_db, m_txn, &m_raw_key, 0)); }
void ShowProcessList() { static bool Active = false; if (Active) return; Active = true; SCOPE_EXIT{ Active = false; }; const auto ProcList = VMenu2::create(msg(lng::MProcessListTitle), {}, ScrY - 4); ProcList->SetMenuFlags(VMENU_WRAPMODE); ProcList->SetPosition({ -1, -1, 0, 0 }); bool ShowImage = false; const auto FillProcList = [&] { ProcList->clear(); ProcInfo Info{ ProcList.get(), ShowImage }; if (!EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&Info))) { rethrow_if(Info.ExceptionPtr); return false; } ProcList->SortItems([](const MenuItemEx& a, const MenuItemEx& b, SortItemParam&) { return string_sort::less(std::any_cast<const menu_data&>(a.ComplexUserData).Title, std::any_cast<const menu_data&>(b.ComplexUserData).Title); }); return true; }; if (!FillProcList()) return; ProcList->AssignHighlights(FALSE); ProcList->SetBottomTitle(msg(lng::MProcessListBottom)); ProcList->Run([&](const Manager::Key& RawKey) { const auto Key=RawKey(); int KeyProcessed = 1; switch (Key) { case KEY_F1: help::show(L"TaskList"sv); break; case KEY_NUMDEL: case KEY_DEL: { if (const auto MenuData = ProcList->GetComplexUserDataPtr<menu_data>()) { if (Message(MSG_WARNING, msg(lng::MKillProcessTitle), { msg(lng::MAskKillProcess), MenuData->Title, msg(lng::MKillProcessWarning) }, { lng::MKillProcessKill, lng::MCancel }) == Message::first_button) { const os::handle Process(OpenProcess(PROCESS_TERMINATE, FALSE, MenuData->Pid)); if (!Process || !TerminateProcess(Process.native_handle(), 0xFFFFFFFF)) { const auto ErrorState = error_state::fetch(); Message(MSG_WARNING, ErrorState, msg(lng::MKillProcessTitle), { msg(lng::MCannotKillProcess) }, { lng::MOk }); } } } } [[fallthrough]]; case KEY_CTRLR: case KEY_RCTRLR: { if (!FillProcList()) ProcList->Close(-1); break; } case KEY_F2: { // TODO: change titles, don't enumerate again ShowImage = !ShowImage; const auto SelectPos = ProcList->GetSelectPos(); if (!FillProcList()) { ProcList->Close(-1); } else { ProcList->SetSelectPos(SelectPos); } break; } default: KeyProcessed = 0; } return KeyProcessed; }); if (ProcList->GetExitCode() < 0) return; const auto MenuData = ProcList->GetComplexUserDataPtr<menu_data>(); if (!MenuData) return; SwitchToWindow(MenuData->Hwnd); }