📄 complexmsgfindwinc.c
字号:
* push button is enabled only if the text field is not empty. */voidComplexMsgFindWinC::EnablePB(Widget tf, Widget pb, XtPointer){ char *cs = XmTextFieldGetString(tf); XtSetSensitive(pb, strlen(cs)>0); XtFree(cs);}/*--------------------------------------------------------------- * Callback routines to handle operator menu selections */voidComplexMsgFindWinC::ChangeDateOp(Widget w, ComplexMsgFindWinC *This, XtPointer){ MsgDateExpC::MsgDateOp ptr; XtVaGetValues(w, XmNuserData, &ptr, NULL); This->dateOp = ptr;}voidComplexMsgFindWinC::ChangeNumOp(Widget w, ComplexMsgFindWinC *This, XtPointer){ MsgNumExpC::MsgNumOp ptr; XtVaGetValues(w, XmNuserData, &ptr, NULL); This->numOp = ptr;}voidComplexMsgFindWinC::ChangeLineOp(Widget w, ComplexMsgFindWinC *This, XtPointer){ MsgLineExpC::MsgLineOp ptr; XtVaGetValues(w, XmNuserData, &ptr, NULL); This->lineOp = ptr;}voidComplexMsgFindWinC::ChangeByteOp(Widget w, ComplexMsgFindWinC *This, XtPointer){ MsgByteExpC::MsgByteOp ptr; XtVaGetValues(w, XmNuserData, &ptr, NULL); This->byteOp = ptr;}/*--------------------------------------------------------------- * Callback routine to handle press of status type button */voidComplexMsgFindWinC::ChangeStatus(Widget w, ComplexMsgFindWinC *This, XtPointer){ MsgStatusT ptr; XtVaGetValues(w, XmNuserData, &ptr, NULL); This->stat = ptr;}/*--------------------------------------------------------------- * Callback routine to handle press of "find prev" button in find * message dialog */voidComplexMsgFindWinC::DoFindPrev(Widget, ComplexMsgFindWinC *This, XtPointer){//// Replace the apply callback// This->RemoveApplyCallback((CallbackFn *)DoFind, (void *)This); This->AddApplyCallback((CallbackFn *)DoFindPrev2, (void *)This); This->Apply();//// Restore the apply callback// This->RemoveApplyCallback((CallbackFn *)DoFindPrev2, (void *)This); This->AddApplyCallback((CallbackFn *)DoFind, (void *)This);} // End DoFindPrev/*--------------------------------------------------------------- * Callback routine to handle press of "find all" button in find * message dialog */voidComplexMsgFindWinC::DoFindAll(Widget, ComplexMsgFindWinC *This, XtPointer){//// Replace the apply callback// This->RemoveApplyCallback((CallbackFn *)DoFind, (void *)This); This->AddApplyCallback((CallbackFn *)DoFindAll2, (void *)This); This->Apply();//// Restore the apply callback// This->RemoveApplyCallback((CallbackFn *)DoFindAll2, (void *)This); This->AddApplyCallback((CallbackFn *)DoFind, (void *)This);} // End DoFindAll/*--------------------------------------------------------------- * Callback routine to handle press of find button in find message dialog */voidComplexMsgFindWinC::DoFind(BoolExpC *be, ComplexMsgFindWinC *This){ This->ClearMessage(); if ( !be ) return;//// Loop through message list of current folder// VItemListC& msgList = ishApp->mainWin->MsgVBox().VisItems(); unsigned count = msgList.size(); MsgItemC *item = NULL; Boolean found = False; int index; int start;//// If there is a single selected message, use that as the start index// VItemListC& selList = ishApp->mainWin->MsgVBox().SelItems(); if ( selList.size() == 1 ) { VItemC *item = selList[0]; start = msgList.indexOf(item) + 1; if ( start >= count ) start = 0; } else start = This->findIndex;//// Loop from the start position to the end of the list// for (index=start; !found && index<count; index++) { item = (MsgItemC*)msgList[index]; found = be->Match(item); }//// Loop from the beginning of the list to the start position// if ( !found ) { for (index=0; !found && index<start; index++) { item = (MsgItemC*)msgList[index]; found = be->Match(item); } }//// Select the item if it was found// if ( found ) {//// See if there is an unpinned reading window displayed// 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 { ishApp->mainWin->MsgVBox().DeselectAllItems(); This->findIndex = 0; This->Message("No match"); XBell(halApp->display, ishApp->appPrefs->bellVolume); }} // End DoFind/*--------------------------------------------------------------- * Callback routine to handle press of "find prev" button */voidComplexMsgFindWinC::DoFindPrev2(BoolExpC *be, ComplexMsgFindWinC *This){ This->ClearMessage(); if ( !be ) return;//// Loop through message list of current folder// VItemListC& msgList = ishApp->mainWin->MsgVBox().VisItems(); unsigned count = msgList.size(); MsgItemC *item = NULL; Boolean found = False; int index; int start;//// If there is a single selected message, use that as the start index// VItemListC& selList = ishApp->mainWin->MsgVBox().SelItems(); if ( selList.size() == 1 ) { VItemC *item = selList[0]; start = msgList.indexOf(item) - 1; if ( start <= 0 ) start = count - 1; } else start = This->findIndex;//// Loop from the start position to the beginning of the list// for (index=start; !found && index>=0; index--) { item = (MsgItemC*)msgList[index]; found = be->Match(item); }//// Loop from the end of the list to the start position// if ( !found ) { for (index=count-1; !found && index>start; index--) { item = (MsgItemC*)msgList[index]; found = be->Match(item); } }//// Select the item if it was found// if ( found ) {//// See if there is an unpinned reading window displayed// 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->findIndex = 0; This->Message("No match"); XBell(halApp->display, ishApp->appPrefs->bellVolume); }} // End DoFindPrev2/*--------------------------------------------------------------- * Callback routine for Apply function */voidComplexMsgFindWinC::DoFindAll2(BoolExpC *be, ComplexMsgFindWinC *This){ This->ClearMessage(); if ( !be ) return; ishApp->mainWin->BusyCursor(True);//// Loop through message list of current folder// This->findIndex = 0; ishApp->mainWin->MsgVBox().DeselectAllItems(False); VItemListC& msgList = ishApp->mainWin->MsgVBox().VisItems(); unsigned count = msgList.size(); for (int i=0; i<count; i++) { MsgItemC *item = (MsgItemC*)msgList[i]; if ( be->Match(item) ) ishApp->mainWin->MsgVBox().SelectItem(*item, False); } // End for each item 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);} // End DoFindAll2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -