0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
| | Index: sakura_core/CDlgFuncList.cpp
===================================================================
--- sakura_core/CDlgFuncList.cpp (revision 1011)
+++ sakura_core/CDlgFuncList.cpp (working copy)
@@ -100,6 +100,7 @@
}
CDlgFuncList::CDlgFuncList()
+ : m_nCurLineCRLF( 0 )
{
m_pcFuncInfoArr = NULL; /* 関数情報配列 */
m_nCurLine = 0; /* 現在行 */
@@ -173,6 +174,17 @@
hwndList = ::GetDlgItem( m_hWnd, IDC_LIST1 );
hwndTree = ::GetDlgItem( m_hWnd, IDC_TREE1 );
+ // From Here Oct. 29, 2006 genta
+ CLayoutMgr* pcLayoutMgr = &(((CEditView*)m_lParam)->m_pcEditDoc->m_cLayoutMgr);
+ {
+ // 現在の論理行に対応する物理行を取得(現在位置判定に使う)
+ int phx, phy;
+
+ pcLayoutMgr->CaretPos_Log2Phys( 0, m_nCurLine - 1, &phx, &phy );
+ m_nCurLineCRLF = phy + 1; // 1〜
+ }
+ // To Here Oct. 29, 2006 genta
+
//2002.02.08 hor 隠しといてアイテム削除→あとで表示
::ShowWindow( hwndList, SW_HIDE );
::ShowWindow( hwndTree, SW_HIDE );
@@ -251,7 +263,7 @@
// Jul 10, 2003 little YOSHI 処理が長くなったので独立
m_nViewType = 0;
/* リストビューコントロールの初期化:Visual Basic アウトライン */
- SetListVB();
+ SetListVB( pcLayoutMgr );
::SetWindowText( m_hWnd, "Visual Basic アウトライン" );
}else{
m_nViewType = 0;
@@ -296,16 +308,16 @@
for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){
pcFuncInfo = m_pcFuncInfoArr->GetAt( i );
if( !bSelected ){
- if( i == 0 && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( i == 0 && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
bSelected = TRUE;
nSelectedLine = i;
}else
- if( i > 0 && nFuncLineOld <= m_nCurLine && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( i > 0 && nFuncLineOld <= m_nCurLineCRLF && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
bSelected = TRUE;
nSelectedLine = i - 1;
}
}
- nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT;
+ nFuncLineOld = pcFuncInfo->m_nFuncLineCRLF;
}
if( 0 < m_pcFuncInfoArr->GetNum() && !bSelected ){
bSelected = TRUE;
@@ -320,7 +332,11 @@
if(m_bLineNumIsCRLF ){
wsprintf( szText, "%d", pcFuncInfo->m_nFuncLineCRLF );
}else{
- wsprintf( szText, "%d", pcFuncInfo->m_nFuncLineLAYOUT );
+ // 2006.10.29 genta 物理行番号からその都度変換
+ // 現在の物理行に対応する論理行を取得
+ int layx, layy;
+ pcLayoutMgr->CaretPos_Phys2Log( 0, pcFuncInfo->m_nFuncLineCRLF - 1, &layx, &layy );
+ wsprintf( szText, "%d", layy + 1 );
}
item.mask = LVIF_TEXT | LVIF_PARAM;
item.pszText = szText;
@@ -654,18 +670,18 @@
}
/* 現在カーソル位置のメソッドかどうか調べる */
if( !bSelected ){
- if( i == 0 && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( i == 0 && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
bSelected = TRUE;
nSelectedLine = i;
htiSelected = htiItem;
}else
- if( i > 0 && nFuncLineOld <= m_nCurLine && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( i > 0 && nFuncLineOld <= m_nCurLineCRLF && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
bSelected = TRUE;
nSelectedLine = i - 1;
htiSelected = htiItemOld;
}
}
- nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT;
+ nFuncLineOld = pcFuncInfo->m_nFuncLineCRLF;
if( NULL != pClassName ){
delete [] pClassName;
@@ -952,18 +968,18 @@
/* 現在カーソル位置のメソッドかどうか調べる */
if( !bSelected ){
- if( i == 0 && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( i == 0 && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
bSelected = TRUE;
nSelectedLine = i;
htiSelected = htiItem;
}else
- if( i > 0 && nFuncLineOld <= m_nCurLine && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( i > 0 && nFuncLineOld <= m_nCurLineCRLF && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
bSelected = TRUE;
nSelectedLine = i - 1;
htiSelected = htiItemOld;
}
}
- nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT;
+ nFuncLineOld = pcFuncInfo->m_nFuncLineCRLF;
htiItemOld = htiItem;
// Jan. 04, 2001 genta
// deleteはその都度行うのでここでは不要
@@ -995,7 +1011,7 @@
@date Jul 10, 2003 little YOSHI
*/
-void CDlgFuncList::SetListVB (void)
+void CDlgFuncList::SetListVB ( CLayoutMgr* pcLayoutMgr )
{
int i;
char szText[2048], szType[128], szOption[256];
@@ -1016,16 +1032,16 @@
for( i = 0; i < m_pcFuncInfoArr->GetNum(); ++i ){
pcFuncInfo = m_pcFuncInfoArr->GetAt( i );
if( !bSelected ){
- if( i == 0 && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( i == 0 && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
bSelected = TRUE;
nSelectedLine = i;
}else
- if( i > 0 && nFuncLineOld <= m_nCurLine && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( i > 0 && nFuncLineOld <= m_nCurLineCRLF && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
bSelected = TRUE;
nSelectedLine = i - 1;
}
}
- nFuncLineOld = pcFuncInfo->m_nFuncLineLAYOUT;
+ nFuncLineOld = pcFuncInfo->m_nFuncLineCRLF;
}
if( 0 < m_pcFuncInfoArr->GetNum() && !bSelected ){
bSelected = TRUE;
@@ -1040,7 +1056,11 @@
if(m_bLineNumIsCRLF ){
wsprintf( szText, "%d", pcFuncInfo->m_nFuncLineCRLF );
}else{
- wsprintf( szText, "%d", pcFuncInfo->m_nFuncLineLAYOUT );
+ // 2006.10.29 genta 物理行番号からその都度変換
+ // 現在の物理行に対応する論理行を取得
+ int layx, layy;
+ pcLayoutMgr->CaretPos_Phys2Log( 0, pcFuncInfo->m_nFuncLineCRLF - 1, &layx, &layy );
+ wsprintf( szText, "%d", layy + 1 );
}
item.mask = LVIF_TEXT | LVIF_PARAM;
item.pszText = szText;
@@ -1274,7 +1294,7 @@
/* pcFuncInfoに登録されている行数を確認して、選択するアイテムを考える
*/
- if ( pcFuncInfo->m_nFuncLineLAYOUT <= m_nCurLine ){
+ if ( pcFuncInfo->m_nFuncLineCRLF <= m_nCurLineCRLF ){
hItemSelected = hItem;
}
@@ -1378,22 +1398,22 @@
m_cmemClipText.AppendSz( (const char *)"\r\n" ); /* クリップボードコピー用テキスト */
/* 現在カーソル位置のメソッドかどうか調べる */
- if( nBgn == 0 && m_nCurLine < pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( nBgn == 0 && m_nCurLineCRLF < pcFuncInfo->m_nFuncLineCRLF ){
/* 現在カーソル位置のメソッドを選択状態にする */
// TreeView_SelectItem( hwndTree, htiItem );
*phtiItemSelected = htiItem;
}else{
if( nBgn + 1 < m_pcFuncInfoArr->GetNum() ){
pcFuncInfoNext = m_pcFuncInfoArr->GetAt( nBgn + 1 );
- if( m_nCurLine >= pcFuncInfo->m_nFuncLineLAYOUT &&
- m_nCurLine < pcFuncInfoNext->m_nFuncLineLAYOUT
+ if( m_nCurLineCRLF >= pcFuncInfo->m_nFuncLineCRLF &&
+ m_nCurLineCRLF < pcFuncInfoNext->m_nFuncLineCRLF
){
/* 現在カーソル位置のメソッドを選択状態にする */
// TreeView_SelectItem( hwndTree, htiItem );
*phtiItemSelected = htiItem;
}
}else{
- if( m_nCurLine >= pcFuncInfo->m_nFuncLineLAYOUT ){
+ if( m_nCurLineCRLF >= pcFuncInfo->m_nFuncLineCRLF ){
/* 現在カーソル位置のメソッドを選択状態にする */
// TreeView_SelectItem( hwndTree, htiItem );
*phtiItemSelected = htiItem;
Index: sakura_core/CDlgFuncList.h
===================================================================
--- sakura_core/CDlgFuncList.h (revision 1011)
+++ sakura_core/CDlgFuncList.h (working copy)
@@ -25,6 +25,7 @@
#include <windows.h>
#include "CDialog.h"
class CFuncInfoArr; // 2002/2/10 aroka
+class CLayoutMgr; // 2006.10.29 genta
//! アウトライン解析ダイアログボックス
@@ -47,7 +48,8 @@
void Redraw( int nOutLineType, CFuncInfoArr*, int nCurLine );
CFuncInfoArr* m_pcFuncInfoArr; /* 関数情報配列 */
- int m_nCurLine; /* 現在行 */
+ int m_nCurLine; /*!< 現在行 (レイアウト行)*/
+ int m_nCurLineCRLF; /*!< 現在行(物理行: 1~) 2006.10.29 genta */
int m_nSortCol; /* ソートする列番号 */
int m_nListType; /* 一覧の種類 */
CMemory m_cmemClipText; /* クリップボードコピー用テキスト */
@@ -69,7 +71,7 @@
void SetTreeCpp( HWND ); /* ツリーコントロールの初期化:C++メソッドツリー */
void SetTreeJava( HWND, BOOL ); /* ツリーコントロールの初期化:Javaメソッドツリー */
void SetTree(); /* ツリーコントロールの初期化:汎用品 */
- void SetListVB( void ); /* リストビューコントロールの初期化:VisualBasic */ // Jul 10, 2003 little YOSHI
+ void SetListVB( CLayoutMgr* pcLayoutMgr ); /* リストビューコントロールの初期化:VisualBasic */ // Jul 10, 2003 little YOSHI
// 2002/11/1 frozen
void SortTree(HWND hWndTree,HTREEITEM htiParent);//!< ツリービューの項目をソートする(ソート基準はm_nSortTypeを使用)
Index: sakura_core/CDlgJump.cpp
===================================================================
--- sakura_core/CDlgJump.cpp (revision 1011)
+++ sakura_core/CDlgJump.cpp (working copy)
@@ -202,7 +202,9 @@
void CDlgJump::SetData( void )
{
CEditDoc* pCEditDoc = (CEditDoc*)m_lParam;
- CFuncInfoArr cFuncInfoArr;
+ CFuncInfoArr cFuncInfoArr( pCEditDoc );
+ // 2006.10.30 genta 行番号変換用
+ CLayoutMgr* pcLayoutMgr = &(pCEditDoc->m_cLayoutMgr);
int i;
HWND hwndCtrl;
char szText[1024];
@@ -232,58 +234,56 @@
nWorkLine = -1;
nIndex = 0;
nPLSQLBlockNum = 0;
+ // 2006.10.30 genta 行数の数え方はアウトライン解析の設定値を使う
+ bool bLineNumCRLF = pCEditDoc->GetDocumentAttribute().m_bLineNumIsCRLF ? true : false;
for( i = 0; i < cFuncInfoArr.GetNum(); ++i ){
- if( 31 == cFuncInfoArr.GetAt( i )->m_nInfo ||
- 41 == cFuncInfoArr.GetAt( i )->m_nInfo ){
+ // 2006.10.30 genta FuncInfoの参照を一時変数で
+ CFuncInfo *pFuncInfo = cFuncInfoArr.GetAt( i );
+ if( 31 == pFuncInfo->m_nInfo ||
+ 41 == pFuncInfo->m_nInfo ){
// MYTRACE( "cFuncInfoArr.GetAt( i )->m_cmemFuncName=%s(%d)\n",
// (char*)(cFuncInfoArr.GetAt( i )->m_cmemFuncName.GetPtr() ),
// cFuncInfoArr.GetAt( i )->m_nFuncLineCRLF
// );
}
- if( 31 == cFuncInfoArr.GetAt( i )->m_nInfo ){
-//@@@ 2002.01.08 YAZAKI 設定を保存するためにShareDataに移動
- if( m_pShareData->m_bLineNumIsCRLF ){ /* 行番号の表示 FALSE=折り返し単位/TRUE=改行単位 */
- wsprintf( szText, "%d 行 %s パッケージ仕様部",
- cFuncInfoArr.GetAt( i )->m_nFuncLineCRLF,
- cFuncInfoArr.GetAt( i )->m_cmemFuncName.GetPtr()
- );
- }else{
- wsprintf( szText, "%d 行 %s パッケージ仕様部",
- cFuncInfoArr.GetAt( i )->m_nFuncLineLAYOUT,
- cFuncInfoArr.GetAt( i )->m_cmemFuncName.GetPtr()
- );
+ if( 31 == pFuncInfo->m_nInfo ){
+ // 2006.10.30 genta 行番号計算と重複コードまとめ
+ // 行番号表示方法はアウトライン解析の設定値を使う
+ int linenum;
+ if( bLineNumCRLF ){ /* 行番号の表示 FALSE=折り返し単位/TRUE=改行単位 */
+ linenum = pFuncInfo->m_nFuncLineCRLF;
}
+ else {
+ // 2006.10.29 genta 物理行番号からその都度変換
+ // 現在の物理行に対応する論理行を取得
+ int layx, layy;
+ pcLayoutMgr->CaretPos_Phys2Log( 0, pFuncInfo->m_nFuncLineCRLF - 1, &layx, &layy );
+ linenum = layy + 1;
+ }
+ wsprintf( szText, "%d 行 %s パッケージ仕様部", linenum,
+ pFuncInfo->m_cmemFuncName.GetPtr() );
nIndex = ::SendMessage( hwndCtrl, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)szText );
-//@@@ 2002.01.08 YAZAKI 設定を保存するためにShareDataに移動
- if( m_pShareData->m_bLineNumIsCRLF ){ /* 行番号の表示 FALSE=折り返し単位/TRUE=改行単位 */
- ::SendMessage( hwndCtrl, CB_SETITEMDATA, (WPARAM)nIndex, (LPARAM) (DWORD)cFuncInfoArr.GetAt( i )->m_nFuncLineCRLF );
- }else{
- ::SendMessage( hwndCtrl, CB_SETITEMDATA, (WPARAM)nIndex, (LPARAM) (DWORD)cFuncInfoArr.GetAt( i )->m_nFuncLineLAYOUT );
- }
- nPLSQLBlockNum++;
+ ::SendMessage( hwndCtrl, CB_SETITEMDATA, (WPARAM)nIndex, (LPARAM) (DWORD)linenum );
+ ++nPLSQLBlockNum;
}
- if( 41 == cFuncInfoArr.GetAt( i )->m_nInfo ){
-//@@@ 2002.01.08 YAZAKI 設定を保存するためにShareDataに移動
- if( m_pShareData->m_bLineNumIsCRLF ){ /* 行番号の表示 FALSE=折り返し単位/TRUE=改行単位 */
- wsprintf( szText, "%d 行 %s パッケージ本体部",
- cFuncInfoArr.GetAt( i )->m_nFuncLineCRLF,
- cFuncInfoArr.GetAt( i )->m_cmemFuncName.GetPtr()
- );
- }else{
- wsprintf( szText, "%d 行 %s パッケージ本体部",
- cFuncInfoArr.GetAt( i )->m_nFuncLineLAYOUT,
- cFuncInfoArr.GetAt( i )->m_cmemFuncName.GetPtr()
- );
+ if( 41 == pFuncInfo->m_nInfo ){
+ // 2006.10.30 genta 行番号計算と重複コードまとめ
+ // 行番号表示方法はアウトライン解析の物を使う
+ int linenum;
+ if( bLineNumCRLF ){ /* 行番号の表示 FALSE=折り返し単位/TRUE=改行単位 */
+ linenum = pFuncInfo->m_nFuncLineCRLF;
}
+ else {
+ // 2006.10.29 genta 物理行番号からその都度変換
+ // 現在の物理行に対応する論理行を取得
+ int layx, layy;
+ pcLayoutMgr->CaretPos_Phys2Log( 0, pFuncInfo->m_nFuncLineCRLF - 1, &layx, &layy );
+ linenum = layy + 1;
+ }
+ wsprintf( szText, "%d 行 %s パッケージ本体部", linenum,
+ cFuncInfoArr.GetAt( i )->m_cmemFuncName.GetPtr() );
nIndexCurSel = nIndex = ::SendMessage( hwndCtrl, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)szText );
-//@@@ 2002.01.08 YAZAKI 設定を保存するためにShareDataに移動
- if( m_pShareData->m_bLineNumIsCRLF ){ /* 行番号の表示 FALSE=折り返し単位/TRUE=改行単位 */
- nWorkLine = cFuncInfoArr.GetAt( i )->m_nFuncLineCRLF;
- ::SendMessage( hwndCtrl, CB_SETITEMDATA, (WPARAM)nIndex, (LPARAM) (DWORD)cFuncInfoArr.GetAt( i )->m_nFuncLineCRLF );
- }else{
- nWorkLine = cFuncInfoArr.GetAt( i )->m_nFuncLineLAYOUT;
- ::SendMessage( hwndCtrl, CB_SETITEMDATA, (WPARAM)nIndex, (LPARAM) (DWORD)cFuncInfoArr.GetAt( i )->m_nFuncLineLAYOUT );
- }
+ ::SendMessage( hwndCtrl, CB_SETITEMDATA, (WPARAM)nIndex, (LPARAM) (DWORD)linenum );
++nPLSQLBlockNum;
}
}
Index: sakura_core/CDocLineMgr.cpp
===================================================================
--- sakura_core/CDocLineMgr.cpp (revision 1011)
+++ sakura_core/CDocLineMgr.cpp (working copy)
@@ -2505,5 +2505,33 @@
}
+//--------------------------------------------------------
+// Iterator for CDocLine
+//--------------------------------------------------------
+/*!
+ increment position ++ite
+*/
+CDocLineMgr::iterator CDocLineMgr::iterator::operator++()
+{
+ if( m_current == NULL ){
+ return *this; // end + 1 = end
+ }
+ m_current = m_current->m_pNext;
+ return *this;
+}
+
+/*!
+ increment position ite++
+*/
+CDocLineMgr::iterator CDocLineMgr::iterator::operator++(int)
+{
+ if( m_current == NULL ){
+ return *this; // end + 1 = end
+ }
+ iterator t( *this );
+ m_current = m_current->m_pNext;
+ return t;
+}
+
/*[EOF]*/
Index: sakura_core/CDocLineMgr.h
===================================================================
--- sakura_core/CDocLineMgr.h (revision 1011)
+++ sakura_core/CDocLineMgr.h (working copy)
@@ -12,6 +12,7 @@
Copyright (C) 2001, hor, genta
Copyright (C) 2002, aroka, MIK, hor
Copyright (C) 2003, Moca, ryoji
+ Copyright (C) 2006, genta
This source code is designed for sakura editor.
Please contact the copyright holder to use this code for other purpose.
@@ -23,6 +24,7 @@
#define _CDOCLINEMGR_H_
#include <windows.h>
+#include <iterator> // 2006.10.28 genta
#include "global.h" // 2002/2/10 aroka
#include "CEol.h" // 2002/2/10 aroka
class CDocLine; // 2002/2/10 aroka
@@ -188,7 +190,7 @@
*/
CDocLine* m_pDocLineTop;
CDocLine* m_pDocLineBot;
- CDocLine* m_pDocLineCurrent; /* 順アクセス時の現在位置 */
+ mutable CDocLine* m_pDocLineCurrent; /* 順アクセス時の現在位置 */
int m_nLines; /* 全行数 */
int m_nPrevReferLine;
CDocLine* m_pCodePrevRefer;
@@ -200,8 +202,47 @@
*/
protected:
+ // Oct. 28, 2006 genta : iterator追加
+public:
+ /*!
+ CDocLineMgrの保持するデータをCDocLineMgr::m_pDocLineCurrentに
+ 影響を与えることなく効率的にスキャンする.
+ 主としてアウトライン解析(全てのデータを読む)での利用を想定.
+ そのためunidirectionalとしてある.(戻ることは出来ない)
+ @note データが編集されると値は無効となる.
+ 無効な値に対する操作結果は保証されない.
+ (不正なアドレスにアクセスする可能性がある)
+
+ @date 2006.10.28 genta 新規作成
+ @author genta
+ */
+ class iterator : public std::iterator<std::forward_iterator_tag, CDocLine>{
+ public:
+ // operator
+ iterator operator++();
+ iterator operator++(int);
+ bool operator==(const iterator& rhs)
+ { return m_current == rhs.m_current && m_pcDocLineMgr == rhs.m_pcDocLineMgr; }
+ bool operator!=(const iterator& rhs) { return ! ( *this == rhs ); }
+
+ // constructor
+ iterator ( CDocLineMgr* m, CDocLine* p ) :
+ m_pcDocLineMgr( m ), m_current( p ){}
+ iterator( const iterator& c )
+ : m_pcDocLineMgr( c.m_pcDocLineMgr ), m_current( c.m_current ){}
+
+ protected:
+ CDocLineMgr* m_pcDocLineMgr;
+ CDocLine* m_current;
+
+ };
+
+ friend iterator;
+ iterator begin() { return iterator( this, GetDocLineTop() ); }
+ iterator end(){ return iterator( this, 0 ); }
+ iterator beginat(int l){ return iterator( this, GetLineInfo( l ) ); }
};
Index: sakura_core/CEditDoc_FuncList1.cpp
===================================================================
--- sakura_core/CEditDoc_FuncList1.cpp (revision 1011)
+++ sakura_core/CEditDoc_FuncList1.cpp (working copy)
@@ -20,9 +20,9 @@
#include <string.h>
#include "global.h"
-#include "CEditDoc.h"
+//#include "CEditDoc.h" // 2006.10.30 genta delete
#include "CFuncInfoArr.h"
-#include "CDocLine.h"
+//#include "CDocLine.h" // 2006.10.30 genta delete
#include "charcode.h"
// Mar. 15, 2000 genta
@@ -246,6 +246,8 @@
return length; // 基本的にプリプロセッサ指令は無視
}
+namespace OutlineAnalyzer {
+
/*!
@brief C/C++関数リスト作成
@@ -274,11 +276,10 @@
@param pcFuncInfoArr [out] 関数一覧を返すためのクラス。
ここに関数のリストを登録する。
*/
-void CEditDoc::MakeFuncList_C( CFuncInfoArr* pcFuncInfoArr ,bool bVisibleMemberFunc )
+void MakeFuncList_C( CFuncInfoArr* pcFuncInfoArr ,bool bVisibleMemberFunc )
{
const char* pLine;
int nLineLen;
- int nLineCount;
int i;
// 2002/10/27 frozen ここから
@@ -365,10 +366,12 @@
// FuncNum = 0;
// bCppInitSkip = false;
-// for( nLineCount = 0; nLineCount < m_cLayoutMgr.GetLineCount(); ++nLineCount ){
- for( nLineCount = 0; nLineCount < m_cDocLineMgr.GetLineCount(); ++nLineCount ){
-// pLine = m_cLayoutMgr.GetLineStr( nLineCount, &nLineLen );
- pLine = m_cDocLineMgr.GetLineStr( nLineCount, &nLineLen );
+ // 2006.10.30 genta iterator利用
+ CDocLineMgr::iterator endmark = pcFuncInfoArr->end_data();
+ for( CFuncInfoArr::CDocIterator it = pcFuncInfoArr->begin_data();
+ it != endmark; ++it ){
+ pLine = it.c_str();
+ nLineLen = it.length();
// From Here Aug. 10, 2004 genta
// プリプロセス処理
@@ -599,7 +602,7 @@
if( nItemFuncId != 0 )
{
nMode2 = M2_NAMESPACE_SAVE;
- nItemLine = nLineCount + 1;
+ nItemLine = it.count();
strcpy(szItemName,"無名");
}
}
@@ -719,21 +722,8 @@
nNestPoint_class = nNestLevel_global;
}
}
- /*
- カーソル位置変換
- 物理位置(行頭からのバイト数、折り返し無し行位置)
- →
- レイアウト位置(行頭からの表示桁位置、折り返しあり行位置)
- */
- int nPosX;
- int nPosY;
- m_cLayoutMgr.CaretPos_Phys2Log(
- 0,
- nItemLine - 1,
- &nPosX,
- &nPosY
- );
- pcFuncInfoArr->AppendData( nItemLine, nPosY + 1 , szNamespace, nItemFuncId);
+ // 2006.10.30 genta iterator利用
+ pcFuncInfoArr->AppendData( nItemLine, szNamespace, nItemFuncId);
// Jan. 30, 2005 genta M2_KR_FUNC 追加
if( nMode2 != M2_FUNC_NAME_END && nMode2 != M2_KR_FUNC )
{
@@ -784,7 +774,7 @@
// 2002/10/27 frozen ここから
// if( nNestLevel == 0 && !bCppInitSkip ){
// strcpy( szFuncName, szWordPrev );
-// nFuncLine = nLineCount + 1;
+// nFuncLine = it.count();
// nNestLevel2 = 1;
// }
// nMode = 0;
@@ -794,7 +784,7 @@
if(nNestLevel_fparam==0)
{
strcpy( szItemName, szWordPrev);
- nItemLine = nLineCount + 1;
+ nItemLine = it.count(); // 2006.10.30 genta iterator利用
}
++ nNestLevel_fparam;
}
@@ -834,22 +824,7 @@
// if( 0 != strcmp( "sizeof", szFuncName ) ){
// nFuncId = 1;
// ++nFuncNum;
-// /*
-// カーソル位置変換
-// 物理位置(行頭からのバイト数、折り返し無し行位置)
-// →
-// レイアウト位置(行頭からの表示桁位置、折り返しあり行位置)
-// */
-// int nPosX;
-// int nPosY;
-// m_cLayoutMgr.CaretPos_Phys2Log(
-// 0,
-// nFuncLine - 1,
-// &nPosX,
-// &nPosY
-// );
-// pcFuncInfoArr->AppendData( nFuncLine, nPosY + 1, szFuncName, nFuncId);
-//// pcFuncInfoArr->AppendData( nFuncLine, szFuncName, nFuncId );
+// pcFuncInfoArr->AppendData( nFuncLine, szFuncName, nFuncId );
// }
// }
// nNestLevel2 = 0;
@@ -878,21 +853,8 @@
strcpy( &szNamespace[nNamespaceLen[ nNestLevel_global]] , szItemName);
nItemFuncId = 1;
- /*
- カーソル位置変換
- 物理位置(行頭からのバイト数、折り返し無し行位置)
- →
- レイアウト位置(行頭からの表示桁位置、折り返しあり行位置)
- */
- int nPosX;
- int nPosY;
- m_cLayoutMgr.CaretPos_Phys2Log(
- 0,
- nItemLine - 1,
- &nPosX,
- &nPosY
- );
- pcFuncInfoArr->AppendData( nItemLine, nPosY + 1, szNamespace, nItemFuncId);
+ // 2006.10.30 genta iterator利用
+ pcFuncInfoArr->AppendData( nItemLine, szNamespace, nItemFuncId);
}
nMode2 = M2_NORMAL;
// 2002/10/27 frozen ここまで
@@ -1040,3 +1002,5 @@
}
return;
}
+
+} // namespace OutlineAnalyzer
Index: sakura_core/CEditView_Command.cpp
===================================================================
--- sakura_core/CEditView_Command.cpp (revision 1011)
+++ sakura_core/CEditView_Command.cpp (working copy)
@@ -4697,9 +4697,10 @@
return;
}
+namespace OutlineAnalyzer {
+ void MakeFuncList_C( CFuncInfoArr*, bool = true );
+};
-
-
/*! アウトライン解析
2002/3/13 YAZAKI nOutlineTypeとnListTypeを統合。
@@ -4711,7 +4712,8 @@
// return TRUE;
// }
- static CFuncInfoArr cFuncInfoArr;
+ // Oct. 28, 2006 genta
+ static CFuncInfoArr cFuncInfoArr( m_pcEditDoc );
// int nLine;
// int nListType;
@@ -4758,7 +4760,8 @@
switch( nOutlineType ){
// case OUTLINE_C: m_pcEditDoc->MakeFuncList_C( &cFuncInfoArr );break;
case OUTLINE_CPP:
- m_pcEditDoc->MakeFuncList_C( &cFuncInfoArr );
+ //m_pcEditDoc->MakeFuncList_C( &cFuncInfoArr );
+ OutlineAnalyzer::MakeFuncList_C( &cFuncInfoArr );
/* C言語標準保護委員会勧告特別処理実装箇所(嘘) */
if( CheckEXT( m_pcEditDoc->GetFilePath(), "c" ) ){
nOutlineType = OUTLINE_C; /* これでC関数一覧リストビューになる */
Index: sakura_core/CFuncInfo.cpp
===================================================================
--- sakura_core/CFuncInfo.cpp (revision 1011)
+++ sakura_core/CFuncInfo.cpp (working copy)
@@ -17,14 +17,15 @@
/*! CFuncInfoクラス構築 */
CFuncInfo::CFuncInfo(
int nFuncLineCRLF, /*!< 関数のある行(CRLF単位) */
- int nFuncLineLAYOUT,/*!< 関数のある行(折り返し単位) */
+// int nFuncLineLAYOUT,/*!< 関数のある行(折り返し単位) */
// int nFuncLine, /*!< 関数のある行 */
const char* pszFuncName, /*!< 関数名 */
int nInfo /*!< 付加情報 */
) : m_nDepth(0) /*!< 深さ */
{
m_nFuncLineCRLF = nFuncLineCRLF; /* 関数のある行(CRLF単位) */
- m_nFuncLineLAYOUT = nFuncLineLAYOUT; /* 関数のある行(折り返し単位) */
+ // 2006.10.30 genta m_nFuncLineLAYOUT廃止
+// m_nFuncLineLAYOUT = nFuncLineLAYOUT; /* 関数のある行(折り返し単位) */
// m_nFuncLine = nFuncLine;;
// m_cmemFuncName = pszFuncName;
// m_cmemFuncName.SetData( pszFuncName, lstrlen( pszFuncName ) );
Index: sakura_core/CFuncInfo.h
===================================================================
--- sakura_core/CFuncInfo.h (revision 1011)
+++ sakura_core/CFuncInfo.h (working copy)
@@ -29,7 +29,8 @@
//@date 2002.04.01 YAZAKI 深さ導入
class CFuncInfo {
public:
- CFuncInfo( int, int, const char*, int ); /* CFuncInfoクラス構築 */
+ // 2006.10.30 genta レイアウト行を削除
+ CFuncInfo( int, const char*, int ); /* CFuncInfoクラス構築 */
~CFuncInfo(); /* CFuncInfoクラス消滅 */
//! クリップボードに追加する要素か?
@@ -40,7 +41,7 @@
// private:
int m_nFuncLineCRLF; /*!< 関数のある行(CRLF単位) */
- int m_nFuncLineLAYOUT; /*!< 関数のある行(折り返し単位) */
+ // 2006.10.30 genta m_nFuncLineLAYOUT 廃止
CMemory m_cmemFuncName; /*!< 関数名 */
int m_nInfo; /*!< 付加情報 */
int m_nDepth; /*!< 深さ */
Index: sakura_core/CFuncInfoArr.cpp
===================================================================
--- sakura_core/CFuncInfoArr.cpp (revision 1011)
+++ sakura_core/CFuncInfoArr.cpp (working copy)
@@ -16,20 +16,20 @@
#include <stdlib.h>
#include <malloc.h>
#include "CFuncInfoArr.h"
+#include "CEditDoc.h" // 2006.10.28 genta
+#include "CDocLine.h" // 2006.10.28 genta
#include "debug.h"// 2002/2/10 aroka
-/* CFuncInfoArrクラス構築 */
-CFuncInfoArr::CFuncInfoArr()
+/*! CFuncInfoArrクラス構築
+
+ @date 2006.10.18 genta 引数追加 CEditDoc
+*/
+CFuncInfoArr::CFuncInfoArr(CEditDoc* doc)
+ : m_pcEditDoc( doc ), m_nFuncInfoArrNum( 0 ), m_ppcFuncInfoArr( NULL )
{
- m_nFuncInfoArrNum = 0; /* 配列要素数 */
- m_ppcFuncInfoArr = NULL; /* 配列 */
- return;
}
-
-
-
/* CFuncInfoArrクラス消滅 */
CFuncInfoArr::~CFuncInfoArr()
{
@@ -92,13 +92,37 @@
int nDepth /* 深さ */
)
{
- CFuncInfo* pcFuncInfo = new CFuncInfo( nFuncLineCRLF, nFuncLineLAYOUT, pszFuncName, nInfo );
+ CFuncInfo* pcFuncInfo = new CFuncInfo( nFuncLineCRLF, pszFuncName, nInfo );
pcFuncInfo->m_nDepth = nDepth;
AppendData( pcFuncInfo );
return;
}
+void CFuncInfoArr::AppendData(
+ int nFuncLineCRLF, /* 関数のある行(CRLF単位) */
+ const char* pszFuncName, /* 関数名 */
+ int nInfo, /* 付加情報 */
+ int nDepth /* 深さ */
+)
+{
+ CFuncInfo* pcFuncInfo = new CFuncInfo( nFuncLineCRLF, pszFuncName, nInfo );
+ pcFuncInfo->m_nDepth = nDepth;
+ AppendData( pcFuncInfo );
+ return;
+}
+void CFuncInfoArr::AppendData(
+ CFuncInfoArr::CDocIterator& itr_line,
+ const char* pszFuncName, /* 関数名 */
+ int nInfo, /* 付加情報 */
+ int nDepth /* 深さ */
+)
+{
+ CFuncInfo* pcFuncInfo = new CFuncInfo( itr_line.count(), pszFuncName, nInfo );
+ pcFuncInfo->m_nDepth = nDepth;
+ AppendData( pcFuncInfo );
+}
+
void CFuncInfoArr::DUMP( void )
{
#ifdef _DEBUG
@@ -107,7 +131,8 @@
for( i = 0; i < m_nFuncInfoArrNum; i++ ){
MYTRACE( "[%d]------------------\n", i );
MYTRACE( "m_nFuncLineCRLF =%d\n", m_ppcFuncInfoArr[i]->m_nFuncLineCRLF );
- MYTRACE( "m_nFuncLineLAYOUT =%d\n", m_ppcFuncInfoArr[i]->m_nFuncLineLAYOUT );
+ // 2006.10.28 genta m_nFuncLineLAYOUTは使わない方向で
+ //MYTRACE( "m_nFuncLineLAYOUT =%d\n", m_ppcFuncInfoArr[i]->m_nFuncLineLAYOUT );
MYTRACE( "m_cmemFuncName =[%s]\n", m_ppcFuncInfoArr[i]->m_cmemFuncName.GetPtr() );
MYTRACE( "m_nInfo =%d\n", m_ppcFuncInfoArr[i]->m_nInfo );
}
@@ -115,5 +140,29 @@
#endif
}
+//----------------------------------------------------------
+// Document Iterator class methods
+//----------------------------------------------------------
+/*!
+ Get an iterator that points the head of document data
+*/
+CFuncInfoArr::CDocIterator CFuncInfoArr::begin_data()
+{
+ return CFuncInfoArr::CDocIterator( m_pcEditDoc->m_cDocLineMgr.begin(), 1 );
+}
+
+CDocLineMgr::iterator CFuncInfoArr::end_data()
+{
+ return m_pcEditDoc->m_cDocLineMgr.end();
+}
+
+const char* CFuncInfoArr::CDocIterator::c_str()
+{
+ return m_current->m_pLine->GetPtr();
+}
+int CFuncInfoArr::CDocIterator::length()
+{
+ return m_current->m_pLine->GetLength();
+}
/*[EOF]*/
Index: sakura_core/CFuncInfoArr.h
===================================================================
--- sakura_core/CFuncInfoArr.h (revision 1011)
+++ sakura_core/CFuncInfoArr.h (working copy)
@@ -18,11 +18,14 @@
#define _CFUNCINFOARR_H_
#include "CFuncInfo.h"
+#include "CDocLineMgr.h"
+class CEditDoc;
+
//! アウトライン解析 データ配列
class CFuncInfoArr {
public:
- CFuncInfoArr(); /* CFuncInfoArrクラス構築 */
+ CFuncInfoArr(CEditDoc*); /* CFuncInfoArrクラス構築 */
~CFuncInfoArr(); /* CFuncInfoArrクラス消滅 */
CFuncInfo* GetAt( int ); /* 0<=の指定番号のデータを返す */
void AppendData( CFuncInfo* ); /* 配列の最後にデータを追加する */
@@ -37,6 +40,48 @@
private:
int m_nFuncInfoArrNum; /*!< 配列要素数 */
CFuncInfo** m_ppcFuncInfoArr; /*!< 配列 */
+
+ CEditDoc* m_pcEditDoc; //!< Oct. 28, 2006 genta
+
+ public:
+ /*!
+ アウトライン解析に特化したデータ読み出しiterator
+
+ operator++で行番号のカウントも行う.
+
+ @date 2006.10.28 genta 新規作成
+ @author genta
+ */
+ class CDocIterator : public CDocLineMgr::iterator {
+ public:
+ typedef CDocLineMgr::iterator super;
+
+ /*!
+ 次の行への移動と行番号のカウントアップ
+
+ @note iteratorが最後の要素の末尾 end_data() を指しているときに
+ ++を行ってはいけない.行うと行番号だけがカウントアップされてしまう.
+ */
+ CDocIterator operator++() { super::operator++(); ++m_linenum; return *this; } ;
+ CDocIterator operator++(int) { CDocIterator t(*this); this->operator++(); return t; }
+
+ // constructor
+ CDocIterator( const CDocLineMgr::iterator& it, int num )
+ : CDocLineMgr::iterator( it ), m_linenum( num ){}
+
+ int count() const { return m_linenum; }
+ void reset_flag();
+ const char* c_str();
+ int length();
+ private:
+ int m_linenum; //!< 現在の行番号(1〜)
+ };
+
+ CDocIterator begin_data();
+ CDocLineMgr::iterator end_data();
+ void AppendData( CDocIterator&, const char*, int, int nDepth = 0 );
+ // layout行を外したバージョン
+ void AppendData( int, const char*, int, int nDepth = 0 );
};
|