gevauxold.sl 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. % GEVAUX.SL.21 28 March 83
  2. % Auxiliary functions for PSL version of GEV, HP 9836 version.
  3. % GSN 07 March 83
  4. % Interlisp Substring function.
  5. (de substring (string first last)
  6. (cond ((not (stringp string)) (setq string (gevstringify string))))
  7. (cond ((minusp first)
  8. (setq first (add1 (plus (add1 (size string)) first)))))
  9. (cond ((minusp last)
  10. (setq last (add1 (plus (add1 (size string)) last)))))
  11. (subseq string (sub1 first) last) )
  12. % Make a string out of anything
  13. (de gevstringify (x)
  14. (cond ((stringp x) x)
  15. (t (bldmsg "%p" x))))
  16. % Concatenate an arbitrary number of items
  17. (de concatn (l)
  18. (cond ((null l) "")
  19. ((null (cdr l)) (gevstringify (car l)))
  20. (t (concat (gevstringify (car l)) (concatn (cdr l))))))
  21. (de concatln (l)
  22. (cond ((null l) "")
  23. ((null (cdr l)) (gevstringify (eval (car l))))
  24. (t (concat (gevstringify (eval (car l))) (concatln (cdr l))))))
  25. (df concatl (concatlarg) (concatln concatlarg))
  26. (de gevconcat (l) (concatn l))
  27. (de dreverse (l) (reversip l))
  28. (de mkatom (s) (intern s))
  29. (de gevputd (fn form)
  30. (put fn 'gloriginalexpr (cons 'lambda (cdr form)))
  31. (put fn 'glcompiled nil)
  32. (remd fn)
  33. (putd fn 'macro '(lambda (gldgform) (glhook gldgform))))
  34. % Apply a function to arguments, Glisp-compiling first if needed.
  35. (de gevapply (fn args)
  36. (cond ((and (atom fn)
  37. (or (null (get fn 'glcompiled))
  38. (not (eq (getddd fn) (get fn 'glcompiled)))))
  39. (glcc fn)
  40. (apply fn args))
  41. (t (apply fn args))))
  42. % TTY input replacement for mouse operations.
  43. % GSN 07 March 83
  44. (dg gevmouseloop ()
  45. (prog (input n tmp)
  46. lp (prin2 "GEV: ")
  47. (input _ (read))
  48. (if input='t and (n _ (read))
  49. is numeric then (gevnselect n nil)
  50. (go lp)
  51. elseif input is numeric
  52. then (gevnselect input t) (go lp)
  53. elseif (tmp _ (assoc input
  54. '((q quit)(pop pop)(e edit)(pr program)
  55. (p prop)(a adj)(i isa)(m msg))))
  56. then (gevcommandfn (cadr tmp))
  57. (if (cadr tmp)='quit or ~gevactiveflg
  58. then (return nil)
  59. else (go lp)))
  60. err (prin2 "? Quit POP Edit PRogram Prop Adj Isa Msg")
  61. (terpri)
  62. (go lp) ))
  63. % GEVCRT.SL.4 28 March 83
  64. % derived from <NOVAK>GEVCRT.PSL.1 20-Mar-83 12:41:24
  65. (GLOBAL '(GEVMENUWINDOW GEVSAVEESC GEVSAVEGLQUIET GEVSAVEGCGAG GEVMOUSEAREA))
  66. (DE GEVENTER NIL
  67. (setq gevsavegcgag !*GC)
  68. (setq !*GC nil)
  69. (SETQ GEVSAVEGLQUIET GLQUIETFLG)
  70. (SETQ GLQUIETFLG T)
  71. (window-init nil))
  72. (DE GEVEXIT NIL
  73. (setq !*GC gevsavegcgag)
  74. (SETQ GLQUIETFLG GEVSAVEGLQUIET)
  75. (window-term nil))
  76. % edited: 19-Mar-83 22:41
  77. (DG GEVINITEDITWINDOW NIL
  78. (PROG NIL (GEVWINDOW _ (A WINDOW WITH START =
  79. (A VECTOR WITH X = 0 Y = 0)
  80. SIZE =
  81. (A VECTOR WITH X = 300 Y = 500)
  82. TITLE = "GEV Structure Inspector"))
  83. (RETURN GEVWINDOW)))
  84. % edited: 19-Mar-83 21:42
  85. % Select the Nth item in the display and push down to zoom in on it.
  86. (DG GEVNSELECT (N:INTEGER FLAG:BOOLEAN)
  87. (PROG (L TOP SUBLIST GROUP ITEM)
  88. (GROUP _ 0)
  89. (TOP _ GEVEDITCHAIN:TOPFRAME)
  90. LP
  91. (IF ~TOP THEN (RETURN NIL))
  92. (SUBLIST -_ TOP)
  93. (GROUP _+ 1)
  94. (IF GROUP=1 AND (L _ (LENGTH SUBLIST))
  95. >=N THEN (ITEM _ (CAR (PNth SUBLIST (L + 1 - N))))
  96. ELSEIF ~ (ITEM _ (GEVNTHITEM SUBLIST))
  97. THEN
  98. (GO LP))
  99. (IF ITEM:NODETYPE <= '(STRUCTURE SUBTREE LISTOF)
  100. THEN
  101. (RETURN NIL)
  102. ELSE
  103. (RETURN (GEVITEMEVENTFN ITEM GROUP FLAG)))))
  104. % edited: 19-Mar-83 22:15
  105. % Find the Nth item in a tree structure of items.
  106. (DG GEVNTHITEM (L: (LISTOF GSEITEM))
  107. (GLOBAL N:INTEGER)(PROG (TMP RES)
  108. (IF N<=0 THEN (ERROR 0 NIL)
  109. ELSEIF ~L THEN (RETURN NIL)
  110. ELSEIF N=1 THEN (RETURN (CAR L))
  111. ELSE
  112. (N _- 1)
  113. (TMP -_ L)
  114. (IF TMP:NODETYPE <= '(STRUCTURE SUBTREE LISTOF)
  115. AND
  116. (RES _ (GEVNTHITEM TMP:SUBVALUES))
  117. THEN
  118. (RETURN RES)
  119. ELSE
  120. (RETURN (GEVNTHITEM L))))))
  121. (GLISPCONSTANTS
  122. (GEVNUMBERCHARS 2 INTEGER)
  123. (GEVNUMBERPOS 1 INTEGER)
  124. )
  125. (SETQ GEVMENUWINDOW NIL)
  126. (SETQ GEVMOUSEAREA NIL)