forked from tech-squares/sd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdutil.cpp
More file actions
3753 lines (3218 loc) · 135 KB
/
Copy pathsdutil.cpp
File metadata and controls
3753 lines (3218 loc) · 135 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
// -*- mode:c++; indent-tabs-mode:nil; c-basic-offset:3; fill-column:88 -*-
// SD -- square dance caller's helper.
//
// Copyright (C) 1990-2014 William B. Ackerman.
//
// This file is part of "Sd".
//
// ===================================================================
//
// If you received this file with express permission from the licensor
// to modify and redistribute it it under the terms of the Creative
// Commons CC BY-NC-SA 3.0 license, then that license applies. See
// http://creativecommons.org/licenses/by-nc-sa/3.0/
//
// ===================================================================
//
// Otherwise, the GNU General Public License applies.
//
// Sd is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Sd 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 General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License,
// in the file COPYING.txt, along with Sd. See
// http://www.gnu.org/licenses/
//
// ===================================================================
//
// This is for version 38.
/* This defines the following functions:
get_escape_string
write_history_line
unparse_call_name
print_recurse
clear_screen
ui_utils::writechar
newline
doublespace_file
ui_utils::writestuff
parse_block::clear
parse_block::get_block
parse_block::get_parse_block_mark
parse_block::release_parse_blocks_to_mark
parse_block::final_cleanup
copy_parse_tree
reset_parse_tree
save_parse_state
restore_parse_state
randomize_couple_colors
string_copy
display_initial_history
initialize_parse
run_program
and the following external variables:
GLOB_doing_frequency
GLOB_stats_filename
GLOB_decorated_stats_filename
global_error_flag
global_cache_failed_flag
global_cache_miss_reason
global_reply
clipboard
clipboard_size
wrote_a_sequence
retain_after_error
outfile_string
header_comment
creating_new_session
sequence_number
starting_sequence_number
old_filename_strings
new_filename_strings
filename_strings
concept_key_table
*/
#include <stdlib.h>
#include <string.h>
#include "sd.h"
#include "sdui.h"
#include "sort.h"
// External variables.
ui_option_type ui_options;
Cstring cardinals[NUM_CARDINALS+1];
Cstring ordinals[NUM_CARDINALS+1];
abridge_mode_t glob_abridge_mode;
bool GLOB_doing_frequency;
char GLOB_stats_filename[MAX_TEXT_LINE_LENGTH];
char GLOB_decorated_stats_filename[MAX_TEXT_LINE_LENGTH];
error_flag_type global_error_flag;
bool global_cache_failed_flag;
// Word 0 is the error code
// (Zero if hit, missing index+1 if miss, 9 if couldn't open the cache file.)
// Word 1 is what we wanted at the index.
// Word 2 is what we got.
int global_cache_miss_reason[3];
uims_reply_thing global_reply(ui_user_cancel, 99);
configuration *clipboard = (configuration *) 0;
int clipboard_size = 0;
bool wrote_a_sequence = false;
bool retain_after_error = false;
char outfile_string[MAX_FILENAME_LENGTH] = SEQUENCE_FILENAME;
char header_comment[MAX_TEXT_LINE_LENGTH];
bool creating_new_session = false;
int sequence_number = -1;
int starting_sequence_number;
// Under DJGPP, the default is always old-style filenames, because
// the underlying system (DOS or Windows 3.1) presumably can only
// handle "8.3" failenames. Even under Windows NT, the emulation
// seems to handle only 8.3 filenames. Under Windows 2000, it
// seems to handle long filenames, but is totally broken in other
// respects (compilation with Cygwin crashed in ntvdm.) The bug
// has been reported to Microsoft, and, of course, was never fixed.
#if defined(DJGPP)
const Cstring *filename_strings = old_filename_strings;
#else
const Cstring *filename_strings = old_filename_strings; // ******** For now
#endif
// BEWARE!! These lists are keyed to the definition of "dance_level" in database.h
const Cstring old_filename_strings[] = {
".MS",
".Plus",
".A1",
".A2",
".C1",
".C2",
".C3A",
".C3",
".C3X",
".C4A",
".C4",
".C4X",
".all",
".all",
""};
const Cstring new_filename_strings[] = {
"_MS.txt",
"_Plus.txt",
"_A1.txt",
"_A2.txt",
"_C1.txt",
"_C2.txt",
"_C3A.txt",
"_C3.txt",
"_C3X.txt",
"_C4A.txt",
"_C4.txt",
"_C4X.txt",
"_all.txt",
"_all.txt",
""};
const Cstring concept_key_table[] = {
/* These are the standard bindings. */
"cu deleteline",
"cx deleteword",
"e6 lineup",
"e8 linedown",
"e1 pageup",
"e2 pagedown",
"+f1 heads start",
"+sf1 sides start",
"+cf1 just as they are",
"f2 two calls in succession",
"sf2 twice",
"f3 pick random call",
"sf3 pick concept call",
"cf3 pick simple call",
"f4 resolve",
"e4 resolve", // home
"sf4 reconcile",
"cf4 normalize",
"f5 refresh display",
"sf5 keep picture",
"cf5 insert a comment",
"e13 insert a comment", // insert
"f6 simple modifications",
"sf6 allow modifications",
"cf6 centers",
"f7 toggle concept levels",
"+f7 toggle concept levels",
"sf7 toggle active phantoms",
"+sf7 toggle active phantoms",
"f8 quoteanything",
"sf8 cut to clipboard",
"cf8 paste one call",
"f9 undo last call",
"+f9 exit from the program",
"*f9 abort the search",
"sf9 undo last call",
"+sf9 exit from the program",
"*sf9 abort the search",
"f10 write this sequence",
"*f10 write this sequence",
"*e3 write this sequence", // end
"sf10 change output file",
"+sf10 change output file",
"f11 pick level call",
"sf11 pick 8 person level call",
"cf11 standardize",
"*f12 find another",
"*sf12 accept current choice",
"*cf12 previous",
"*af12 next",
"*se6 raise reconcile point", // shift up arrow
"*e5 previous", // left arrow
"*e7 find another", // right arrow
"*se8 lower reconcile point", // shift down arrow
(char *) 0};
static Cstring sessions_init_table[] = {
"[Options]",
"new_style_filename",
"",
"[Sessions]",
"+ C1 1 Sample",
"",
"# \"Enhanced\" accelerator keys can be plain, shifted, control, alt, or control-alt.",
"# e1 = page up",
"# e2 = page down",
"# e3 = end",
"# e4 = home",
"# e5 = left arrow",
"# e6 = up arrow",
"# e7 = right arrow",
"# e8 = down arrow",
"# e13 = insert",
"# e14 = delete",
"",
"[Accelerators]",
(char *) 0};
static Cstring abbreviations_table[] = {
"[Abbreviations]",
"u U-turn back",
"rlt right and left thru",
(char *) 0};
// Some things fail under Visual C++ version 5 and version 6. (Under different
// circumstances for those 2 compilers!) I complained, and they won't even
// acknowledge the existence of the bug report unless I pay them money.
extern void FuckingThingToTryToKeepTheFuckingStupidMicrosoftCompilerFromScrewingUp()
{
}
/* Getting blanks into all the right places in the presence of substitions,
insertions, and elisions is way too complicated to do in the database, or
to test. For example, consider calls like "@4keep @5busy@1",
"fascinat@pe@q@ning@o@t", or "spin the pulley@7 but @8". So we try to
help by never putting two blanks together, always putting blanks adjacent
to the outside of brackets, and never putting blanks adjacent to the
inside of brackets. This procedure is part of that mechanism. */
void ui_utils::write_blank_if_needed()
{
if (m_writechar_block.lastchar != ' ' &&
m_writechar_block.lastchar != '[' &&
m_writechar_block.lastchar != '(' &&
m_writechar_block.lastchar != '-') writechar(' ');
}
/* This examines the indicator character after an "@" escape. If the escape
is for something that is supposed to appear in the menu as a "<...>"
wildcard, it returns that string. If it is an escape that starts a
substring that would normally be elided, as in "@7 ... @8", it returns
a non-null pointer to a null character. If it is an escape that is normally
simply dropped, it returns a null pointer. */
const char *get_escape_string(char c)
{
switch (c) {
case '0': case 'm': case 'T':
return "<ANYTHING>";
case 'N':
return "<ANYCIRC>";
case '6': case 'k': case 'K': case 'V':
return "<ANYONE>";
case 'h':
return "<DIRECTION>";
case '9':
return "<N>";
case 'a': case 'b': case 'B': case 'D':
return "<N/4>";
case 'u':
return "<Nth>";
case 'v': case 'w': case 'x': case 'y':
return "<ATC>";
case '7': case 'n': case 'j': case 'J': case 'E': case 'Q':
return "";
default:
return (char *) 0;
}
}
void ui_utils::write_nice_number(char indicator, int num)
{
if (num < 0) {
writestuff(get_escape_string(indicator));
}
else {
switch (indicator) {
case '9': case 'a': case 'b': case 'B': case 'D':
if (indicator == '9')
writestuff(cardinals[num]);
else if (indicator == 'B' || indicator == 'D') {
if (num == 1)
writestuff("quarter");
else if (num == 2)
writestuff("half");
else if (num == 3)
writestuff("three quarter");
else if (num == 4)
writestuff("four quarter");
else {
writestuff(cardinals[num]);
writestuff("/4");
}
}
else if (num == 2)
writestuff("1/2");
else if (num == 4 && indicator == 'a')
writestuff("full");
else {
writestuff(cardinals[num]);
writestuff("/4");
}
break;
case 'u': /* Need to plug in an ordinal number. */
writestuff(ordinals[num]);
break;
}
}
}
void ui_utils::writestuff_with_decorations(const call_conc_option_state *cptr, Cstring f, bool is_concept)
{
uint32 index = cptr->number_fields;
int howmany = cptr->howmanynumbers;
while (f[0]) {
if (f[0] == '@') {
switch (f[1]) {
case 'a': case 'b': case 'B': case 'D': case 'u': case '9':
// DJGPP has a problem with this, need convert to int.
write_nice_number(f[1], (howmany <= 0) ? -1 : (int) (index & NUMBER_FIELD_MASK));
index >>= BITS_PER_NUMBER_FIELD;
howmany--;
break;
case 'h':
writestuff(is_concept ? direction_names[cptr->where].name_uc : direction_names[cptr->where].name);
break;
case '6': case 'K': case 'V':
writestuff(selector_list[cptr->who].name_uc);
break;
case 'k':
writestuff(selector_list[cptr->who].sing_name_uc);
break;
default: /**** maybe we should really do what "translate_menu_name"
does, using call to "get_escape_string". */
break;
}
f += 2;
}
else
writechar(*f++);
}
}
void ui_utils::printperson(uint32 x)
{
if (x & BIT_PERSON) {
if (enable_file_writing || ui_options.use_escapes_for_drawing_people == 0) {
/* We never write anything other than standard ASCII to the transcript file. */
writechar(' ');
writechar(ui_options.pn1[(x >> 6) & 7]);
writechar(ui_options.pn2[(x >> 6) & 7]);
if (enable_file_writing)
writechar(ui_options.stddirec[x & 017]);
else
writechar(ui_options.direc[x & 017]);
}
else {
/* Write an escape sequence, so that the user interface can display
the person in color. */
writechar('\013');
writechar((char) (((x >> 6) & 7) | 040));
writechar((char) ((x & 017) | 040));
}
}
else {
if (enable_file_writing || ui_options.use_escapes_for_drawing_people <= 1)
writestuff(" . ");
else
writechar('\014'); /* If we have full ("checker") escape sequences, use this. */
}
}
void ui_utils::do_write(Cstring s)
{
char c;
int ri = roti * 011;
for (;;) {
if (!(c=(*s++))) return;
else if (c == '@') {
if (*s == '7') {
s++;
ui_options.squeeze_this_newline = 1;
newline();
ui_options.squeeze_this_newline = 0;
}
else
newline();
}
else if (c >= 'a' && c <= 'x')
printperson(rotperson(printarg->people[personstart + ((c-'a'-offs)%modulus)].id1, ri));
else {
// We need to do the mundane translation of "5" and "6" if the result
// isn't going to be used by something that uses same.
if (enable_file_writing ||
ui_options.use_escapes_for_drawing_people <= 1 ||
ui_options.no_graphics != 0) {
if (c == '6')
writestuff(" "); /* space equivalent to 1 full glyph. */
else if (c == '9')
writestuff(" "); /* space equivalent to 3/4 glyph. */
else if (c == '5')
writestuff(" "); /* space equivalent to 1/2 glyph. */
else if (c == '8')
writestuff(" "); /* Like 5, but one space less if doing ASCII.
(Exactly same as 5 if doing checkers. */
else
writechar(c);
}
else
writechar(c);
}
}
}
void ui_utils::print_4_person_setup(int ps, small_setup *s, int elong)
{
Cstring str;
modulus = attr::klimit(s->skind)+1;
roti = (s->srotation & 3);
personstart = ps;
offs = (((roti >> 1) & 1) * (modulus / 2)) - modulus;
if (s->skind == s2x2) {
if (elong < 0)
str = "ab@dc@";
else if (elong == 1)
str = "a6b@d6c@";
else if (elong == 2)
str = "ab@@@dc@";
else
str = "a6b@@@d6c@";
}
else
str = setup_attrs[s->skind].print_strings[roti & 1];
if (str) {
newline();
do_write(str);
}
else
writestuff(" ????");
newline();
}
void ui_utils::printsetup(setup *x)
{
Cstring str;
ui_options.drawing_picture = 1;
printarg = x;
modulus = attr::slimit(x)+1;
roti = x->rotation & 3;
newline();
personstart = 0;
if (setup_attrs[x->kind].four_way_symmetry) {
/* still to do???
s_1x1
s2x2
s_star
s_hyperglass */
offs = (roti * (modulus / 4)) - modulus;
str = setup_attrs[x->kind].print_strings[0];
}
else {
offs = ((roti & 2) * (modulus / 4)) - modulus;
str = setup_attrs[x->kind].print_strings[roti & 1];
}
if (str)
do_write(str);
else {
switch (x->kind) {
case s_qtag:
if ((x->people[0].id1 & x->people[1].id1 &
x->people[4].id1 & x->people[5].id1 & 1) &&
(x->people[2].id1 & x->people[3].id1 &
x->people[6].id1 & x->people[7].id1 & 010)) {
// People are in diamond-like orientation.
if (x->rotation & 1)
do_write("6 g@7f 6 a@76 h@@6 d@7e 6 b@76 c");
else
do_write("5 a6 b@@g h d c@@5 f6 e");
}
else {
// People are not. Probably 1/4-tag-like orientation.
if (x->rotation & 1)
do_write("6 g@f h a@e d b@6 c");
else
do_write("6 a b@@g h d c@@6 f e");
}
break;
case s_c1phan:
// Look for nice "classic C1 phantom" occupations, and,
// if so, draw tighter diagram.
if (!(x->people[0].id1 | x->people[2].id1 |
x->people[4].id1 | x->people[6].id1 |
x->people[8].id1 | x->people[10].id1 |
x->people[12].id1 | x->people[14].id1))
str = "8 b@786 h f@78 d@7@868 l@7n p@7868 j";
else if (!(x->people[1].id1 | x->people[3].id1 |
x->people[5].id1 | x->people[7].id1 |
x->people[9].id1 | x->people[11].id1 |
x->people[13].id1 | x->people[15].id1))
str = "868 e@7a c@7868 g@7@8 o@786 k i@78 m";
else
str = "58b66e@a88c h88f@58d66g@@58o66l@n88p k88i@58m66j";
do_write(str);
break;
case s_trngl8:
offs = 0;
switch (roti) {
case 0:
str = "e f g h@@6 5d@6 5c@6 5b@6 5a";
break;
case 1:
str = "6 6 6 6 e@@6 6 6 6 f@7a b c d@76 6 6 6 g@@6 6 6 6 h";
break;
case 2:
str = "6 5a@6 5b@6 5c@6 5d@@h g f e";
break;
default:
str = "h@@g@76 d c b a@7f@@e";
break;
}
do_write(str);
break;
case s1x3p1dmd:
offs = 0;
switch (roti) {
case 0:
str = "6 6 6 d@7a b c 6 e@76 6 6 f";
break;
case 1:
str = " 5a@@ 5b@@ 5c@@ fd@@ 5e@";
break;
case 2:
str = "6 f@7e 6 c b a@76 d";
break;
default:
str = " 5e@@ df@@ 5c@@ 5b@@ 5a@";
break;
}
do_write(str);
break;
case s4p2x1dmd:
offs = 0;
switch (roti) {
case 0:
str = "6 6 6 9e@@a b c d g f@@6 6 6 9h";
break;
case 1:
str = "6 a@@6 b@@6 c@@6 d@7h 6 e@76 g@@6 f";
break;
case 2:
str = "6 9h@@f g d c b a@@6 9e";
break;
default:
str = "6 f@@6 g@7e 6 h@76 d@@6 c@@6 b@@6 a";
break;
}
do_write(str);
break;
case s3p1x1dmd:
// Stolen from s4p2x1dmd
offs = 0;
switch (roti) {
case 0:
str = "6 6 9d@@a b c e@@6 6 9f";
break;
case 1:
str = "6 a@@6 b@@6 c@7f 6 d@76 e";
break;
case 2:
str = "9f@@e c b a@@9d";
break;
default:
str = "6 e@7d 6 f@76 c@@6 b@@6 a";
break;
}
do_write(str);
break;
case s1x4p2dmd:
offs = 0;
switch (roti) {
case 0:
str = "6 6 6 6 e@7a b c d 6 g f@76 6 6 6 h";
break;
case 1:
str = " 5a@@ 5b@@ 5c@@ 5d@@ he@@ 5g@@ 5f@";
break;
case 2:
str = "6 6 h@7f g 6 d c b a@76 6 e";
break;
default:
str = " 5f@@ 5g@@ eh@@ 5d@@ 5c@@ 5b@@ 5a@";
break;
}
do_write(str);
break;
case splinepdmd:
offs = 0;
switch (roti) {
case 0:
str = "6 6 6 6 6 f@7a b c d e 6 g@76 6 6 6 6 h";
break;
case 1:
str = " 5a@@ 5b@@ 5c@@ 5d@@ 5e@@ hf@@ 5g@";
break;
case 2:
str = "6 h@7g 6 e d c b a@76 f";
break;
default:
str = " 5g@@ fh@@ 5e@@ 5d@@ 5c@@ 5b@@ 5a@";
break;
}
do_write(str);
break;
case splinedmd:
offs = 0;
switch (roti) {
case 0:
str = "6 6 6 6 9f@@a b c d e g@@6 6 6 6 9h";
break;
case 1:
str = "6 a@@6 b@@6 c@@6 d@@6 e@7h 6 f@76 g";
break;
case 2:
str = "9h@@g e d c b a@@9f";
break;
default:
str = "6 g@7f 6 h@76 e@@6 d@@6 c@@6 b@@6 a";
break;
}
do_write(str);
break;
case slinedmd:
offs = 0;
switch (roti) {
case 0:
str = "e f h g@@6 8b@78a 6 c@76 8d";
break;
case 1:
str = "9a9e@969f@7d b@7969h@9c9g";
break;
case 2:
str = "6 8d@78c 6 a@76 8b@@g h f e";
break;
default:
str = "g9c@h@76 b d@7f@e9a";
break;
}
do_write(str);
break;
case slinepdmd:
offs = 0;
switch (roti) {
case 0:
str = "e f h g@@6 5c@@6 b d@@6 5a";
break;
case 1:
str = "6 6 6 e@6 b 6 f@7a 6 c@76 d 6 h@6 6 6 g";
break;
case 2:
str = "6 5a@@6 d b@@6 5c@@g h f e";
break;
default:
str = "g@h 6 d@76 c 6 a@7f 6 b@e";
break;
}
do_write(str);
break;
case slinebox:
offs = 0;
switch (roti) {
case 0:
str = "6 6 6 6 e f@7a b c d@76 6 6 6 h g";
break;
case 1:
str = " 5a@@ 5b@@ 5c@@ 5d@@ he@@ gf@";
break;
case 2:
str = "g h@76 6 d c b a@7f e";
break;
default:
str = " fg@@ eh@@ 5d@@ 5c@@ 5b@@ 5a@";
break;
}
do_write(str);
break;
case sboxdmd:
offs = 0;
switch (roti) {
case 0:
str = "6e f@@6h g@@6 8b@78a 6 c@76 8d";
break;
case 1:
str = "9a@969h e@7d b@7969g f@9c";
break;
case 2:
str = "6 8d@78c 6 a@76 8b@@6g h@@6f e";
break;
default:
str = "696 c@f g@76 6 b d@7e h@696 a";
break;
}
do_write(str);
break;
case sboxpdmd:
offs = 0;
switch (roti) {
case 0:
str = "6 e f@@6 h g@@6 5c@@6 b d@@6 5a";
break;
case 1:
str = "6 b 6 h e@7a 6 c@76 d 6 g f";
break;
case 2:
str = "6 5a@@6 d b@@6 5c@@6 g h@@6 f e";
break;
default:
str = "f g 6 d@76 6 c 6 a@7e h 6 b";
break;
}
do_write(str);
break;
case sdmdpdmd:
offs = 0;
switch (roti) {
case 0:
str = "65f@7e 6 g@765h@@65c@@6b d@@65a";
break;
case 1:
str = "6 6 6 5 e@76 b@7a 6 c h f@76 d@76 6 6 5 g";
break;
case 2:
str = "65a@@6d b@@65c@@65h@7g 6 e@765f";
break;
default:
str = "5g@76 6 6 d@7f h c 6 a@76 6 6 b@75e";
break;
}
do_write(str);
break;
case s_dead_concentric:
ui_options.drawing_picture = 0;
writestuff(" centers only:");
newline();
ui_options.drawing_picture = 1;
print_4_person_setup(0, &(x->inner), -1);
break;
case s_normal_concentric:
ui_options.drawing_picture = 0;
writestuff(" centers:");
newline();
ui_options.drawing_picture = 1;
print_4_person_setup(0, &(x->inner), -1);
ui_options.drawing_picture = 0;
writestuff(" ends:");
newline();
ui_options.drawing_picture = 1;
print_4_person_setup(12, &(x->outer), x->concsetup_outer_elongation);
break;
default:
ui_options.drawing_picture = 0;
writestuff("???? UNKNOWN SETUP ????");
newline();
ui_options.drawing_picture = 1;
}
}
newline();
ui_options.drawing_picture = 0;
newline();
}
void ui_utils::write_history_line(int history_index,
bool picture,
bool leave_missing_calls_blank,
file_write_flag write_to_file)
{
m_leave_missing_calls_blank = leave_missing_calls_blank;
int w, i;
parse_block *thing;
configuration *this_item = &configuration::history[history_index];
if (write_to_file == file_write_double && !ui_options.singlespace_mode)
doublespace_file();
// Do not put index numbers into output file -- user may edit it later.
if (!enable_file_writing && !ui_options.diagnostic_mode) {
i = history_index-configuration::whole_sequence_low_lim+1;
if (i > 0) {
char indexbuf[10];
sprintf(indexbuf, "%2d: ", i);
writestuff(indexbuf);
}
}
if (this_item->nontrivial_startinfo_specific()) {
if (this_item->get_startinfo_specific()->into_the_middle) goto morefinal;
writestuff(this_item->get_startinfo_specific()->name);
goto final;
}
thing = this_item->command_root;
// Need to check for the special case of starting a sequence with heads or sides.
// If this is the first line of the history, and we started with heads of sides,
// change the name of this concept from "centers" to the appropriate thing.
if (history_index == 2 &&
thing->concept->kind == concept_centers_or_ends &&
thing->concept->arg1 == selector_centers) {
if (configuration::history[1].get_startinfo_specific()->into_the_middle) {
writestuff(configuration::history[1].get_startinfo_specific()->name);
writestuff(" ");
thing = thing->next;
}
}
print_recurse(thing, 0);
final:
newline();
morefinal:
// Check for warnings to print.
// Do not double space them, even if writing final output.
// First, don't print both "bad concept level" and "bad modifier level".
if (this_item->test_one_warning_specific(warn__bad_concept_level))
this_item->clear_one_warning_specific(warn__bad_modifier_level);
// Or "opt for parallelogram" and "each 1x4".
if (this_item->test_one_warning_specific(warn__check_pgram))
this_item->clear_one_warning_specific(warn__each1x4);
// Or both varieties of "each 1x3".
if (this_item->test_one_warning_specific(warn__split_to_1x3s_always))
this_item->set_one_warning_specific(warn__split_to_1x3s);
this_item->clear_one_warning_specific(warn__split_to_1x3s_always);
// Or "each 1x6" and "each 1x3".
if (this_item->test_one_warning_specific(warn__split_to_1x3s))
this_item->clear_one_warning_specific(warn__split_to_1x6s);
// Or "really_no_eachsetup".
this_item->clear_one_warning_specific(warn__really_no_eachsetup);
// Or "do your part" (that is, the "warn__dyp_or_2faced" version) and "you ought to say 2-faced".
// And don't say "do your part" twice.
if (this_item->test_one_warning_specific(warn__two_faced))
this_item->clear_one_warning_specific(warn__unusual_or_2faced);
if (!ui_options.nowarn_mode) {
for (w=0 ; w<warn__NUM_WARNINGS ; w++) {
if (this_item->test_one_warning_specific((warning_index) w)) {
writestuff(" Warning: ");
writestuff(&warning_strings[w][1]);
newline();
}
}
}
// The "keep all pictures" flag could trick us into drawing a picture of
// an invalid setup during sequence startup when the very intricate
// "heads/sides start" mechanism is being used. But when writing out
// the transcript file, the same setup will be valid. We use the
// "state_is_valid" flag to tell when it is permissible to draw the
// picture.
if (this_item->state_is_valid &&
(picture || this_item->draw_pic || ui_options.keep_all_pictures)) {
printsetup(&this_item->state);
if (this_item->state.eighth_rotation != 0) {
writestuff(" Note: Actual setup is 45 degrees clockwise from diagram above.");
newline();
if (write_to_file == file_write_double && ui_options.singlespace_mode)
doublespace_file();
}
}
// Record that this history item has been written to the UI.
this_item->text_line = text_line_count;
}
uint32_t ui_utils::get_number_fields(int nnumbers, bool odd_number_only, bool forbid_zero)
{
int i;
uint32 number_fields = matcher_p->m_final_result.match.call_conc_options.number_fields;
int howmanynumbers = matcher_p->m_final_result.match.call_conc_options.howmanynumbers;
uint32 number_list = 0;
for (i=0 ; i<nnumbers ; i++) {
uint32 this_num;
if (!matcher_p->m_final_result.valid || (howmanynumbers <= 0)) {
this_num = iob88.get_one_number(*matcher_p);
}
else {
this_num = number_fields & NUMBER_FIELD_MASK;
number_fields >>= BITS_PER_NUMBER_FIELD;
howmanynumbers--;
}