source: dev/trunk/abdev/ProjectEditor/StringCount.cpp@ 225

Last change on this file since 225 was 24, checked in by dai_9181, 18 years ago

保存されていないドキュメントのタブに(*)をつける機能に対応。
MDITEXTEDITINFOをCMdiTextEditに変更。今後、オブジェクト指向化を進める。

File size: 2.0 KB
Line 
1#include "common.h"
2
3#ifdef THETEXT
4
5BOOL CALLBACK DlgStringCount(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
6 if(message==WM_INITDIALOG){
7 SetPosCenter(hwnd);
8
9 int i,WndNum;
10
11 WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
12
13 char *pBuf;
14 if(lParam){
15 //選択範囲
16 CHARRANGE CharRange;
17 TextEdit_GetSel(WndNum,&CharRange);
18 pBuf=(char *)HeapAlloc(hHeap,0,(CharRange.cpMax-CharRange.cpMin)+1);
19 TextEdit_GetSelText(WndNum,&CharRange,pBuf);
20
21 SetWindowText(hwnd,"選択範囲の文字カウント");
22 }
23 else{
24 //すべての範囲
25 pBuf=(char *)HeapAlloc(hHeap,0,lstrlen(MdiInfo[WndNum].pMdiTextEdit->buffer)+1);
26 lstrcpy(pBuf,MdiInfo[WndNum].pMdiTextEdit->buffer);
27 }
28
29 //総バイト数を取得
30 int iByte;
31 iByte=lstrlen(pBuf);
32
33 //文字数(スペースを含めない)を取得
34 int iOmitSpace=0;
35 for(i=0;i<iByte;i++){
36 if(pBuf[i]==' '||pBuf[i]=='\t') continue;
37 if(pBuf[i]==(char)0x81&&pBuf[i+1]==(char)0x40){
38 i++;
39 continue;
40 }
41 if(pBuf[i]=='\r'&&pBuf[i+1]=='\n'){
42 i++;
43 continue;
44 }
45 iOmitSpace++;
46 if(IsDBCSLeadByte(pBuf[i])){
47 i++;
48 continue;
49 }
50 }
51
52 //文字数(スペースを含む)を取得
53 int iWithSpace=0,iLineNum=0;
54 for(i=0;i<iByte;i++){
55 if(pBuf[i]=='\r'&&pBuf[i+1]=='\n'){
56
57 //行数
58 iLineNum++;
59
60 i++;
61 continue;
62 }
63 iWithSpace++;
64 if(IsDBCSLeadByte(pBuf[i])){
65 i++;
66 continue;
67 }
68 }
69
70 if(iByte) iLineNum++;
71
72 char temporary[255];
73
74 //総バイト数
75 Digit(iByte,temporary);
76 SetDlgItemText(hwnd,IDC_SCOUNT_BYTE,temporary);
77
78 //文字数(スペースを含めない)
79 Digit(iOmitSpace,temporary);
80 SetDlgItemText(hwnd,IDC_SCOUNT_OMIT_SPACE,temporary);
81
82 //文字数(スペースを含む)
83 Digit(iWithSpace,temporary);
84 SetDlgItemText(hwnd,IDC_SCOUNT_WITH_SPACE,temporary);
85
86 //行数
87 Digit(iLineNum,temporary);
88 SetDlgItemText(hwnd,IDC_SCOUNT_LINENUM,temporary);
89
90
91 HeapDefaultFree(pBuf);
92 }
93 if(message==WM_COMMAND&&LOWORD(wParam)==IDCANCEL) EndDialog(hwnd,NULL);
94 return 0;
95}
96
97#endif //THETEXT
98
Note: See TracBrowser for help on using the repository browser.