forked from n5ac/mmsstv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMmcg.cpp
More file actions
1521 lines (1421 loc) · 34.7 KB
/
Mmcg.cpp
File metadata and controls
1521 lines (1421 loc) · 34.7 KB
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
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Copyright+LGPL
//-----------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2000-2013 Makoto Mori, Nobuyuki Oba
//-----------------------------------------------------------------------------------------------------------------------------------------------
// This file is part of MMSSTV.
// MMSSTV is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// MMSSTV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License along with MMTTY. If not, see
// <http://www.gnu.org/licenses/>.
//-----------------------------------------------------------------------------------------------------------------------------------------------
/************************************************************************
MMCG
Copyright (C) JE3HHT 1993.
Modifed on 2000 for MMTTY by JE3HHT
************************************************************************/
#include <vcl.h> //ja7ude 0521
#pragma hdrstop
#include "ComLib.h"
#include "Mmcg.h"
#include "string.h"
#include "stdlib.h"
#include "Country.h"
CMMCG mmcg;
static LPCSTR ptbl[]={
"",
"北海道", "青森県","岩手県","秋田県","山形県","宮城県","福島県","新潟県",
"長野県", "東京都","神奈川県","千葉県","埼玉県","茨城県","栃木県","群馬県",
"山梨県","静岡県","岐阜県","愛知県","三重県","京都府","滋賀県","奈良県",
"大阪府","和歌山県","兵庫県","富山県","福井県","石川県","岡山県","島根県",
"山口県","鳥取県","広島県","香川県","徳島県","愛媛県","高知県","福岡県",
"佐賀県","長崎県","熊本県","大分県","宮崎県","鹿児島県","沖縄県"
};
static LPCSTR ptbleng[]={
"",
"Hokkaido", "Aomori","Iwate","Akita","Yamagata","Miyazaki","Fukushima","Nigata",
"Nagano", "Tokyo","Kanagawa","Chiba","Saitama","Ibaragi","Tochigi","Gunma",
"Yamanashi","Shizuoka","Gifu","Aichi","Mie","Kyoto","Shiga","Nara",
"Osaka","Wakayama","Hyogo","Toyama","Fukui","Ishikawa","Okayama","Shimane",
"Yamaguchi","Tottri","Hiroshima","Kagawa","Tokushima","Ehime","Kochi","Fukuoka",
"Saga","Nagasaki","Kumamoto","Oita","Miyazaki","Kagoshima","Okinawa"
};
CMMCG::CMMCG()
{
m_bp = NULL;
m_Max = 0;
m_Cnt = 0;
m_sinc = 0;
m_mask = -1;
}
CMMCG::~CMMCG()
{
Free();
}
void CMMCG::Free(void)
{
if( m_bp != NULL ){
int i;
MMCG *mp;
for( mp = m_bp, i = 0; i < m_Cnt; i++, mp++ ){
if( mp->Code != NULL ) delete mp->Code;
if( mp->QTH != NULL ) delete mp->QTH;
if( mp->Key != NULL ) delete mp->Key;
}
m_bp = NULL;
}
if( m_fp != NULL ){
delete m_fp;
m_fp = NULL;
}
m_Max = m_Cnt = m_FindCnt = 0;
}
void CMMCG::Alloc(int n)
{
if( n >= m_Max ){
int max = m_Max ? m_Max * 2 : 256;
MMCG *np = (MMCG *)new BYTE[sizeof(MMCG) * max];
if( m_bp != NULL ){
memcpy(np, m_bp, sizeof(MMCG) * m_Cnt);
delete m_bp;
}
m_bp = np;
m_Max = max;
}
}
/*#$%
======================================================
ローマ綴りを調整する
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
LPSTR CMMCG::adjspl(LPSTR p)
{
static char bf[50];
LPCSTR tp[]={
"TSU","TU",
"CHA","CYA",
"CHI","CI",
"CHU","CYU",
"CHO","CYO",
"JYA","JA",
"JYU","JU",
"JYO","JO",
"SHA","SYA",
"SHI","SI",
"SHU","SYU",
"SHE","SYE",
"SHO","SYO",
};
int i, f;
char *t;
for( t = bf; *p;){
for( f = 0, i = 0; i < AN(tp); i+=2 ){
if( !strncmp(p, tp[i], strlen(tp[i])) ){
strcpy(t, tp[i+1]);
t += strlen(t);
p += strlen(tp[i]);
f++;
break;
}
}
if( !f ){
*t++ = *p++;
}
}
*t = 0;
return(bf);
}
/*#$%
======================================================
最後のローマ綴りで検索起動を断念する
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
int CMMCG::chkspl(LPCSTR p)
{
static char *tp[]={
"TS","CH","JY","SH",
};
int i;
i = strlen(p);
if( i >= 2 ){
p += (i-2);
for( i = 0; i < AN(tp); i++ ){
if( !strcmp(tp[i], p) ) return 0;
}
}
return 1;
}
/*#$%
======================================================
文字列の最後の一致を調べる
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
int CMMCG::LastMatch(LPSTR t, LPSTR s)
{
t = lastp(t) - strlen(s) + 1;
return !strcmp(t, s);
}
/*#$%
======================================================
入力されたQTHを正規化する
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
int CMMCG::NormQth(LPSTR p)
{
int i;
LPCSTR *cp;
for( i = 1, cp = &ptbl[1]; i < AN(ptbl); i++, cp++ ){
if( !strncmp(p, *cp, strlen(*cp)) ){
if( *(p + strlen(*cp)) ){
strcpy(p, p + strlen(*cp));
return 1;
}
}
}
return 0;
}
/*#$%
======================================================
エリアマスクを設定する
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void CMMCG::SetMask(void)
{
LPCSTR p;
m_mask = -1;
if( m_Call[0] ){ /* エリアマスク */
p = m_Call;
if( (m_Call[0] == '7') && (m_Call[1] != 'J') ){
m_mask = 1;
p += 3;
}
for( ; *p; p++ ){
if( isdigit(*(LPUSTR)p) ) m_mask = ((*p) & 0x0f);
}
}
}
/*#$%
======================================================
コードから検索対象にするかどうか調べる
------------------------------------------------------
p : コードのポインタ
------------------------------------------------------
------------------------------------------------------
======================================================
*/
int CMMCG::isfind(LPCSTR p)
{
const char _tt[]={
-1,
8, /* 01 */
7, 7, 7, 7, 7, 7, /* 02-07 */
0, 0, /* 08-09 */
1, 1, 1, 1, 1, 1, 1, 1, /* 10-17 */
2, 2, 2, 2, /* 18-21 */
3, 3, 3, 3, 3, 3, /* 22-27 */
9, 9, 9, /* 28-30 */
4, 4, 4, 4, 4, /* 31-35 */
5, 5, 5, 5, /* 36-39 */
6, 6, 6, 6, 6, 6, 6, 6, /* 40-47 */
};
if( m_mask == -1 ){
return 1;
}
else {
return( (_tt[atoin(p, 2)] == m_mask) ? 1 : 0 );
}
}
/*#$%
======================================================
指定位置の文字の種類を得る
------------------------------------------------------
p : バッファのポインタ
x : 位置
------------------------------------------------------
------------------------------------------------------
======================================================
*/
int CMMCG::_ischrtyp(char *p, int x)
{
int xx, jis;
for( jis = xx = 0; xx < x; xx++, p++ ){
if( jis ){
jis = 0;
}
else if( _mbsbtype((unsigned char *)p, 0) == _MBC_LEAD ){
jis = 1;
}
}
if( jis ){ /* KANJI2 */
return 2;
}
else if( _mbsbtype((unsigned char *)p, 0) == _MBC_LEAD ){ /* KANJI1 */
return 1;
}
else { /* ANK */
return 0;
}
}
/*#$%
======================================================
データファイルを読み込む
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void CMMCG::LoadDef(LPCSTR pFileName)
{
FILE *fp;
char hbf[512];
LPSTR t, p;
Free();
if( (fp = fopen(pFileName, "rt"))!=NULL ){
while( !feof(fp) ){
if( fgets(hbf, 512, fp)!=NULL ){
if( hbf[0] == '$' ) break;
ClipLF(hbf);
if( hbf[0] != '!' ){
p = StrDlm(t, hbf, TAB);
clipsp(t);
Alloc(m_Cnt);
m_bp[m_Cnt].Code = StrDupe(t);
if( p != NULL ){
p = StrDlm(t, p, TAB);
if( *t == '%' ) *t = 0;
clipsp(t);
m_bp[m_Cnt].QTH = StrDupe(SkipSpace(t));
}
else {
m_bp[m_Cnt].QTH = StrDupe("");
}
if( p != NULL ){
clipsp(p);
m_bp[m_Cnt].Key = StrDupe(SkipSpace(p));
}
else {
m_bp[m_Cnt].Key = StrDupe("");
}
m_Cnt++;
}
}
}
fclose(fp);
m_fp = (MMCG **)new BYTE[sizeof(MMCG*)*m_Cnt];
}
else {
WarningMB(MsgEng ? "'%s' was not found.\r\n\r\nYou cannot use a JCC/JCG list function.\r\nThis is not a problem if you do not need it":"'%s'が見つかりません.", pFileName);
}
}
/*#$%
======================================================
コードから県名を得る
------------------------------------------------------
code : コードのポインタ
------------------------------------------------------
県名のポインタ
------------------------------------------------------
======================================================
*/
LPCSTR CMMCG::getprf(LPCSTR pCode)
{
int n;
n = atoin(pCode, 2);
return(MsgEng ? ptbleng[n] : ptbl[n]);
}
/*#$%
======================================================
郡名を得る
------------------------------------------------------
p : 町村コードのポインタ
------------------------------------------------------
QTHのポインタ
------------------------------------------------------
======================================================
*/
void CMMCG::GetGun(LPSTR t, LPCSTR pCode)
{
strcpy(wbf, pCode);
wbf[5] = 0;
MMCG *mp = m_bp;
int i;
for( i = 0; i < m_Cnt; i++, mp++ ){
if( !strcmp(mp->Code, wbf) ){
strcpy(t, mp->QTH);
return;
}
}
*t = 0;
}
/*#$%
======================================================
QTHの文字列を得る
------------------------------------------------------
cp : データのポインタ
------------------------------------------------------
QTHのポインタ
------------------------------------------------------
======================================================
*/
LPCSTR CMMCG::GetQTH(MMCG *mp)
{
char bf[512];
if( MsgEng ){
char qth[128];
strcpy(qth, mp->Key);
LPSTR t;
LPSTR p = qth;
while(*p){
p = StrDlm(t, p, ',');
}
if( strlen(mp->Code) == 6 ){
if( isalpha((unsigned char)LastC(mp->Code)) ){ /* 町村コード */
strcpy(bf, t);
strcat(bf, ",");
GetGun(qth, mp->Code);
strcat(bf, qth);
}
else { /* 政令指定都市 */
strcpy(bf, t);
}
}
else { /* 都道府県を追加 */
if( *t ){
sprintf( bf, "%s,%s", t, getprf(mp->Code));
}
else {
sprintf( bf, "%s", getprf(mp->Code));
}
}
}
else {
if( strlen(mp->Code) == 6 ){
if( isalpha((unsigned char)LastC(mp->Code)) ){ /* 町村コード */
GetGun(bf, mp->Code);
strcat(bf, mp->QTH);
}
else { /* 政令指定都市 */
strcpy(bf, mp->QTH);
}
}
else { /* 都道府県を追加 */
sprintf( bf, "%s%s", getprf(mp->Code), mp->QTH);
}
}
bf[MLQTH] = 0;
m_QTH = bf;
return m_QTH.c_str();
}
/*#$%
======================================================
データの検索を行う(すべて)
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void CMMCG::FindAll(void)
{
MMCG *mp;
int i;
m_FindCnt = 0;
mp = m_bp;
for( i = 0; i < m_Cnt; i++, mp++ ){
if( isfind(mp->Code) ){
m_fp[m_FindCnt] = mp;
m_FindCnt++;
}
}
}
/*#$%
======================================================
同一データが存在するか調べる
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
int CMMCG::isEnt(MMCG *mp)
{
int i;
for( i = 0; i < m_FindCnt; i++ ){
if( m_fp[i] == mp ) return 1;
}
return 0;
}
/*#$%
======================================================
データの検索を行う
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void CMMCG::FindQTH(LPSTR pKey)
{
MMCG *mp;
int i;
int len, kj;
LPSTR t, p;
kj = _mbsbtype((unsigned char *)pKey, 0) == _MBC_LEAD ? 1 : 0;
if( kj ) NormQth(pKey);
len = strlen(pKey);
m_FindCnt = 0;
mp = m_bp;
char bf[256];
for( i = 0; i < m_Cnt; i++, mp++ ){
if( isfind(mp->Code) ){
if( kj ){
if( strstr(mp->QTH, pKey) != NULL ){
m_fp[m_FindCnt] = mp;
m_FindCnt++;
goto _nx;
}
}
strcpy(bf, mp->Key);
for( p = bf; *p; ){
p = StrDlm(t, p, ',');
if( (!strncmp(t, pKey, len)) || (m_sinc && (strstr(t, pKey)!=NULL)) ){
m_fp[m_FindCnt] = mp;
m_FindCnt++;
break;
}
}
_nx:;
}
}
}
/*#$%
======================================================
データの検索を行う
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void CMMCG::FindNumb(LPSTR pKey)
{
MMCG *mp;
int i;
int len;
m_FindCnt = 0;
len = strlen(pKey);
mp = m_bp;
for( i = 0; i < m_Cnt; i++, mp++ ){
if( (!strncmp(mp->Code, pKey, len)) || (m_sinc && (strstr(mp->Code, pKey)!=NULL)) ){
m_fp[m_FindCnt] = mp;
m_FindCnt++;
}
}
}
/*#$%
======================================================
データの検索を行う
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void CMMCG::Find(LPSTR p)
{
if( *p ){
if( isdigit(*(LPUSTR)p) ){
FindNumb(p);
}
else {
jstrupr(p);
if( chkspl(p) ) FindQTH(adjspl(p));
}
}
else {
FindAll();
}
}
#if 0
/*#$%
======================================================
定義領域を確保する
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
int allocdef(int blk)
{
if( cseg == 0 ){
if( (cseg=__malloc(blk))!=0 ){ /* メモリの確保 */
return(NOERR);
}
return(ERR);
}
return(NOERR);
}
/*#$%
======================================================
定義領域を開放する
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void freedef(void)
{
if( cseg ){
__free(cseg);
cseg = 0;
}
}
#define XW 60
#define YW 16
/*#$%
======================================================
検索データのメニュー表示をオープンする
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
VEWP *opencc(void)
{
cc.xw = XW-1;
cc.yw = YW-1;
cc.x = (crt.hmax-cc.xw+2)/2;
cc.y = (crt.vmax-cc.yw+2)/2;
cc.yt = cc.y;
cc.ye = cc.y + cc.yw;
cc.tb = cc.cy = 0;
cc.xe = cc.x + cc.xw - 1;
if( (cc.vp=openvew(cc.x, cc.y, cc.x+cc.xw, cc.ye, _menuwcol))!=NULL ){
_dprintf( cc.x, cc.yt, " 検索>" );
cc.x++;
cc.y++;
/* _dprintf( cc.x, cc.ye, "<ESC>中止, <CR>決定, <↓><↑>選択, <SPC>クリア, <HOME>エリア/ALL" );*/
_dprintf( cc.x, cc.ye, "<ESC>中止,<CR>決定,<SPC>クリア,<F1>検索方法,<F2><HOME>エリア/ALL" );
}
return(cc.vp);
}
/*#$%
======================================================
検索データのメニュー表示をクローズする
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void closecc(void)
{
if( cc.vp ){
closevew(cc.vp);
cc.vp = NULL;
}
}
/*#$%
======================================================
1行の表示を行う
------------------------------------------------------
y : 表示位置
tp: テーブル番号
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near dspone(int y, int tp)
{
CD cd;
int l;
uchar bf[60];
/*0123456789012345678901234567890123456789012345678901234567*/
/*250119__ 大阪府__ 大阪市阿倍野区______ ABENO______________*/
/*12345678 12345678 12345678901234567890 1234567890123456789*/
_fills(cc.x, y, cc.xe, y);
if( tp < cc.fn ){
getdat(cc.ctbl[tp], &cd);
l = strlen(cd.code);
_dprintf(cc.x, y, "%-.8s", cd.code );
_dprintf(cc.x+9, y, "%-.8s", getprf(cd.code));
if( l == 6 ){
if( isalpha(lastc(cd.code)) ){ /* 町村 */
GetGun(bf, cd.code);
}
else { /* 制令 */
bf[0] = 0;
}
strcat(bf, cd.qth);
_dprintf(cc.x+18, y, "%-.20s", bf );
}
else {
_dprintf(cc.x+18, y, "%-.20s", cd.qth );
}
_dprintf(cc.x+39, y, "%-.19s", cd.key );
}
}
/*#$%
======================================================
検索データの表示をする
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near dspcc(void)
{
int y, cp;
CD cd;
for( cp = cc.tb, y = cc.y; y < cc.ye; y++, cp++ ){
dspone(y, cp);
}
}
/*#$%
======================================================
カーソルの表示
------------------------------------------------------
sw : 0-OFF, 1-ON
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near ecursor(int sw)
{
int at;
at = sw ? _menuccol : CRT_ATTR_NORMAL;
_afill(cc.x, cc.y + cc.cy, cc.xe, cc.y + cc.cy, at );
}
/*#$%
======================================================
カーソルのアップ
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near cup(void)
{
if( cc.cy ){
cc.cy--;
}
else if( cc.tb ){
cc.tb--;
_scrdwn(cc.x, cc.y, cc.xe, cc.ye-1);
dspone(cc.y, cc.tb);
}
}
/*#$%
======================================================
カーソルのダウン
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near cdown(void)
{
if( (cc.tb + cc.cy) < (cc.fn - 1) ){
if( cc.cy < (cc.yw - 2) ){
cc.cy++;
}
else {
cc.tb++;
_scrup(cc.x, cc.y, cc.xe, cc.ye-1);
dspone(cc.ye-1, cc.tb+cc.cy);
}
}
}
/*#$%
======================================================
指定位置へのSEEK
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near cdseek(int tp)
{
if( tp >= cc.fn ) tp = cc.fn - 1;
if( tp < 0 ) tp = 0;
cc.tb = tp;
cc.cy = 0;
dspcc();
}
/*#$%
======================================================
ページアップ
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near pup(void)
{
CD cd;
int tp, m;
tp = cc.tb + cc.cy;
getdat(cc.ctbl[tp], &cd);
m = atoin(cd.code, 2);
for( tp--; tp >= 0; tp-- ){
getdat(cc.ctbl[tp], &cd);
if( m != atoin(cd.code, 2) ){
cdseek(tp);
return;
}
}
cdseek(0);
}
/*#$%
======================================================
ページダウン
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near pdown(void)
{
CD cd;
int tp, m;
tp = cc.tb + cc.cy;
getdat(cc.ctbl[tp], &cd);
m = atoin(cd.code, 2);
for( tp++; tp < cc.fn; tp++ ){
getdat(cc.ctbl[tp], &cd);
if( m != atoin(cd.code, 2) ){
cdseek(tp);
return;
}
}
cdseek(32767);
}
/*#$%
======================================================
バッファ内容の表示
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
static void near dspbf(void)
{
_dprintf(cc.x+5, cc.yt, "%-40s", kbf );
_dprintf(cc.xe - 15, cc.yt, sinc ? "含み":"先頭");
_dprintf(cc.xe - 10, cc.yt, (m_mask != -1) ? "%uエリア" : "ALL ", m_mask );
_dprintf(cc.xe-4, cc.yt, "%4u", cc.fn );
}
/*#$%
======================================================
MMCGの処理を行う
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void mmcg(void)
{
int c;
int xx;
loaddat();
if( nosel == 1 ){
strcpy(kbf, _dspopt(optnmb, &cc.sd));
findnosel(jstrupr(kbf));
setdat();
return;
}
if( opencc() == NULL ) return;
find1st();
if( nosel == 2 ){
if( cc.fn == 1 ) setdat();
closecc();
return;
}
dspcc();
xx = strlen(kbf);
_cursor(ON);
while(1){
dspbf();
_locate(cc.x+5 + xx, cc.yt);
ecursor(ON);
c = _bgetch();
ecursor(OFF);
switch(c){
case K_RU:
pdown();
break;
case K_RD:
pup();
break;
case K_UP:
cup();
break;
case K_DOWN:
cdown();
break;
case ESC:
goto _ex;
case K_CR:
setdat();
goto _ex;
case K_BS:
if( xx ){
xx--;
if( xx && (_ischrtyp(kbf, xx)==2) ) xx--;
kbf[xx] = 0;
find(kbf);
dspcc();
}
break;
case ' ':
kbf[0] = 0;
xx = 0;
findall();
dspcc();
break;
case K_F1:
sinc = sinc ? 0 : 1;
find(kbf);
dspcc();
break;
case K_F2:
case K_HOME:
if( mask == -1 ){
setmask();
}
else {
mask = -1;
}
find(kbf);
dspcc();
break;
default:
if( (c > 0x0020) && (c <= 0x00ff) ){
if( xx < 40 ){
kbf[xx] = c;
xx++;
kbf[xx] = 0;
if( _ischrtyp(kbf, xx-1) != 1 ){
finds(kbf);
}
dspcc();
}
}
break;
}
}
_ex:;
closecc();
}
/*#$%
======================================================
データの検索を行う(すべて)
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
======================================================
*/
void findall(void)