home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 January / VPR0201B.ISO / APUPDATE / VC / TXC0601M / TXC0601M.LZH / _IDMFORM.C < prev    next >
C/C++ Source or Header  |  2001-01-01  |  9KB  |  406 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.  
  16. //##見出し
  17.  
  18. static BOOL _txIDM_SWITCHHEADLINE(TX* text,int idm)
  19. {
  20.     //WCE1.01 980112 カーソル行を簡単に見出しにできるようにした(v.c.)
  21.     //PWZ2BETA0.6 980620 カーソル位置が変化しないようにした
  22.     IFILE adr = txGetAddress(text);
  23.     int iHeadline = txHeadlineMatch(text);
  24.     int ly = text->ly;
  25.     txSetUndispSilent(text);
  26.     if (iHeadline) {
  27.         if (idm == IDM_SWITCHHEADLINEPREV) {
  28.             iHeadline--;
  29.         } else {
  30.             iHeadline++;
  31.             if (iHeadline > HEADLINE_N) iHeadline = 0;
  32.         }
  33.     } else {
  34.         if (txHeadlineSearchPrev(text)) {
  35.             iHeadline = txHeadlineMatch(text);
  36.         }
  37.         if (iHeadline == 0) iHeadline = 1;
  38.     }
  39.     txJumpAddress(text,adr);
  40.     txHeadlineChange(text,iHeadline);
  41.     txfRightChartopTxf(text);
  42.     txSetLy(text,ly);
  43.     txSetDispSilent(text);
  44.     return TRUE;
  45. }
  46.  
  47. BOOL txIDM_SWITCHHEADLINE(TX* text)
  48. {
  49.     return _txIDM_SWITCHHEADLINE(text,IDM_SWITCHHEADLINE);
  50. }
  51.  
  52. BOOL txIDM_SWITCHHEADLINEPREV(TX* text)
  53. {
  54.     return _txIDM_SWITCHHEADLINE(text,IDM_SWITCHHEADLINEPREV);
  55. }
  56.  
  57. //##文字装飾
  58.  
  59. BOOL txIDM_INSERTTAGCHAR(TX* text)
  60. {
  61.     // タグ記号<>を挿入。タグ内のときはタグセパレータを挿入
  62.     // タグ解釈モード時はタグ表示モードに切り替え
  63.     if (text->fTxf) txfTagSwitchDisp(text);
  64.     if (text->fTxfEnable) {
  65.         if (text->fClip) {
  66.             HDIALOG hd = dialog("タグ名の指定");
  67.             TEXTCHAR szTag[CCHWORD] = {0};
  68.             dialogString(hd,"タグ(&T):",14,szTag,textcchof(szTag),20);
  69.             if (dialogOpen(hd)) {
  70.                 txfCharatrEx(text,szTag,NULL);
  71.             }
  72.         } else {
  73.             TEXTCHAR buff[3];
  74.             TEXTCHAR* p = text->buff + text->cur;
  75.             BOOL fInsertSeparator = FALSE;
  76.             while(1) {
  77.                 TEXTCHAR c = *p++;
  78.                 if (IschReturn(c)) break;
  79.                 if (c == CHAR_TXF) break;
  80.                 if (c == CHAR_TXFEND) {
  81.                     fInsertSeparator = TRUE;
  82.                     break;
  83.                 }
  84.             }
  85.             if (fInsertSeparator) {
  86.                 txInsertChar(text,CHAR_ATRDELI);
  87.             } else {
  88.                 buff[0] = CHAR_TXF;
  89.                 buff[1] = CHAR_TXFEND;
  90.                 buff[2] = 0;
  91.                 txInsert(text,buff);
  92.                 txLeft(text);
  93.             }
  94.         }
  95.         return TRUE;
  96.     }
  97.     return FALSE;
  98. }
  99.  
  100. BOOL txIDM_UICHARPROPERTY(TX* text)
  101. {
  102.     txfCharProperty(text);
  103.     return TRUE;
  104. }
  105.  
  106. //##段落体裁
  107.  
  108. BOOL txIDM_UIPARAPROPERTY(TX* text)
  109. {
  110.     txfParaProperty(text);
  111.     return TRUE;
  112. }
  113.  
  114. //##特殊文字
  115.  
  116. BOOL txIDM_INSERTFF(TX* text)
  117. {
  118.     txInsertChar(text,CHAR_FF);
  119.     return TRUE;
  120. }
  121.  
  122. BOOL txIDM_INSERTBEAM(TX* text)
  123. {
  124.     if (text->fTxfEnable) {
  125.         txfBeam(text);
  126.         if (text->fTxf) txfBeamFlush(text,TRUE);
  127.         return TRUE;
  128.     }
  129.     return FALSE;
  130. }
  131.  
  132. BOOL txIDM_UIINSERTTABLE(TX* text)
  133. {
  134.     if (text->filekind == TEXT_HTML) {    //WZ4.00A 981230 HTMLで「挿入|表」でHTMLの表を挿入するようにした。
  135.     #if !__TXC__
  136.         #if WZFUNC_HTMLHIGH
  137.         txuiHtmlInsertTable(text);
  138.         #else
  139.         txuiKeisenInsertTable(text);
  140.         #endif
  141.     #endif // !__TXC__
  142.     } else if (!text->fTxf) {
  143.         txuiKeisenInsertTable(text);
  144.     } else {
  145.         txfUiInsertTable(text);
  146.     }
  147.     return TRUE;
  148. }
  149.  
  150. #if WZFUNC_BITMAP
  151. BOOL txIDM_UIINSERTBITMAP(TX* text)
  152. {
  153.     txfUiInsertImg(text);
  154.     return TRUE;
  155. }
  156. #endif
  157.  
  158. #if WZFUNC_EDITOR
  159. BOOL txIDM_RUBY(TX* text)
  160. {
  161.     HDIALOG hd = dialog("ルビ");
  162.     mchar szRuby[CCHWORD] = {0};
  163.     hd->fPpcPopup = TRUE;    //WZ4.00Eb 010101 
  164.     dialogString(hd,"ルビ(&R):",10,szRuby,cchof(szRuby),20);
  165.     if (dialogOpen(hd)) {
  166.         mchar szAtr[80 + cchof(szRuby)];
  167.         atrAddString(szAtr,NULL,szRuby);
  168.         txfCharatrEx(text,"RUBY",szAtr);
  169.         return TRUE;
  170.     }
  171.     return FALSE;
  172. }
  173. #endif
  174.  
  175. BOOL txIDM_INSERTHR(TX* text)
  176. {
  177.     if (text->filekind == TEXT_HTML) {    //WZ4.00A 981230 HTMLで「挿入|水平線」は<HR>を挿入するようにした。
  178.         txInsertWithReturn(text,"<HR>");
  179.     } else {
  180.         txApfInsertHR(text);
  181.     }
  182.     return TRUE;
  183. }
  184.  
  185. #if 0//WZ4.00Ab 990117 
  186. BOOL txIDM_PROOF(TX* text)
  187. {
  188.  
  189.     HDIALOG hd = dialog("校正入力");
  190.     mchar szProof[CCHWORD*3] = {0};
  191.     static mchar szReader[CCHNAME] = {0};
  192.     dialogString(hd,"校正(&P):",10,szProof,cchof(szProof),20);
  193.     dialogString(hd,"校正者(&R):",10,szReader,cchof(szReader),20);
  194.     if (dialogOpen(hd)) {
  195.         mchar szAtr[CCHWORD * 4];
  196.         mchar* dst = szAtr;
  197.         dst = atrAddString(dst,NULL,szProof);
  198.         dst = atrAddString(dst,"READER",szReader);
  199.         txfCharatrEx(text,"PROOF",szAtr);
  200.         return TRUE;
  201.     }
  202.     return FALSE;
  203. }
  204. #endif
  205.  
  206. //##脚注
  207.  
  208. #if !WINDOWSCE && WZFUNC_EDITOR
  209.  
  210. enum {
  211.     IDD_INSERTRETURN = 100,
  212. };
  213.  
  214. BOOL CALLBACK dlgprocFootnote(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  215. {
  216.     HDIALOG hd = dialogFromHwnd(hwnd);
  217. //    CONTEXT_PARAPROPERTY* context = dialogGetCustdata(hd);
  218.     switch(message) {
  219.         case WM_INITDIALOG: {
  220.             TX* text = hwndtextGetText(GetDlgItem(hwnd,IDD_LIST));
  221.             text->fSetWidthByWindow = TRUE;
  222.         #if 1//WZ4.00Bl 990911 
  223.             text->dlgcode = DLGC_WANTARROWS|DLGC_WANTCHARS;
  224.         #else
  225.             text->dlgcode = DLGC_WANTARROWS;
  226.         #endif
  227.             txFlush(text);
  228.             break;
  229.         }
  230.         case WM_COMMAND: {
  231.             int id = GET_WM_COMMAND_ID(wParam,lParam);
  232.             int cmd = GET_WM_COMMAND_CMD(wParam,lParam);
  233.             switch(id) {
  234.                 case IDD_INSERTRETURN: {
  235.                     TX* text = hwndtextGetText(GetDlgItem(hwnd,IDD_LIST));
  236.                     txInsertReturn(text);
  237.                     return TRUE;
  238.                 }
  239.             }
  240.             break;
  241.         }
  242.     }
  243.     return FALSE;
  244. }
  245.  
  246. static BOOL _txfUiFootnoteInsert(TX* text,int mode)
  247. {
  248.     BOOL fProperty = (mode == 1);
  249.     HDIALOG hd = dialog(fProperty ? "脚注のプロパティ" : "脚注の挿入");
  250.     TX* text2 = textopen(NULL);
  251.     int number = 1;    //WZ4.00A 981221 脚注のプロパティで脚注番号が1に初期化された
  252.     //
  253.     if (fProperty) {
  254.         number = txfTagFootnoteGetText(text->buff + text->cur,text2);
  255.         txJumpFileTop(text2);
  256.     }
  257.     dialogSetDlgproc(hd,dlgprocFootnote);
  258.     //
  259.     dialogControlID(hd,IDD_LIST);
  260.     dialogEditWz(hd,"内容(&D):",text2,60,15,WS_VSCROLL|WS_HSCROLL);
  261.     //
  262.     dialogLFV(hd);
  263.     dialogOK(hd,18);
  264.     dialogCancel(hd,18);
  265.     dialogSpaceV(hd);
  266.     dialogControlID(hd,IDD_INSERTRETURN);
  267.     dialogCmd(hd,"改行(&R)",18);
  268.     //
  269.     if (dialogOpen(hd)) {
  270.         if (fProperty) txDeleteBytes(text,txfTagGetLch(text->buff + text->cur));
  271.         txfFootnoteInsert(text,number,text2);
  272.         if (fProperty) txLeft(text);
  273.     }
  274.     textclose(text2);
  275.     return TRUE;
  276. }
  277.  
  278. BOOL txIDM_UIINSERTFOOTNOTE(TX* text)
  279. {
  280.     return _txfUiFootnoteInsert(text,0);
  281. }
  282.  
  283. BOOL txfUiFootnoteProperty(TX* text)
  284. {
  285.     return _txfUiFootnoteInsert(text,1);
  286. }
  287.  
  288. BOOL txIDM_FOOTNOTE(TX* text)
  289. {
  290.     BOOL ret = FALSE;
  291.     HDIALOG hd = dialog("脚注の操作");
  292.     static BYTE mode = 0;
  293.     dialogControlRadioV(hd);
  294.     dialogChoiceRadioB(hd,&mode,"番号振り直し(&N)","出力(&O)...",NULL);
  295.     if (dialogOpen(hd)) {
  296.         ret = TRUE;
  297.         if (mode == 0) {
  298.             txfFootnoteFlushAll(text);
  299.         } else if (mode == 1) {
  300.             txfFootnoteOutput(text);
  301.         }
  302.     }
  303.     return ret;    //WZ3.90P 981206 
  304. }
  305.  
  306. #endif    // !WINDOWSCE
  307.  
  308. //##整形
  309.  
  310. BOOL txIDM_FORMREFNAME(TX* text)
  311. {
  312.     text->fApfNameSymbol = TRUE;
  313.     if (text->fApfing) {
  314.         txApfExit(text);
  315.     } else {
  316.         txApfEnter(text);
  317.     }
  318.     text->fApfNameSymbol = FALSE;
  319.     return TRUE;
  320. }
  321.  
  322. BOOL txIDM_FORM(TX* text)
  323. {
  324.     if (text->fApfing) {
  325.         //WCE0.95 970923 IDM_FORMで既に自動整形中のときは自動整形を終了するようにした。
  326.         txApfExit(text);
  327.     } else {
  328.         txApfEnter(text);
  329.     }
  330.     return TRUE;
  331. }
  332.  
  333. BOOL txIDM_SWITCHAUTOFORM(TX* text)
  334. {
  335.     text->fApf ^= TRUE;
  336.     txFlushMenuCheck(text,FMC_CONFIG);
  337.     statprintf("自動整形モード %s",text->fApf ? "ON" : "OFF");//WCE0.94 970921 
  338.     return TRUE;
  339. }
  340.  
  341. //##その他
  342.  
  343. static BOOL _txIDM_UIFORMPROPERTY(TX* text,int idm)
  344. {
  345. //WZ4.00Ac 990205 newarg:idm
  346.     if (text->fTxf) {
  347.         if (txchIsKeisen(txGetChar(text)) || txKeisenGetLeft(text)) {
  348.             txKeisenProperty(text);
  349.         } else {
  350.             txfProperty(text);
  351.         }
  352.     } else {
  353.         if (txchIsKeisen(txGetChar(text)) || txKeisenGetLeft(text)) {
  354.             txKeisenProperty(text);
  355.         } else {
  356.             //WZ4.00Ac 990205 Alt+Enterで自動整形の段落体裁ダイアログを開かないようにした。このダイアログが開くと自動整形が行われ、ユーザの意志によらず勝手にテキストを書き換える事になるため。
  357.             //WZ4.00Ad 990210 自動整形モード、自動整形中はAlt+Enterで自動整形の段落体裁ダイアログを開くようにした
  358.             if (idm == IDM_UIFORMPROPERTY || text->fApfing || text->fApf) txuiApfConfig(text);
  359.         }
  360.     }
  361.     return TRUE;
  362. }
  363.  
  364. BOOL txIDM_ALTENTER(TX* text)
  365. {
  366.     return _txIDM_UIFORMPROPERTY(text,IDM_ALTENTER);
  367. }
  368.  
  369. BOOL txIDM_UIFORMPROPERTY(TX* text)
  370. {
  371.     return _txIDM_UIFORMPROPERTY(text,IDM_UIFORMPROPERTY);
  372. }
  373.  
  374. //##プラグイン
  375.  
  376. #if __TXC__
  377. void __pluginGetProperty(mchar* prop,txstr res)
  378. {
  379. //information("%s",prop);
  380.     if (!stricmp(prop,"name")) res = "書式IDM処理";
  381.     if (!stricmp(prop,"author")) res = sysGetName();
  382.     if (!stricmp(prop,"version")) res = sysGetVersionPrim();
  383. }
  384.  
  385. static HOOKRESULT CALLBACK wndprocTextHook(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  386. {
  387.     if (message == WM_TXEVENT && wParam == TXEVENT_IDMEXEC) {
  388.         TX* text = hwndtextGetText(hwnd);
  389.         int idm = lParam;
  390.         switch(idm) {
  391.             case IDM_ALTENTER: {    // サンプル
  392. statprintf("プロパティ by macro");
  393.                 txIDM_ALTENTER(text);
  394.                 return HOOK_CAPTURE;
  395.             }
  396.         }
  397.     }
  398.     return HOOK_CONTINUE;
  399. }
  400.  
  401. void __on_txFrameNew(TX* text)
  402. {
  403.     txSetHookWndproctextTxpcode(text,wndprocTextHook);
  404. }
  405. #endif
  406.