-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.fs
2069 lines (1878 loc) · 58.9 KB
/
gui.fs
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
\ net2o GUI
\ Copyright © 2018-2023 Bernd Paysan
\ This program is free software: you can redistribute it and/or modify
\ it under the terms of the GNU Affero General Public License as published by
\ the Free Software Foundation, either version 3 of the License, or
\ (at your option) any later version.
\ This program 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 Affero General Public License for more details.
\ You should have received a copy of the GNU Affero General Public License
\ along with this program. If not, see <http://www.gnu.org/licenses/>.
\ utf-8 set-encoding
require minos2/widgets.fs
[IFDEF] window-title$
"net2o GUI" window-title$ $!
[THEN]
[IFDEF] window-app-id$
"net2o" window-app-id$ $!
[THEN]
Forth definitions also minos
require minos2/font-style.fs
require unix/open-url.fs
gl-init
: bar-frame ( glue color -- o )
font-size# 20% f* }}frame dup .button3 ;
#64 Value lines/diag
: update-gsize# ( -- )
screen-pwh dup * swap dup * + s>f fsqrt
screen-diag default-diag f/ .5e f** lines/diag fm* f/
m2c:scale% f@ f* fround to font-size#
font-size# 133% f* fround to baseline#
font-size# 32e f/ to pixelsize# ;
require minos2/md-viewer.fs
require i18n-date.fs
' update-gsize# is rescaler
rescaler
\ check if dispose damages things
[IFDEF] dispose-check-xxx
: pollfds-check ( -- )
pollfds ['] @ catch nip IF
." Dispose check failed! " up@ h. cr
THEN ;
: net2o:dispose-check ( -- )
up@ >r
net2o-tasks $@ bounds U+DO
I @ up! pollfds-check
cell +LOOP
r> up! pollfds-check ;
' net2o:dispose-check is dispose-check
[THEN]
\ frames
0 Value pw-frame
0 Value id-frame
0 Value chat-frame
0 Value post-frame
0 Value n2o-frame
\ password screen
0 Value pw-err
0 Value pw-num
0 Value phrase-unlock
0 Value create-new-id
0 Value too-short-id
0 Value phrase-first
0 Value phrase-again
0 Value plus-login
0 Value minus-login
0 Value nick-edit
: err-fade ( r addr -- )
1e fover [ pi f2* ] Fliteral f* fcos 1e f+ f2/ f-
2 tries# @ lshift s>f f* fdup 1e f> IF fdrop 1e ELSE +sync +resize THEN
.fade fdrop ;
glue new Constant glue-sleft
glue new Constant glue-sright
: shake-lr ( r addr -- )
[ pi 16e f* ] FLiteral f* fsin f2/ 0.5e f+ \ 8 times shake
font-size# f2/ f* font-size# f2/ fover f-
glue-sleft >o 0g fdup hglue-c glue! o>
glue-sright >o 0g fdup hglue-c glue! o> +sync +resize drop ;
0e 0 shake-lr
: pres-frame# ( color# -- o1 o2 ) \ drop $FFFFFFFF
glue*wh slide-frame dup .button1 ;
: err-fade? ( -- flag ) 0 { flag }
anims@ 0 ?DO
>o action-of animate ['] err-fade = flag or to flag
o anims[] >stack o>
LOOP flag ;
forward show-nicks
forward gui-msgs
0 Value title-vp
0 Value pw-field
0 Value nick-field
0 Value nick-pw
0 Value pw-gen
0 Value pw-back
2 Value min-id-len#
Variable nick$
0.001e FConstant engage-delay#
: >engage ( field -- )
engage-delay# [: 1e f= IF engage ELSE drop THEN ;] >animate ;
: nick-check? ( -- flag )
nick$ $@ x-width min-id-len# u< ;
: nick-too-short ( -- )
create-new-id /hflip drop
too-short-id /flop drop +lang
nick-field >engage ;
: phrase-first-show ( -- )
create-new-id /hflip drop
too-short-id /hflip drop
phrase-first /flop drop +lang
phrase-again /hflip drop ;
: nick-done ( max span addr pos -- max span addr pos flag )
over 3 pick nick$ $!
nick-check? IF nick-too-short false EXIT THEN
pw-field >engage phrase-first-show
1 to nick-pw true ;
: nick-engaged ( -- )
nick-pw IF
create-new-id too-short-id
nick-check? IF swap THEN
/hflip drop
/flop drop
THEN
phrase-first /hflip drop
phrase-again /hflip drop
0 to nick-pw
+lang ;
: pw-engaged ( -- )
pw-gen to nick-pw
nick-field .text$ nick$ $!
nick-check? IF nick-too-short EXIT THEN
pw-gen IF phrase-first-show THEN
+lang ;
: clear-edit ( max span addr pos -- max 0 addr 0 true )
drop nip 0 tuck true ;
: do-shake ( max span addr pos -- max span addr pos flag )
keys sec[]free
clear-edit invert
1e o ['] shake-lr >animate
1 tries# @ lshift s>f f2/ pw-err ['] err-fade >animate ;
: right-phrase ( max span addr pos -- max span addr pos flag )
\ ." Right passphrase" cr
0 >o 0 secret-key init-client >raw-key
read-chatgroups announce-me
o>
show-nicks clear-edit ;
: pw-done ( max span addr pos -- max span addr pos flag )
case nick-pw
1 of
1 +to nick-pw
over 3 pick >passphrase +key
create-new-id /hflip
phrase-first /hflip
phrase-again /flop
clear-edit invert
endof
2 of
over 3 pick >passphrase lastkey@ str= IF
\ ." Create nick " nick$ $. ." with passphrase (hashed) " lastkey@ 85type cr
gen-keys-dir nick$ $@ 0 .new-key,
right-phrase
ELSE
1 to nick-pw
phrase-first /flop
phrase-again /hflip
1 tries# ! do-shake
THEN
endof
err-fade? IF false EXIT THEN
drop over 3 pick >passphrase +key
read-keys secret-keys# 0= IF
\ ." Wrong passphrase" cr
1 tries# +! tries# @ 0 <# #s #> pw-num >o to text$ o>
do-shake
ELSE
right-phrase
THEN 0
endcase +lang +resize ;
: 20%bt ( o -- o ) >o font-size# 20% f* to bordert o o> ;
: 25%b ( o -- o ) >o font-size# 25% f* to border o o> ;
: 25%bv ( o -- o ) >o font-size# 25% f* fdup to border fnegate to borderv o o> ;
: 40%b ( o -- o ) >o font-size# 40% f* to border o o> ;
\ password frame
tex: net2o-logo-tex
$FF0040FF text-color, FValue pw-num-col#
$666666FF text-color, FValue pw-text-col#
$000000FF text-color, FValue show-sign-color#
$FFCCCCFF $44FF44FF fade-color, FValue pw-bg-col#
$0000BFFF new-color, FValue dark-blue#
$0000FF08 new-color, FValue chbs-col#
$FFFFFFFF new-color, FValue login-bg-col#
$FF000000 $FF0000FF fade-color, FValue pw-err-col#
$000000FF dup text-emoji-color: black-emoji
$000000FF new-color, FValue otr-col#
$FFFFFFFF new-color, FValue chat-col#
$80FFFFFF new-color, FValue chat-bg-col#
$70eFeFFF new-color, FValue chat-hist-col#
$FFFFFFFF new-color, FValue posting-bg-col#
$444444FF new-color, FValue close-color#
$FF6633FF new-color, FValue recording-color#
: entropy-colorize ( -- )
prev-text$ erase addr prev-text$ $free
edit-w .text$ passphrase-entropy 1e fmin pw-bg-col# f+
pw-back >o to w-color o> ;
: size-limit ( -- )
edit-w .text$ nip #800 u> IF
prev-text$ edit-w >o to text$ o>
THEN ;
: nick-filter ( -- ) edit-w >o
0 >r BEGIN text$ r@ safe/string WHILE
c@ dup bl = over '@' = or swap '#' = or
IF addr text$ r@ 1 $del
r@ curpos u< +to curpos
ELSE r> 1+ >r THEN REPEAT drop rdrop
o> ;
glue new Constant glue*lll±
glue*lll± >o 1Mglue fnip 1000e fswap hglue-c glue! 0glue fnip 1filll fswap dglue-c glue! 1glue vglue-c glue! o>
glue new Constant glue*shrink
glue*shrink >o 0e 1filll 0e hglue-c glue! 1glue dglue-c glue! 1glue vglue-c glue! o>
' dark-blue >body f@
{{ login-bg-col# pres-frame#
dark-blue# ' dark-blue >body f!
{{
{{ glue*lll± }}glue }}v
' net2o-logo-tex "doc/net2o.png" 0.666e }}image-file Constant net2o-glue /center
!i18n l" net2o GUI" /title
!lit
\footnote cbl dark-blue net2o-version }}text /center
!i18n l" Copyright © 2010–2025 Bernd Paysan" }}text' /center !lit
{{
{{
glue*ll }}glue
blackish \large "👤" }}text \normal
{{
glue*l pw-bg-col# font-size# f2/ f2/ }}frame dup .button3
{{
nt
blackish \bold
"nick" }}edit 25%b dup to nick-field
glue*lll }}glue \regular
}}h bx-tab nick-field ' nick-done edit[]
' nick-filter filter[]
' nick-engaged engaged[]
}}z box[] blackish
{{ \large "👤" }}text \normal }}h /phantom
glue*ll }}glue
}}h box[]
}}v box[] /vflip dup to nick-edit
{{
glue*lll }}glue
glue-sleft }}glue
{{
\large \sans "🔐" }}text
\large pw-num-col# to x-color s" " }}text
25%b dup to pw-num /center
}}z
{{
glue*l pw-bg-col# font-size# f2/ f2/ }}frame dup .button3
dup to pw-back
\mono \normal
{{ chbs-col# to x-color "Correct Horse Battery Staple" }}text 25%b
glue*l }}h
{{
glue-sright }}glue
glue*l }}glue \bold
l" wrong passphrase!" pw-err-col#
to x-color }}i18n-text \regular
25%b dup to pw-err
glue*l }}glue
glue-sleft }}glue
}}h
blackish
{{
{{
pw-text-col# to x-color
"" }}pw dup to pw-field
25%b >o config:passmode# @ to pw-mode o o>
glue*lll }}glue
}}h
pw-field ' pw-done edit[] ' entropy-colorize filter[]
' pw-engaged engaged[]
\normal \sans white# to x-color
"" }}text blackish
dup value show-pw-sign
\regular
: pw-show/hide ( flag -- )
dup IF "" ELSE "" THEN show-pw-sign >o to text$ o>
2 config:passmode# @ 1 min rot select pw-field >o to pw-mode o>
pw-field >engage +sync ;
' pw-show/hide config:passmode# @ 1 > toggle[]
\normal
}}h box[]
}}z box[] bx-tab
{{
\large
"🔴" }}text \normal >o font-size# 10% f* to raise o o>
"➕️" }}text /center dup to plus-login
"➖️" }}text /center dup to minus-login /vflip
\large
: id-show-hide ( flag -- )
IF
phrase-unlock /hflip drop
create-new-id /flop drop
too-short-id /hflip drop
phrase-first /hflip drop
phrase-again /hflip drop
plus-login /flip drop
minus-login /flop drop
nick-edit /flop drop
[ x-baseline ] FLiteral nick-edit >o
fdup gap% f* to gap to baseline o>
"nick" nick-field engage-edit
1 to pw-gen
1 to nick-pw
ELSE
phrase-unlock /flop drop
create-new-id /hflip drop
too-short-id /hflip drop
phrase-first /hflip drop
phrase-again /hflip drop
plus-login /flop drop
minus-login /flip drop
nick-edit /vflip drop
0e nick-edit >o to baseline o>
pw-field >engage
0 to pw-gen
0 to nick-pw
THEN +resize +lang ;
\normal
}}z ' id-show-hide false toggle[] dup Value id-toggler
glue-sright }}glue
glue*lll }}glue
}}h box[] \skip >bl
\ Advices, context sensitive
{{ \small dark-blue !i18n
glue*l login-bg-col# font-size# f2/ f2/ }}frame dup .button1
{{ l" Enter passphrase to unlock" }}text' }}h dup to phrase-unlock
{{ l" Create new ID" }}text' }}h dup to create-new-id /hflip
{{ l" ID too short!" }}text' }}h dup to too-short-id /hflip
{{ l" Enter new passphrase" }}text' }}h dup to phrase-first /hflip
{{ l" Enter new passphrase again" }}text' }}h dup to phrase-again /hflip
!lit
}}z /center 25%b >bl
[: k-enter pw-frame .act .ekeyed ;] 0 click[]
{{ glue*lll }}glue }}v
}}v box[]
}}z box[] to pw-frame
' dark-blue >body f!
\ id frame
0 Value mykey-box
0 Value groups-box
0 Value nicks-box
0 value peers-box
0 Value msgs-box
0 Value msg-box
0 Value msg-par
0 Value msg-vbox
0 Value group-name
0 Value group-members
new-htab tab-glue: name-tab
new-htab tab-glue: pk-tab
new-htab tab-glue: group-tab
new-htab tab-glue: chatname-tab
?: child+ ( o -- ) o over >o to parent-w o> childs[] >stack ;
Create ke-imports#rgb
Create imports#rgb-bg
$33EE33FF new-color, sf, \ myself is pretty green
$BBDD66FF new-color, sf, \ manually imported is green, too
$55DD55FF new-color, sf, \ scanned is more green
$CCEE55FF new-color, sf, \ seen in chat is more yellow
$EECC55FF new-color, sf, \ imported from DHT is pretty yellow
$FF8844FF new-color, sf, \ invited is very yellow
$FFFFFFFF new-color, sf, \ provisional is just white
$FF0000FF new-color, sf, \ untrusted is last
Create imports#rgb-fg
$003300FF text-color, sf,
$000000FF text-color, sf,
$000000FF text-color, sf,
$000000FF text-color, sf,
$0000FFFF text-color, sf,
$0000FFFF text-color, sf,
$000000FF text-color, sf, \ provisional is just white
$00FFFFFF text-color, sf,
\ more colors
$88FF88FF new-color: my-signal
$CCFFCCFF new-color: other-signal
$CC00CCFF new-color: my-signal-otr
$880088FF new-color: other-signal-otr
$4444CCFF text-color: link-blue
$44CC44FF text-color: re-green
$CC4444FF text-color: obj-red
$00BFFFFF text-color: light-blue
$44FF44FF text-color: greenish
$33883366 new-color: day-color
$88333366 new-color: hour-color
$FFFFFFFF text-color: realwhite
$FFFFFFFF new-color: edit-bg
$808080C0 new-color: log-bg
$80FF80FF new-color: send-color
$00FF0020 new-color: pet-color
$FFFF80FF new-color, fvalue users-color#
$FF6666FF new-color, fvalue gps-color#
$000077FF new-color, fvalue chain-color#
$FF000000 $FF0000FF fade-color: show-error-color
$00990000 $009900FF fade-color: show-info-color
$338833FF text-color: lock-color
$883333FF text-color: lockout-color
$FFAA44FF text-color, fvalue perm-color#
\ $553300FF text-color: mono-col
$FFFFDDFF text-color: mono-otr-col
: nick[] ( box o:nick -- box )
[: data >o ." clicked on " ke-nick $. cr o> ;] o click[] ;
Hash: avatar#
glue new Constant glue*avatar
glue*avatar >o pixelsize# 64 fm* 0e 0g glue-dup hglue-c glue! vglue-c glue! 0glue dglue-c glue! o>
: wh-glue! ( w h -- )
default-imgwh% 15% f* fswap 20% f* fswap wh>glue ;
: glue*thumb ( w h -- o )
glue new >o wh-glue! 0glue dglue-c glue! o o> ;
: read-avatar ( addr u -- addr' u' )
?read-enc-hashed mem>thumb atlas-region +textures ;
Variable user-avatar#
Variable dummy-thumb#
Variable user.png$
Variable thumb.png$
: read-user ( -- region )
user.png$ $@len 0= IF
[ "doc/user.png" ]path user.png$ $slurp-file THEN
user.png$ $@ mem>thumb atlas-region +textures ;
: read-thumb ( -- )
thumb.png$ $@len 0= IF
[ "minos2/thumb.png" ]path thumb.png$ $slurp-file THEN
thumb.png$ $@ mem>thumb atlas-region +textures ;
: user-avatar ( -- addr )
user-avatar# @ 0= IF
read-user user-avatar# $!
THEN user-avatar# $@ drop ;
: dummy-thumb ( -- addr )
dummy-thumb# @ 0= IF
read-thumb dummy-thumb# $!
THEN dummy-thumb# $@ drop ;
: avatar-thumb ( avatar -- )
glue*avatar swap }}thumb >r {{ r> }}v 40%b ;
: avatar-frame ( addr u -- frame# )
key| 2dup avatar# #@ nip 0= IF
2dup read-avatar 2swap avatar# #!
ELSE 2drop THEN last# cell+ $@ drop ;
: show-avatar ( addr u -- o / 0 )
[: avatar-frame avatar-thumb ;] catch IF 2drop 0 nothrow THEN ;
: re-avatar ( last# -- )
dup >r $@ read-avatar r> cell+ $@ smove ;
: re-dummy ( -- )
dummy-thumb# @ 0= ?EXIT \ nobody has a dummy thumb
read-thumb dummy-thumb# $@ smove ;
: re-user ( -- )
user-avatar# @ 0= ?EXIT \ nobody has a dummy thumb
read-user user-avatar# $@ smove ;
:is free-thumbs defers free-thumbs
re-user re-dummy avatar# ['] re-avatar #map
fetch-finish# #frees ;
: ev-update-avatar ( thumb hash u1 -- )
avatar-frame swap .childs[] $@ drop @ >o to frame# o>
['] +sync peers-box .vp-needed +sync ;
: ev-fetch-avatar [{: thumb task hash u1 pk u2 :}h1
pk u2 $8 $A pk-connect? IF +resend +flow-control
net2o-code expect+slurp $10 blocksize! $A blockalign!
hash u1 net2o:copy# end-code| net2o:close-all disconnect-me
thumb hash u1
[{: thumb hash u1 :}h1 thumb hash u1 ev-update-avatar ;]
task send-event
ELSE 2drop THEN ;] ;
: ?+avatars ( o:key o/0 -- o )
?dup-0=-IF
user-avatar avatar-thumb
dup up@ ke-avatar $@ ke-pk $@ ev-fetch-avatar
?query-task send-event
THEN ;
: ?avatar ( addr u -- o / )
key# #@ IF
cell+ .ke-avatar $@ dup IF
show-avatar ?dup-0=-IF THEN
ELSE 2drop THEN
ELSE drop THEN ;
: >re-color-edit ( bg-color backframe -- )
>o to frame-color o> +resize +sync ;
: un-act ( edit-x engage-o -- )
>o act .dispose 0 to act o> 0 to inside-move? ;
: edit-pen[] ( backframe edit-x update-xt -- xt )
\G create a closure for an edit pen
[{: backframe edit-x xt: upd :}d
data >o edit-x .act IF \ push back to default
edit-x un-act true upd transp#
ELSE \ engage+select
edit-x o
action-of upd backframe edit-x r@ .caller-w
[{: xt: upd backframe edit-x click-o :}d
edit-x click-o [{: edit-x click-o :}h1
edit-x click-o >engage un-act +sync ;] up@ send-event
true upd
transp# backframe >re-color-edit
-1 to outselw
true ;] edit[]
['] nick-filter filter[] drop
edit-x >engage false upd
imports#rgb-bg sf@
THEN backframe >re-color-edit o> ;] ;
: nick-upd[] ( edit-x o:key -- xt )
o [{: edit-x o:key :}d
IF edit-x .text$ o:key >o
ke-nick $@ nick# #@ nip IF
o:key last# cell+ del$cell
ELSE 2drop THEN
ke-nick $! nick! key-sign
o> save-seckeys
['] add-me-id ?query-task send-event
THEN ;] ;
: show-nick ( o:key -- )
ke-imports @ [ 1 import#provisional lshift ]L and ?EXIT
ke-imports @ >im-color# sfloats { ki }
{{ glue*l imports#rgb-bg ki + sf@ slide-frame dup .button1
{{
{{ \large imports#rgb-fg ki + sf@ to x-color
ke-avatar $@ dup IF show-avatar ?+avatars
ELSE 2drop user-avatar avatar-thumb THEN
\sans ke-sk sec@ nip IF
\bold
{{
glue*l }}glue
{{
glue*l transp# font-size# 40% f* }}frame
dup .button3 dup { backframe }
{{
['] .nick-base $tmp }}edit 25%b dup { edit-x }
l" " black# }}button /hfix
backframe edit-x dup nick-upd[]
edit-pen[] edit-x click[]
}}h box[]
}}z box[]
}}v box[] >o 0e to baseline 0e to gap o o>
ELSE
\regular
['] .nick-base $tmp }}text 25%b
THEN
ke-pets[] $[]# IF
{{
x-color glue*l pet-color x-color slide-frame dup .button3 to x-color
['] .pet-base $tmp }}text 25%b
}}z
THEN
glue*l }}glue }}h name-tab box[]
{{
{{ \sans \script ke-selfsig $@ ['] .sigdates $tmp }}text glue*l }}glue }}h
{{ \mono \script ke-pk $@ key| ['] 85type $tmp }}text 20%bt glue*l }}glue }}h swap
}}v pk-tab
glue*lll }}glue }}h box[]
}}z box[] \regular
mykey-box nicks-box ke-sk sec@ nip select /flop .child+ ;
: fill-nicks ( -- )
keys>sort[]
key-list[] $@ bounds ?DO
I @ .show-nick
cell +LOOP ;
: refresh-top ( -- )
+sync +lang
top-widget >o htop-resize <draw-init draw-init draw-init> htop-resize
false to grab-move? o> ;
: show-connected ( -- ) main-up@ connection .wait-task ! ;
: gui-chat-connects ( -- )
[: up@ wait-task ! ;] IS do-connect
[: chat-keys [:
2dup search-connect ?dup-IF >o +group greet o> 2drop EXIT THEN
2dup pk-peek? IF chat-connect true !!connected!!
ELSE 2drop THEN ;] $[]map ;] catch nothrow
[ ' !!connected!! >body @ ]L = IF show-connected THEN ;
: ev-chat-connects gui-chat-connects
connection dup [{: con :}h1 con to connection ;]
swap .wait-task-event ;
false Value in-group?
: group[] ( box group -- box )
[: in-group? ?EXIT true to in-group?
data $@ group-name >o to text$ o>
data cell+ $@ drop cell+ >o groups:id$ groups:member[] o>
[: chat-keys $+[]! ;] $[]map
gui-msgs ['] ev-chat-connects ?query-task send-event
next-slide +lang +resize
;] swap click[] ;
: show-group ( group-o -- )
dup { g -- } cell+ $@ drop cell+ >o
{{ glue*l chat-bg-col# slide-frame dup .button1
{{
{{ \large blackish
\regular \sans g $@ }}text 25%b
glue*l }}glue }}h name-tab
{{
{{
\mono \bold \script groups:id$
2dup g $@ str= 0= IF key| ['] 85type $tmp THEN
}}text 20%bt glue*l }}glue }}h
glue*l }}glue
}}v pk-tab
glue*lll }}glue }}h
}}z g group[] o>
groups-box /flop .child+ ;
: fill-groups ( -- )
groups>sort[]
group-list[] $@ bounds ?DO
I @ show-group
cell +LOOP ;
also [ifdef] android android [then]
tex: vp-title
$F110 Constant 'spinner'
$F012 Constant 'signal'
$F234 Constant 'user-plus'
$F503 Constant 'user-minus'
$F235 Constant 'user-times'
0 Value online-flag
: online-symbol ( -- addr u )
'signal' 'spinner' online? select ['] xemit $tmp ;
: !online-symbol ( -- )
online-symbol online-flag >o to text$ o> +sync ;
:is addr-changed true to online? ['] announce-me catch nothrow 0= to online?
!online-symbol ;
: nicks-title ( -- )
{{ glue*l black# slide-frame dup .button1
{{
{{
{{
{{ \large \bold \sans realwhite
l" Nick+Pet" }}i18n-text 25%b glue*l }}glue }}h name-tab
{{
{{ \script \mono \bold l" Pubkey" }}i18n-text 20%bt glue*l }}glue }}h
{{ \script \sans \bold l" Key date" }}i18n-text glue*l }}glue }}h
}}v pk-tab
glue*lll± }}glue
}}h box[]
vp-title glue*lll ['] vp-title }}vp vp[] dup to title-vp
}}h box[]
}}z box[] ;
previous
{{ users-color# pres-frame#
{{
{{
nicks-title
glue*shrink }}glue
\Large
s" ❌️" close-color# }}button-lit /hfix [: -1 data +! ;]
[IFDEF] android android:level# [ELSE] level# [THEN] click[]
}}h box[] /vfix
{{
{{
{{ glue*l $303000FF new-color, bar-frame
{{ \script l" My key" }}i18n-text 25%b glue*l }}glue }}h }}z
{{ }}v box[] dup to mykey-box
{{ glue*l $300030FF new-color, bar-frame
{{ \script l" My groups" }}i18n-text 25%b glue*l }}glue }}h }}z
{{ }}v box[] dup to groups-box /vflip
{{ glue*l $003030FF new-color, bar-frame
{{ \script l" My peers" }}i18n-text 25%b glue*l }}glue }}h }}z
{{ }}v box[] dup to nicks-box /vflip
glue*lll }}glue
tex: vp-nicks vp-nicks glue*lll ' vp-nicks }}vp vp[] dup to peers-box
$444444FF new-color, to slider-color
$CCCCCCFF new-color, to slider-fgcolor
font-size# 33% f* to slider-border
dup font-size# 66% f* fdup vslider }}h box[]
}}v box[]
}}z box[] to id-frame
: show-nicks ( -- )
user-avatar drop dummy-thumb drop
fill-nicks fill-groups !online-symbol
next-slide +lang +resize peers-box >engage
peers-box 0.01e [: .vp-top fdrop title-vp .vp-top +sync +resize ;] >animate ;
\ messages
msg:class class
end-class wmsg-class
Variable last-bubble-pk
0 Value last-otr?
0 Value last-bubble
64#0 64Value last-tick
64#-1 64Value end-tick
#300 #1000000000 um* d>64 64Constant delta-bubble
: >bubble-border ( o me? -- )
swap >o font-size# 25% f*
IF
fdup f2* to border
fnegate fdup to borderl fdup to borderv to bordert
ELSE
fdup f2* to border
0e to borderl fnegate f2* to bordert 0e to borderv
THEN o o> ;
: msgs-box+resize ( -- )
[ ' +resize >body @ ' +resizeall >body @ or ]L msgs-box .vp-need or! ;
: >msgs-box ( child -- )
msgs-box .child+ msgs-box+resize ;
: add-dtms ( ticks -- )
\sans \small blackish
>fticks fticks>day { day } day last-day <> IF
{{
x-color { f: xc }
glue*l day-color x-color slide-frame dup .button1
xc to x-color
\bold day ['] localized.day $tmp -trailing }}text 25%b \regular
}}z /center >msgs-box
THEN day to last-day
24 fm* fsplit { hour } hour last-hour <>
60 fm* fsplit { minute } minute 10 / last-minute 10 / <> or
IF
{{
x-color { f: xc }
glue*l hour-color x-color slide-frame dup .button1
xc to x-color
60 fm* fsplit minute hour
[: #60 * + #60 * + localized.hms .tz ;] $tmp }}text 25%b
}}z /center >msgs-box
THEN hour to last-hour minute to last-minute
fdrop \normal ;
: otr? ( tick -- flag )
64dup 64#-1 64<> ;
: text-color! ( -- ) last-otr? IF greenish ELSE blackish THEN ;
hash: chain-tags#
scope{ dvcs
dvcs-log-class class
end-class posting-log-class
Variable like-char
posting-log-class :method msg:start ( addr u -- )
+ sigpksize# - [ keysize $10 + ]L dvcs-log:id$ $!
like-char off false to msg:silent?
;
posting-log-class :method msg:silent-start ( addr u -- )
key| to msg:id$ true to msg:silent? ;
posting-log-class :method msg:like ( xchar -- ) like-char ! ;
' 2drop posting-log-class is msg:tag
' 2drop posting-log-class is msg:id
' 2drop posting-log-class is msg:text
posting-log-class :method msg:text+format 2drop drop ;
' 2drop posting-log-class is msg:action
' drop posting-log-class is msg:vote \ !!FIXME!! what do we need here?
posting-log-class :method msg:chain ( addr u -- )
like-char @ 0= IF 2drop EXIT THEN
8 umin { | w^ id+like }
like-char @ dvcs-log:id$ $@ [: forth:type forth:xemit ;] id+like $exec
id+like cell
2over chain-tags# #@ d0= IF
2swap chain-tags# #!
ELSE
2nip last# cell+ $+!
THEN
;
posting-log-class :method msg:url ( addr u -- )
[: dvcs-log:id$ $. forth:type ;] dvcs-log:urls[] dup $[]# swap $[] $exec
;
: new-posting-log ( -- o )
posting-log-class new >o msg-table @ token-table ! o o> ;
}scope
0 Value posting-vp
: posting-box+resize ( -- )
[ ' +resize >body @ ' +resizeall >body @ or ]L posting-vp .vp-need or! ;
{{
posting-bg-col# pres-frame#
{{
{{
glue*l $000000FF new-color, slide-frame dup .button1
{{
\large realwhite
"⬅️" }}text 40%b [: prev-slide ;] over click[]
!i18n l" Post" }}text' !lit 40%b
glue*l }}glue
}}h box[]
}}z box[]
{{
{{
glue*ll }}glue
tex: vp-md
glue*l ' vp-md }}vp dup to posting-vp
>o "posting" to name$
font-size# dpy-w @ s>f fover maxcols# fm* f- f2/ 0e fmax fover f-
fdup fnegate to borderv f+ to border o o> dup Value posting-box
dup font-size# 66% f* fdup vslider }}h box[]
>o "posting-slider" to name$ o o>
}}v box[]
>o "posting-vbox" to name$ o o>
}}z box[]
>o "posting-zbox" to name$ o o>
to post-frame
:is re-config defers re-config
posting-box >o
font-size# dpy-w @ s>f fover maxcols# fm* f- f2/ 0e fmax fover f-
fdup fnegate to borderv f+ to border o> ;
hash: buckets#
: #!+ ( addr u hash -- ) >r
2dup r@ #@ IF
1 swap +! rdrop 2drop
ELSE
drop 1 { w^ one }
one cell 2swap r> #!
THEN ;
Variable emojis$ "👍👎🤣😍😘😛🤔😭😡😱🔃" emojis$ $! \ list need to be bigger
: chain-string ( addr u -- addr' u' )
buckets# #frees
bounds U+DO
I $@ [ keysize 2 64s + ]L /string buckets# #!+
cell +LOOP
emojis$ $@ bounds DO
I dup I' over - x-size 2dup buckets# #@
IF @ >r tuck type r> .
ELSE drop nip THEN
+LOOP ;
: display-title { d: prj | ki -- }
prj key>o ?dup-IF .ke-imports @ >im-color# sfloats to ki THEN
{{
glue*l imports#rgb-bg ki + sf@ slide-frame dup .button1
{{
prj key| ?avatar
\large imports#rgb-fg ki + sf@ to x-color
prj key| ['] .key-id? $tmp }}text 25%b
glue*ll }}glue
\small prj drop keysize + le-64@ [: .ticks space ;] $tmp }}text 25%b
\normal
prj drop keysize + 8 chain-tags# #@
['] chain-string $tmp }}text 25%b blackish
}}h box[]
}}z box[] posting-vp .child+ ;
: display-file { d: prj -- }
prj display-title
prj [ keysize $10 + ]L safe/string
2dup "file:" string-prefix? IF
0 to md-box
5 /string [: ." ~+/" type ;] $tmp markdown-parse
md-box posting-vp .child+
dpy-w @ dup s>f dpy-h @ >
IF font-size# maxcols# fm* fmin
ELSE font-size# f2* f- THEN
p-format
ELSE 2drop THEN ;
: display-posting ( addr u -- )
posting-vp >o dispose-childs free-thumbs 0 to active-w o>
project:branch$ $@ { d: branch }
dvcs:new-posting-log >o
>group msg-log@ 2dup { log u }
bounds ?DO
I $@ msg:display \ this will only set the URLs
cell +LOOP
glue*lll }}glue posting-vp dup .act 0= IF vp[] THEN .child+
log free
dvcs-log:urls[] ['] display-file $[]map
dvcs:dispose-dvcs-log o>
posting-box+resize ;
: .posting-log ( -- )
album-imgs[] $[]free
dvcs:new-dvcs >o config>dvcs
project:project$ $@ @/ 2drop 2dup load-msg
display-posting
dvcs:dispose-dvcs o> ;
: album>path ( -- )
>dir
album-imgs[] $@ bounds U+DO
"/" I 0 $ins dir@ I 0 $ins
cell +LOOP
dir> ;
: open-posting { d: prj -- }
>dir "posts" ~net2o-cache/ chat-keys $[]free
." open " prj .posting cr
prj 2dup keysize /string [: type '@' emit key| .key-id? ;] $tmp nick>chat
handle-clone
prj keysize /string set-dir throw
.posting-log next-slide +lang +resize +resizeall album>path
posting-vp 0.01e [: >o vp-top box-flags box-touched# invert and to box-flags o>
fdrop +sync +resize +resizeall ;] >animate
dir> ;
wmsg-class :method msg:end ( -- )
msg:silent? IF false to msg:silent? EXIT THEN
glue*ll }}glue msg-box .child+
dpy-w @ 80% fm* msg-par .par-split
{{ msg-par unbox }} cbl
dup >r 0 ?DO I pick box[] >bl "unboxed" name! drop LOOP r>
msg-vbox .+childs enqueue
;
0 Value edit-infobar-text \ nobody is online warning
l" Deactivate Verbatim"
l" Activate Verbatim"
l" On The Record"
l" Off The Record"
l" Nobody is online"
Create edit-infos
' show-error-color , , \ nobody
' show-info-color , , \ otr on
' show-info-color , , \ otr off
' show-info-color , , \ mono
' show-info-color , , \ normal
: change-edit-info ( n -- )
2* cells edit-infos + 2@ execute
edit-infobar-text >o x-color to text-color
dup to l-text locale@ to text$
o> +resize
2e edit-infobar-text [: f2* sin-t .fade +sync ;] >animate ;
wmsg-class :method msg:.nobody ( -- )