-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.1.4-ash.sh
executable file
·4667 lines (3980 loc) · 112 KB
/
2.1.4-ash.sh
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
abc="$(stty -g)"
p=1;n1=0;l=0;n=1;output25=0;outputed=0;use=${use:-2};wlist=1;a0=1;lastn=0;tno=0;ca0=0;bigi=0;RC=1;record=0;RWN1=1;gcounts=0;alrw=;allrw=
Path="$(dirname $0)"
tline=$(printf "\033[32m●\033[0m")
fline=$(printf "\033[31m●\033[0m")
nline=$(printf "\033[33m○\033[0m")
eline=$(printf "\033[32m○\033[0m")
save=$(printf "\033[s\n")
reset=$(printf "\033[u\n")
enter=$(printf "\r")
newline="$(printf "\n")"
v=$(printf "\v")
t=$(printf "\t")
Block=" "
Back="$(printf "\b")"
Backs="$Back$Back"
IFSbak=$IFS
needo=;now2=0;new3=0;passd=-1;getin=3;vback=0;whereb=-1;wherec=-2;vback=0;premode=1;calenda=-1;pos1=-1;pos2=-2
ccat(){
printf "%d" "'$1"
}
read -n1 AScii <<EOF
`printf "\033[0m"`
EOF
read -n1 B <<EOF
`printf "\177"`
EOF
read -n1 ENTER <<EOF
`printf "\15"`
EOF
read -n1 CR <<EOF
`printf "\15"`
EOF
read -n1 LF <<EOF
`printf "\12"`
EOF
read -n1 D <<EOF
`printf "\004"`
EOF
read -n1 x02 <<EOF
`printf "\x02"`
EOF
read -n1 x19 <<EOF
`printf "\x19"`
EOF
xzh=`printf "\xe3\x80\x79"`
xzhmax=`printf "%d" "'Z"`
struct(){
allif=
for ti in `seq $((tno))` ;do
iii=$ti
ii=$((ti-1))
eval thei=\${ca$ii}
eval lasti=\${ca$ti}
thei=$(($thei+1))
atop=""
aif="if [[ \"\$m\" -ge \"$thei\" ]] && [[ \"\$m\" -le \"$lasti\" ]] ;then
echo \"$iii\"
fi
"
allif="$allif
$aif"
done
allif="$atop
$allif"
}
calendar()
{
calenda=1
#stty echo
# clear
cd $Path
if [[ ${txtp:-0} -eq 1 ]];then
cd "$txtname"
else
cd ./txt
fi
[[ "$?" -ne 0 ]] && echo 未在脚本所在目录找到txt文件夹 && calenda=0 && return 1
txtp=2
pathls="$(ls -F | grep '/$' )"
pathlsl="$(echo "$pathls" | wc -l)"
printf "\33[?25l"
printf "按空格选择txt文件夹\n"
inn=0;
inlineall=0;
while read inline ;do
inline=" ${inline}"
inn=$((inn+1))
#theam="$inline"
la=$((${#inline}*2-2))
for i in $(seq $((${la}+2+${#inline})));do
if [[ "${inline:i:1}" == [\ -\~] ]] ;then
la=$((la-1))
fi
done
eval inline$inn=$((la/$((COLUMN+1))+1))
#eval printf \$inline$inn
eval inlineall=\$inline$inn+\$inlineall
echo "$inline"
done << EOF
$pathls
EOF
eval inlineallB=$inlineall-\$inline$inn
printf "\033[0m$enter"
order=1
printf "\033[$((inlineall))A\033[35m ››\033[0m\r"
while true ;do
printf "$enter"
IFS=$newline
read -s -n1 ascanf
tf=$?
IFS=$IFSbak
sleep 0.01
if [[ "$ascanf" == ' ' ]];then
[[ "$order" -eq $((pathlsl)) ]] && [[ $((pathlsl)) -eq 1 ]] && continue
printf " $enter"
[[ "$order" -eq $((pathlsl)) ]] && printf "\033[$((inlineallB))A$enter" && printf "\033[35m ››\033[0m$enter"
[[ "$order" -eq $((pathlsl)) ]] && order=1 && continue
eval thenext=\$inline$order
order=$((order+1))
printf "\033[$((thenext))B\033[35m ››\033[0m$enter"
elif [[ "$ascanf" == "$_1B5B" ]] ;then
read -n1 && read -n1 WSAD
if [[ "$WSAD" == "B" ]] ;then
[[ "$order" -eq $((pathlsl)) ]] && [[ $((pathlsl)) -eq 1 ]] && continue
printf " $enter"
[[ "$order" -eq $((pathlsl)) ]] && printf "\033[$((inlineallB))A$enter" && printf "\033[35m ››\033[0m$enter"
[[ "$order" -eq $((pathlsl)) ]] && order=1 && continue
eval thenext=\$inline$order
order=$((order+1))
printf "\033[$((thenext))B\033[35m ››\033[0m$enter"
elif [[ "$WSAD" == "A" ]] ;then
[[ "$order" -eq $((pathlsl)) ]] && [[ $((pathlsl)) -eq 1 ]] && continue
printf " $enter"
[[ "$order" -eq 1 ]] && printf "\033[$((inlineallB))B$enter" && printf "\033[35m ››\033[0m$enter"
[[ "$order" -eq 1 ]] && order="$pathlsl" && continue
order=$((order-1))
eval thenext=\$inline$order
printf "\033[$((thenext))A\033[35m ››\033[0m$enter"
elif [[ "$WSAD" == "C" ]] ;then
stty echo
break
else
stty echo
continue
fi
elif [[ "$ascanf" == '' ]] || [[ "$ascanf" == "$CR" ]] ;then
stty echo
break
fi
done
thepath=$(echo "$pathls" | sed -n "${order},${order}p" )
down=$((pathlsl+1-$order))
printf "\033[${down}B$enter"
cd "$thepath" && printf "open \033[1m$thepath\033[0m\n"
if [[ "$?" -ne "0" ]];then
calenda=0
echo 未找到词表路径,请在该项目文件夹中运行
read -t3
echo
return 1
fi
txtall=$(find . | grep -a ".txt" | sort -n -t \/ -k 2.2n -k 3 -k 3.4 -k 3.3)
bk="$txtall
"
[[ "$txtall" == "" ]] && echo 找不到.txt文件 && return 1
printf "\033[2m"
if [[ $COLUMN -gt 35 ]];then
pt="$(echo "$txtall
" | sed 'N;s/\n/ /')"
while read line ;do
sleep 0.008
[[ "${#line}" -le "$((COLUMN-2))" ]] && printf "%-16s %s\n" $line && continue
[[ "${#line}" -gt "$((COLUMN-2))" ]] && printf "%s\n%s\n" $line && continue
done <<EOF
$pt
EOF
printf "\33[?25h"
for i in $(seq 100)
do
[[ $use -eq 1 ]] && mpreload
echo
printf "\033[0m"
stty "$abc" # ash only
read -p 请输入目标,按回车键加载词表: the #双列
[[ $i -eq 1 ]] && [[ "$the" == '' ]] && echo 未选择...加载第一张 && the="$(echo "$txtall" | tail -n1)" && read -t 2
[[ "$the" == '' ]] && echo 加载中...... && break
txtall="$(echo "$txtall" | grep -e "$the" )"
pt="$(printf "${txtall}\n\n" | sed 'N;s/\n/ /')"
#none="$(echo ${txtall})"
if [[ "$txtall" != "" ]] ;then
clear && while read line ;do
sleep 0.008
[[ "${#line}" -le "$((COLUMN-2))" ]] && printf "%-16s %s\n" $line && continue
[[ "${#line}" -gt "$((COLUMN-2))" ]] && printf "%s\n%s\n" $line && continue
done <<EOF
$pt
EOF
else
txtall="$bk" && pt="$(echo "$txtall" | sed 'N;s/\n/ /')" && echo 请重新输入 && read -t1
clear && printf "\033[2m" && while read line ;do
sleep 0.008
[[ "${#line}" -le "$((COLUMN-2))" ]] && printf "%-16s %s\n" $line && continue
[[ "${#line}" -gt "$((COLUMN-2))" ]] && printf "%s\n%s\n" $line && continue
done <<EOF
$pt
EOF
fi
done
txtall="$(echo "$txtall" | tr " " "\n" )"
while read line ;do
(cat ${line} ) >&/dev/null
catable=$?
if [[ $catable -eq 0 ]];then
etxt=
eetxt=
exec 3<"$line"
read -r -d "" -u 3 aetxt
if [[ "${aetxt}" =~ " " ]] ;then
targets=$targets' '${line}
#aetxt="$(printf "%s" "$aetxt" | tr ' ' '/')"
if [[ "${Json:-0}" -eq 1 ]];then
txtjson="${line%%txt}json"
if [[ -e "$txtjson" ]] ;then
[[ $alljson != "" ]] && alljson="$alljson
$txtjson
"
[[ "$alljson" == "" ]] && alljson="$txtjson"
else
echo "$txtjson"不存在
alljson="$alljson
"
fi
fi
while read line ;do
if [[ "$line" =~ " " ]] ;then
eetxt="$line"
[[ "$etxt" != "" ]] && etxt="$etxt
$eetxt"
[[ "$etxt" == "" ]] && etxt="$eetxt"
else
eetxt=
continue
fi
done <<EOF
$aetxt
EOF
if [[ "$etxt" != "" ]] ;then
[[ "$txt" != "" ]] && txt="$txt
$etxt"
[[ "$txt" == "" ]] && txt="$etxt"
n=$(echo "${txt}" | wc -l)
tno=$((tno+1))
eval ca$tno=$((n*2))
fi
fi
fi
done <<EOF
$txtall
EOF
printf "\033[0m"
txt=$(printf "$txt" | tr -d "\r" ) #优化wsl
#n=$(echo "$txt" | wc -l )
n=$((n*2))
echo "准备加载$((n/2))组单词"
return 0
else
printf "\033[2m"
echo "$txtall"
printf "\033[0m"
echo
for i in $(seq 100)
do
[[ $use -eq 1 ]] && mpreload
stty "$abc" # ash only
read -p 请输入目标,按回车键结束: the #单列
[[ $i -eq 1 ]] && [[ "$the" == '' ]] && echo 未选择...加载第一张 && the="$(echo "$txtall" | tail -n1)" && read -t 2
[[ "$the" == '' ]] && echo 加载中...... && break
txtall=$(echo "$txtall" | grep -e "$the" )
#none="$(echo ${txtall})"
if [[ "$txtall" != "" ]] ;then
clear && echo "$txtall"
else
txtall="$bk" && echo 请重新输入 && read -t1
clear && printf "\033[2m" && echo "$txtall"
printf "\033[0m"
fi
done
txtall="$(echo "$txtall" | tr " " "\n" )"
while read line ;do
(cat ${line} ) >&/dev/null
catable=$?
if [[ $catable -eq 0 ]];then
etxt=
eetxt=
exec 3<"$line"
read -r -d "" -u 3 aetxt
if [[ "$aetxt" =~ " " ]] ;then
targets=$targets' '${line}
aetxt="$(printf "%s" "$aetxt" )"
if [[ "${Json:-0}" -eq 1 ]];then
txtjson="${line%%txt}json"
if [[ -e "$txtjson" ]] ;then
[[ $alljson != "" ]] && alljson="$alljson
$txtjson
"
[[ "$alljson" == "" ]] && alljson="$txtjson"
else
echo "$txtjson"不存在
alljson="$alljson
"
fi
fi
while read line ;do
if [[ "$line" =~ " " ]] ;then
eetxt="$line"
else
eetxt=
continue
fi
[[ "$etxt" != "" ]] && etxt="$etxt
$eetxt"
[[ "$etxt" == "" ]] && etxt="$eetxt"
done <<EOF
$aetxt
EOF
if [[ "$etxt" != "" ]] ;then
[[ "$txt" != "" ]] && txt="$txt
$etxt"
[[ "$txt" == "" ]] && txt="$etxt"
n=$(echo "${txt}" | wc -l)
tno=$((tno+1))
eval ca$tno=$((n*2))
fi
fi
fi
done <<EOF
$txtall
EOF
txt=$(printf "$txt" | tr -d "\r" ) #优化wsl
#n=$(echo "$txt" | wc -l )
n=$((n*2))
read -t 1 -p 准备加载$((n/2))组单词
return 0
fi
}
fetchJson()
{
throw() {
echo "$*" >&2
return 1
}
BRIEF=0
LEAFONLY=0
PRUNE=0
NO_HEAD=0
NORMALIZE_SOLIDUS=0
usage() {
echo
echo "Usage: JSON.sh [-b] [-l] [-p] [-s] [-h]"
echo
echo "-p - Prune empty. Exclude fields with empty values."
echo "-l - Leaf only. Only show leaf nodes, which stops data duplication."
echo "-b - Brief. Combines 'Leaf only' and 'Prune empty' options."
echo "-n - No-head. Do not show nodes that have no path (lines that start with [])."
echo "-s - Remove escaping of the solidus symbol (straight slash)."
echo "-h - This help text."
echo
}
parse_options() {
set -- "$@"
local ARGN=$#
while [ "$ARGN" -ne 0 ]
do
case $1 in
-h) usage
return 0
;;
-b) BRIEF=1
LEAFONLY=1
PRUNE=1
;;
-l) LEAFONLY=1
;;
-p) PRUNE=1
;;
-n) NO_HEAD=1
;;
-s) NORMALIZE_SOLIDUS=1
;;
?*) echo "ERROR: Unknown option."
usage
return 0
;;
esac
shift 1
ARGN=$((ARGN-1))
done
}
awk_egrep () {
local pattern_string=$1
gawk '{
while ($0) {
start=match($0, pattern);
token=substr($0, start, RLENGTH);
print token;
$0=substr($0, start+RLENGTH);
}
}' pattern="$pattern_string"
}
tokenize () {
local GREP
local ESCAPE
local CHAR
if echo "test string" | grep -E -ao --color=never "test" >/dev/null 2>&1
then
GREP='grep -E -ao --color=never'
else
GREP='grep -E -ao '
fi
if echo "test string" | grep -E -o "test" >/dev/null 2>&1
then
ESCAPE='(\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
CHAR='[^[:cntrl:]"\\]'
else
GREP=awk_egrep
ESCAPE='(\\\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
CHAR='[^[:cntrl:]"\\\\]'
fi
local STRING="\"$CHAR*($ESCAPE$CHAR*)*\""
local NUMBER='-?(0|[1-9][0-9]*)([.][0-9]*)?([eE][+-]?[0-9]*)?'
local KEYWORD='null|false|true'
local SPACE='[[:space:]]+'
# Force zsh to expand $A into multiple words
local is_wordsplit_disabled=$(unsetopt 2>/dev/null | grep -c '^shwordsplit$')
if [ $is_wordsplit_disabled != 0 ]; then setopt shwordsplit; fi
$GREP "$STRING|$NUMBER|$KEYWORD|$SPACE|." | grep -E -v "^$SPACE$"
if [ $is_wordsplit_disabled != 0 ]; then unsetopt shwordsplit; fi
}
parse_array () {
local index=0
local ary=''
read -r token
case "$token" in
']') ;;
*)
while :
do
parse_value "$1" "$index"
index=$((index+1))
ary="$ary""$value"
read -r token
case "$token" in
']') break ;;
',') ary="$ary," ;;
*) throw "EXPECTED , or ] GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
[ "$BRIEF" -eq 0 ] && value=$(printf '[%s]' "$ary") || value=
:
}
parse_object () {
local key
local obj=''
read -r token
case "$token" in
'}') ;;
*)
while :
do
case "$token" in
'"'*'"') key=$token ;;
*) throw "EXPECTED string GOT ${token:-EOF}" ;;
esac
read -r token
case "$token" in
':') ;;
*) throw "EXPECTED : GOT ${token:-EOF}" ;;
esac
read -r token
parse_value "$1" "$key"
obj="$obj$key:$value"
read -r token
case "$token" in
'}') break ;;
',') obj="$obj," ;;
*) throw "EXPECTED , or } GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
[ "$BRIEF" -eq 0 ] && value=$(printf '{%s}' "$obj") || value=
:
}
parse_value () {
local jpath="${1:+$1,}$2" isleaf=0 isempty=0 print=0
case "$token" in
'{') parse_object "$jpath" ;;
'[') parse_array "$jpath" ;;
# At this point, the only valid single-character tokens are digits.
''|[!0-9]) throw "EXPECTED value GOT ${token:-EOF}" ;;
*) value=$token
# if asked, replace solidus ("\/") in json strings with normalized value: "/"
[ "$NORMALIZE_SOLIDUS" -eq 1 ] && value=$(echo "$value" | sed 's#\\/#/#g')
isleaf=1
[ "$value" = '""' ] && isempty=1
;;
esac
[ "$value" = '' ] && return
[ "$NO_HEAD" -eq 1 ] && [ -z "$jpath" ] && return
[ "$LEAFONLY" -eq 0 ] && [ "$PRUNE" -eq 0 ] && print=1
[ "$LEAFONLY" -eq 1 ] && [ "$isleaf" -eq 1 ] && [ $PRUNE -eq 0 ] && print=1
[ "$LEAFONLY" -eq 0 ] && [ "$PRUNE" -eq 1 ] && [ "$isempty" -eq 0 ] && print=1
[ "$LEAFONLY" -eq 1 ] && [ "$isleaf" -eq 1 ] && \
[ $PRUNE -eq 1 ] && [ $isempty -eq 0 ] && print=1
[ "$print" -eq 1 ] && printf "[%s]\t%s\n" "$jpath" "$value"
:
}
parse () {
read -r token
parse_value
read -r token
case "$token" in
'') ;;
*) throw "EXPECTED EOF GOT $token" ;;
esac
}
parse_options "$@"
tokenize | parse
}
stdin()
{
LINE=$(stty size|awk '{print $1}')
COLUMN=$(stty size|awk '{print $2}')
[[ "$((COLUMN%2))" -eq 1 ]] && aspace=' '
spaces=''
for space in $(seq $((COLUMN/2)));do
spaces="$spaces "
done
title=${spaces# }
for STR in $(seq $((COLUMN)));do
strs="$strs"─
done
[[ "$COLUMN" -lt 28 ]] && spaces=' '
for i in $(seq $((COLUMN)));do
strs_="$strs_"=
done
strs="$(printf "\033[2m$strs\033[0m")"
COL=$((COLUMN-2))
COL2=$((COLUMN/2-2))
eval ' hello=`cat`' <<"blocks"
___ __
/ _ | ___ / /
/ __ |(_-</ _ \
/_/ |_/___/_//_/
blocks
eval ' hi=`cat`' <<"blocks"
____ ___ __
/ __/__ ___ _/ (_)__ / /
/ _// _ \/ _ `/ / (_-</ _ \
/___/_//_/\_, /_/_/___/_//_/
/___/
blocks
eval ' hey=`cat`' <<"blocks"
______ _ _
/_ __/______ _(_)__ (_)__ ___ _
/ / / __/ _ `/ / _ \/ / _ \/ _ `/
/_/ /_/ \_,_/_/_//_/_/_//_/\_, /
/___/
blocks
prt()
{
height=`echo "$1"|wc -l`
for i in `seq "$height"`;do
sleep 0.006 && read -s -t0 && break
char=`echo $1`
[ -n "$char" ] && printf "$(echo "$1"|sed -n "$i"p)"
echo
done
}
clear
[[ $COLUMN -ge 34 ]] && prt "\033[1m$hello\n$hi\n$hey"
sleep 0.1
stty "${abc}"
echo
printf "\033[0m\033[1A"
printf "\033[2m\033[3m"
printf "\r$(date +"%Y-%m-%d %H\033[5m:\033[0m\033[2m\033[3m%M\033[5m:\033[0m\033[2m\033[3m%S")\r"
echo
printf "\033[?25l\033[0m"
printf "\033[1m${strs/"2m"/"1m"}\r──\n"
printf "\033[2A\033[2m\033[3m"
while true;do
sleep 0.2 && read -t0 && break
printf "\r$(date +"%Y-%m-%d %H\033[1C%M\033[1C%S")\033[K\r" &
done
read -t 0.1
printf "\033[0m\033[3m"
echo
}
loading()
{
while true;do
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '´`´`´'
sleep 0.44 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '``´`´'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '`´´`´'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '`´``´'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '`´`´´'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '`´`´`'
sleep 0.44 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '´´`´`'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '´``´`'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '´`´´`'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '´`´``'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '´`´`´'
sleep 0.11 && read -s -t0 && break
printf "\r\033[2m\033[%dC%s\r" "$COL2" '´`´`´'
done
read -s -t0.1
}
loadcontent()
{
if [[ "${verify:-0}" != "y" ]] ;then
struct
c="$(echo "$targets" | tr " " "\n")"
#cnum="$(echo "$c" | wc -l)"
while read line ;do
if [[ "${line}" != "" ]] ;then
exec 4<"$line" && content="$(grep -v " " <&4)
$content"
eval pt$RWN1="${line}"
RWN1=$((RWN1+1))
fi
done <<EOF
$c
EOF
fi
RWN1=1
if [[ "${Json:-0}" -eq 1 ]] ;then
for S in $(seq 1 $COLUMN);do
strss="$strss-"
done
strss="$(printf "\033[2m${strss}\033[0m")"
while read line ;do
if [[ "${line}" != "" ]] ;then
printf 加载"$line"\\n
eval js$RWN1='"$(fetchJson -b <"$line" | grep -e "lexicalEntries\"" | grep -v "id\"" | grep -v "\"metadata\"" | grep -v "\"en\""$ )"'
RWN1=$((RWN1+1))
fi
done <<EOF
$alljson
EOF
fi
#for i in $(seq $cnum);do
#content="$(cat $(echo "$c" | sed -n "$i,${i}p" ) | grep -A 99999 \\\\ )
echo
if [[ "${record:-0}" == 1 ]] && [[ "${calenda:-0}" == 1 ]] ;then
echo
RWN=1
cd ..
if [[ ! -d ./CORRECT/${thepath} ]] ;then
mkdir CORRECT
echo "在txt目录创建 /CORRECT/${thepath} 文件夹" && cp -r ${thepath%%/} ./CORRECT/ && find ./CORRECT/$thepath | grep .txt | xargs rm -f
fi
cd CORRECT
cd "$thepath"
#[[ -d ./CORRECT ]] &&
while read atarget ;do
#echo $atarget
[[ "${atarget}" == "" ]] && continue
[[ ! -e ${atarget} ]] && echo >"$atarget"
ifnull="$(cat "${atarget}" | uniq )"
if [[ "$ifnull" == "" ]];then
echo >"${atarget}"
else
echo "$ifnull" >"$atarget"
fi
eval rw$RWN="${atarget}"
RWN=$((RWN+1))
if [[ $txtp -eq 2 ]];then
printf 使用错题集"$txtname"/CORRECT/$thepath${atarget##"./"}\\n
else
[[ -e ${atarget} ]] && printf 使用错题集./txt/CORRECT/$thepath${atarget##"./"}\\n
fi
if [[ "$?" -ne 0 ]];then
printf 找不到"$atarget"中的文件夹,请生成子文件夹或删除整个CORRECT\\n
fi
done <<EOF
$(echo "$targets" | tr " " "\n" )
EOF
cd ../../"$thepath"
read -t 3
fi
if [[ "$record" == 1 ]] && [[ "$calenda" == 0 ]] ;then
echo 找不到txt文件夹,获取当前路径
read
RWN=1
echo
[[ ! -d ./CORRECT ]] && echo 在当前目录创建CORRECT/allinone.txt && mkdir CORRECT
while read atarget ;do
[[ ! -e ./CORRECT/allinone.txt ]] && echo \\\\\\\\\\\\ > ./CORRECT/allinone.txt
ifnull="$(cat ./CORRECT/allinone.txt | uniq )"
if [[ "$ifnull" == "" ]];then
echo >./CORRECT/allinone.txt
else
echo "$ifnull" >./CORRECT/allinone.txt
fi
chmod 777 ./CORRECT/allinone.txt
eval rw$RWN=./CORRECT/allinone.txt
RWN=$((RWN+1))
[[ -e ./CORRECT/allinone.txt ]] && printf 使用错题集./CORRECT/allinone.txt\\n
done <<EOF
$(echo "$targets" | tr " " "\n" )
EOF
read -t 3
return 0
fi
#echo "$content"
}
mpreload()
{
nn=$((n/2))
n11=$((n1+1))
[[ $((nn-n1)) -ne 0 ]] && l=$((l+1))
echo
echo 加载动画已关闭
echo 已加载"$l"张词表 #需要"",否则输出为??
n1=$nn
echo "${strs}"
}
preload()
{
echo 载入词表中...
nn=$((n-lastn))
n11=$((n1+a0))
list=1
wlist=$n11
thetxt=$(echo "$txt" | tr -s ' ' | head -n$((nn/2)))
printf "\033[?25l"
echo
while read line;do
cha=$((nn/2))
if [[ $cha -gt 25 ]];then
list100=$(($((list*100))))
output=$((list100/$((cha))))
#echo $output
output25=$((output/4))
trial=$((output25-outputed))
[[ $trial -eq 1 ]] && str="$str"=
outputed=${output25:-0}
[[ "$COLUMN" -gt 30 ]] && printf "\033[k\r\033[2m--------------------------\033[0m]%s\r %s\r[" "${output}%" "${str}"
[[ "$COLUMN" -le 30 ]] && printf "%s\r" "${output}%"
elif [[ $cha -le 25 ]];then
list100=$(($((list*100))))
output=$((list100/$((cha))))
output5=$((output/20))
trial=$((output5-outputed))
[[ $trial -eq 1 ]] && str="$str"=====
outputed=${output5:-0}
[[ "$COLUMN" -gt 30 ]] && printf "\033[k\r\033[2m--------------------------\033[0m]%s\r %s\r[" "${output}%" "${str}"
[[ "$COLUMN" -le 30 ]] && printf "%s\r" "${output}%"
fi
[[ ${#str} -eq 25 ]] && str=
lleft=$(echo "$line" | awk 'BEGIN{FS=" ";RS="\n"}{printf $1}' )
right="$(echo "$thetxt" | sed -n "$list,${list}p" | awk 'BEGIN{FS=" "}{print $NF}' )"
right=${right:-/}
alldata="$lleft $right"
aline="$(printf "%s" "${line}" | tr -s " " | tr " " " " )"
if [[ "$alldata" == "$aline" ]] ;then
eval lr$wlist="$(echo "\$lleft")"
eval lr$((wlist+1))="$(echo "\$right")"
else
verify=n
row=$(eval "$allif")
eval therw=\${rw$row}
soutcome="$soutcome
${therw}词表中的 \033[1m ${aline} \033[0m 可能不兼容"
eval lr$wlist="$(echo "\$lleft")"
eval lr$((wlist+1))="$(echo "\$right")"
fi
list=$((list+1))
wlist=$((wlist+2))
done <<EOF
$thetxt
EOF
echo
if [[ "$verify" == "n" ]] ;then
printf "$soutcome
1.英文在行首,中文在行末,中间用多个tab制表符隔开
2.删除多余的空格和缩进
3.检查tab制表符
4.仅英文单词部分可使用空格"
read
fi
nn=$((list))
str=
output=0
output25=0
verify=
[[ $((nn-n1)) -ne 0 ]] && l=$((l+1)) && a0=0
echo
echo 已加载"$l"张词表 #需要"",否则输出为??
n1=$((wlist))
echo "${strs}"
therw=
}
Fresh() #ash only
{
if [[ "$1" != "" ]];then
p="$1"
fi
#echo $p
tt=0
whereadd=0
counts=0
counts2=0
CO=$COLUMN
#iq=${#p}
iq="$(printf "$p" | wc -c)"
skip=0
st=0
t=1
nq=0
maxstrs=${#p}
izhpt=0
while true;do
temp1=0
tt=$t #第几个字节
t1=$((tt-1))
[[ $iq -le $tt ]] && break #第几个字符
id=${p:$t1:1}
#echo $id | hexdump
#printf "$id"
if [[ "$skip" -eq 1 ]] && [[ "$id" == "m" ]];then
skip=0
nq=$((nq+1))
t=$((t+1))
continue
fi
if [[ "$skip" -eq 1 ]] ;then
nq=$((nq+1))
t=$((t+1))
continue
fi