-
Notifications
You must be signed in to change notification settings - Fork 0
/
ese-007e0.patch
2369 lines (2357 loc) · 61.7 KB
/
ese-007e0.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.
diff -u slashem-0.0.7E0/include/config.h slashem/include/config.h
--- slashem-0.0.7E0/include/config.h Tue Apr 1 02:28:17 2003
+++ slashem/include/config.h Wed Apr 9 14:56:46 2003
@@ -50,7 +50,7 @@
* 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 KDE */ /* KDE Interface */
@@ -60,12 +60,13 @@
/* #define MSWIN_GRAPHICS */ /* Windows NT, CE, Graphics */
/* #define GL_GRAPHICS */ /* OpenGL graphics */
/* #define SDL_GRAPHICS */ /* Software SDL graphics */
+#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, gtk, proxy, GL, SDL
+ * tty, X11, mac, amii, BeOS, Qt, Gem, Gnome, gtk, proxy, GL, SDL, lisp
*/
/* MAC also means MAC windows */
@@ -170,6 +171,12 @@
# if defined(VANILLA_GLHACK)
# define compress nh_compress
# define uncompress nh_uncompress
+# endif
+#endif
+
+#ifdef LISP_GRAPHICS
+# ifndef DEFAULT_WINDOW_SYS
+# define DEFAULT_WINDOW_SYS "lisp"
# endif
#endif
diff -u /dev/null slashem/include/winlisp.h
--- /dev/null Thu Jan 31 23:52:42 2002
+++ slashem/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 */
diff -u slashem-0.0.7E0/src/windows.c slashem/src/windows.c
--- slashem-0.0.7E0/src/windows.c Tue Apr 1 02:28:18 2003
+++ slashem/src/windows.c Wed Apr 9 14:58:56 2003
@@ -60,6 +60,11 @@
#ifdef MSWIN_GRAPHICS
extern struct window_procs mswin_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));
@@ -112,6 +117,9 @@
#endif
#ifdef MSWIN_GRAPHICS
{ &mswin_procs, 0 },
+#endif
+#ifdef LISP_GRAPHICS
+ { &lisp_procs, win_lisp_init },
#endif
{ 0, 0 } /* must be last */
};
diff -u slashem-0.0.7E0/sys/unix/Makefile.src slashem/sys/unix/Makefile.src
--- slashem-0.0.7E0/sys/unix/Makefile.src Tue Apr 1 02:28:18 2003
+++ slashem/sys/unix/Makefile.src Wed Apr 9 16:47:05 2003
@@ -279,10 +279,15 @@
gl_rendu.o gl_role.o gl_softw.o gl_stat.o \
gl_text.o gl_tile.o gl_unit.o gl_win.o tile.o
SDLGL_CFLAGS = `sdl-config --cflags`
+#
+# Files for the lisp port
+WINLISPSRC = ../win/lisp/winlisp.c tile.c
+WINLISPOBJ = winlisp.o tile.o
+
# Use these declarations if you only want to support the TTY windowing system
-WINSRC = $(WINTTYSRC)
-WINOBJ = $(WINTTYOBJ)
+# WINSRC = $(WINTTYSRC)
+# WINOBJ = $(WINTTYOBJ)
# Use these declarations if you want to support the X11 windowing system
# WINSRC = $(WINTTYSRC) $(WINX11SRC)
# WINOBJ = $(WINTTYOBJ) $(WINX11OBJ)
@@ -305,6 +310,9 @@
# Use these declarations if you want to support external windowing systems
# WINSRC = $(WINTTYSRC) $(WINPROXYSRC) $(PROXYUTLSRC) $(PROXYCOMSRC)
# WINOBJ = $(WINTTYOBJ) $(WINPROXYOBJ) $(PROXYUTLOBJ) $(PROXYCOMOBJ)
+# Use these declarations if you want to only support the lisp windowing system
+WINSRC = $(WINLISPSRC)
+WINOBJ = $(WINLISPOBJ)
#
# You must also change the definition of WINLIB (below) to match these
@@ -354,9 +362,12 @@
#
# libraries for proxy
WINPROXYLIB =
+#
+# libraries for lisp port
+WINLISPLIB =
# Use this declaration if you only want to support the TTY windowing system
-WINLIB = $(WINTTYLIB)
+# WINLIB = $(WINTTYLIB)
# Use this declaration if you want to support the X11 windowing system
# WINLIB = $(WINTTYLIB) $(WINX11LIB)
# Use this declaration if you want to support the Qt windowing system
@@ -371,6 +382,8 @@
# WINLIB = $(WINGLLIB)
# Use this declaration if you want to support external windowing systems
# WINLIB = $(WINTTYLIB) $(WINPROXYLIB)
+# Use this declaration if you want to support the lisp windowing system
+WINLIB = $(WINLISPLIB)
# any other strange libraries your system needs (for Sysunix only -- the more
# specialized targets should already be right)
@@ -456,7 +469,7 @@
# all windowing-system-dependent .c (for dependencies and such)
WINCSRC = $(WINTTYSRC) $(WINX11SRC) $(WINGTKSRC) $(WINGNOMESRC) $(WINGEMSRC) \
$(WINPROXYSRC) $(PROXYUTLSRC) $(PROXYCLNTSRC) $(PROXYCOMSRC) \
- $(WINGLSRC) tile.c
+ $(WINGLSRC) $(WINLISPSRC) tile.c
# all windowing-system-dependent .cpp (for dependencies and such)
WINCXXSRC = $(WINQTSRC) $(WINBESRC)
@@ -941,6 +954,9 @@
../include/patchlevel.h ../include/winGL.h
$(CC) $(CFLAGS) $(SDLGL_CFLAGS) -c ../win/gl/gl_win.c
tile.o: tile.c $(HACK_H)
+winlisp.o: ../win/lisp/winlisp.c $(HACK_H) ../include/winlisp.h \
+ ../include/func_tab.h ../include/dlb.h ../include/patchlevel.h
+ $(CC) $(CFLAGS) -c ../win/lisp/winlisp.c
qt_win.o: ../win/Qt/qt_win.cpp $(HACK_H) ../include/func_tab.h \
../include/dlb.h ../include/date.h ../include/patchlevel.h \
../include/tile2x11.h ../include/qt_win.h \
diff -u slashem-0.0.7E0/util/makedefs.c slashem/util/makedefs.c
diff -u slashem-0.0.7E0/win/tty/termcap.c slashem/win/tty/termcap.c
--- slashem-0.0.7E0/win/tty/termcap.c Tue Apr 1 02:28:18 2003
+++ slashem/win/tty/termcap.c Wed Apr 9 16:46:52 2003
@@ -1161,6 +1161,11 @@
if (windowprocs.name != NULL &&
!strcmpi(windowprocs.name, "Gem")) return TRUE;
#endif
+#ifdef LISP_GRAPHICS
+ /* XXX has_color() should be added to windowprocs */
+ if (windowprocs.name != NULL &&
+ !strcmpi(windowprocs.name, "lisp")) return TRUE;
+#endif
#ifdef QT_GRAPHICS
/* XXX has_color() should be added to windowprocs */
if (windowprocs.name != NULL &&
diff -u /dev/null slashem/win/lisp/ChangeLog
--- /dev/null Thu Jan 31 23:52:42 2002
+++ slashem/win/lisp/ChangeLog Sat Mar 8 19:52:08 2003
@@ -0,0 +1,293 @@
+2002-09-19 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_cmd): nethack-api-* renamed to nhapi-*.
+
+2002-09-16 Ryan Yeske <[email protected]>
+
+ * ../tty/termcap.c (has_color): Add condition for LISP_GRAPHICS
+ which returns TRUE.
+
+2002-09-12 Ryan Yeske <[email protected]>
+
+ * winlisp.c (lisp_display_nhwindow): Add call to
+ `nethack-api-end'.
+
+ * ../../include/config.h: Default to LISP_GRAPHICS.
+
+ * ../../sys/unix/Makefile.src (WINSRC,WINOBJ,WINLIB): Set to
+ WINLISP* values.
+ (depend): Add winlisp.o dependancies.
+
+ * winlisp.c (lisp_curs): Don't send winid. Add error check.
+ (lisp_putstr): Call `nethack-api-message' or
+ `nethack-api-menu-putstr' when appropriate.
+ (lisp_nhgetch): Update error message call.
+ (lisp_create_nhwindow): Don't send winids when creating message,
+ map, or status windows.
+ (lisp_clear_nhwindow): Call clear-message or clear-map instead of
+ clear-nhwindow.
+ (lisp_display_nhwindow): Call display-menu instead of
+ display-nhwindow. Call block when handling case of blocking on
+ displaying the map window.
+ (lisp_destroy_nhwindow): Use WIN_* values instead of hardcoded
+ numbers.
+ (lisp_print_glyph): Don't send winid. Add error check for bad
+ winids.
+ (lisp_outrip): Change reference to Enethack to nethack-el.
+
+2002-04-23 Shawn <[email protected]>
+
+ * winlisp.c (lisp_player_selection): Update to use new 3.4.0
+ functionality.
+ (lisp_print_glyph): likewise
+
+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.
diff -u /dev/null slashem/win/lisp/winlisp.c
--- /dev/null Thu Jan 31 23:52:42 2002
+++ slashem/win/lisp/winlisp.c Mon Mar 10 04:05:25 2003
@@ -0,0 +1,1821 @@
+/* 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",
+ WC_COLOR|WC_HILITE_PET,
+ 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,
+ genl_preference_update,
+};
+
+/* macros for printing lisp output */
+#define lisp_cmd(s,body) \
+ do \
+ { \
+ printf("(nhapi-%s ",s); \
+ body; \
+ printf(")\n"); \
+ } \
+ while (0)
+/* #define lisp_cmd0(s) printf ("(nhapi-%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 \
+ || s[nhi] == 92) 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');