tangled
alpha
login
or
join now
eldridge.cam
/
paper-terminal
0
fork
atom
Print Markdown to a paper in your terminal
0
fork
atom
overview
issues
pulls
pipelines
Improve cjk width measurements more, in tables
eldridge.cam
3 years ago
76c19ee2
80adf035
+154
-166
5 changed files
expand all
collapse all
unified
split
Cargo.lock
Cargo.toml
src
main.rs
str_width.rs
table.rs
+125
-147
Cargo.lock
···
16
17
[[package]]
18
name = "aho-corasick"
19
-
version = "0.7.15"
20
source = "registry+https://github.com/rust-lang/crates.io-index"
21
-
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
22
dependencies = [
23
"memchr",
24
-
]
25
-
26
-
[[package]]
27
-
name = "ansi_term"
28
-
version = "0.11.0"
29
-
source = "registry+https://github.com/rust-lang/crates.io-index"
30
-
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
31
-
dependencies = [
32
-
"winapi",
33
]
34
35
[[package]]
···
54
55
[[package]]
56
name = "autocfg"
57
-
version = "1.0.1"
58
source = "registry+https://github.com/rust-lang/crates.io-index"
59
-
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
60
61
[[package]]
62
name = "bitflags"
63
-
version = "1.2.1"
64
source = "registry+https://github.com/rust-lang/crates.io-index"
65
-
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
66
67
[[package]]
68
name = "bytemuck"
69
-
version = "1.5.1"
70
source = "registry+https://github.com/rust-lang/crates.io-index"
71
-
checksum = "bed57e2090563b83ba8f83366628ce535a7584c9afa4c9fc0612a03925c6df58"
72
73
[[package]]
74
name = "byteorder"
···
78
79
[[package]]
80
name = "cc"
81
-
version = "1.0.67"
82
source = "registry+https://github.com/rust-lang/crates.io-index"
83
-
checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd"
84
85
[[package]]
86
name = "cfg-if"
···
102
103
[[package]]
104
name = "clap"
105
-
version = "2.33.3"
106
source = "registry+https://github.com/rust-lang/crates.io-index"
107
-
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
108
dependencies = [
109
-
"ansi_term 0.11.0",
110
"atty",
111
"bitflags",
112
"strsim",
···
138
139
[[package]]
140
name = "crc32fast"
141
-
version = "1.2.1"
142
source = "registry+https://github.com/rust-lang/crates.io-index"
143
-
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
144
dependencies = [
145
"cfg-if",
146
]
147
148
[[package]]
149
name = "crossbeam-channel"
150
-
version = "0.5.0"
151
source = "registry+https://github.com/rust-lang/crates.io-index"
152
-
checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
153
dependencies = [
154
"cfg-if",
155
"crossbeam-utils",
···
168
169
[[package]]
170
name = "crossbeam-epoch"
171
-
version = "0.9.3"
172
source = "registry+https://github.com/rust-lang/crates.io-index"
173
-
checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12"
174
dependencies = [
0
175
"cfg-if",
176
"crossbeam-utils",
177
-
"lazy_static",
178
"memoffset",
0
179
"scopeguard",
180
]
181
182
[[package]]
183
name = "crossbeam-utils"
184
-
version = "0.8.8"
185
source = "registry+https://github.com/rust-lang/crates.io-index"
186
-
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
187
dependencies = [
188
"cfg-if",
189
-
"lazy_static",
190
]
191
192
[[package]]
···
234
235
[[package]]
236
name = "enquote"
237
-
version = "1.0.3"
238
source = "registry+https://github.com/rust-lang/crates.io-index"
239
-
checksum = "2ec878a5d2f3b6e9eaee72373dd23414cfc7d353104741471bec712ef241a66e"
0
0
0
240
241
[[package]]
242
name = "getopts"
···
249
250
[[package]]
251
name = "getrandom"
252
-
version = "0.2.2"
253
source = "registry+https://github.com/rust-lang/crates.io-index"
254
-
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
255
dependencies = [
256
"cfg-if",
257
"libc",
···
260
261
[[package]]
262
name = "gif"
263
-
version = "0.11.2"
264
source = "registry+https://github.com/rust-lang/crates.io-index"
265
-
checksum = "5a668f699973d0f573d15749b7002a9ac9e1f9c6b220e7b165601334c173d8de"
266
dependencies = [
267
"color_quant",
268
"weezl",
···
270
271
[[package]]
272
name = "heck"
273
-
version = "0.3.2"
274
source = "registry+https://github.com/rust-lang/crates.io-index"
275
-
checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
276
dependencies = [
277
"unicode-segmentation",
278
]
279
280
[[package]]
281
name = "hermit-abi"
282
-
version = "0.1.18"
283
source = "registry+https://github.com/rust-lang/crates.io-index"
284
-
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
285
dependencies = [
286
"libc",
287
]
···
310
"scoped_threadpool",
311
"tiff",
312
]
313
-
314
-
[[package]]
315
-
name = "itoa"
316
-
version = "0.4.7"
317
-
source = "registry+https://github.com/rust-lang/crates.io-index"
318
-
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
319
320
[[package]]
321
name = "jpeg-decoder"
···
334
335
[[package]]
336
name = "libc"
337
-
version = "0.2.92"
338
source = "registry+https://github.com/rust-lang/crates.io-index"
339
-
checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714"
340
341
[[package]]
342
name = "memchr"
343
-
version = "2.3.4"
344
source = "registry+https://github.com/rust-lang/crates.io-index"
345
-
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
346
347
[[package]]
348
name = "memoffset"
349
-
version = "0.6.3"
350
source = "registry+https://github.com/rust-lang/crates.io-index"
351
-
checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d"
352
dependencies = [
353
"autocfg",
354
]
···
374
375
[[package]]
376
name = "num-integer"
377
-
version = "0.1.44"
378
source = "registry+https://github.com/rust-lang/crates.io-index"
379
-
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
380
dependencies = [
381
"autocfg",
382
"num-traits",
···
384
385
[[package]]
386
name = "num-iter"
387
-
version = "0.1.42"
388
source = "registry+https://github.com/rust-lang/crates.io-index"
389
-
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
390
dependencies = [
391
"autocfg",
392
"num-integer",
···
406
407
[[package]]
408
name = "num-traits"
409
-
version = "0.2.14"
410
source = "registry+https://github.com/rust-lang/crates.io-index"
411
-
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
412
dependencies = [
413
"autocfg",
414
]
415
416
[[package]]
417
name = "num_cpus"
418
-
version = "1.13.0"
419
source = "registry+https://github.com/rust-lang/crates.io-index"
420
-
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
421
dependencies = [
422
"hermit-abi",
423
"libc",
424
]
0
0
0
0
0
0
425
426
[[package]]
427
name = "paper-terminal"
428
version = "2.2.0"
429
dependencies = [
430
-
"ansi_term 0.12.1",
431
"cjk",
432
"console",
433
"directories-next",
···
477
478
[[package]]
479
name = "proc-macro2"
480
-
version = "1.0.26"
481
source = "registry+https://github.com/rust-lang/crates.io-index"
482
-
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
483
dependencies = [
484
-
"unicode-xid",
485
]
486
487
[[package]]
···
498
499
[[package]]
500
name = "quote"
501
-
version = "1.0.9"
502
source = "registry+https://github.com/rust-lang/crates.io-index"
503
-
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
504
dependencies = [
505
"proc-macro2",
506
]
507
508
[[package]]
509
name = "rayon"
510
-
version = "1.5.0"
511
source = "registry+https://github.com/rust-lang/crates.io-index"
512
-
checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674"
513
dependencies = [
514
"autocfg",
515
"crossbeam-deque",
···
519
520
[[package]]
521
name = "rayon-core"
522
-
version = "1.9.0"
523
source = "registry+https://github.com/rust-lang/crates.io-index"
524
-
checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a"
525
dependencies = [
526
"crossbeam-channel",
527
"crossbeam-deque",
528
"crossbeam-utils",
529
-
"lazy_static",
530
"num_cpus",
531
]
532
533
[[package]]
534
name = "redox_syscall"
535
-
version = "0.2.5"
536
source = "registry+https://github.com/rust-lang/crates.io-index"
537
-
checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9"
538
dependencies = [
539
"bitflags",
540
]
541
542
[[package]]
543
name = "redox_users"
544
-
version = "0.4.0"
545
source = "registry+https://github.com/rust-lang/crates.io-index"
546
-
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
547
dependencies = [
548
"getrandom",
549
"redox_syscall",
0
550
]
551
552
[[package]]
553
name = "regex"
554
-
version = "1.4.5"
555
source = "registry+https://github.com/rust-lang/crates.io-index"
556
-
checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19"
557
dependencies = [
558
"aho-corasick",
559
"memchr",
···
562
563
[[package]]
564
name = "regex-syntax"
565
-
version = "0.6.23"
566
source = "registry+https://github.com/rust-lang/crates.io-index"
567
-
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
568
-
569
-
[[package]]
570
-
name = "ryu"
571
-
version = "1.0.5"
572
-
source = "registry+https://github.com/rust-lang/crates.io-index"
573
-
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
574
575
[[package]]
576
name = "scoped_threadpool"
···
585
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
586
587
[[package]]
588
-
name = "serde"
589
-
version = "1.0.125"
590
-
source = "registry+https://github.com/rust-lang/crates.io-index"
591
-
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
592
-
593
-
[[package]]
594
-
name = "serde_derive"
595
-
version = "1.0.125"
596
-
source = "registry+https://github.com/rust-lang/crates.io-index"
597
-
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
598
-
dependencies = [
599
-
"proc-macro2",
600
-
"quote",
601
-
"syn",
602
-
]
603
-
604
-
[[package]]
605
-
name = "serde_json"
606
-
version = "1.0.64"
607
-
source = "registry+https://github.com/rust-lang/crates.io-index"
608
-
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
609
-
dependencies = [
610
-
"itoa",
611
-
"ryu",
612
-
"serde",
613
-
]
614
-
615
-
[[package]]
616
name = "strsim"
617
version = "0.8.0"
618
source = "registry+https://github.com/rust-lang/crates.io-index"
···
620
621
[[package]]
622
name = "structopt"
623
-
version = "0.3.21"
624
source = "registry+https://github.com/rust-lang/crates.io-index"
625
-
checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c"
626
dependencies = [
627
"clap",
628
"lazy_static",
···
631
632
[[package]]
633
name = "structopt-derive"
634
-
version = "0.4.14"
635
source = "registry+https://github.com/rust-lang/crates.io-index"
636
-
checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90"
637
dependencies = [
638
"heck",
639
"proc-macro-error",
···
644
645
[[package]]
646
name = "syn"
647
-
version = "1.0.68"
648
source = "registry+https://github.com/rust-lang/crates.io-index"
649
-
checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87"
650
dependencies = [
651
"proc-macro2",
652
"quote",
653
-
"unicode-xid",
654
]
655
656
[[package]]
657
name = "syncat-stylesheet"
658
-
version = "2.2.0"
659
source = "registry+https://github.com/rust-lang/crates.io-index"
660
-
checksum = "d58d4411972200fcd5277e93f359573f19c3688ccf39073d5cc4ebdb46240ac0"
661
dependencies = [
662
-
"ansi_term 0.12.1",
663
"cc",
664
"enquote",
665
"hex",
···
669
670
[[package]]
671
name = "terminal_size"
672
-
version = "0.1.16"
673
source = "registry+https://github.com/rust-lang/crates.io-index"
674
-
checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406"
675
dependencies = [
676
"libc",
677
"winapi",
···
687
]
688
689
[[package]]
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
690
name = "tiff"
691
version = "0.6.1"
692
source = "registry+https://github.com/rust-lang/crates.io-index"
···
699
700
[[package]]
701
name = "tree-sitter"
702
-
version = "0.6.3"
703
source = "registry+https://github.com/rust-lang/crates.io-index"
704
-
checksum = "376e181cb69da67bad2d69806cf2500656fd68123c526a61e5cbbfc65110c5b0"
705
dependencies = [
706
"cc",
707
"regex",
708
-
"serde",
709
-
"serde_derive",
710
-
"serde_json",
711
]
712
713
[[package]]
···
726
checksum = "588aff0737b18e4172b3b827fac917e10b955df566a78f701d25cca354c65b73"
727
728
[[package]]
729
-
name = "unicode-segmentation"
730
-
version = "1.7.1"
731
source = "registry+https://github.com/rust-lang/crates.io-index"
732
-
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
733
734
[[package]]
735
-
name = "unicode-width"
736
-
version = "0.1.8"
737
source = "registry+https://github.com/rust-lang/crates.io-index"
738
-
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
739
740
[[package]]
741
-
name = "unicode-xid"
742
-
version = "0.2.1"
743
source = "registry+https://github.com/rust-lang/crates.io-index"
744
-
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
745
746
[[package]]
747
name = "vec_map"
···
751
752
[[package]]
753
name = "version_check"
754
-
version = "0.9.3"
755
source = "registry+https://github.com/rust-lang/crates.io-index"
756
-
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
757
758
[[package]]
759
name = "wasi"
760
-
version = "0.10.2+wasi-snapshot-preview1"
761
source = "registry+https://github.com/rust-lang/crates.io-index"
762
-
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
763
764
[[package]]
765
name = "weezl"
766
-
version = "0.1.4"
767
source = "registry+https://github.com/rust-lang/crates.io-index"
768
-
checksum = "4a32b378380f4e9869b22f0b5177c68a5519f03b3454fde0b291455ddbae266c"
769
770
[[package]]
771
name = "widestring"
···
16
17
[[package]]
18
name = "aho-corasick"
19
+
version = "0.7.18"
20
source = "registry+https://github.com/rust-lang/crates.io-index"
21
+
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
22
dependencies = [
23
"memchr",
0
0
0
0
0
0
0
0
0
24
]
25
26
[[package]]
···
45
46
[[package]]
47
name = "autocfg"
48
+
version = "1.1.0"
49
source = "registry+https://github.com/rust-lang/crates.io-index"
50
+
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
51
52
[[package]]
53
name = "bitflags"
54
+
version = "1.3.2"
55
source = "registry+https://github.com/rust-lang/crates.io-index"
56
+
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
57
58
[[package]]
59
name = "bytemuck"
60
+
version = "1.9.1"
61
source = "registry+https://github.com/rust-lang/crates.io-index"
62
+
checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc"
63
64
[[package]]
65
name = "byteorder"
···
69
70
[[package]]
71
name = "cc"
72
+
version = "1.0.73"
73
source = "registry+https://github.com/rust-lang/crates.io-index"
74
+
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
75
76
[[package]]
77
name = "cfg-if"
···
93
94
[[package]]
95
name = "clap"
96
+
version = "2.34.0"
97
source = "registry+https://github.com/rust-lang/crates.io-index"
98
+
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
99
dependencies = [
100
+
"ansi_term",
101
"atty",
102
"bitflags",
103
"strsim",
···
129
130
[[package]]
131
name = "crc32fast"
132
+
version = "1.3.2"
133
source = "registry+https://github.com/rust-lang/crates.io-index"
134
+
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
135
dependencies = [
136
"cfg-if",
137
]
138
139
[[package]]
140
name = "crossbeam-channel"
141
+
version = "0.5.5"
142
source = "registry+https://github.com/rust-lang/crates.io-index"
143
+
checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c"
144
dependencies = [
145
"cfg-if",
146
"crossbeam-utils",
···
159
160
[[package]]
161
name = "crossbeam-epoch"
162
+
version = "0.9.9"
163
source = "registry+https://github.com/rust-lang/crates.io-index"
164
+
checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d"
165
dependencies = [
166
+
"autocfg",
167
"cfg-if",
168
"crossbeam-utils",
0
169
"memoffset",
170
+
"once_cell",
171
"scopeguard",
172
]
173
174
[[package]]
175
name = "crossbeam-utils"
176
+
version = "0.8.10"
177
source = "registry+https://github.com/rust-lang/crates.io-index"
178
+
checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83"
179
dependencies = [
180
"cfg-if",
181
+
"once_cell",
182
]
183
184
[[package]]
···
226
227
[[package]]
228
name = "enquote"
229
+
version = "1.1.0"
230
source = "registry+https://github.com/rust-lang/crates.io-index"
231
+
checksum = "06c36cb11dbde389f4096111698d8b567c0720e3452fd5ac3e6b4e47e1939932"
232
+
dependencies = [
233
+
"thiserror",
234
+
]
235
236
[[package]]
237
name = "getopts"
···
244
245
[[package]]
246
name = "getrandom"
247
+
version = "0.2.7"
248
source = "registry+https://github.com/rust-lang/crates.io-index"
249
+
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
250
dependencies = [
251
"cfg-if",
252
"libc",
···
255
256
[[package]]
257
name = "gif"
258
+
version = "0.11.3"
259
source = "registry+https://github.com/rust-lang/crates.io-index"
260
+
checksum = "c3a7187e78088aead22ceedeee99779455b23fc231fe13ec443f99bb71694e5b"
261
dependencies = [
262
"color_quant",
263
"weezl",
···
265
266
[[package]]
267
name = "heck"
268
+
version = "0.3.3"
269
source = "registry+https://github.com/rust-lang/crates.io-index"
270
+
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
271
dependencies = [
272
"unicode-segmentation",
273
]
274
275
[[package]]
276
name = "hermit-abi"
277
+
version = "0.1.19"
278
source = "registry+https://github.com/rust-lang/crates.io-index"
279
+
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
280
dependencies = [
281
"libc",
282
]
···
305
"scoped_threadpool",
306
"tiff",
307
]
0
0
0
0
0
0
308
309
[[package]]
310
name = "jpeg-decoder"
···
323
324
[[package]]
325
name = "libc"
326
+
version = "0.2.126"
327
source = "registry+https://github.com/rust-lang/crates.io-index"
328
+
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
329
330
[[package]]
331
name = "memchr"
332
+
version = "2.5.0"
333
source = "registry+https://github.com/rust-lang/crates.io-index"
334
+
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
335
336
[[package]]
337
name = "memoffset"
338
+
version = "0.6.5"
339
source = "registry+https://github.com/rust-lang/crates.io-index"
340
+
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
341
dependencies = [
342
"autocfg",
343
]
···
363
364
[[package]]
365
name = "num-integer"
366
+
version = "0.1.45"
367
source = "registry+https://github.com/rust-lang/crates.io-index"
368
+
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
369
dependencies = [
370
"autocfg",
371
"num-traits",
···
373
374
[[package]]
375
name = "num-iter"
376
+
version = "0.1.43"
377
source = "registry+https://github.com/rust-lang/crates.io-index"
378
+
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
379
dependencies = [
380
"autocfg",
381
"num-integer",
···
395
396
[[package]]
397
name = "num-traits"
398
+
version = "0.2.15"
399
source = "registry+https://github.com/rust-lang/crates.io-index"
400
+
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
401
dependencies = [
402
"autocfg",
403
]
404
405
[[package]]
406
name = "num_cpus"
407
+
version = "1.13.1"
408
source = "registry+https://github.com/rust-lang/crates.io-index"
409
+
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
410
dependencies = [
411
"hermit-abi",
412
"libc",
413
]
414
+
415
+
[[package]]
416
+
name = "once_cell"
417
+
version = "1.12.0"
418
+
source = "registry+https://github.com/rust-lang/crates.io-index"
419
+
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
420
421
[[package]]
422
name = "paper-terminal"
423
version = "2.2.0"
424
dependencies = [
425
+
"ansi_term",
426
"cjk",
427
"console",
428
"directories-next",
···
472
473
[[package]]
474
name = "proc-macro2"
475
+
version = "1.0.40"
476
source = "registry+https://github.com/rust-lang/crates.io-index"
477
+
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
478
dependencies = [
479
+
"unicode-ident",
480
]
481
482
[[package]]
···
493
494
[[package]]
495
name = "quote"
496
+
version = "1.0.20"
497
source = "registry+https://github.com/rust-lang/crates.io-index"
498
+
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
499
dependencies = [
500
"proc-macro2",
501
]
502
503
[[package]]
504
name = "rayon"
505
+
version = "1.5.3"
506
source = "registry+https://github.com/rust-lang/crates.io-index"
507
+
checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d"
508
dependencies = [
509
"autocfg",
510
"crossbeam-deque",
···
514
515
[[package]]
516
name = "rayon-core"
517
+
version = "1.9.3"
518
source = "registry+https://github.com/rust-lang/crates.io-index"
519
+
checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f"
520
dependencies = [
521
"crossbeam-channel",
522
"crossbeam-deque",
523
"crossbeam-utils",
0
524
"num_cpus",
525
]
526
527
[[package]]
528
name = "redox_syscall"
529
+
version = "0.2.13"
530
source = "registry+https://github.com/rust-lang/crates.io-index"
531
+
checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42"
532
dependencies = [
533
"bitflags",
534
]
535
536
[[package]]
537
name = "redox_users"
538
+
version = "0.4.3"
539
source = "registry+https://github.com/rust-lang/crates.io-index"
540
+
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
541
dependencies = [
542
"getrandom",
543
"redox_syscall",
544
+
"thiserror",
545
]
546
547
[[package]]
548
name = "regex"
549
+
version = "1.5.6"
550
source = "registry+https://github.com/rust-lang/crates.io-index"
551
+
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
552
dependencies = [
553
"aho-corasick",
554
"memchr",
···
557
558
[[package]]
559
name = "regex-syntax"
560
+
version = "0.6.26"
561
source = "registry+https://github.com/rust-lang/crates.io-index"
562
+
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
0
0
0
0
0
0
563
564
[[package]]
565
name = "scoped_threadpool"
···
574
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
575
576
[[package]]
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
577
name = "strsim"
578
version = "0.8.0"
579
source = "registry+https://github.com/rust-lang/crates.io-index"
···
581
582
[[package]]
583
name = "structopt"
584
+
version = "0.3.26"
585
source = "registry+https://github.com/rust-lang/crates.io-index"
586
+
checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
587
dependencies = [
588
"clap",
589
"lazy_static",
···
592
593
[[package]]
594
name = "structopt-derive"
595
+
version = "0.4.18"
596
source = "registry+https://github.com/rust-lang/crates.io-index"
597
+
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
598
dependencies = [
599
"heck",
600
"proc-macro-error",
···
605
606
[[package]]
607
name = "syn"
608
+
version = "1.0.98"
609
source = "registry+https://github.com/rust-lang/crates.io-index"
610
+
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
611
dependencies = [
612
"proc-macro2",
613
"quote",
614
+
"unicode-ident",
615
]
616
617
[[package]]
618
name = "syncat-stylesheet"
619
+
version = "2.2.1"
620
source = "registry+https://github.com/rust-lang/crates.io-index"
621
+
checksum = "2abdfdde201305d60c7f184dde404f6cae02390dda149567b7fca39fe76c21d4"
622
dependencies = [
623
+
"ansi_term",
624
"cc",
625
"enquote",
626
"hex",
···
630
631
[[package]]
632
name = "terminal_size"
633
+
version = "0.1.17"
634
source = "registry+https://github.com/rust-lang/crates.io-index"
635
+
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
636
dependencies = [
637
"libc",
638
"winapi",
···
648
]
649
650
[[package]]
651
+
name = "thiserror"
652
+
version = "1.0.31"
653
+
source = "registry+https://github.com/rust-lang/crates.io-index"
654
+
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
655
+
dependencies = [
656
+
"thiserror-impl",
657
+
]
658
+
659
+
[[package]]
660
+
name = "thiserror-impl"
661
+
version = "1.0.31"
662
+
source = "registry+https://github.com/rust-lang/crates.io-index"
663
+
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
664
+
dependencies = [
665
+
"proc-macro2",
666
+
"quote",
667
+
"syn",
668
+
]
669
+
670
+
[[package]]
671
name = "tiff"
672
version = "0.6.1"
673
source = "registry+https://github.com/rust-lang/crates.io-index"
···
680
681
[[package]]
682
name = "tree-sitter"
683
+
version = "0.19.5"
684
source = "registry+https://github.com/rust-lang/crates.io-index"
685
+
checksum = "ad726ec26496bf4c083fff0f43d4eb3a2ad1bba305323af5ff91383c0b6ecac0"
686
dependencies = [
687
"cc",
688
"regex",
0
0
0
689
]
690
691
[[package]]
···
704
checksum = "588aff0737b18e4172b3b827fac917e10b955df566a78f701d25cca354c65b73"
705
706
[[package]]
707
+
name = "unicode-ident"
708
+
version = "1.0.1"
709
source = "registry+https://github.com/rust-lang/crates.io-index"
710
+
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
711
712
[[package]]
713
+
name = "unicode-segmentation"
714
+
version = "1.9.0"
715
source = "registry+https://github.com/rust-lang/crates.io-index"
716
+
checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
717
718
[[package]]
719
+
name = "unicode-width"
720
+
version = "0.1.9"
721
source = "registry+https://github.com/rust-lang/crates.io-index"
722
+
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
723
724
[[package]]
725
name = "vec_map"
···
729
730
[[package]]
731
name = "version_check"
732
+
version = "0.9.4"
733
source = "registry+https://github.com/rust-lang/crates.io-index"
734
+
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
735
736
[[package]]
737
name = "wasi"
738
+
version = "0.11.0+wasi-snapshot-preview1"
739
source = "registry+https://github.com/rust-lang/crates.io-index"
740
+
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
741
742
[[package]]
743
name = "weezl"
744
+
version = "0.1.6"
745
source = "registry+https://github.com/rust-lang/crates.io-index"
746
+
checksum = "9c97e489d8f836838d497091de568cf16b117486d529ec5579233521065bd5e4"
747
748
[[package]]
749
name = "widestring"
+1
-1
Cargo.toml
···
22
pulldown-cmark = "0.8"
23
ansi_term = "0.12"
24
image = "0.23"
25
-
console = "0.14"
26
directories-next = "2.0"
27
syncat-stylesheet = { version = "2.1.4", features = ["ansi_term"] }
28
unicode-width = "0.1"
···
22
pulldown-cmark = "0.8"
23
ansi_term = "0.12"
24
image = "0.23"
25
+
console = { version = "0.14", features = ["unicode-width"] }
26
directories-next = "2.0"
27
syncat-stylesheet = { version = "2.1.4", features = ["ansi_term"] }
28
unicode-width = "0.1"
+2
-8
src/main.rs
···
8
use structopt::StructOpt;
9
use syncat_stylesheet::Stylesheet;
10
use terminal_size::{terminal_size, Width};
11
-
use unicode_width::UnicodeWidthChar;
12
13
mod dirs;
14
mod printer;
0
15
mod table;
16
mod termpix;
17
mod words;
18
19
use printer::Printer;
0
20
use words::Words;
21
-
22
-
fn str_width(s: &str) -> usize {
23
-
strip_ansi_codes(s)
24
-
.chars()
25
-
.flat_map(UnicodeWidthChar::width_cjk)
26
-
.sum()
27
-
}
28
29
/// Prints papers in your terminal
30
#[derive(StructOpt, Debug)]
···
8
use structopt::StructOpt;
9
use syncat_stylesheet::Stylesheet;
10
use terminal_size::{terminal_size, Width};
0
11
12
mod dirs;
13
mod printer;
14
+
mod str_width;
15
mod table;
16
mod termpix;
17
mod words;
18
19
use printer::Printer;
20
+
use str_width::str_width;
21
use words::Words;
0
0
0
0
0
0
0
22
23
/// Prints papers in your terminal
24
#[derive(StructOpt, Debug)]
+15
src/str_width.rs
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
use console::strip_ansi_codes;
2
+
use unicode_width::UnicodeWidthChar;
3
+
4
+
pub fn str_width(s: &str) -> usize {
5
+
strip_ansi_codes(s)
6
+
.chars()
7
+
.flat_map(|ch| {
8
+
if cjk::is_cjk_codepoint(ch) {
9
+
UnicodeWidthChar::width_cjk(ch)
10
+
} else {
11
+
UnicodeWidthChar::width(ch)
12
+
}
13
+
})
14
+
.sum()
15
+
}
+11
-10
src/table.rs
···
0
1
use crate::words::Words;
2
use ansi_term::Style;
3
-
use console::{measure_text_width, strip_ansi_codes};
4
use pulldown_cmark::Alignment;
5
use std::io::Write;
6
···
49
.iter()
50
.map(|title| {
51
Words::new(title)
52
-
.map(|word| word.trim().len())
53
.max()
54
.unwrap_or(0)
55
})
···
61
row.iter()
62
.map(|cell| {
63
Words::new(cell)
64
-
.map(|word| word.trim().len())
65
.max()
66
.unwrap_or(0)
67
})
68
.collect::<Vec<_>>()
69
})
70
-
.fold(title_longest_words.clone(), |mut chars, row| {
71
for i in 0..row.len() {
72
chars[i] = usize::max(chars[i], row[i]);
73
}
···
76
77
let mut title_chars = titles
78
.iter()
79
-
.map(|title| title.lines().map(measure_text_width).max().unwrap_or(0))
80
.collect::<Vec<_>>();
81
title_chars.resize(num_cols, 0);
82
let max_chars_per_col = rows
83
.iter()
84
.map(|row| {
85
row.iter()
86
-
.map(|cell| cell.lines().map(measure_text_width).max().unwrap_or(0))
87
.collect::<Vec<_>>()
88
})
89
.fold(title_chars.clone(), |mut chars, row| {
···
159
loop {
160
match words.next() {
161
Some(next) => {
162
-
if measure_text_width(&line) + measure_text_width(&next) <= cols[i] {
163
line += &next;
164
} else {
165
words.undo();
···
172
}
173
line = line.trim().to_string();
174
let padded = if alignment[i] == Alignment::Center {
175
-
format!(" {: ^width$} │", line, width = cols[i])
176
} else if alignment[i] == Alignment::Right {
177
-
format!(" {: >width$} │", line, width = cols[i])
178
} else {
179
-
format!(" {: <width$} │", line, width = cols[i])
180
};
181
write!(w, "{}", paper_style.paint(padded)).unwrap();
182
}
···
1
+
use crate::str_width;
2
use crate::words::Words;
3
use ansi_term::Style;
4
+
use console::strip_ansi_codes;
5
use pulldown_cmark::Alignment;
6
use std::io::Write;
7
···
50
.iter()
51
.map(|title| {
52
Words::new(title)
53
+
.map(|word| str_width(word.trim()))
54
.max()
55
.unwrap_or(0)
56
})
···
62
row.iter()
63
.map(|cell| {
64
Words::new(cell)
65
+
.map(|word| str_width(word.trim()))
66
.max()
67
.unwrap_or(0)
68
})
69
.collect::<Vec<_>>()
70
})
71
+
.fold(title_longest_words, |mut chars, row| {
72
for i in 0..row.len() {
73
chars[i] = usize::max(chars[i], row[i]);
74
}
···
77
78
let mut title_chars = titles
79
.iter()
80
+
.map(|title| title.lines().map(str_width).max().unwrap_or(0))
81
.collect::<Vec<_>>();
82
title_chars.resize(num_cols, 0);
83
let max_chars_per_col = rows
84
.iter()
85
.map(|row| {
86
row.iter()
87
+
.map(|cell| cell.lines().map(str_width).max().unwrap_or(0))
88
.collect::<Vec<_>>()
89
})
90
.fold(title_chars.clone(), |mut chars, row| {
···
160
loop {
161
match words.next() {
162
Some(next) => {
163
+
if str_width(&line) + str_width(&next) <= cols[i] {
164
line += &next;
165
} else {
166
words.undo();
···
173
}
174
line = line.trim().to_string();
175
let padded = if alignment[i] == Alignment::Center {
176
+
format!(" {: ^width$} │", line, width = cols[i] - (line.len().saturating_sub(str_width(&line))))
177
} else if alignment[i] == Alignment::Right {
178
+
format!(" {: >width$} │", line, width = cols[i] - (line.len().saturating_sub(str_width(&line))))
179
} else {
180
+
format!(" {: <width$} │", line, width = cols[i] - (line.len().saturating_sub(str_width(&line))))
181
};
182
write!(w, "{}", paper_style.paint(padded)).unwrap();
183
}