-
Notifications
You must be signed in to change notification settings - Fork 0
/
enh-331.patch
2339 lines (2327 loc) · 59.8 KB
/
enh-331.patch
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
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution.
3. The name of the author may not be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- nethack-3.3.1/include/config.h Fri Jul 21 18:13:51 2000
+++ nethack/include/config.h Fri Jan 11 15:52:37 2002
@@ -42,16 +42,17 @@
* Define all of those you want supported in your binary.
* Some combinations make no sense. See the installation document.
*/
-#define TTY_GRAPHICS /* good old tty based graphics */
+/* #define TTY_GRAPHICS */ /* good old tty based graphics */
/* #define X11_GRAPHICS */ /* X11 interface */
/* #define QT_GRAPHICS */ /* Qt interface */
/* #define GNOME_GRAPHICS */ /* Gnome interface */
+#define LISP_GRAPHICS /* lisp interface */
/*
* Define the default window system. This should be one that is compiled
* into your system (see defines above). Known window systems are:
*
- * tty, X11, mac, amii, BeOS, Qt, Gem, Gnome
+ * tty, X11, mac, amii, BeOS, Qt, Gem, Gnome, lisp
*/
/* MAC also means MAC windows */
@@ -94,6 +95,12 @@
# define GRAPHIC_TOMBSTONE /* Use graphical tombstone (rip.ppm) */
# ifndef DEFAULT_WINDOW_SYS
# define DEFAULT_WINDOW_SYS "Gnome"
+# endif
+#endif
+
+#ifdef LISP_GRAPHICS
+# ifndef DEFAULT_WINDOW_SYS
+# define DEFAULT_WINDOW_SYS "lisp"
# endif
#endif
--- /dev/null Wed Apr 10 03:16:35 2002
+++ nethack/include/winlisp.h Thu Jan 10 19:54:20 2002
@@ -0,0 +1,70 @@
+#ifndef WINLISP_H
+#define WINLISP_H
+
+#ifndef E
+#define E extern
+#endif
+
+#if defined(BOS) || defined(NHSTDC)
+#define DIMENSION_P int
+#else
+# ifdef WIDENED_PROTOTYPES
+#define DIMENSION_P unsigned int
+# else
+#define DIMENSION_P Dimension
+# endif
+#endif
+
+extern struct window_procs tty_procs;
+
+/* ### winlisp.c ### */
+E void NDECL(win_lisp_init);
+E void FDECL(lisp_init_nhwindows, (int *, char **));
+E void NDECL(lisp_player_selection);
+E void NDECL(lisp_askname);
+E void NDECL(lisp_get_nh_event) ;
+E void FDECL(lisp_exit_nhwindows, (const char *));
+E void FDECL(lisp_suspend_nhwindows, (const char *));
+E void NDECL(lisp_resume_nhwindows);
+E winid FDECL(lisp_create_nhwindow, (int));
+E void FDECL(lisp_clear_nhwindow, (winid));
+E void FDECL(lisp_display_nhwindow, (winid, BOOLEAN_P));
+E void FDECL(lisp_destroy_nhwindow, (winid));
+E void FDECL(lisp_curs, (winid,int,int));
+E void FDECL(lisp_putstr, (winid, int, const char *));
+E void FDECL(lisp_display_file, (const char *, BOOLEAN_P));
+E void FDECL(lisp_start_menu, (winid));
+E void FDECL(lisp_add_menu, (winid,int,const ANY_P *,
+ CHAR_P, CHAR_P, int, const char *, BOOLEAN_P));
+E void FDECL(lisp_end_menu, (winid, const char *));
+E int FDECL(lisp_select_menu, (winid, int, MENU_ITEM_P **));
+E char FDECL(lisp_message_menu, (char, int, const char *mesg));
+E void NDECL(lisp_update_inventory);
+E void NDECL(lisp_mark_synch);
+E void NDECL(lisp_wait_synch);
+#ifdef CLIPPING
+E void FDECL(lisp_cliparound, (int, int));
+#endif
+#ifdef POSITIONBAR
+E void FDECL(lisp_update_positionbar, (char *));
+#endif
+E void FDECL(lisp_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
+E void FDECL(lisp_raw_print, (const char *));
+E void FDECL(lisp_raw_print_bold, (const char *));
+E int NDECL(lisp_nhgetch);
+E int FDECL(lisp_nh_poskey, (int *, int *, int *));
+E void NDECL(lisp_nhbell);
+E int NDECL(lisp_doprev_message);
+E char FDECL(lisp_yn_function, (const char *, const char *, CHAR_P));
+E void FDECL(lisp_getlin, (const char *,char *));
+E int NDECL(lisp_get_ext_cmd);
+E void FDECL(lisp_number_pad, (int));
+E void NDECL(lisp_delay_output);
+
+/* other defs that really should go away (they're tty specific) */
+E void NDECL(lisp_start_screen);
+E void NDECL(lisp_end_screen);
+
+E void FDECL(lisp_outrip, (winid,int));
+
+#endif /* WINLISP_H */
--- nethack-3.3.1/src/windows.c Mon May 8 13:56:52 2000
+++ nethack/src/windows.c Thu Jan 10 19:55:39 2002
@@ -37,6 +37,10 @@
#include "winGnome.h"
extern struct window_procs Gnome_procs;
#endif
+#ifdef LISP_GRAPHICS
+#include "winlisp.h"
+extern struct window_procs lisp_procs;
+#endif
STATIC_DCL void FDECL(def_raw_print, (const char *s));
@@ -74,6 +78,9 @@
#endif
#ifdef GNOME_GRAPHICS
{ &Gnome_procs, 0 },
+#endif
+#ifdef LISP_GRAPHICS
+ { &lisp_procs, win_lisp_init },
#endif
{ 0, 0 } /* must be last */
};
--- nethack-3.3.1/sys/unix/Makefile.src Sat Aug 5 03:52:57 2000
+++ nethack/sys/unix/Makefile.src Thu Jan 10 19:54:59 2002
@@ -202,6 +202,11 @@
#WINBEOBJ = winbe.o NHWindow.o NHMenuWindow.o NHMapWindow.o tile.o
#
+# Files for the lisp port
+WINLISPSRC = ../win/lisp/winlisp.c tile.c
+WINLISPOBJ = winlisp.o tile.o
+
+#
#
WINSRC = $(WINTTYSRC)
WINOBJ = $(WINTTYOBJ)
@@ -243,6 +248,9 @@
#
# libraries for BeOS
WINBELIB = -lbe
+#
+# libraries for lisp port
+WINLISPLIB = -lm
WINLIB = $(WINTTYLIB)
@@ -323,7 +331,7 @@
../sys/unix/unixunix.c ../sys/be/bemain.c
# all windowing-system-dependent .c (for dependencies and such)
-WINCSRC = $(WINTTYSRC) $(WINX11SRC) $(WINGNOMESRC) $(WINGEMSRC)
+WINCSRC = $(WINTTYSRC) $(WINX11SRC) $(WINGNOMESRC) $(WINGEMSRC) $(WINLISPSRC)
# all windowing-system-dependent .cpp (for dependencies and such)
WINCXXSRC = $(WINQTSRC) $(WINBESRC)
--- /dev/null Wed Apr 10 03:16:35 2002
+++ nethack/win/lisp/ChangeLog Fri Mar 22 06:00:35 2002
@@ -0,0 +1,250 @@
+2002-02-16 Shawn Betts <[email protected]>
+
+ * winlisp.c (read_string): take a pointer to a string as the
+ second argument. All callers updated. Rewritten to dynamically
+ resize the string in order to read an entire line.
+ (read_command): free the string returned from read_string
+ (lisp_askname): likewise
+ (lisp_display_nhwindow): likewise
+ (lisp_delay_output): likewise
+ (lisp_yn_function): likewise
+
+2002-02-14 Shawn Betts <[email protected]>
+
+ * winlisp.c (lisp_print_glyph): Handle warning glyphs.
+
+2002-01-27 Ryan C Yeske <[email protected]>
+
+ * winlisp.c (generate_status_line): Send flag values
+ individually. Always send values for all attributes.
+
+2002-01-21 Ryan C Yeske <[email protected]>
+
+ * winlisp.c (lisp_add_menu): Add tile argument.
+
+2002-01-22 shawn <[email protected]>
+
+ * winlisp.c (lisp_player_selection): use the existing menu system
+ to select a player.
+ (lisp_menu_item_t): add a new member, accelerator.
+ (lisp_current_accelerator): new static global.
+ (lisp_add_menu): pick our own selector when ch is 0.
+ (lisp_start_menu): reset lisp_current_accelerator to 'a'.
+ (lisp_add_menu): remove the identifier argument to the lisp_cmd
+ "add_menu".
+ (lisp_get_menu_identifier): first argument is now a char.
+
+2002-01-20 Ryan C Yeske <[email protected]>
+
+ * winlisp.c (cmd_index): Add remaining functions.
+
+2002-01-16 Ryan C Yeske <[email protected]>
+
+ * winlisp.c (lisp_exit_nhwindows): Don't wait for a dummy return
+ value.
+ (lisp_destroy_nhwindow): Don't destroy the status, message or map
+ windows.
+
+2002-01-15 Ryan C Yeske <[email protected]>
+
+ * winlisp.c (lisp_exit_nhwindows): Don't wait for a dummy return
+ value.
+
+2002-01-10 shawn <[email protected]>
+
+ * winlisp.c (win_lisp_init): new function
+
+2002-01-09 Ryan C Yeske <[email protected]>
+
+ * winlisp.c (cmd_index): Add redraw command.
+ (C): New macro.
+
+2002-01-01 shawn <[email protected]>
+
+ * winlisp.c (winid_list): new static global
+ (winid_list_len): likewise
+ (winid_list_max): likewise
+ (find_empty_cell): new function
+ (winid_is_taken): likewise
+ (add_winid): likewise
+ (get_unique_winid): likewise
+ (return_winid): likewise
+ (init_winid_list): likewise
+
+2001-12-20 shawn <[email protected]>
+
+ * winlisp.c (read_command): return the command count as a string.
+ (num_digits): remove function
+ (power_of_ten): likewise
+ (lisp_nhgetch): command count works.
+ (enc_stat): extern reference
+ (hunger_stat): new constant
+ (generate_status_line): new function
+ (lisp_putstr): use generate_status_line to create the status line
+ call.
+
+2001-12-19 shawn <[email protected]>
+
+ * winlisp.c: add extern declaration for glyph2tile and
+ total_tiles_used.
+ (lisp_print_glyph): pass the glyph's graphics tile index as an argument.
+
+2001-12-02 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_cmd, lisp_list, lisp_t, lisp_nil, lisp_literal)
+ (lisp_cons, lisp_int, lisp_string): Update macros. Update all api
+ functions to use these macros.
+ (read_int, read_string, read_command): New functions. Update all
+ api functions to use these functions.
+ (lisp_create_nhwindow): Send specific window creation commands.
+ (lisp_cliparound): Comment out body.
+
+2001-10-23 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_nhgetch): Don't silently loop on invalid
+ commands, send back a warning.
+ (lisp_yn_function): Make sure special handling is done for all
+ direction questions. Include prompt in call to
+ nethack-api-ask-direction. Include up, down and self directions.
+ If no default is set for a direction question, return space.
+
+2001-10-19 shawn <[email protected]>
+
+ * winlisp.c (lisp_init_nhwindows): turn on showexp and time flags.
+
+2001-10-17 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_display_nhwindow): Wait for a string if we are
+ blocking.
+
+2001-07-19 shawn <[email protected]>
+
+ * winlisp.c (lisp_player_selection): terminate if we read a -1 as
+ a selection.
+
+2001-07-16 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_delay_output): expect a return value from the
+ client.
+
+2001-07-14 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_add_menu): Quote the attribute.
+ (lisp_outrip): Add a newline to output.
+
+2001-07-06 shawn <[email protected]>
+
+ * winlisp.c (num_digits): new function
+ (power_of_ten): likewise
+ (lisp_nhgetch): handles repeated commands.
+
+2001-07-05 shawn <[email protected]>
+
+ * winlisp.c (WINLISP_VOID_RETVAL): flushes stdout
+
+2001-07-04 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_add_menu): Convert printf to lisp_* macros,
+ fixing a string quote bug.
+
+2001-06-28 shawn <[email protected]>
+
+ * winlisp.c (zap_color): new define
+ (cmap_color): likewise
+ (obj_color): likewise
+ (mon_color): likewise
+ (invis_color): likewise
+ (pet_color): likewise
+ (lisp_print_glyph): export the color. export the ascii character
+ as a number.
+
+2001-06-27 shawn <[email protected]>
+
+ * winlisp.c: fix a typo cmd_index
+ (lisp_yn_function): pass characters as numbers instead of ascii
+ characters. specially handle the "In what direction?" question.
+ (lisp_outrip): prints a properly formed lisp expression.
+
+2001-06-21 Shawn Betts <[email protected]>
+
+ * winlisp.c (lisp_add_menu): items that are not selectable are
+ sent with an identifier of -1.
+ (lisp_select_menu): handle failed memory
+ allocation.
+
+2001-05-06 shawn <[email protected]>
+
+ * winlisp.c (LINESIZ): new define
+ (lisp_menu_item_t): new struct
+ (lisp_menu_item_list): new static global
+ (lisp_menu_list_size): likewise
+ (lisp_menu_list_num): likewise
+ (cmd_index): fixed ddrop entry
+ (read_int): new function
+ (lisp_player_selection): use read_int
+ (lisp_askname): read the entire line to a string and parse data
+ from it.
+ (lisp_nhgetch): likewise
+ (lisp_create_nhwindow): likewise
+ (lisp_getlin): likewise
+ (lisp_yn_function): likewise
+ (lisp_start_menu): set lisp_menu_list_num to 0
+ (lisp_add_menu): add an entry to lisp_menu_item_list
+ (lisp_add_menu): pass the item's ID to the client instead of the
+ actual identifier.
+ (lisp_get_menu_identifier): new function
+ (lisp_select_menu): parse the list of selected menu items
+ (lisp_print_glyph): escape backslashes in output
+
+2000-10-01 Ryan Yeske <[email protected]>
+
+ * winlisp.c (cmd_index): renamed "ddoremarm" to "remarm" and
+ "ddoinv" to "inv".
+
+2000-09-25 Shawn <[email protected]>
+
+ * winlisp.c: Added more key commands.
+ (lisp_player_selection): honours default player selections as
+ specified in the nethackrc file.
+
+2000-09-22 Shawn <[email protected]>
+
+ * winlisp.c (lisp_nhgetch): changed while loop stop condition.
+
+2000-09-19 Ryan yeske <[email protected]>
+
+ * winlisp.c (lisp_nh_getch): renamed from lisp_nh_getcmd() since
+ this is really called by the core when nethack wants a key.
+ (cmd_index): added gowest, gosouth, gonorth, goeast.
+
+2000-09-12 shawn <[email protected]>
+
+ * winlisp.c (lisp_nh_poskey): Added code to read in an x,y,mod
+ combination instead of calling lisp_nhgetcmd. Currently commented
+ out until the lisp side catches up. added cmd_index structure to
+ translate incoming command strings to extended commands or
+ keystrokes. Changed lisp_nhgetch to lisp_nhgetcmd and changed the
+ lisp command it calls to 'nethack-get-command'.
+
+2000-09-11 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_cmd, lisp_close_cmd, lisp_open, lisp_close,
+ lisp_quote, lisp_int, lisp_string, lisp_dot): created macros.
+
+2000-09-10 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_outrip): added closing paren.
+
+2000-08-21 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_nhgetch): change ch type to int from char.
+
+2000-08-20 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_player_selection): role/race/gender/alignment
+ selection now sends (nethack-apix-choose-X ALIST) instead of
+ simply an alist.
+ (lisp_update_inventory):
+ s/nethack-api-updated-inventory/nethack-api-update-inventory/
+ (WINLISP_VOID_RETVAL): added macro, called for every void
+ function.
--- /dev/null Wed Apr 10 03:16:35 2002
+++ nethack/win/lisp/TODO Fri Mar 22 06:00:35 2002
@@ -0,0 +1,55 @@
+-*- outline -*-
+
+This is a list of things I think need to be done before release. Add
+to it and subtract from it.
+
+* high priority
+** finish up the cooked status window stuff
+
+* low priority
+** tiles under xemacs
+
+** scrolling the map should happen *before* you step across the edge
+ C-l now works, so you can manually recenter
+
+** turning on DEC graphics (for example) breaks things (invalid characters)
+We need to hardcode/override some of the preferences.
+
+** indicate/track the menu state
+;; FIXME: we should somehow track when a menu is active, so if the
+;; window configuration gets mixed up while a menu is active, the
+;; user knows this and can easily continue working in a menu and not
+;; be confused when keystokes in the map buffer arent getting any
+;; response.
+
+** design a clean way to customize the printing
+ (how and where (ie modeline)).
+
+* lower priority
+** make RET or SPC toggle menu entries that the point is on
+we have too many potential bindings for these keys. what exactly
+should the defaults be?
+
+** print a message in the echo area describing how to dismiss a popup
+
+** nethack options should be respected where possible
+in particular the color boolean
+
+** there should be some indication of whether or not a menu
+is pick-one or pick-any or pick-none. This is not shown in any other
+port however.
+
+** the menu that never goes away is actually a dedicated inventory window.
+try to bury it if possible after submitting it, otherwise its always
+the next buffer in the list, so switching away from the map lands you
+there. at best, erase its contents so its not quite so confusing.
+perhaps it should be a hidden buffer?
+
+* finished, sorta?
+** make all the variables customizable through M-x customize
+most of these are done. do the rest of them.
+
+** window configuration stuff should be customizable and good
+something like what gnus has. or maybe something else.
+
+I like what we have now, I think we can call this done.
--- /dev/null Wed Apr 10 03:16:35 2002
+++ nethack/win/lisp/winlisp.c Fri Mar 22 06:00:35 2002
@@ -0,0 +1,1842 @@
+/* Copyright (c) Shawn Betts, Ryan Yeske, 2001 */
+/* NetHack may be freely redistributed. See license for details. */
+
+/*
+ * "Main" file for the lisp/emacs window-port. This contains most of
+ * the interface routines. Please see doc/window.doc for an
+ * description of the window interface.
+ */
+
+#ifdef MSDOS /* from compiler */
+#define SHORT_FILENAMES
+#endif
+
+#include "hack.h"
+#include "winlisp.h"
+#include "func_tab.h"
+
+#include "dlb.h"
+#ifdef SHORT_FILENAMES
+#include "patchlev.h"
+#else
+#include "patchlevel.h"
+#endif
+
+#define CMD_KEY 0
+#define CMD_EXT 1
+
+/* from tile.c */
+extern short glyph2tile[];
+extern int total_tiles_used;
+
+typedef struct
+{
+ anything identifier;
+ char accelerator;
+} lisp_menu_item_t;
+
+/* An iterator for assigning accelerator keys. */
+static char lisp_current_accelerator;
+
+/* Helper structures to map menu id's to nethack anything's */
+static lisp_menu_item_t lisp_menu_item_list[1000];
+static int lisp_menu_list_size = 1000;
+static int lisp_menu_list_num;
+
+extern char *enc_stat[];
+const char *hunger_stat[] = {
+ "Satiated",
+ "",
+ "Hungry",
+ "Weak",
+ "Fainting",
+ "Fainted",
+ "Starved"
+};
+
+typedef struct
+{
+ char *name;
+ int type;
+ int cmd; /* The command (a keystroke) */
+}cmd_index_t;
+
+#ifndef C
+#define C(c) (0x1f & (c))
+#endif
+
+cmd_index_t cmd_index[] = { {"gowest", CMD_KEY, 'h'},
+ {"gowestontop", CMD_KEY, 'H'},
+ {"gowestnear", CMD_KEY, C('h')},
+
+ {"gosouth", CMD_KEY, 'j'},
+ {"gosouthontop", CMD_KEY, 'J'},
+ {"gosouthnear", CMD_KEY, C('j')},
+
+ {"gonorth", CMD_KEY, 'k'},
+ {"gonorthontop", CMD_KEY, 'K'},
+ {"gonorthnear", CMD_KEY, C('k')},
+
+ {"goeast", CMD_KEY, 'l'},
+ {"goeastontop", CMD_KEY, 'L'},
+ {"goeastnear", CMD_KEY, C('l')},
+
+ {"gonorthwest", CMD_KEY, 'y'},
+ {"gonorthwestontop", CMD_KEY, 'Y'},
+ {"gonorthwestnear", CMD_KEY, C('y')},
+
+ {"gonortheast", CMD_KEY, 'u'},
+ {"gonortheastontop", CMD_KEY, 'U'},
+ {"gonortheastnear", CMD_KEY, C('u')},
+
+ {"gosouthwest", CMD_KEY, 'b'},
+ {"gosouthwestontop", CMD_KEY, 'B'},
+ {"gosouthwestnear", CMD_KEY, C('b')},
+
+ {"gosoutheast", CMD_KEY, 'n'},
+ {"gosoutheastontop", CMD_KEY, 'N'},
+ {"gosoutheastnear", CMD_KEY, C('n')},
+
+ {"idtrap", CMD_KEY, '^'},
+ {"apply", CMD_KEY, 'a'},
+ {"remarm", CMD_KEY, 'A'},
+ {"close", CMD_KEY, 'c'},
+ {"drop", CMD_KEY, 'd'},
+
+ {"ddrop", CMD_KEY, 'D'},
+ {"eat", CMD_KEY, 'e'},
+ {"engrave", CMD_KEY, 'E'},
+ {"fire", CMD_KEY, 'f'},
+ {"inv", CMD_KEY, 'i'},
+
+ {"typeinv", CMD_KEY, 'I'},
+ {"open", CMD_KEY, 'o'},
+ {"set", CMD_KEY, 'O'},
+ {"pay", CMD_KEY, 'p'},
+ {"puton", CMD_KEY, 'P'},
+
+ {"drink", CMD_KEY, 'q'},
+ {"wieldquiver", CMD_KEY, 'Q'},
+ {"read", CMD_KEY, 'r'},
+ {"remring", CMD_KEY, 'R'},
+ {"search", CMD_KEY, 's'},
+
+ {"save", CMD_KEY, 'S'},
+ {"throw", CMD_KEY, 't'},
+ {"takeoff", CMD_KEY, 'T'},
+ {"simpleversion", CMD_KEY, 'v'},
+ {"history", CMD_KEY, 'V'},
+
+ {"wield", CMD_KEY, 'w'},
+ {"wear", CMD_KEY, 'W'},
+ {"swapweapon", CMD_KEY, 'x'},
+ {"enter_explore_mode", CMD_KEY, 'X'},
+ {"zap", CMD_KEY, 'z'},
+
+ {"cast", CMD_KEY, 'Z'},
+ {"up", CMD_KEY, '<'},
+ {"down", CMD_KEY, '>'},
+ {"whatis", CMD_KEY, '/'},
+ {"help", CMD_KEY, '?'},
+
+ {"whatdoes", CMD_KEY, '&'},
+ {"sh", CMD_KEY, '!'},
+ {"discovered", CMD_KEY, '\\'},
+ {"null", CMD_KEY, '.'},
+ {"look", CMD_KEY, ':'},
+
+ {"quickwhatis", CMD_KEY, ';'},
+ {"pickup", CMD_KEY, ','},
+ {"togglepickup", CMD_KEY, '@'},
+ {"prinuse", CMD_KEY, '*'},
+ {"countgold", CMD_KEY, '$'},
+
+ {"kick", CMD_KEY, C('d')},
+ {"listspells", CMD_KEY, '+'},
+ {"redraw", CMD_KEY, C('r')},
+ {"teleport", CMD_KEY, C('t')},
+ {"callmon", CMD_KEY, 'C'},
+ {"fight", CMD_KEY, 'F'},
+ {"movenear", CMD_KEY, 'g'},
+ {"move", CMD_KEY, 'G'},
+ {"movenopickuporfight", CMD_KEY, 'm'},
+ {"movenopickup", CMD_KEY, 'M'},
+ {"showweapon", CMD_KEY, ')'},
+ {"showarmor", CMD_KEY, '['},
+ {"showrings", CMD_KEY, '='},
+ {"showamulet", CMD_KEY, '"'},
+ {"showtool", CMD_KEY, '('},
+ {"attributes", CMD_KEY, C('x')},
+#ifdef REDO
+ {"again", CMD_KEY, DOAGAIN},
+#endif /* REDO */
+
+ /* wizard commands */
+ {"wiz_detect", CMD_KEY, C('e')},
+ {"wiz_map", CMD_KEY, C('f')},
+ {"wiz_genesis", CMD_KEY, C('g')},
+ {"wiz_identify", CMD_KEY, C('i')},
+ {"wiz_where", CMD_KEY, C('o')},
+ {"wiz_level_tele", CMD_KEY, C('v')},
+ {"wiz_wish", CMD_KEY, C('w')},
+
+ /* wizard extended commands */
+#ifdef WIZARD
+ {"light sources", CMD_EXT, 0},
+ {"seenv", CMD_EXT, 0},
+ {"stats", CMD_EXT, 0},
+ {"timeout", CMD_EXT, 0},
+ {"vision", CMD_EXT, 0},
+#ifdef DEBUG
+ {"wizdebug", CMD_EXT, 0},
+#endif /* DEBUG */
+ {"wmode", CMD_EXT, 0},
+#endif /* WIZARD */
+ {"pray", CMD_EXT, 0},
+ {"adjust", CMD_EXT, 0},
+ {"chat", CMD_EXT, 0},
+ {"conduct", CMD_EXT, 0},
+ {"dip", CMD_EXT, 0},
+
+ {"enhance", CMD_EXT, 0},
+ {"force", CMD_EXT, 0},
+ {"invoke", CMD_EXT, 0},
+ {"jump", CMD_EXT, 0},
+ {"loot", CMD_EXT, 0},
+
+ {"monster", CMD_EXT, 0},
+ {"name", CMD_EXT, 0},
+ {"offer", CMD_EXT, 0},
+ {"quit", CMD_EXT, 0},
+ {"ride", CMD_EXT, 0},
+
+ {"rub", CMD_EXT, 0},
+ {"sit", CMD_EXT, 0},
+ {"turn", CMD_EXT, 0},
+ {"twoweapon", CMD_EXT, 0},
+ {"untrap", CMD_EXT, 0},
+
+ {"version", CMD_EXT, 0},
+ {"wipe", CMD_EXT, 0},
+
+ {0, CMD_KEY, '\0'} };
+
+/* This variable is set when the user has selected an extended command. */
+static int extended_cmd_id;
+
+/* Interface definition, for windows.c */
+struct window_procs lisp_procs = {
+ "lisp",
+ lisp_init_nhwindows,
+ lisp_player_selection,
+ lisp_askname,
+ lisp_get_nh_event,
+ lisp_exit_nhwindows,
+ lisp_suspend_nhwindows,
+ lisp_resume_nhwindows,
+ lisp_create_nhwindow,
+ lisp_clear_nhwindow,
+ lisp_display_nhwindow,
+ lisp_destroy_nhwindow,
+ lisp_curs,
+ lisp_putstr,
+ lisp_display_file,
+ lisp_start_menu,
+ lisp_add_menu,
+ lisp_end_menu,
+ lisp_select_menu,
+ genl_message_menu,
+ lisp_update_inventory,
+ lisp_mark_synch,
+ lisp_wait_synch,
+#ifdef CLIPPING
+ lisp_cliparound,
+#endif
+#ifdef POSITIONBAR
+ lisp_update_positionbar,
+#endif
+ lisp_print_glyph,
+ lisp_raw_print,
+ lisp_raw_print_bold,
+ lisp_nhgetch,
+ lisp_nh_poskey,
+ lisp_nhbell,
+ lisp_doprev_message,
+ lisp_yn_function,
+ lisp_getlin,
+ lisp_get_ext_cmd,
+ lisp_number_pad,
+ lisp_delay_output,
+#ifdef CHANGE_COLOR /* the Mac uses a palette device */
+ donull,
+ donull,
+#endif
+ /* other defs that really should go away (they're tty specific) */
+ lisp_start_screen,
+ lisp_end_screen,
+ lisp_outrip
+};
+
+/* macros for printing lisp output */
+#define lisp_cmd(s,body) \
+ do \
+ { \
+ printf("(nethack-api-%s ",s); \
+ body; \
+ printf(")\n"); \
+ } \
+ while (0)
+/* #define lisp_cmd0(s) printf ("(nethack-api-%s)\n", s) */
+#define lisp_list(body) \
+ do \
+ { \
+ printf("("); \
+ body; \
+ printf(") "); \
+ } \
+ while (0)
+
+#define lisp_open printf("(")
+#define lisp_close printf(") ")
+#define lisp_quote printf("'")
+#define lisp_dot printf(". ")
+#define lisp_t printf("t ")
+#define lisp_nil printf("nil ")
+#define lisp_literal(x) \
+ do \
+ { \
+ lisp_quote; \
+ printf ("%s ", x); \
+ } \
+ while (0)
+#define lisp_cons(x,y) \
+ do \
+ { \
+ lisp_open; \
+ x; \
+ lisp_dot; \
+ y; \
+ lisp_close; \
+ } \
+ while (0)
+#define lisp_int(i) printf("%d ",i)
+#define lisp_string(s) \
+ do \
+ { \
+ int nhi; \
+ printf ("\""); \
+ if (s) \
+ for (nhi=0;nhi<strlen(s);nhi++) \
+ { \
+ if (s[nhi] == 34) putchar('\\'); \
+ putchar(s[nhi]); \
+ } \
+ printf("\" "); \
+ } \
+ while (0)
+
+static const char*
+attr_to_string(attr)
+ int attr;
+{
+ switch (attr)
+ {
+ case ATR_NONE:
+ return "atr-none";
+ case ATR_ULINE:
+ return "atr-uline";
+ case ATR_BOLD:
+ return "atr-bold";
+ case ATR_BLINK:
+ return "atr-blink";
+ case ATR_INVERSE:
+ return "atr-inverse";
+ default:
+ /* Should never happen. */
+ impossible ("Invalid attribute code.");
+ exit (EXIT_FAILURE);
+ break;
+ }
+}
+
+static const char*
+wintype_to_string(type)
+ int type;
+{
+ switch (type)
+ {
+ case NHW_MAP:
+ return "nhw-map";
+ case NHW_MESSAGE:
+ return "nhw-message";
+ case NHW_STATUS:
+ return "nhw-status";
+ case NHW_MENU:
+ return "nhw-menu";
+ case NHW_TEXT:
+ return "nhw-text";
+ default:
+ fprintf (stderr, "Invalid window code\n");
+ exit (EXIT_FAILURE);
+ break;
+ }
+}
+
+static const char*
+how_to_string (how)
+ int how;
+{
+ switch (how)
+ {
+ case PICK_NONE:
+ return "pick-none";
+ case PICK_ONE:
+ return "pick-one";
+ case PICK_ANY:
+ return "pick-any";
+ default:
+ impossible ("Invalid how value %d", how);
+ }
+}
+
+static int
+read_int (prompt, i)
+ const char* prompt;
+ int *i;
+{
+ char line[BUFSZ];
+ int rv;
+ printf ("%s> ", prompt);
+ fgets (line, BUFSZ, stdin);
+ rv = sscanf (line, "%d", i);
+ if (rv != 1) *i = -1;
+ return rv;
+}
+
+static int
+read_string (prompt, str)
+ const char* prompt;
+ char **str;
+{
+ char* rv;
+ int len;
+ int size;
+ char tmp[BUFSZ];
+
+ len = 0;
+ size = BUFSZ * 2;
+ *str = malloc (size);
+ (*str)[0] = '\0';
+
+ printf ("%s> ", prompt);
+
+ do
+ {
+ /* Read the string */
+ rv = fgets (tmp, BUFSZ, stdin);
+ if (rv == NULL)
+ break;
+
+ len += strlen (tmp);
+ if (len >= size - 1)
+ {
+ size *= 2;
+ *str = realloc (*str, size);
+ if (*str == NULL)
+ panic ("Memory allocation failure; cannot get %u bytes", size);
+ }
+ strcat (*str, tmp);
+ } while (tmp[strlen (tmp) - 1] != '\n');
+
+ /* Did we read a string or error out? */
+ if (rv == NULL)
+ {
+ free (*str);
+ return -1;
+ }
+ else
+ {
+ /* chop the newline */
+ (*str) [strlen (*str) - 1] = '\0';
+ return 0;
+ }
+}
+
+
+static int
+read_command (prompt, cmd, count)
+ const char *prompt;
+ char *cmd;
+ char *count;
+{
+ char *buf;
+ int rv;
+ cmd[0] = '\0';
+ *count = 0;
+ if (read_string (prompt, &buf) == -1)
+ return -1;
+ rv = sscanf (buf, "%s %s", cmd, count);
+ free (buf);
+ if (rv != 2) *count = 0;
+ return rv;
+}
+
+void
+bail(mesg)
+ const char *mesg;
+{
+ clearlocks ();
+ lisp_exit_nhwindows (mesg);
+ terminate (EXIT_SUCCESS);
+ /*NOTREACHED*/
+}
+
+void
+win_lisp_init ()
+{
+ /* Code to be executed on startup. */
+}
+
+void
+lisp_player_selection ()
+{
+ int i, k, n;