home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 January / VPR0201B.ISO / APUPDATE / VC / TXC0601M / TXC0601M.LZH / _IDMJUMP.C < prev    next >
C/C++ Source or Header  |  2001-01-29  |  47KB  |  1,795 lines

  1. /*
  2.     検索・ジャンプ関係のIDMコマンド処理群
  3.         Start 99年11月19日
  4. */
  5.  
  6. #if __TXC__
  7.     #include <_wz.h>
  8.     #include <windows.h>
  9.     #include <windowsx.h>
  10.     #include <_idm.h>
  11. #else
  12.     #include "_sys.h"
  13. #endif
  14. #include "_idmlib.h"
  15. #include "_list.h"
  16.  
  17. BOOL txuiSearchList(TX* text,SEARCH_PACKET* search);
  18.  
  19. //##基本
  20.  
  21. void txStatusbarFlushDispPagingmode(TX* text)
  22. {
  23.     txDispAll(text);    //WZ4.00Bl 990909 for 検索モード時のみ検索文字列色分けON
  24.     txStatusbarSetPaneString(
  25.         text,STATUSBAR_PANE_PAGINGMODE,
  26.         sh->pagingmode == 'P' ? "ページ" : (sh->pagingmode == 'S' ? "検索" : "見出")
  27.     );
  28.     txStatusbarSetPaneString(text,STATUSBAR_PANE_FILENAME,(sh->pagingmode=='S')?sh->search.szfind:NULL);    //WZ4.00Bl 990904 VZ.KEYで検索モードの時にステータスバーに検索文字列を表示するようにした。ユーザ要望。
  29. }
  30.  
  31. mchar* GetFind(void)
  32. {
  33.     return sh->search.szfind;
  34. }
  35.  
  36. //##検索置換ダイアログ
  37.  
  38. #if !WINDOWSCE && !__TXC__
  39. static BOOL searchlist(TX* text)
  40. {
  41.     return txuiSearchlist(text,&sh->search);
  42. }
  43. #endif
  44.  
  45. BOOL CALLBACK dlgprocSearch(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  46. {
  47.     HDIALOG hd = dialogFromHwnd(hwnd);
  48.     SEARCHOPT* opt = dialogGetCustdata(hd);
  49.     TX* text = opt->text;
  50.     switch(message) {
  51.         case WM_INITDIALOG: {
  52.             PostMessage(hwnd,WM_TXUSER,0,0);
  53.             PostMessage(hwnd,WM_TXUSER+1,0,0);    //WZ3.90H 980908 
  54.             if (text->fWestern && text->hfontSearch) {    //WZ3.90K 981112 
  55.                 SendMessage(GetDlgItem(hwnd,IDD_SEARCH),WM_SETFONT,text->hfontSearch,TRUE);
  56.                 SendMessage(GetDlgItem(hwnd,IDD_REPLACE),WM_SETFONT,text->hfontSearch,TRUE);
  57.             }
  58.             return FALSE;
  59.         }
  60.         case WM_COMMAND: {
  61.             switch(GET_WM_COMMAND_ID(wParam,lParam)) {
  62.                 case IDD_SEARCHMODE:
  63.                 case IDD_SEARCHMODE+1:
  64.                 case IDD_SEARCHMODE+2:
  65.                 case IDD_SEARCHMODE+3:
  66.                 case IDD_FUZZY:
  67.                 case IDD_RE: PostMessage(hwnd,WM_TXUSER+1,0,0);break;    //WZ3.90H 980908 
  68.                 case IDD_HISTORY: {    //WZ3.90H 980910 
  69.                     searchoptFromSearchmode(opt,sh->search.searchmode);
  70.                     dialogWrite(hd);
  71.                     PostMessage(hwnd,WM_TXUSER+1,0,0);
  72.                     break;
  73.                 }
  74.                 #if !WINDOWSCE && !__TXC__
  75.                 case IDD_LIST: {
  76.                     if (searchlist(text)) {
  77.                         searchoptFromSearchmode(opt,sh->search.searchmode);
  78.                         dialogWrite(hd);
  79.                         PostMessage(hwnd,WM_TXUSER+1,0,0);
  80.                     }
  81.                     break;
  82.                 }
  83.                 #endif
  84.                 case IDD_GET: opt->fSearchSet = TRUE;break;    //WZ3.90H 980910 
  85.             }
  86.             break;
  87.         }
  88.         case WM_TXUSER: {
  89.             if (sh->fSearchGetText || txIsClipInPara(text)) {    //WZ3.90I 981103 選択されている場合は検索文字列を取り込む。
  90.                 int type = GetCharType(text,text->buff + text->cur);
  91.                 //WZ3.90O 981204 選択していてカーソルが改行上にあると取り込まれなかった
  92.                 if (!txIsClipInPara(text) && (type == CT_EOF || type == CT_LF || type == CT_SPACE)) {
  93.                     //WCE1.01 980402 これらの場合は検索文字列に取り込まない
  94.                 } else {
  95.                     mchar buff[CCHSEARCH];
  96.                     txGetWordEx(text,buff,cchof(buff));
  97.                     SetDlgItemText_A(hwnd,IDD_SEARCH,buff);
  98.                     SetFocus(GetDlgItem(hwnd,IDD_SEARCH));
  99.                 }
  100.             }
  101.             break;
  102.         }
  103.         case WM_TXUSER+1: {    //WZ3.90H 980908 
  104.             wndSetEnableSearchOption(hwnd);
  105.             break;
  106.         }
  107.     }
  108.     return FALSE;
  109. }
  110.  
  111. static BOOL uiSearch(TX* text,BOOL mode)
  112. {
  113.     BOOL fReplace = !!(mode & 0x02);
  114.     HDIALOG hd = dialog(fReplace ? "置換" : "検索");
  115.     SEARCHOPT opt;
  116.     //
  117.     structClear(opt);
  118.     opt.text = text;
  119.     opt.fSearchSet = (mode & 0x01);
  120.     opt.fArea = fReplace && (text->fClip && !txIsClipInPara(text));
  121.     opt.fReplace = fReplace;
  122. #if 1//WZ4.00Bl 990908 for searchmodeInit
  123.     searchoptFromSearchmode(&opt,text->searchmode);
  124. #else
  125.     searchoptFromSearchmode(&opt,sh->search.searchmode);
  126. #endif
  127.     //
  128. #if WINDOWSCE
  129.     hd->fPspcNoLimitSize = FALSE;    //WZ4.00Eb 010103 マクロから_pspcスタイルのダイアログを使うにはこれを指定すること。
  130.     dialogSetDialoghelp(hd,4);        // "「検索」「置換」ダイアログの使い方"
  131. #endif
  132.     dialogSetCustdata(hd,&opt);
  133.     dialogSetDlgproc(hd,dlgprocSearch);
  134.     dialogControlID(hd,IDD_SEARCH);
  135.     dialogControlHist(hd,HIST_SEARCH);
  136.     dialogControlHelp(hd,237);
  137.     dialogString(hd,"検索(&S):",12-_pspc*4,sh->search.szfind,CCHSEARCH,33-_pspc*8);
  138.     if (fReplace) {
  139.         dialogControlID(hd,IDD_REPLACE);
  140.         dialogControlHist(hd,HIST_SEARCH);
  141.         dialogControlHelp(hd,238);
  142.         dialogString(hd,"置換(&R):",12-_pspc*4,sh->search.szreplace,CCHSEARCH,33-_pspc*8);
  143.     }
  144.     //
  145.     dialogSetH(hd);
  146.     dialogIndent(hd,13);
  147.     dialogControlID(hd,IDD_HISTORY);
  148.     dialogControlHelp(hd,228);
  149. #if WINDOWSCE    //WZ4.00Bb 990309 CEではアクセスキーAlt+Hは使えない。ヘルプと重なっている。
  150.     dialogPushbutton(hd,fReplace ? "前回の置換(&I)" : "前回の検索(&I)",16);
  151. #else
  152.     dialogPushbutton(hd,fReplace ? "前回の置換(&H)" : "前回の検索(&H)",16);
  153. #endif
  154.     #if !WINDOWSCE && !__TXC__
  155.     dialogControlID(hd,IDD_LIST);
  156.     dialogControlHelp(hd,229);
  157.     dialogPushbutton(hd,"スタイル(&Q)...",16);    //WZ3.90L 981115 "検索リスト"はWZ3の同一名称別機能とまぎらわしいので名前を変更。
  158.     #endif
  159.     dialogLFSetV(hd);
  160.     //
  161.     dialogSetPosLF(hd);
  162.     if (!_pspc) dialogIndent(hd,3);
  163.     dialogAddSearchopt(hd,&opt,fReplace);
  164.     //
  165.     if (_pspc) {
  166.         dialogLF(hd);
  167.         dialogSetPosX(hd,DTCX);
  168.     } else {
  169.         dialogLFV(hd);
  170.         #if SEARCHOPT_DIALOG_NEW    //WZ3.90J 981112 
  171.             #if WINDOWSCE
  172.             dialogIndent(hd,6);
  173.             #else
  174.             dialogIndent(hd,5);
  175.             #endif
  176.         #endif
  177.         dialogSetPosY(hd,DTCY/2);
  178.         #if !WINDOWSCE
  179.         dialogOK(hd,10);
  180.         dialogCancel(hd,10);
  181.         #endif
  182.     }
  183.     if (!fReplace && !opt.fSearchSet) {
  184.         dialogSpaceV(hd);
  185.         dialogControlID(hd,IDD_GET);
  186.         dialogControlHelp(hd,232);
  187.         dialogCmd(hd,"取得(&G)",10);
  188.         #if !WINDOWSCE
  189.         dialogControlID(hd,IDD_UISEARCHSELECT);
  190.         dialogControlHelp(hd,233);
  191.         dialogCmd(hd,"閲覧(&N)",10);
  192.         #endif
  193.     }
  194.     //
  195.     {
  196.         int ret;
  197.         if (ret = dialogOpen(hd)) {    //WZ3.90H 980906 
  198.             text->searchmode = sh->search.searchmode = searchoptToSearchmode(&opt);    //WZ4.00Bo 991011 text->searchmodeにもセット。検索してもう一度検索ダイアログを開いたときに前回の検索オプションをONにするようにした。ユーザ要望。
  199. //information("%d",strlen(sh->search.szfind));
  200.             #if WINDOWSCE
  201.             searchoptSearchExec(&opt);
  202.             #else
  203.             if (ret == IDD_UISEARCHSELECT) {
  204.                 txuiSearchList(text,&sh->search);
  205.             } else {
  206.                 #if !__TXC__ && WZFUNC_EDITOR
  207.                 if (opt.fOpenTempWindow) txMultiWindow(text,TRUE);
  208.                 #endif
  209.                 searchoptSearchExec(&opt);
  210.             }
  211.             #endif
  212.             return TRUE;
  213.         }
  214.     }
  215.     return FALSE;
  216. }
  217.  
  218. BOOL txIDM_UISEARCH(TX* text)
  219. {
  220.     return uiSearch(text,FALSE);
  221. }
  222.  
  223. BOOL txuiSearchGet(TX* text,SEARCH_PACKET* search)
  224. {
  225.     if (uiSearch(text,0x01)) {
  226.         *search = sh->search;
  227.         return TRUE;
  228.     }
  229.     return FALSE;
  230. }
  231.  
  232. BOOL txIDM_UISEARCHSET(TX* text)
  233. {
  234.     if (uiSearch(text,0x01)) {
  235.         if (text->modeEditor == ME_VZ) {    //WZ4.00Bj 990830 VZキー以外でIDM_UISEARCHSETすると検索モードになってPageUp/Downができなくなったのを改良。
  236.             sh->pagingmode = sh->search.szfind[0] ? 'S' : 'P';
  237.         }
  238.         txStatusbarFlushDispPagingmode(text);
  239.         return TRUE;
  240.     } else {
  241.         sh->pagingmode = 'P';
  242.         txStatusbarFlushDispPagingmode(text);
  243.         return FALSE;
  244.     }
  245. }
  246.  
  247. BOOL txIDM_UIREPLACE(TX* text)
  248. {
  249.     return uiSearch(text,0x02);
  250. }
  251.  
  252. BOOL txIDM_UIREPLACEQUERY(TX* text)
  253. {
  254.     sh->search.searchmode |= REPLACE_CONFIRM;
  255.     text->searchmode |= REPLACE_CONFIRM;    //WZ4.00Ec 010123 
  256.     return txIDM_UIREPLACE(text);
  257. }
  258.  
  259. BOOL txIDM_UIREPLACENOQUERY(TX* text)
  260. {
  261.     sh->search.searchmode &= ~REPLACE_CONFIRM;
  262.     text->searchmode &= ~REPLACE_CONFIRM;    //WZ4.00Ec 010123 IDM_UIREPLACENOQUERYを動作するようにした。
  263.     return txIDM_UIREPLACE(text);
  264. }
  265.  
  266. //##検索
  267.  
  268. BOOL txIDM_UISEARCHPREV(TX* text)
  269. {
  270.     text->searchmode |= SEARCH_PREV;
  271.     return txIDM_UISEARCH(text);
  272. }
  273.  
  274. BOOL txIDM_UISEARCHNEXT(TX* text)
  275. {
  276.     text->searchmode &= ~SEARCH_PREV;
  277.     return txIDM_UISEARCH(text);
  278. }
  279.  
  280. BOOL txIDM_SEARCHGET(TX* text)
  281. {
  282.     if (text->idmPrev == IDM_SEARCHGET) {
  283.     } else {
  284.         sh->search.szfind[0] = 0;
  285.     }
  286.     if (txIsClipInPara(text)) {    //WZ3.90M 981128 IDM_SEARCHGETで選択時は選択文字を追加。
  287.         mchar buff[CCHSEARCH];
  288.         txGetWordEx(text,buff,CCHSEARCH);
  289.         txSelectQuit(text);
  290.         sstrcat(sh->search.szfind,buff);
  291.     } else {
  292.         int len = strlen(sh->search.szfind);
  293.         IBUFF cur = text->cur + len;
  294.         int type0 = 0;
  295.         BOOL fFirst = TRUE;
  296.         for (;;) {
  297.             int type = GetCharType(text,text->buff + cur);
  298.             if (type == CT_EOF || type == CT_LF) break;//WCE1.01 980322 空テキストでIDM_SEARCHGETすると無限ループに入った    //WZ4.00Bl 990904 IDM_SEARCHGETで改行で止まるようにした。ユーザ要望。
  299.             if (!fFirst && type != type0) break;
  300.             cur += txGetCharSize(text,cur);
  301.             type0 = type;
  302.             if (fFirst && (type == CT_SYMBOL || type == CT_SPACE)) {
  303.                 //WZ4.00Bl 990904 IDM_SEARCHGETで記号や空白で区切らないようにした。ユーザ要望
  304.             } else {
  305.                 fFirst = FALSE;
  306.             }
  307.         }
  308.         strcpylenmax(sh->search.szfind,text->buff + text->cur,cur - text->cur,sizeof(sh->search.szfind));
  309.     }
  310.     {
  311.         wchar buff[CCHSEARCH];
  312.         strtowstr(sh->search.szfind,-1,buff,CCHSEARCH);
  313.         wstatprintf(L"%s",buff);    //WZ4.00A 981224 IDM_SEARCHGETで%を含む文字を取得したときに取得文字の表示がおかしかった。
  314.     }
  315. #if 1//WZ3.90L 981125 VZ以外でIDM_SEARCHGETするとPAGEUP/DOWNで検索になってしまった。
  316.     if (text->modeEditor == ME_VZ) {
  317.         sh->pagingmode = 'S';
  318.         txStatusbarFlushDispPagingmode(text);    //WZ4.00Bl 990904 IDM_SEARCHGETしたときステータスバーの表示を「検索」モードにした。
  319.     }
  320. #else
  321.     sh->pagingmode = 'S';
  322. #endif
  323.     return TRUE;
  324. }
  325.  
  326. BOOL txIDM_TOSEARCHBOX(TX* text)
  327. {
  328.     //WZ4.00Ca 000103 (PWZ)IDM_TOSEARCHBOXでコマンドバーの検索ボックスにフォーカスを移動するようにした。
  329.     if (text->hwndCBCB && (WINDOWSCE||txGetDispToolbar(text))) {    //WZ4.00A 981224 ツールバーが非表示の時にCtrl+Fで検索ダイアログが開かない場合があった。
  330.         if (text->fClip && !text->fClipSearch && txIsClipInPara(text)) {
  331.             //WCE0.91 970914 選択してCtrl+Fしたときはその文字列を検索ボックスに取り込む
  332.             // VZ,MIでも選択したときは取り込む
  333.             mchar szbuff[CCHSEARCH];
  334.             txGetWordEx(text,szbuff,CCHSEARCH);
  335.             SetWindowText_A(text->hwndCBCB,szbuff);
  336.         }
  337.         SetFocus(text->hwndCBCB);
  338.     } else {
  339.         txIDM_UISEARCH(text);
  340.     }
  341.     return TRUE;
  342. }
  343.  
  344. void txSearchAlltextInit(TX* text,SEARCHMODE searchmode)
  345. {
  346. //WZ4.00Bl 990916 new
  347.     if (searchmode & SEARCH_ALLTEXT) {
  348.         wzlock(LOCK_WZPROCESS);
  349.         {
  350.             int n = sh->nOpen;
  351.             WZPROCESS* p = sh->tWzprocess;
  352.             for (;n--;p++) {
  353.                 p->fSearched = (text->hwndbase == p->hwnd);
  354.             }
  355.         }
  356.         wzunlock(LOCK_WZPROCESS);
  357.     }
  358. }
  359.  
  360. BOOL txIDM_UIREPLACECONTINUE(TX* text)
  361. {
  362.     txSearchAlltextInit(text,sh->search.searchmode);
  363.     PostMessage(text->hwndtext,WM_TXIDLEEXEC,IDLE_EXECFIND,TRUE);
  364.     return TRUE;
  365. }
  366.  
  367. BOOL txIDM_SWITCHPAGE(TX* text)
  368. {
  369.     if (sh->pagingmode == 'P') {
  370.         if (text->fSearchTitle) {
  371.             sh->pagingmode = 'C';
  372.         } else {
  373.             if (*GetFind()) {
  374.                 sh->pagingmode = 'S';
  375.             } else {
  376.                 sh->pagingmode = 'P';
  377.             }
  378.         }
  379.     } else if (sh->pagingmode == 'C') {
  380.         if (*GetFind()) {
  381.             sh->pagingmode = 'S';
  382.         } else {
  383.             sh->pagingmode = 'P';
  384.         }
  385.     } else {
  386.         sh->pagingmode = 'P';
  387.     }
  388. #if 0//WZ4.00Bl 990904 
  389.     switch(sh->pagingmode) {
  390.         case 'C': wstatprintf(L"見出し");break;
  391.         case 'S': wstatprintf(L"検索");break;
  392.         case 'P': wstatprintf(L"ページ");break;
  393.     }
  394. #endif
  395.     txStatusbarFlushDispPagingmode(text);
  396.     return TRUE;
  397. }
  398.  
  399. BOOL txIDM_CLEARSEARCHMODE(TX* text)
  400. {
  401.     sh->pagingmode = 'P';
  402.     txStatusbarFlushDispPagingmode(text);
  403.     return TRUE;
  404. }
  405.  
  406. static BOOL _txIDM_SEARCHCONTINUE(TX* text,int idm)
  407. {
  408.     if (
  409.         text->fClipMouse && !text->fClipSearch && txIsClipInPara(text) &&
  410.         txGetAddressSelectTop(text) != txGetAddressSelectEnd(text)    //WZ4.00Bp 991014 選択範囲が空のときは、選択した単語を検索する動作は無効にした。
  411.     ) {    //WZ4.00Bl 990908 選択してIDM_SEARCHCONTINUE/PREVすると選択した単語を検索するようにした。ユーザ要望。
  412. //beep();
  413.         txGetWordEx(text,sh->search.szfind,cchof(sh->search.szfind));
  414.     }
  415.     ((idm == IDM_SEARCHCONTINUEPREV)?txSearchContinuePrev:txSearchContinue)(text);
  416.     return TRUE;
  417. }
  418.  
  419. BOOL txIDM_SEARCHCONTINUEPREV(TX* text)
  420. {
  421.     return _txIDM_SEARCHCONTINUE(text,IDM_SEARCHCONTINUEPREV);
  422. }
  423.  
  424. BOOL txIDM_SEARCHCONTINUE(TX* text)
  425. {
  426.     return _txIDM_SEARCHCONTINUE(text,IDM_SEARCHCONTINUE);
  427. }
  428.  
  429. void SetFind(mchar* szfind)
  430. {
  431.     sstrcpy(sh->search.szfind,szfind);
  432.     histAdd(HIST_SEARCH,sh->search.szfind);
  433. }
  434.  
  435. void txInitSearchContinueCB(TX* text)
  436. {
  437.     mchar szfind[CCHSEARCH];
  438.     if (
  439.         text->fClip && !text->fClipSearch && txIsClipInPara(text) &&
  440.         txGetAddressSelectTop(text) != txGetAddressSelectEnd(text)    //WZ4.00Bp 991014 選択範囲が空のときは、選択した単語を検索する動作は無効にした。
  441.     ) {
  442.         // 選択されていたら取り込む
  443.         // VZ,MIでも選択したときは取り込む
  444.         txGetWordEx(text,szfind,cchof(szfind));
  445.         SetWindowText_A(text->hwndCBCB,szfind);
  446.     } else {
  447.         GetWindowText_A(text->hwndCBCB,szfind,cchof(szfind));
  448.     }
  449.     if (szfind[0]) {
  450.         //WCE0.91 970906 検索ボックスを使った検索は必ず曖昧検索をするようにした
  451. #if 1//WCE0.99A 970924 検索ボックスで検索すると、置換確認がクリアされた
  452.         SEARCHMODE sm0 = (sh->search.searchmode & REPLACE_CONFIRM);
  453.         sh->search.searchmode = SEARCH_NOSENSECASE|SEARCH_NOSENSEZENHAN|sm0;
  454. #else
  455.         sh->search.searchmode = SEARCH_NOSENSECASE|SEARCH_NOSENSEZENHAN;
  456. #endif
  457.         SetFind(szfind);
  458.     }
  459. }
  460.  
  461. BOOL txIDM_SEARCHCONTINUECBPREV(TX* text)
  462. {
  463.     txInitSearchContinueCB(text);
  464.     txSearchContinuePrev(text);
  465.     SetFocus(text->hwndtext);//WCE0.95 970923 検索BOXの↑/↓で検索したときフォーカスをテキストに戻す
  466.     return TRUE;
  467. }
  468.  
  469. BOOL txIDM_SEARCHCONTINUECB(TX* text)
  470. {
  471.     txInitSearchContinueCB(text);
  472.     txSearchContinue(text);
  473.     SetFocus(text->hwndtext);//WCE0.95 970923 検索BOXの↑/↓で検索したときフォーカスをテキストに戻す
  474.     return TRUE;
  475. }
  476.  
  477. //##インクリメンタル検索
  478. //WZ4.00Ca 991212 インクリメンタル検索コマンド IDM_ISEARCH,IDM_ISEARCHPREV,IDM_ISEARCHREを追加。
  479.  
  480. void txIsearchNext(TX* text,SEARCHMODE searchmode)
  481. {
  482.     SEARCHMODE mode = SEARCH_FORWARD|SEARCH_NOSENSECASE|searchmode;
  483.     if (text->isearch->szIsearch[0]) {
  484.         BOOL ret = FALSE;
  485.         IFILE adr = txGetAddress(text);
  486.         IFILE adrCurscreen = txGetAddressCurscreen(text);
  487.         int ly = text->ly;
  488.         txSetUndisp(text);
  489.         if (text->isearch->fIsearchLastFail) {
  490.             text->isearch->fIsearchLastFail = FALSE;
  491.             if (mode & SEARCH_PREV) {
  492.                 txJumpFileEnd(text);
  493.             } else {
  494.                 txJumpFileTop(text);
  495.             }
  496.             text->isearch->fIsearchWrapped = TRUE;
  497.         }
  498.         sstrcpy(sh->search.szfind,text->isearch->szIsearch);sh->search.searchmode = mode & ~SEARCH_CUR;
  499.         ret = txSearchEx(text,text->isearch->szIsearch,mode);
  500.         if (!ret) {
  501.             text->isearch->fIsearchLastFail = TRUE;
  502.         }
  503.         if (ret) {
  504.             text->isearch->adrIsearch = txGetAddress(text);
  505.             if ((mode & SEARCH_PREV) && !(mode & SEARCH_CUR)) {
  506.                 // 連続実行時でBackward時は実行しない
  507.             } else {
  508.                 txRightBytes(text,ret-1);
  509.             }
  510.             txSetLy(text,ly);
  511.         } else {
  512.             txJumpAddress(text,adr);
  513.             txSetLyCurscreen(text,adrCurscreen);
  514.         }
  515.         txSetDisp(text);
  516.         txIsearchStatprintf(text,ret,mode);
  517.         strcpy(text->isearch->szIsearch0,text->isearch->szIsearch);
  518.     } else {
  519.         txIsearchStatprintf(text,TRUE,searchmode);
  520.     }
  521. }
  522.  
  523. static void isearch(TX* text,SEARCHMODE searchmode)
  524. {
  525.     if (text->fBinedit) return;    //WZ4.00Ec 010129 バイナリ編集モードではインクリメンタルサーチを使えない様にした。落ちる場合があった。
  526.     if (!text->isearch) text->isearch = zmalloc(sizeof(TX_ISEARCH));
  527.     if (!text->isearch) return;
  528.     if (txIsearchIsContinueIdm(text,text->idmLast)) {
  529.         // 連続実行
  530.         if (!text->isearch->fIsearching) {
  531.             text->isearch->fIsearching = TRUE;
  532.         }
  533.         if (!text->isearch->szIsearch[0]) strcpy(text->isearch->szIsearch,text->isearch->szIsearch0);
  534.         txIsearchNext(text,searchmode|text->isearch->Isearchmode);
  535.     } else {
  536. //        if (!text->isearch->fIsearching) {
  537.             text->isearch->fIsearching = TRUE;
  538.             text->isearch->szIsearch[0] = 0;
  539.             text->isearch->fIsearchWrapped = FALSE;
  540.             text->isearch->adrIsearch0 = text->isearch->adrIsearch = txGetAddress(text);
  541.             text->isearch->fIsearchLastFail = FALSE;
  542.             text->isearch->Isearchmode = searchmode & (SEARCH_REWZ|SEARCH_PREV);    //WZ4.00Ec 010129 IDM_ISEARCHPREVの一回目が下方向になるのを修正。
  543. //        }
  544.         txIsearchNext(text,searchmode|SEARCH_CUR);
  545.     }
  546. }
  547.  
  548. BOOL txIDM_ISEARCHPREV(TX* text)
  549. {
  550. // インクリメンタルサーチ(上方向)
  551.     isearch(text,SEARCH_PREV);
  552.     return TRUE;
  553. }
  554.  
  555. BOOL txIDM_ISEARCH(TX* text)
  556. {
  557. // インクリメンタルサーチ(下方向)
  558.     isearch(text,0);
  559.     return TRUE;
  560. }
  561.  
  562. BOOL txIDM_ISEARCHRE(TX* text)
  563. {
  564.     isearch(text,SEARCH_REWZ);
  565.     return TRUE;
  566. }
  567.  
  568. //##GREP
  569.  
  570. #if __TXC__
  571. mchar* sbReadLast(HSTRBLK sb)
  572. {
  573. //WZ4.00Ab 990202 new
  574.     int n = sbGetCount(sb);
  575.     if (n) {
  576.         return sbRead(sb,n-1);
  577.     }
  578.     return NULL;
  579. }
  580. #endif    // __TXC__
  581.  
  582. BOOL txIDM_GREP(TX* text)
  583. {
  584.     mchar szWord[CCHSEARCH] = {0};
  585.     if (txIsClipInPara(text)) {
  586.         txGetWordEx(text,szWord,CCHSEARCH);
  587.         if (strchr(szWord,'"')) szWord[0] = 0;    // 検索文字列に " は含めない
  588.     } else {    //WZ4.00Ab 990202 IDM_GREP:で最後に検索した文字列を検索文字列にセットするようにした。
  589.         mchar* p = sbReadLast(sbFromHist(HIST_SEARCH));
  590.         if (p) sstrcpy(szWord,p);
  591.     }
  592.     if (szWord[0]) {
  593.         mchar szArg[CCHSEARCH + 20];
  594.     #if UNIX
  595.         sprintf_A(szArg,"=s\"%s\"",szWord);
  596.     #else
  597.         sprintf_A(szArg,"-s\"%s\"",szWord);
  598.     #endif
  599.         {
  600.             wchar* wsz = wstrdupA(szArg);
  601.             apGrep(wsz,AP_SINGLE);
  602.             free(wsz);
  603.         }
  604.     } else {
  605.         apGrep(NULL,AP_SINGLE);
  606.     }
  607.     return TRUE;
  608. }
  609.  
  610. //##しおり
  611.  
  612. #define IDD_UMLIST        100
  613. #define IDD_REGISTER    102
  614. #define IDD_KILL        103
  615. #define IDD_ADD            104
  616.  
  617. static void markFlushPrim(HWND hctrl,TX* text,int index)
  618. {
  619.     mchar szline[CCHLINE];
  620.     txGetParaEx(text,szline,cchof(szline));
  621.     {    // tab->space
  622.         mchar* p = szline;
  623.         while(1) {
  624.             p = strchr(szline,'\t');
  625.             if (!p) break;
  626.             if (p) *p = ' ';
  627.         }
  628.     }
  629. #if 1    //WCE0.95 970923 マーク、最近参照した位置のテキストの表示が変だった
  630.         //WCE0.95 970923 実機では、%hs,%hc,%lc,%ls使えない様だ。
  631.     {
  632.         mchar szbuff[CCHLINE + 20];
  633.         sprintf(szbuff,"%d):%d %s",index,text->npara,szline);
  634.         #if 1//WCE1.01 980115 UNICODE
  635.         ListBox_AddString_A(hctrl,szbuff);
  636.         #else
  637.         {
  638.             wchar wsz[CCHLINE + 20];
  639.             strtowstr(szbuff,-1,wsz,wcchof(wsz));
  640.             ListBox_AddString(hctrl,wsz);
  641.         }
  642.         #endif
  643.     }
  644. #else
  645.     {
  646.         wchar wszbuff[CCHLINE + 20];
  647.         wsprintf(wszbuff,L"%d):%d %hs",index,text->npara,szline);
  648.         ListBox_AddString(hctrl,wszbuff);
  649.     }
  650. #endif
  651. }
  652.  
  653. static void markFlush(TX* text,HWND hwnd,BOOL fUiRefer)
  654. {
  655.     HWND hctrl = GetDlgItem(hwnd,IDD_UMLIST);
  656.     int i;
  657.     ListBox_ResetContent(hctrl);
  658.     txSetUndispExSilent(text);
  659.     if (fUiRefer) {
  660.         int n = MAXREFERPOS;
  661.         int i;
  662.         for (i = text->iAdrRefer;n--;) {
  663.             i--;
  664.             if (i < 0) i = MAXREFERPOS - 1;
  665.             txJumpAddress(text,text->tAdrRefer[i]);
  666.             markFlushPrim(hctrl,text,i);
  667.         }
  668.     } else {
  669.         for (i = 1;i < MAXMARK;i++) {
  670.             txJumpAddress(text,text->mark[i]);
  671.             markFlushPrim(hctrl,text,i);
  672.         }
  673.     }
  674.     txSetDispExSilent(text);
  675. }
  676.  
  677. BOOL CALLBACK dlgprocMark(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  678. {
  679.     HDIALOG hd = dialogFromHwnd(hwnd);
  680.     TX* text = (TX*)dialogGetCustdata(hd);
  681.     switch(message) {
  682.         case WM_INITDIALOG: {
  683.             HWND hctrl = GetDlgItem(hwnd,IDD_UMLIST);
  684.             markFlush(text,hwnd,FALSE);
  685.             if (text->iLastJumpMark) {
  686.                 ListBox_SetCurSel(hctrl,text->iLastJumpMark - 1);
  687.             } else {
  688.                 ListBox_SetCurSel(hctrl,0);
  689.             }
  690.             break;
  691.         }
  692.         case WM_COMMAND: {
  693.             int id = GET_WM_COMMAND_ID(wParam,lParam);
  694.             int notify = GET_WM_COMMAND_CMD(wParam,lParam);
  695.             
  696.             switch(id) {
  697.                 case IDD_JUMP: {
  698.                     HWND hctrl = GetDlgItem(hwnd,IDD_UMLIST);
  699.                     int i = ListBox_GetCurSel(hctrl);
  700.                     if (i != LB_ERR) {
  701.                         txJumpMarkN(text,i + 1);
  702.                         text->iLastJumpMark = i + 1;
  703.                     }
  704.                     break;
  705.                 }
  706.                 case IDD_REGISTER: {
  707.                     HWND hctrl = GetDlgItem(hwnd,IDD_UMLIST);
  708.                     int i = ListBox_GetCurSel(hctrl);
  709.                     if (i != LB_ERR) {
  710.                         txMarkN(text,i + 1);
  711.                         text->iLastJumpMark = i + 1;
  712.                         markFlush(text,hwnd,FALSE);
  713.                         ListBox_SetCurSel(hctrl,i);
  714.                     }
  715.                     break;
  716.                 }
  717.             }
  718.             break;
  719.         }
  720.     }
  721.     return FALSE;
  722. }
  723.  
  724. #if !__TXC__
  725. BOOL TXAPI txuiMark(TX* text)
  726. {
  727. // しおり
  728.     HDIALOG hd = dialog("しおり");
  729.     IFILE adr = txGetAddress(text);
  730.     int cx = 12;
  731.     DTRECT r;
  732.     txMarkCur(text);
  733.     text->fNoMarkCur++;
  734.     //
  735. //    dialogSetContexthelp(hd,TRUE);
  736.     dialogSetNotifyAsOK(hd,IDD_UMLIST,LBN_DBLCLK);
  737.     dialogSetDlgproc(hd,dlgprocMark);
  738.     dialogSetCustdata(hd,text);
  739.     
  740.     dialogGetPos(hd,&r);
  741.     r.cx = DTCX * 50 - _pspc*DTCX*20;
  742.     r.cy = DTCY * 6;
  743.     __dialogAddItem(hd,"LISTBOX",NULL,IDD_UMLIST,&r,LBS_NOTIFY|LBS_USETABSTOPS|WS_BORDER|WS_VSCROLL|WS_HSCROLL|WS_CHILD|WS_VISIBLE|WS_TABSTOP);
  744.     dialogSetPosY(hd,r.y + r.cy);
  745.     if (_pspc) {
  746.         dialogSetH(hd);
  747.     } else {
  748.         dialogLFV(hd);
  749.     }
  750.     dialogControlID(hd,IDD_JUMP);
  751.     dialogControlHelp(hd,218);
  752.     dialogCmdDefault(hd,"ジャンプ(&J)",cx);
  753.     //
  754.     dialogControlID(hd,IDD_REGISTER);
  755.     dialogControlHelp(hd,219);
  756.     dialogCmd(hd,"はさむ(&R)",cx);
  757.     //
  758.     if (!_pspc) {
  759.         dialogSpaceV(hd);
  760.         dialogCancel(hd,cx);
  761.     }
  762.     #if !WINDOWSCE
  763.     dialogSetNoButton(hd);
  764.     #endif
  765.     if (!dialogOpen(hd)) {
  766.         txJumpAddress(text,adr);
  767.     }
  768.     text->fNoMarkCur--;
  769.     return TRUE;
  770. }
  771. #endif // !__TXC__
  772.  
  773. void txAddRefer(TX* text,IFILE adr)
  774. {
  775.     if (text->iAdrRefer >= MAXREFERPOS) text->iAdrRefer = 0;
  776.     text->tAdrRefer[text->iAdrRefer++] = adr;
  777.     if (text->iAdrRefer >= MAXREFERPOS) text->iAdrRefer = 0;
  778. }
  779.  
  780. BOOL CALLBACK dlgprocUiRefer(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  781. {
  782.     HDIALOG hd = dialogFromHwnd(hwnd);
  783.     TX* text = (TX*)dialogGetCustdata(hd);
  784.     switch(message) {
  785.         case WM_INITDIALOG: {
  786.             HWND hctrl = GetDlgItem(hwnd,IDD_UMLIST);
  787.             markFlush(text,hwnd,TRUE);
  788.             break;
  789.         }
  790.         case WM_COMMAND: {
  791.             int id = GET_WM_COMMAND_ID(wParam,lParam);
  792.             int notify = GET_WM_COMMAND_CMD(wParam,lParam);
  793.             switch(id) {
  794.                 case IDD_UMLIST: {
  795.                     if (notify == LBN_SELCHANGE) {
  796.                         HWND hctrl = GetDlgItem(hwnd,IDD_UMLIST);
  797.                         int i = ListBox_GetCurSel(hctrl);
  798.                         if (i != LB_ERR) {
  799.                             int index = text->iAdrRefer - (i + 1);
  800.                             if (index < 0) index += MAXREFERPOS;
  801.                             txJumpAddress(text,text->tAdrRefer[index]);
  802.                         }
  803.                     }
  804.                     break;
  805.                 }
  806.                 case IDD_ADD: {//WCE0.92 970918 
  807.                     txAddRefer(text,txGetAddress(text));
  808.                     markFlush(text,hwnd,TRUE);
  809.                     break;
  810.                 }
  811.             }
  812.             break;
  813.         }
  814.     }
  815.     return FALSE;
  816. }
  817.  
  818. #if !__TXC__
  819. BOOL TXAPI txuiRefer(TX* text)
  820. {
  821. // 最近参照した位置
  822.     HDIALOG hd = dialog("最近参照した位置");
  823.     IFILE adr = txGetAddress(text);
  824.     DTRECT r;
  825.     //
  826. //    dialogSetContexthelp(hd,TRUE);
  827.     dialogSetDlgproc(hd,dlgprocUiRefer);
  828.     dialogSetCustdata(hd,text);
  829.     
  830.     dialogGetPos(hd,&r);
  831.     r.cx = DTCX * 50;
  832.     r.cy = DTCY * 10;
  833.     __dialogAddItem(hd,"LISTBOX",NULL,IDD_UMLIST,&r,LBS_NOTIFY|LBS_USETABSTOPS|WS_BORDER|WS_VSCROLL|WS_HSCROLL|WS_CHILD|WS_VISIBLE|WS_TABSTOP);
  834.     dialogSetPosY(hd,r.y + r.cy);
  835.     dialogSetNotifyAsOK(hd,IDD_UMLIST,LBN_DBLCLK);//WCE0.99A 970924 
  836.     
  837.     dialogControlID(hd,IDD_ADD);
  838.     dialogPushbuttonBig(hd,"追加(&A)",12);
  839.     
  840.     if (!dialogOpen(hd)) {
  841.         txJumpAddress(text,adr);
  842.     }
  843.     return TRUE;
  844. }
  845. #endif // !__TXC__
  846.  
  847. //##ハイパーリンク 進む/戻る
  848.  
  849. static BOOL _txLinkhistJumpPrev(TX* text,BOOL fGetAble)
  850. {
  851. // 戻る
  852.     BOOL ret = FALSE;
  853.     if (text->linkhist) {
  854.         LINKHIST* linkhist = text->linkhist;
  855.         if (linkhist->index > linkhist->n) linkhist->index = linkhist->n;
  856.         if (linkhist->index) {
  857.             if (!fGetAble) {
  858.                 linkhist->index--;
  859.                 txJumpAddress(text,linkhist->tAdr[linkhist->index]);
  860.             }
  861.             ret = TRUE;
  862.         }
  863.     }
  864.     return ret;
  865. }
  866.  
  867. BOOL txLinkhistJumpPrev(TX* text)
  868. {
  869. // 戻る
  870.     return _txLinkhistJumpPrev(text,FALSE);
  871. }
  872.  
  873. BOOL txLinkhistJumpPrevGetAble(TX* text)
  874. {
  875. // 戻る
  876.     return _txLinkhistJumpPrev(text,TRUE);
  877. }
  878.  
  879. static BOOL _txLinkhistJumpNext(TX* text,BOOL fGetAble)
  880. {
  881. // 進む
  882.     BOOL ret = FALSE;
  883.     if (text->linkhist) {
  884.         LINKHIST* linkhist = text->linkhist;
  885.         if (linkhist->index + 1 < linkhist->n) {
  886.             if (!fGetAble) {
  887.                 txJumpAddress(text,linkhist->tAdr[++linkhist->index]);
  888.             }
  889.             ret = TRUE;
  890.         }
  891.     }
  892.     return ret;
  893. }
  894.  
  895. BOOL txLinkhistJumpNext(TX* text)
  896. {
  897. // 進む
  898.     return _txLinkhistJumpNext(text,FALSE);
  899. }
  900.  
  901. BOOL txLinkhistJumpNextGetAble(TX* text)
  902. {
  903. // 進む
  904.     return _txLinkhistJumpNext(text,TRUE);
  905. }
  906.  
  907. //##各種ジャンプ
  908.  
  909. //WZ4.00Bj 990824 最後に編集した位置にジャンプできるようにした。
  910.  
  911. enum {
  912.     JUMP_LINE,JUMP_PAGE,JUMP_LASTEDIT,JUMP_EDITPARA,JUMP_HEADLINE,JUMP_LINKPREV,JUMP_URL,
  913.     JUMP_BITMAP,JUMP_TABLE,JUMP_BEAM,JUMP_FOOTNOTE,
  914.     JUMP_RUBY,JUMP_LINK,JUMP_PROOF,
  915.     JUMP_BOLD,JUMP_UNDERLINE,JUMP_ITALIC,
  916.     JUMP_FONT
  917. };
  918. static mchar* _tszTml[] = {
  919.     "行","ページ","最後編集","変更行","見出し","リンク元へ戻る","URL",
  920.     "図","表","桁揃え","脚注",
  921.     "ルビ","リンク","校正",
  922.     "太字","下線","斜体",
  923.     "フォント指定",NULL
  924. };
  925.  
  926. static BOOL txfSearchTag(TX* text,mchar* szTag,SEARCHMODE searchmode)
  927. {
  928.     IFILE adr0 = txGetAddress(text);
  929.     int ly0 = text->ly;
  930.     BOOL ret = FALSE;
  931.     mchar szFind[CCHWORD];
  932.     searchmode |= SEARCH_NOSENSECASE;
  933.     //
  934.     sprintf_A(szFind,"\x1F%s",szTag);
  935.     text->fTxf = FALSE;
  936.     txSetUndisp(text);
  937.     //
  938.     if (searchmode & SEARCH_PREV) {
  939.         txfLeftChartail(text);
  940.     }
  941.     while(1) {
  942.         int result = txSearchEx(text,szFind,searchmode);
  943.         if (!result) break;
  944.         {
  945.             TEXTCHAR* p = text->buff + text->cur;
  946.             if (!IschTagname(p[result - 1])) {
  947.                 ret = TRUE;
  948.                 break;
  949.             }
  950. //            if (!txRightBytes(text,txfTagGetLch(p))) break;    // これすると次のタグがスキップされちゃう。
  951.         }
  952.     }
  953.     text->fTxf = TRUE;
  954.     txFlush(text);
  955.     if (ret) {
  956.         txfRightChartop(text);
  957.     } else {
  958.         txJumpAddress(text,adr0);
  959.         txSetLy(text,ly0);
  960.         statprintf("見つかりません");
  961.     }
  962.     txSetDisp(text);
  963.     return ret;    //WZ3.90P 981206 
  964. }
  965.  
  966. #if 0
  967. static BOOL txfSearchTag(TX* text,mchar* szTag,BOOL fPrev)
  968. {
  969.     IFILE adr0 = txGetAddress(text);
  970.     BOOL ret = FALSE;
  971.     text->fTxf = FALSE;txSetUndisp(text);
  972.     while(1) {
  973.         if (!txSearchEx(text,"\x1F",0)) break;
  974. statprintf("%d",txGetAddress(text));
  975.         {
  976.             TEXTCHAR* p = text->buff + text->cur;
  977.             TEXTCHAR* pName = txfTagGetName(p);
  978.             if (txfTagNameIs(pName,"IMG")) {
  979.                 ret = TRUE;
  980.                 break;
  981.             }
  982. //            if (!txRightBytes(text,txfTagGetLch(p))) break;    // これすると次のタグがスキップされちゃう。
  983.         }
  984.     }
  985.     text->fTxf = TRUE;txFlush(text);
  986.     if (ret) {txfRightChartop(text);} else {txJumpAddress(text,adr0);}
  987.     txSetDisp(text);
  988. }
  989. #endif
  990.  
  991. BOOL txSearchTable(TX* text,SEARCHMODE searchmode)
  992. {
  993. // text->fTxfEnable時はTMLの表、それ以外は罫線表を検索する
  994.     IFILE adr0 = txGetAddress(text);
  995.     int ly0 = text->ly;
  996.     BOOL ret = FALSE;
  997.     BOOL fPrev = (searchmode & SEARCH_PREV);
  998.     txSetUndisp(text);
  999.     if (txfCellGetExist(text)) {
  1000.         while(1) {
  1001.             if (fPrev ? !txPrevPara(text) : !txNextPara(text)) break;
  1002.             if (!txfCellGetExist(text)) break;
  1003.         }
  1004.     }
  1005.     while(1) {
  1006.         if (fPrev ? !txPrevPara(text) : !txNextPara(text)) break;
  1007.         if (txfCellGetExist(text)) {
  1008.             ret = TRUE;
  1009.             if (fPrev) {
  1010.                 while(1) {
  1011.                     if (!txPrevPara(text)) break;
  1012.                     if (!txfCellGetExist(text)) {txNextPara(text);break;}
  1013.                 }
  1014.             }
  1015.             break;
  1016.         }
  1017.     }
  1018.     if (!ret) {
  1019.         txJumpAddress(text,adr0);
  1020.         txSetLy(text,ly0);
  1021.         statprintf("見つかりません");
  1022.     }
  1023.     txSetDisp(text);
  1024.     return ret;    //WZ3.90P 981206 
  1025. }
  1026.  
  1027. BOOL txSearchURL(TX* text,SEARCHMODE searchmode)
  1028. {
  1029.     IFILE adr0 = txGetAddress(text);
  1030.     int ly0 = text->ly;
  1031.     BOOL ret = FALSE;
  1032.     BOOL fPrev = (searchmode & SEARCH_PREV);
  1033.     txSetUndisp(text);
  1034.     if ((fPrev) ? txPrevPara(text) : txNextPara(text)) {
  1035.         if (txSearchEx(text,"\\w+://\\w+",searchmode|SEARCH_REWZ|SEARCH_NOSELECT)) {
  1036.             ret = TRUE;
  1037.         }
  1038.     }
  1039.     if (!ret) {
  1040.         txJumpAddress(text,adr0);
  1041.         txSetLy(text,ly0);
  1042.         statprintf("見つかりません");
  1043.     }
  1044.     txSetDisp(text);
  1045.     return ret;
  1046. }
  1047.  
  1048. BOOL txJumpPage(TX* text,NPAGE npage)
  1049. {
  1050.     if (npage == 0) npage = 1;
  1051.     if (text->flpPreview) {
  1052.         if (npage < text->npage) {
  1053.             txJumpAddress(text,text->tPageatr[npage].ifilePagetop);
  1054.             return TRUE;
  1055.         } else if (npage > text->npage) {
  1056.             txSetUndisp(text);
  1057.             while(text->npage < npage) {
  1058.                 if (!txNextPage(text)) break;
  1059.             }
  1060.             txSetDisp(text);
  1061.             return (text->npage == npage);
  1062.         } else {
  1063.             return TRUE;
  1064.         }
  1065.     } else if (text->height && text->fLineD) {
  1066.         txJumpLine(text,text->height*(npage-1));
  1067.         return TRUE;
  1068.     }
  1069.     return FALSE;
  1070. }
  1071.  
  1072. static BOOL txJumpkind(TX* text,int jumpkind,int jumpline,SEARCHMODE searchmode)
  1073. {
  1074.     BOOL ret = FALSE;
  1075.     BOOL fPrev = (searchmode & SEARCH_PREV);
  1076.     int idm = 0;
  1077.     mchar* szTag = NULL;
  1078.     switch(jumpkind) {
  1079.         case JUMP_LINE: {
  1080.             if (text->fLineD) {
  1081.                 ret = txJumpLine(text,jumpline);
  1082.             } else {
  1083.                 ret = txJumpPara(text,jumpline);
  1084.             }
  1085.             break;
  1086.         }
  1087.         case JUMP_PAGE: ret = txJumpPage(text,jumpline);break;
  1088.         case JUMP_LASTEDIT: {
  1089.             txSetUndisp(text);
  1090.             txMarkCur(text);    //WZ4.00Bl 990914 最後に編集した位置へジャンプする前にカーソル位置をマークするようにした。ユーザ要望。
  1091.             txJumpAddress(text,text->adrLastEdit);
  1092.             txSetLyCenter(text);
  1093.             txSetDisp(text);
  1094.             ret = TRUE;
  1095.             break;
  1096.         }
  1097.         case JUMP_EDITPARA: idm = fPrev ? IDM_JUMPPREVEDITPARA : IDM_JUMPNEXTEDITPARA;break;
  1098.         case JUMP_HEADLINE: idm = fPrev ? IDM_JUMPPREVHEAD : IDM_JUMPNEXTHEAD;break;
  1099.         case JUMP_LINKPREV: {
  1100.             if (fPrev) {
  1101.                 ret = txLinkhistJumpPrev(text);
  1102.             } else {
  1103.                 ret = txLinkhistJumpNext(text);
  1104.             }
  1105.             break;
  1106.         }
  1107.         case JUMP_BITMAP: szTag = "*IMG";break;
  1108.         case JUMP_TABLE: ret = txSearchTable(text,searchmode);break;
  1109.         case JUMP_URL: ret = txSearchURL(text,searchmode);break;
  1110.         case JUMP_BEAM: {
  1111.             if (text->fTxf) {
  1112.                 szTag = "*BEAM";
  1113.             } else {
  1114.                 #if !__TXC__
  1115.                 ret = txSearchTabbeam(text,searchmode);
  1116.                 #endif // !__TXC__
  1117.             }
  1118.             break;
  1119.         }
  1120.         case JUMP_FOOTNOTE: szTag = "*FOOTNOTE";break;
  1121.         case JUMP_RUBY: szTag = "RUBY";break;
  1122.         case JUMP_LINK: szTag = "A";break;
  1123.         case JUMP_PROOF: szTag = "PROOF";break;
  1124.         case JUMP_BOLD: szTag = "B";break;
  1125.         case JUMP_UNDERLINE: szTag = "U";break;
  1126.         case JUMP_ITALIC: szTag = "I";break;
  1127.         case JUMP_FONT: szTag = "FONT";break;
  1128.     }
  1129.     if (idm) {
  1130.         txIdmExec(text,idm);
  1131.     }
  1132.     if (szTag && text->fTxf) {
  1133.         ret = txfSearchTag(text,szTag,searchmode);
  1134.     }
  1135.     return ret;
  1136. }
  1137.  
  1138. enum {
  1139.     IDD_JUMPCAPTION=100,IDD_JUMPLINE,IDD_JUMPLINEPREV
  1140. };
  1141.  
  1142. static int _jumpline;
  1143. static int _jumpkind;
  1144. static BBOOL _fjumpprev;
  1145.  
  1146. static void ListBox_AddStrings(HWND hwnd,mchar** tsz)
  1147. {
  1148.     for (;*tsz;tsz++) {
  1149.         ListBox_AddString_A(hwnd,*tsz);
  1150.     }
  1151. }
  1152.  
  1153. static int szToJumpkind(mchar* sz)
  1154. {
  1155.     mchar** tsz = _tszTml;
  1156.     for (;*tsz;tsz++) {
  1157.         if (!stricmp(*tsz,sz)) return tsz - _tszTml;
  1158.     }
  1159.     return 0;
  1160. }
  1161.  
  1162. static int hwndGetJumpkind(HWND hwnd)
  1163. {
  1164.     HWND hctrl = GetDlgItem(hwnd,IDD_LIST);
  1165.     int isel = ListBox_GetCurSel(hctrl);
  1166.     if (isel >= 0) {
  1167.         mchar buff[CCHWORD];
  1168.         ListBox_GetItemText_A(hctrl,isel,buff,CCHWORD);
  1169.         return szToJumpkind(buff);
  1170.     }
  1171.     return 0;
  1172. }
  1173.  
  1174. static void hwndSetJumpkind(HWND hwnd,int jumpkind)
  1175. {
  1176.     HWND hctrl = GetDlgItem(hwnd,IDD_LIST);
  1177.     int isel = ListBox_FindStringExact(hctrl,-1,_tszTml[jumpkind]);
  1178.     if (isel < 0) isel = 0;
  1179.     ListBox_SetCurSel(hctrl,isel);
  1180. }
  1181.  
  1182. BOOL CALLBACK dlgprocJump(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  1183. {
  1184.     HDIALOG hd = dialogFromHwnd(hwnd);
  1185.     TX* text = dialogGetCustdata(hd);
  1186.     switch(message) {
  1187.         case WM_INITDIALOG: {
  1188.             HWND hctrl = GetDlgItem(hwnd,IDD_LIST);
  1189.             static mchar* tszTxt[] = {"行","ページ","最後編集","変更行","URL","表","桁揃え","見出し",NULL};
  1190.             ListBox_AddStrings(hctrl,(text->fTxf) ? _tszTml : tszTxt);
  1191.             hwndSetJumpkind(hwnd,_jumpkind);
  1192.             FORWARD_WM_COMMAND(hwnd,IDD_LIST,hctrl,CBN_SELCHANGE,PostMessage);
  1193.             if (_jumpkind == JUMP_LINE || _jumpkind == JUMP_PAGE) {
  1194.                 PostMessage(hwnd,WM_TXUSER,0,0);
  1195.             }
  1196.             break;
  1197.         }
  1198.         case WM_COMMAND: {
  1199.             int id = GET_WM_COMMAND_ID(wParam,lParam);
  1200.             int cmd = GET_WM_COMMAND_CMD(wParam,lParam);
  1201.             HWND hctrl = GET_WM_COMMAND_HWND(wParam,lParam);
  1202.             switch(id) {
  1203.                 case IDD_LIST: {
  1204.                     if (cmd == LBN_SELCHANGE) {
  1205.                         int kind = hwndGetJumpkind(hwnd);
  1206.                         mchar* szCaption = NULL;
  1207.                         switch(kind) {
  1208.                             case JUMP_LINE: szCaption = _pspc?"行:":"行(&C):";break;
  1209.                             case JUMP_PAGE: szCaption = _pspc?"頁:":"ページ(&C):";break;
  1210.                         }
  1211.                         SetDlgItemText_A(hwnd,IDD_JUMPCAPTION,szCaption ? szCaption : "");
  1212.                         EnableDlgItem(hwnd,IDD_JUMPLINE,!!szCaption);
  1213.                         EnableDlgItem(hwnd,IDD_JUMPLINEPREV,!szCaption && (kind != JUMP_LASTEDIT));
  1214.                         //
  1215.                         if (_pspc) {
  1216.                             SetDlgItemText_A(hwnd,IDD_JUMPLINEPREV,(kind == JUMP_LINKPREV) ? "リンク先" : "上方向");
  1217.                         } else {
  1218.                             SetDlgItemText_A(hwnd,IDD_JUMPLINEPREV,(kind == JUMP_LINKPREV) ? "リンク先へ進む(&P)" : "上方向へジャンプ(&P)");
  1219.                         }
  1220.                         PostMessage(hwnd,WM_TXUSER+1,0,0);
  1221.                     }
  1222.                     break;
  1223.                 }
  1224.                 case IDD_JUMPLINEPREV: {
  1225.                     PostMessage(hwnd,WM_TXUSER+1,0,0);
  1226.                     break;
  1227.                 }
  1228.                 case IDOK: {
  1229.                     _jumpkind = hwndGetJumpkind(hwnd);
  1230.                     break;
  1231.                 }
  1232.             }
  1233.             break;
  1234.         }
  1235.         case WM_TXUSER: {
  1236.             HWND hctrl = GetDlgItem(hwnd,IDD_JUMPLINE);
  1237.             SetFocus(hctrl);
  1238.             Edit_SetSel(hctrl,0,-1);
  1239.             break;
  1240.         }
  1241.         case WM_TXUSER+1: {
  1242.             int kind = hwndGetJumpkind(hwnd);
  1243.             if (kind == JUMP_LINKPREV) {
  1244.                 BOOL fEnable = IsDlgButtonChecked(hwnd,IDD_JUMPLINEPREV) ? txLinkhistJumpNextGetAble(text) : txLinkhistJumpPrevGetAble(text);
  1245.                 EnableDlgItemEx(hwnd,IDOK,fEnable,IDD_LIST);
  1246.             } else {
  1247.                 EnableDlgItem(hwnd,IDOK,TRUE);
  1248.             }
  1249.             break;
  1250.         }
  1251.     }
  1252.     return FALSE;
  1253. }
  1254.  
  1255. static BOOL _txJumpNext(TX* text,BOOL fPrev)
  1256. {
  1257.     int jumpkind = _jumpkind;
  1258.     if (jumpkind == JUMP_LINE || jumpkind == JUMP_PAGE) jumpkind = JUMP_EDITPARA;
  1259.     return txJumpkind(text,jumpkind,0,fPrev ? SEARCH_PREV : 0);
  1260. }
  1261.  
  1262. BOOL txIDM_JUMPPREV(TX* text)
  1263. {
  1264.     return _txJumpNext(text,TRUE);
  1265. }
  1266.  
  1267. BOOL txIDM_JUMPNEXT(TX* text)
  1268. {
  1269.     return _txJumpNext(text,FALSE);
  1270. }
  1271.  
  1272. BOOL txIDM_UIJUMP(TX* text)
  1273. {
  1274.     if (text->fBinedit) {
  1275.         #if !POCKETWZ
  1276.         HDIALOG hd = dialog("ジャンプ");
  1277.         mchar szAdr[CCHWORD];
  1278.         sprintf_A(szAdr,"%08lX",txGetAddress(text));
  1279.         dialogString(hd,"アドレス(&L):",12,szAdr,CCHWORD,12);
  1280.         if (dialogOpen(hd)) {
  1281.             mchar*p = szAdr;
  1282.             IFILE adr = 0;
  1283.             for (;*p;) {
  1284.                 mchar c = *p++;
  1285.                 if (!isXdigiti(c)) break;
  1286.                 adr *= 16;
  1287.                 adr += xdigitToIntI(c);
  1288.             }
  1289.             {
  1290.                 int ly0 = text->ly;
  1291.                 txSetUndisp(text);
  1292.                 txJumpAddress(text,adr);
  1293.                 if (text->fJumpCursorCenter) {
  1294.                     txSetLyCenter(text);
  1295.                 } else {
  1296.                     txSetLy(text,ly0);
  1297.                 }
  1298.                 txSetDisp(text);
  1299.             }
  1300.         }
  1301.         #endif
  1302.     } else {
  1303. #if 1//WZ3.90L 981117 ジャンプ機能を高度化
  1304.         HDIALOG hd = dialog("ジャンプ");
  1305.         //
  1306.         dialogSetDlgproc(hd,dlgprocJump);
  1307.         dialogSetCustdata(hd,text);
  1308.         //
  1309.         dialogControlID(hd,IDD_LIST);
  1310.         dialogAddListbox(hd,"移動先(&D):",15-_pspc*5,5+_pocketpc*2);
  1311.         //
  1312.             dialogLFV(hd);
  1313.             dialogAddPosY(hd,DTCY);
  1314.             dialogSetPosLF(hd);
  1315.         dialogSetH(hd);
  1316.         hd->dtyAdd = DTCYKEY - DTCY;
  1317.         dialogControlID(hd,IDD_JUMPCAPTION);
  1318.         dialogCaptionDynamic(hd,NULL,10-_pspc*3);
  1319.         dialogControlID(hd,IDD_JUMPLINE);
  1320.         dialogControlUpdown(hd,1,10000);
  1321.         dialogInteger(hd,NULL,0,&_jumpline,8);
  1322.         dialogLF(hd);
  1323.         dialogControlID(hd,IDD_JUMPLINEPREV);
  1324.         dialogCheckB(hd,_pspc?"上方向":"上方向へジャンプ(&P)",&_fjumpprev);
  1325.         //
  1326.         if (dialogOpen(hd)) {
  1327.             SEARCHMODE searchmode = _fjumpprev ? SEARCH_PREV : 0;
  1328.             if (_jumpkind == JUMP_LINKPREV) searchmode = !_fjumpprev ? SEARCH_PREV : 0;    // この場合は逆転
  1329.             txJumpkind(text,_jumpkind,_jumpline,searchmode);
  1330.             return TRUE;
  1331.         }
  1332.         return FALSE;
  1333. #else
  1334.         HDIALOG hd = dialog("ジャンプ");
  1335.         static int line = 0;
  1336.         dialogInteger(hd,"行番号(&L):",12,&line,5);
  1337.         if (dialogOpen(hd)) {
  1338.             if (text->fLineD) {
  1339.                 txJumpLine(text,line);
  1340.             } else {
  1341.                 txJumpPara(text,line);
  1342.             }
  1343.         }
  1344. #endif
  1345.     }
  1346.     return TRUE;
  1347. }
  1348.  
  1349. BOOL txIDM_SELECTJUMP(TX* text)
  1350. {
  1351.     if (text->fClip) {
  1352.         txSelectJump(text);
  1353.     } else {    //WZ4.00Bl 990909 選択しないでIDM_SELECTJUMPしたとき、前回選択開始位置とのジャンプを行うようにした。ユーザ要望。
  1354.         if (txGetAddress(text) == text->cliptop) {
  1355.             txJumpMarkCur(text);
  1356.         } else {
  1357.             txMarkCur(text);
  1358.             txJumpAddress(text,text->cliptop);
  1359.         }
  1360.     }
  1361.     return TRUE;
  1362. }
  1363.  
  1364. //##前位置へ戻る
  1365. //WZ3.90H 980928 new
  1366.  
  1367. enum {
  1368.     IDD_PREVIEW = 900,IDD_PREVPAGE,IDD_NEXTPAGE,
  1369. };
  1370.  
  1371. typedef struct {
  1372.     TX* text;
  1373.     TX* textPreview;
  1374.     BOOL fFlushListing;
  1375.     LIST* list;
  1376. // result
  1377.     BOOL fJumpMarkCur;    // 直前位置へ戻る
  1378.     JH_ITEM item;
  1379. } JH_DIALOG;
  1380.  
  1381. static mchar _szJumpMarkCur[] = "直前位置へ戻る";
  1382.  
  1383. static void jumphistOnSelchange(HWND hwnd)
  1384. {
  1385.     HDIALOG hd = dialogFromHwnd(hwnd);
  1386.     JH_DIALOG* context = (LPVOID)dialogGetCustdata(hd);
  1387.     JH_ITEM* item = listReadCur(context->list);
  1388.     TX* textDst = context->textPreview;
  1389.     txSetUndisp(textDst);
  1390.     txDeleteText(textDst);
  1391.     if (item) {
  1392.         BOOL fJumpMarkCur = !strcmp(item->szfilename,_szJumpMarkCur);
  1393.     #if 1//WZ4.00Bm 990927 「前位置へ戻る」のプレビュー画面で文字コードの自動判別ができてなかった。
  1394.         TX* text = textopenEx(fJumpMarkCur ? context->text->szfilename : item->szfilename,TXO_KCAUTOMODAL|TXO_CRAUTOMODAL);
  1395.     #else
  1396.         TX* text = textopen(fJumpMarkCur ? context->text->szfilename : item->szfilename);
  1397.     #endif
  1398.         txSetHigh(text);
  1399.         if (fJumpMarkCur) {    // 「直前位置」
  1400.             txJumpAddress(text,context->text->mark[0]);
  1401.             item->npara = text->npara;
  1402.             txJumpFileTop(text);
  1403.         }
  1404.         {
  1405.             IBUFF ibuff = text->cur;
  1406.             NPARA npara = item->npara;
  1407.             {
  1408.                 int n = item->npara;
  1409.                 // 100行手前の内容から、(10行手前では使いにくかった)
  1410.                 if (n > 100) {
  1411.                     npara = 100;
  1412.                     txInsert(textDst,"(以上省略)\n");
  1413.                 } else {
  1414.                     npara = n;
  1415.                 }
  1416.                 n -= npara;
  1417.                 while(n--) {
  1418.                     IBUFF ibuffN = txIbuffGetNextPara(text,ibuff);
  1419.                     if (ibuffN == IBUFF_ERROR) break;
  1420.                     ibuff = ibuffN;
  1421.                 }
  1422.             }
  1423.             {
  1424.                 int n = npara + 100;    // npara+100行分までの内容をコピー
  1425.                 BOOL fEofed = FALSE;
  1426.                 for (;n--;) {
  1427.                     txInsertBuff(textDst,text->buff + ibuff,txIbuffGetParaContentEnd(text,ibuff)-ibuff);
  1428.                     txInsertReturn(textDst);
  1429.                     ibuff = txIbuffGetNextPara(text,ibuff);
  1430.                     if (ibuff == IBUFF_ERROR) {fEofed = TRUE;break;}
  1431.                 }
  1432.                 if (!fEofed) txInsert(textDst,"(以下省略)\n");
  1433.             }
  1434.             wstrcpy(textDst->wszfilename,text->wszfilename);txConfigGet(textDst);txFlush(textDst);
  1435.             txJumpNpara(textDst,npara);
  1436.             txSetLyCenter(textDst);
  1437.         }
  1438.         textclose(text);
  1439.     }
  1440.     txSetDisp(textDst);
  1441. }
  1442.  
  1443. BOOL CALLBACK dlgprocJumpHist(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  1444. {
  1445.     HDIALOG hd = dialogFromHwnd(hwnd);
  1446.     JH_DIALOG* context = (LPVOID)dialogGetCustdata(hd);
  1447.     switch(message) {
  1448.         case WM_INITDIALOG: {
  1449.             LIST* list = listFromHwnd(GetDlgItem(hwnd,IDD_LIST));
  1450.             JH_ITEM item;
  1451.             SUBLISTITEMATR* atr = &list->tSubitem[0];
  1452.             atr->type = LISTITEM_INT;
  1453.             atr->offset = (LPBYTE)&item.npara - (LPBYTE)&item;
  1454.             atr->cx = dtcx(DTCX * 6);
  1455.                 atr++;
  1456.             atr->type = LISTITEM_SZ;
  1457.             atr->offset = (LPBYTE)item.szfilename - (LPBYTE)&item;
  1458.             atr->cx = -1;
  1459.                 atr++;
  1460.             list->nSubitem = atr - &list->tSubitem[0];
  1461.             context->list = list;
  1462.             //
  1463.             {
  1464.                 TX* text = context->textPreview = WzBox_GetTx(GetDlgItem(hwnd,IDD_PREVIEW));
  1465.                 text->tabsize = 2;
  1466.                 text->fDispUnder = TRUE;
  1467.                 txFlush(text);
  1468.             }
  1469.             // 最初に、txJumpMarkCurの飛び先を入れる。for 「直前位置へ戻る」代替
  1470.             {
  1471.                 JH_ITEM* item = zmalloc(sizeof(JH_ITEM));
  1472.                 strcpy(item->szfilename,_szJumpMarkCur);
  1473.                 listAdd(context->list,item);
  1474.             }
  1475.             //
  1476.             {
  1477.                 HSTRBLK sb = sbFromHist(HIST_JUMP);
  1478.                 int n = sbGetCount(sb);
  1479.                 for (;n--;) {
  1480.                     mchar* sz = sbRead(sb,n);
  1481.                     JH_ITEM* item = zmalloc(sizeof(JH_ITEM));
  1482.                     histjumpstrAnalyze(sz,item);
  1483.                     listAdd(context->list,item);
  1484.                 }
  1485.             }
  1486.             //
  1487.             jumphistOnSelchange(hwnd);
  1488.             break;
  1489.         }
  1490.         case WM_NOTIFY: {
  1491.             LISTNOTIFY* notify = lParam;
  1492.             LIST* list = context->list;
  1493.             if (list && notify->hdr.hwndFrom == list->hwnd) {
  1494.                 if (notify->hdr.code == LISTN_SELCHANGE) {
  1495.                     jumphistOnSelchange(hwnd);
  1496.                 }
  1497.             }
  1498.             break;
  1499.         }
  1500.         case WM_COMMAND: {
  1501.             int id = GET_WM_COMMAND_ID(wParam,lParam);
  1502.             LIST* list = listFromHwnd(GetDlgItem(hwnd,IDD_LIST));
  1503.             switch(id) {
  1504.                 case IDOK: {
  1505.                     JH_ITEM* item = listReadCur(list);
  1506.                     if (item) {
  1507.                         if (!strcmp(item->szfilename,_szJumpMarkCur)) context->fJumpMarkCur = TRUE;
  1508.                         context->item = *item;
  1509.                     }
  1510.                     break;
  1511.                 }
  1512.                 case IDD_PREVPAGE: {
  1513.                     txPrevPage1(context->textPreview);
  1514.                     return TRUE;
  1515.                 }
  1516.                 case IDD_NEXTPAGE: {
  1517.                     txNextPage1(context->textPreview);
  1518.                     return TRUE;
  1519.                 }
  1520.             }
  1521.             break;
  1522.         }
  1523.     }
  1524.     return FALSE;
  1525. }
  1526.  
  1527. BOOL txIDM_UIJUMPBACK(TX* text)
  1528. {
  1529. //// いずれLISTで実現している部分をTEXTで実装し、検索が使えるようにしたい。
  1530.     HDIALOG hd = dialog("前位置へ戻る");
  1531.     DTRECT r;
  1532.     JH_DIALOG context;
  1533.     //
  1534.     structClear(context);
  1535.     context.text = text;
  1536.     //
  1537.     dialogSetDlgproc(hd,dlgprocJumpHist);
  1538.     dialogSetCustdata(hd,&context);
  1539.     dialogGetPos(hd,&r);
  1540.     r.cx = DTCX * 60;
  1541.     r.cy = DTCY * 6;
  1542. //    listRegister();
  1543.     __dialogAddItem(hd,szclassList,NULL,IDD_LIST,&r,WS_GROUP|WS_TABSTOP|WS_BORDER|WS_CHILD|WS_VISIBLE|LIST_WS_DEFAULT);
  1544.     //
  1545.     r.y += r.cy + DTCY;
  1546.     r.cy = DTCY * 16;    // プレビューが大きい方が使いやすい
  1547.     __dialogAddItem(hd,TXWS_SZCLASSA,NULL,IDD_PREVIEW,&r,TXWS_TEXT|TXWS_OPENTEXT|WS_VSCROLL|WS_VSCROLL|WS_BORDER|WS_CHILD|WS_VISIBLE|WS_TABSTOP);
  1548.     //
  1549.     dialogLFV(hd);
  1550.     //
  1551.     dialogControlID(hd,IDOK);
  1552.     dialogCmdDefault(hd,"ジャンプ(&J)",16);
  1553.     dialogControlID(hd,IDCANCEL);
  1554.     dialogCmd(hd,"キャンセル(&C)",16);
  1555.     dialogSpaceV(hd);
  1556.     dialogControlID(hd,IDD_PREVPAGE);
  1557.     dialogCmd(hd,"前ページ(&<)",16);
  1558.     dialogControlID(hd,IDD_NEXTPAGE);
  1559.     dialogCmd(hd,"後ページ(&>)",16);
  1560.     //
  1561.     if (dialogOpen(hd)) {
  1562.         if (context.fJumpMarkCur) {
  1563.             txJumpMarkCur(text);
  1564.             return TRUE;
  1565.         } else if (context.item.npara) {
  1566.             mchar sz[40];
  1567.             jumphistAdd(text);
  1568.         #if UNIX
  1569.             sprintf_A(sz,"-k -J%d -Yc",context.item.npara);
  1570.         #else
  1571.             sprintf_A(sz,"/k /J%d /Yc",context.item.npara);
  1572.         #endif
  1573.             forkstd(context.item.szfilename,sz);
  1574.             return TRUE;
  1575.         }
  1576.     }
  1577.     return FALSE;
  1578. }
  1579.  
  1580. //##検索閲覧
  1581.  
  1582. #if !WINDOWSCE
  1583.  
  1584. #define IDD_COPY        101
  1585.  
  1586. typedef struct {
  1587.     LISTITEM head;    // 必ず先頭にこれを入れる
  1588. // mydata
  1589.     int npara;
  1590.     mchar szpara[CCHWORD];
  1591. } SL_ITEM;
  1592.  
  1593. typedef struct {
  1594.     TX* text;
  1595.     SEARCH_PACKET* search;
  1596.     BOOL fFlushListing;
  1597.     LIST* list;
  1598. } SL_DIALOG;
  1599.  
  1600. static void searchlistFlush(HWND hwnd)
  1601. {
  1602.     HDIALOG hd = dialogFromHwnd(hwnd);
  1603.     SL_DIALOG* context = (LPVOID)dialogGetCustdata(hd);
  1604.     TX* text = context->text;
  1605.     SEARCH_PACKET* search = context->search;
  1606.     SEARCHMODE searchmode = search->searchmode;
  1607.     LIST* list = context->list;
  1608.     txSetUndispEx(text);
  1609.     txJumpFileTop(text);
  1610.     listDelAll(list);
  1611.     context->fFlushListing++;
  1612.     for (searchmode |= SEARCH_CUR;;searchmode &= ~SEARCH_CUR) {
  1613.         if (txSearchEx(text,search->szfind,searchmode)) {
  1614.             SL_ITEM* item = zmalloc(sizeof(SL_ITEM));
  1615.             item->npara = text->npara;
  1616.             txGetParaEx(text,item->szpara,cchof(item->szpara));
  1617.             listAdd(list,item);
  1618.             listDispAll(list);
  1619.         } else {
  1620.             break;
  1621.         }
  1622.     }
  1623.     context->fFlushListing--;
  1624.     txSetDispEx(text);
  1625.     {    //WZ4.00Bl 990926 検索閲覧で見つけた件数を表示するようにした。
  1626.         mchar sz[CCHWORD];
  1627.         mchar szfind[30];
  1628.         sstrcpy(szfind,search->szfind);    // 画面に収まるように。
  1629.         sprintf_A(sz,"検索閲覧 - %s : %d件",szfind,list->n);
  1630.         SetWindowText_A(hwnd,sz);
  1631.     }
  1632. }
  1633.  
  1634. BOOL CALLBACK dlgprocSearchList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  1635. {
  1636.     HDIALOG hd = dialogFromHwnd(hwnd);
  1637.     SL_DIALOG* context = (LPVOID)dialogGetCustdata(hd);
  1638.     switch(message) {
  1639.         case WM_INITDIALOG: {
  1640.             LIST* list = listFromHwnd(GetDlgItem(hwnd,IDD_LIST));
  1641.             SL_ITEM item;
  1642.             SUBLISTITEMATR* atr = &list->tSubitem[0];
  1643. //information("%d %d %d",(LPBYTE)&list->fSelect - (LPBYTE)list,(LPBYTE)(&list->tSubitem[0]) - (LPBYTE)list,(LPBYTE)(&list->tSubitem[1]) - (LPBYTE)list);
  1644.             atr->type = LISTITEM_INT;
  1645.             atr->offset = (LPBYTE)&item.npara - (LPBYTE)&item;
  1646.             atr->cx = dtcx(DTCX * 6);
  1647.                 atr++;
  1648.             atr->type = LISTITEM_SZ;
  1649.             atr->offset = (LPBYTE)item.szpara - (LPBYTE)&item;
  1650.             atr->cx = -1;
  1651.                 atr++;
  1652.             list->nSubitem = atr - &list->tSubitem[0];
  1653.             context->list = list;
  1654.             //
  1655.             searchlistFlush(hwnd);
  1656.             break;
  1657.         }
  1658.         case WM_NOTIFY: {
  1659.             LISTNOTIFY* notify = lParam;
  1660.             LIST* list = context->list;
  1661.             if (list && notify->hdr.hwndFrom == list->hwnd) {
  1662.                 if (notify->hdr.code == LISTN_SELCHANGE && !context->fFlushListing) {
  1663.                     SL_ITEM* item = listReadCur(list);
  1664.                     if (item) txJumpNpara(context->text,item->npara);
  1665.                 }
  1666.             }
  1667.             break;
  1668.         }
  1669.         case WM_COMMAND: {
  1670.             int id = GET_WM_COMMAND_ID(wParam,lParam);
  1671.             LIST* list = listFromHwnd(GetDlgItem(hwnd,IDD_LIST));
  1672.             switch(id) {
  1673.                 case IDD_COPY: {
  1674.                     SL_ITEM* item = listReadCur(list);
  1675.                     TX* text = context->text;
  1676.                     if (item) {
  1677.                         txSetUndispEx(text);
  1678.                         txJumpNpara(text,item->npara);
  1679.                         txSelectEx(text,CLIP_CHAR);
  1680.                         txNextPara(text);
  1681.                         txSelectCopy(text);
  1682.                         txSelectQuit(text);
  1683.                         txSetDispEx(text);
  1684.                     }
  1685.                     return TRUE;
  1686.                 }
  1687.                 case IDD_SEARCH: {
  1688.                     if (txuiSearchGet(context->text,context->search)) {
  1689.                         searchlistFlush(hwnd);
  1690.                     }
  1691.                     return TRUE;
  1692.                 }
  1693.             }
  1694.             break;
  1695.         }
  1696.     }
  1697.     return FALSE;
  1698. }
  1699.  
  1700. BOOL txuiSearchList(TX* text,SEARCH_PACKET* search)
  1701. {
  1702.     // 検索閲覧では下線、検索文字列の表示を強制ON
  1703.     BOOL fDispUnder0 = text->fDispUnder;
  1704.     BOOL fDispFind0 = text->fDispFind;
  1705.     IFILE adr = txGetAddress(text);
  1706.     HDIALOG hd = dialog("検索閲覧");
  1707.     DTRECT r;
  1708.     SL_DIALOG context;
  1709.     //
  1710.     structClear(context);
  1711.     context.text = text;
  1712.     context.search = search;
  1713.     //
  1714.     text->fDispUnder = TRUE;
  1715.     if (!text->fDispFind) text->fDispFind = COLORING_COLOR_UNDER;
  1716.     txFlush(text);
  1717.     //
  1718.     dialogSetDlgproc(hd,dlgprocSearchList);
  1719.     dialogSetCustdata(hd,&context);
  1720.     dialogGetPos(hd,&r);
  1721.     r.cx = DTCX * 60;
  1722.     r.cy = DTCY * 15;
  1723. //    listRegister();
  1724.     __dialogAddItem(hd,szclassList,NULL,IDD_LIST,&r,WS_GROUP|WS_TABSTOP|WS_BORDER|WS_CHILD|WS_VISIBLE|LIST_WS_DEFAULT);
  1725.     dialogLFV(hd);
  1726.     //
  1727.     dialogControlID(hd,IDOK);
  1728.     dialogCmdDefault(hd,"ジャンプ(&J)",12);
  1729.     dialogControlID(hd,IDD_COPY);
  1730.     dialogCmd(hd,"コピー(&C)",12);
  1731.     dialogControlID(hd,IDD_SEARCH);
  1732.     dialogCmd(hd,"条件(&S)...",12);
  1733.     dialogCancel(hd,12);
  1734.     //
  1735.     if (dialogOpen(hd) != IDOK) {
  1736.         txSetUndisp(text);
  1737.         txJumpAddress(text,adr);
  1738.     } else {
  1739.         txSetUndisp(text);
  1740.     }
  1741.     //
  1742.     text->fDispUnder = fDispUnder0;
  1743.     text->fDispFind = fDispFind0;
  1744.     txFlush(text);
  1745.     txSetDisp(text);
  1746.     //
  1747.     return TRUE;
  1748. }
  1749.  
  1750. #endif    // !WINDOWSCE
  1751.  
  1752. //##プラグイン
  1753.  
  1754. #if __TXC__
  1755. void __pluginGetProperty(mchar* prop,txstr res)
  1756. {
  1757. //information("%s",prop);
  1758.     if (!stricmp(prop,"name")) res = "検索/ジャンプIDM処理";
  1759.     if (!stricmp(prop,"author")) res = sysGetName();
  1760.     if (!stricmp(prop,"version")) res = sysGetVersionPrim();
  1761. }
  1762.  
  1763. static HOOKRESULT CALLBACK wndprocTextHook(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  1764. {
  1765.     if (message == WM_TXEVENT && wParam == TXEVENT_IDMEXEC) {
  1766.         TX* text = hwndtextGetText(hwnd);
  1767.         int idm = lParam;
  1768.         switch(idm) {
  1769.             case IDM_UISEARCH: {    // サンプル
  1770. statprintf("IDM_UISEARCH by macro");
  1771.                 txIDM_UISEARCH(text);
  1772.                 return HOOK_CAPTURE;
  1773.             }
  1774.             case IDM_UIREPLACE: {    // サンプル
  1775. statprintf("IDM_UIREPLACE by macro");
  1776.                 txIDM_UIREPLACE(text);
  1777.                 return HOOK_CAPTURE;
  1778.             }
  1779.             case IDM_GREP: {    // サンプル
  1780. statprintf("IDM_GREP by macro");
  1781.                 txIDM_GREP(text);
  1782.                 return HOOK_CAPTURE;
  1783.             }
  1784.         }
  1785.     }
  1786.     return HOOK_CONTINUE;
  1787. }
  1788.  
  1789. void __on_txFrameNew(TX* text)
  1790. {
  1791.     txSetHookWndproctextTxpcode(text,wndprocTextHook);
  1792. }
  1793.  
  1794. #endif
  1795.