📄 compleximapfindwinc.c
字号:
// for (index=0; !found && index<start; index++) { item = (MsgItemC*)msgList[index]; found = This->numList.includes(item->msg->Number()); }//// Select the item if it was found// if ( found ) {//// See if there is an unpinned reading window displayed// Boolean found = False; unsigned rcount = ishApp->readWinList.size(); for (int i=0; !found && i<rcount; i++) { ReadWinC *readWin = (ReadWinC*)*ishApp->readWinList[i]; found = (readWin->IsShown() && !readWin->Pinned()); } if ( found ) { ishApp->DisplayMessage(item->msg); } else { ishApp->mainWin->FieldView().ScrollToItem(*item); ishApp->mainWin->MsgVBox().SelectItemOnly(*item); }// // Next time, start at message after this one// This->findIndex = index + 1; if ( This->findIndex >= count ) This->findIndex = 0; } else { This->findIndex = 0; ishApp->mainWin->MsgVBox().DeselectAllItems(); This->Message("No match"); XBell(halApp->display, ishApp->appPrefs->bellVolume); } ishApp->mainWin->BusyCursor(False); This->stateChanged = False;} // End DoFindNext/*--------------------------------------------------------------- * Callback routine to handle press of find prev */voidComplexImapFindWinC::DoFindPrev(Widget, ComplexImapFindWinC *This, XtPointer){ This->ClearMessage(); ishApp->mainWin->BusyCursor(True); if ( This->stateChanged ) if ( !This->GetNumList() ) return; VBoxC& vbox = ishApp->mainWin->MsgVBox(); VItemListC& msgList = vbox.VisItems(); u_int count = msgList.size();//// If there is a single selected message, use that as the start index// int start; VItemListC& selList = ishApp->mainWin->MsgVBox().SelItems(); if ( selList.size() == 1 ) { VItemC *vi = selList[0]; start = msgList.indexOf(vi) - 1; if ( start <= 0 ) start = count-1; } else start = This->findIndex;//// Loop from the start position to the beginning of the list and look for the// previous message whose number appears in the IMAP number list// Boolean found = False; MsgItemC *item; int index; for (index=start; !found && index>=0; index--) { item = (MsgItemC*)msgList[index]; found = This->numList.includes(item->msg->Number()); }//// Loop from the end of the list to the start position// for (index=count-1; !found && index>start; index--) { item = (MsgItemC*)msgList[index]; found = This->numList.includes(item->msg->Number()); } if ( found ) {//// See if there is an unpinned reading window displayed// Boolean found = False; unsigned rcount = ishApp->readWinList.size(); for (int i=0; !found && i<rcount; i++) { ReadWinC *readWin = (ReadWinC*)*ishApp->readWinList[i]; found = (readWin->IsShown() && !readWin->Pinned()); } if ( found ) { ishApp->DisplayMessage(item->msg); } else { ishApp->mainWin->FieldView().ScrollToItem(*item); ishApp->mainWin->MsgVBox().SelectItemOnly(*item); }// // Next time, start at message before this one// This->findIndex = index - 1; if ( This->findIndex <= 0 ) This->findIndex = count - 1; } else { ishApp->mainWin->MsgVBox().DeselectAllItems(); This->Message("No match"); XBell(halApp->display, ishApp->appPrefs->bellVolume); } ishApp->mainWin->BusyCursor(False); This->stateChanged = False;} // End DoFindPrev/*--------------------------------------------------------------- * Callback routine to handle press of find all */voidComplexImapFindWinC::DoFindAll(Widget, ComplexImapFindWinC *This, XtPointer){ This->ClearMessage(); ishApp->mainWin->BusyCursor(True); if ( This->stateChanged ) if ( !This->GetNumList() ) return; This->findIndex = 0; ishApp->mainWin->MsgVBox().DeselectAllItems(False);//// Loop through the visible messages. Select any that appear in the numList// VBoxC& vbox = ishApp->mainWin->MsgVBox(); VItemListC& msgList = vbox.VisItems(); unsigned count = msgList.size(); for (int i=0; i<count; i++) {//// See if this one matches// MsgItemC *item = (MsgItemC*)msgList[i]; if ( This->numList.includes(item->msg->Number()) ) vbox.SelectItem(*item, False); } VItemListC& selItems = ishApp->mainWin->MsgVBox().SelItems(); if ( selItems.size() > 0 ) { StringC tmp; tmp += (int)selItems.size(); tmp += " item"; if ( selItems.size() > 1 ) tmp += "s"; tmp += " selected"; This->Message(tmp);//// See if there is an unpinned reading window displayed// Boolean found = False; unsigned rcount = ishApp->readWinList.size(); for (int i=0; !found && i<rcount; i++) { ReadWinC *readWin = (ReadWinC*)*ishApp->readWinList[i]; found = (readWin->IsShown() && !readWin->Pinned()); } MsgItemC *item = (MsgItemC*)selItems[0]; if ( found ) ishApp->DisplayMessage(item->msg); else ishApp->mainWin->FieldView().ScrollToItem(*item); } else { This->Message("No match"); XBell(halApp->display, ishApp->appPrefs->bellVolume); } ishApp->mainWin->MsgVBox().Refresh(); ishApp->mainWin->EnableButtons(); ishApp->mainWin->BusyCursor(False); This->stateChanged = False;} // End DoFindAll/*--------------------------------------------------------------- * Method to query the IMAP server for a list of the numbers of matching * messages. */BooleanComplexImapFindWinC::GetNumList(){//// Build query string. At this point we know we're checking the body// StringC query; CharC str; if ( !AddTerm(query, "TO", toTB, toTF) ) return False; if ( !AddTerm(query, "CC", ccTB, ccTF) ) return False; if ( !AddTerm(query, "BCC", bccTB, bccTF) ) return False; if ( !AddTerm(query, "FROM", fromTB, fromTF) ) return False; if ( !AddTerm(query, "SUBJECT", subjTB, subjTF) ) return False; if ( !AddTerm(query, "BODY", bodyTB, bodyTF) ) return False; if ( !AddTerm(query, "TEXT", msgTB, msgTF) ) return False; if ( !AddTerm(query, "BEFORE", befDateTB, befDateTF) ) return False; if ( !AddTerm(query, "ON", onDateTB, onDateTF) ) return False; if ( !AddTerm(query, "SINCE", aftDateTB, aftDateTF) ) return False; if ( !AddTerm(query, "RECENT", recTB) ) return False; if ( !AddTerm(query, "OLD", notRecTB) ) return False; if ( !AddTerm(query, "SEEN", seenTB) ) return False; if ( !AddTerm(query, "UNSEEN", notSeenTB) ) return False; if ( !AddTerm(query, "ANSWERED", repTB) ) return False; if ( !AddTerm(query, "UNANSWERED", notRepTB) ) return False; if ( !AddTerm(query, "DELETED", delTB) ) return False; if ( !AddTerm(query, "UNDELETED", notDelTB) ) return False;//// Run search// ImapFolderC *folder = (ImapFolderC*)ishApp->mainWin->curFolder; StringListC output; numList.removeAll(); if ( !folder->server->Search(query, numList, output) ) { StringC errmsg("Could not communicate with IMAP server "); errmsg += folder->server->name; PopupMessage(errmsg); return False; } return True;} // End GetNumList/*--------------------------------------------------------------- * Method to add a query term for the specified text field */BooleanComplexImapFindWinC::AddTerm(StringC& query, const char *key, Widget tb, Widget tf){ if ( !XmToggleButtonGetState(tb) ) return True; char *cs = XmTextFieldGetString(tf); CharC str(cs); str.Trim(); if ( str.Length() == 0 ) { set_invalid(tf, True, True); StringC errmsg("Please enter a search string."); PopupMessage(errmsg); return False; } StringListC valList; ExtractList(str, valList, ","); u_int count = valList.size(); for (int i=0; i<count; i++) { StringC *val = valList[i];//// Fix escaped commas// int pos = val->PosOf("\\,"); while ( pos >= 0 ) { (*val)(pos,2) = ","; pos = val->PosOf("\\,", (u_int)(pos+1)); }//// Add term// query += key; query += " {"; query += (int)val->size(); query += "}\r\n"; query += *val; query += ' '; } // End for each value return True;} // End AddTerm/*--------------------------------------------------------------- * Method to add a query term for the specified toggle */BooleanComplexImapFindWinC::AddTerm(StringC& query, const char *key, Widget tb){ if ( XmToggleButtonGetState(tb) ) { query += key; query += ' '; } return True;} // End AddTerm/*--------------------------------------------------------------- * Callback routine to handle press of clear */voidComplexImapFindWinC::DoClear(Widget, ComplexImapFindWinC *This, XtPointer){ XmTextFieldSetString(This->toTF, ""); XmTextFieldSetString(This->ccTF, ""); XmTextFieldSetString(This->bccTF, ""); XmTextFieldSetString(This->fromTF, ""); XmTextFieldSetString(This->subjTF, ""); XmTextFieldSetString(This->bodyTF, ""); XmTextFieldSetString(This->msgTF, ""); XmTextFieldSetString(This->befDateTF, ""); XmTextFieldSetString(This->onDateTF, ""); XmTextFieldSetString(This->aftDateTF, ""); XmToggleButtonSetState(This->recTB, False, True); XmToggleButtonSetState(This->notRecTB, False, True); XmToggleButtonSetState(This->seenTB, False, True); XmToggleButtonSetState(This->notSeenTB, False, True); XmToggleButtonSetState(This->repTB, False, True); XmToggleButtonSetState(This->notRepTB, False, True); XmToggleButtonSetState(This->delTB, False, True); XmToggleButtonSetState(This->notDelTB, False, True);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -