home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / EDWIN / ALLCOMS3.S < prev    next >
Encoding:
Text File  |  1993-10-24  |  11.3 KB  |  341 lines

  1. ;;;
  2. ;;;    Copyright (c) 1985 Massachusetts Institute of Technology
  3. ;;;
  4. ;;;    This material was developed by the Scheme project at the
  5. ;;;    Massachusetts Institute of Technology, Department of
  6. ;;;    Electrical Engineering and Computer Science.  Permission to
  7. ;;;    copy this software, to redistribute it, and to use it for any
  8. ;;;    purpose is granted, subject to the following restrictions and
  9. ;;;    understandings.
  10. ;;;
  11. ;;;    1. Any copy made of this software must include this copyright
  12. ;;;    notice in full.
  13. ;;;
  14. ;;;    2. Users of this software agree to make their best efforts (a)
  15. ;;;    to return to the MIT Scheme project any improvements or
  16. ;;;    extensions that they make, so that these may be included in
  17. ;;;    future releases; and (b) to inform MIT of noteworthy uses of
  18. ;;;    this software.
  19. ;;;
  20. ;;;    3.  All materials developed as a consequence of the use of
  21. ;;;    this software shall duly acknowledge such use, in accordance
  22. ;;;    with the usual standards of acknowledging credit in academic
  23. ;;;    research.
  24. ;;;
  25. ;;;    4. MIT has made no warrantee or representation that the
  26. ;;;    operation of this software will be error-free, and MIT is
  27. ;;;    under no obligation to provide any services, by way of
  28. ;;;    maintenance, update, or otherwise.
  29. ;;;
  30. ;;;    5.  In conjunction with products arising from the use of this
  31. ;;;    material, there shall be no use of the name of the
  32. ;;;    Massachusetts Institute of Technology nor of any adaptation
  33. ;;;    thereof in any advertising, promotional, or sales literature
  34. ;;;    without prior written consent from MIT in each case.
  35. ;;;
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;;
  38. ;;;     Modified by Texas Instruments Inc 8/15/85
  39. ;;;
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41.  
  42. ;;;Lisp commands
  43.  
  44. (define *current-mode-scheme?* #T)
  45.  
  46. (define ^r-lisp-insert-paren-command '())            ;3.02
  47. (define paren-mark '())                        ;3.02
  48. (define (cached-paren-mark) paren-mark)                ;3.02
  49. (define (cache-paren-mark mark) (set! paren-mark mark))        ;3.02
  50.  
  51. (define-initial-command-key ("^R Lisp Insert Paren" (argument 1))
  52.   "Insert close paren, showing matching parens"
  53. (              ;;;;(
  54.  (define-initial-key  #\) procedure)
  55.  (set! ^r-lisp-insert-paren-command procedure)            ;3.02
  56. )
  57.   (insert-chars (current-command-char) argument (current-point))
  58.   (if *current-mode-scheme?*
  59.       (if (not (char-ready? buffer-screen))
  60.           (let ((mark (if (cached-paren-mark)            ;3.02
  61.                           (backward-sexp:top (cached-paren-mark)  ;3.02
  62.                                              (group-start (current-point))
  63.                                              1)
  64.                           (backward-one-list (current-point)
  65.                                              (group-start (current-point))))))
  66.             (if mark
  67.                 (let ((string (line-string (mark-line mark))))
  68.                   (cache-paren-mark mark)            ;3.02
  69.                   (set-temp-message-status)
  70.                   (set-screen-cursor! typein-screen 0 0)
  71.                   (%substring-display string (mark-position mark) 
  72.                       (string-length string) 0 typein-screen)
  73.                   (if (window-mark-visible? (current-window) mark)
  74.                       (let ((old-point (current-point)))
  75.                         (set-current-point! mark)
  76.                         (with-reverse-attributes)
  77.                         (set-current-point! old-point))))
  78.         (beep))))))
  79.  
  80. ;;;(define %%temp (lambda () (with-reverse-attributes)))
  81.  
  82. ;;;
  83.  
  84.  
  85. ;;;
  86.  
  87. (define-initial-command-key ("^R Forward Sexp" (argument 1))
  88. "Move forward one sexp"
  89. (
  90. (define-initial-key (list meta-char (integer->char 6)) procedure) ;;; M C-F
  91. )
  92. (move-thing forward-sexp argument))
  93.  
  94. (define-initial-command-key ("^R Backward Sexp" (argument 1))
  95. "Move backward one sexp"
  96. (
  97. (define-initial-key (list meta-char (integer->char 2)) procedure) ;;; M C-B
  98. )
  99. (move-thing backward-sexp argument))
  100.  
  101. (define-initial-command-key ("^R Mark Sexp" (argument 1))
  102.   "Set mark one or more sexp from point."
  103. (
  104.  (define-initial-key (list meta-char alt-char (integer->char 3)) procedure)
  105.                                                             ;;; C-M-@
  106. )
  107.   (mark-thing forward-sexp argument))
  108.  
  109. (define-initial-command-key ("^R Kill Sexp" (argument 1))
  110.  "Kill one or more sexp forward"
  111. (
  112.  (define-initial-key (list meta-char (integer->char 11)) procedure) ;;; M C-K
  113. )
  114.  (kill-thing forward-sexp argument))
  115.  
  116. ;;;(define-initial-command-key ("^R Backward Kill sexp" (argument 1))
  117. ;;;  "Kill one or more words backwards"
  118. ;;;(
  119. ;;; (define-initial-key (list ctrl-z-char #\backspace) procedure)   ;;; C-Z backsp
  120. ;;;)
  121. ;;;  (kill-thing backward-sexp argument))
  122.  
  123. (define-initial-command-key ("^R Forward List"(argument 1))
  124.   "Move forward over one list"
  125. (
  126. (define-initial-key (list meta-char (integer->char 14)) procedure) ;; M C-N
  127. )
  128.   (move-thing forward-list argument))
  129.  
  130. (define-initial-command-key ("^R Backward List"(argument 1))
  131.   "Move backward over one list"
  132. (
  133. (define-initial-key (list meta-char (integer->char 16)) procedure) ;; M C-P
  134. )
  135.   (move-thing backward-list argument))
  136.  
  137. (define-initial-command-key ("^R Forward Down List" (argument 1))
  138.   "Move down one level of list structure, forward."
  139. (
  140. (define-initial-key (list meta-char (integer->char 4)) procedure) ;;M C-D
  141. )
  142.   (move-thing forward-down-list argument))
  143.  
  144. ;;; (define-initial-command-key ("^R Backward Down List" (argument 1))
  145. ;;;  "Move down one level of list structure, backward."
  146. ;;;(#F)
  147. ;;;  (move-thing backward-down-list argument))
  148.  
  149. ;;;(define-initial-command-key ("^R Forward Up List" (argument 1))
  150. ;;;  "Move up one level of list structure, forward."
  151. ;;;(                                                      ;;;(
  152. ;;; (define-initial-key (list ctrl-z-char #\) ) procedure)    ;;; ( C-Z )
  153. ;;;)
  154. ;;;  (move-thing forward-up-list argument))
  155.  
  156. (define-initial-command-key ("^R Backward Up List" (argument 1))
  157.   "Move up one level of list structure, backward."
  158. (
  159. (define-initial-key (list meta-char (integer->char 21)) procedure)
  160. )
  161.   (move-thing backward-up-list argument))
  162.  
  163.  
  164. ;;; New commands added
  165.  
  166. ;;; Some additional commands
  167.  
  168. ;;; File commands
  169.  
  170. (define-initial-command-key ("^R Set File Read Only" argument)
  171.   " Make file read-only, or not."
  172. (
  173.  (define-initial-key (list ctrl-x-char (integer->char 17)) procedure);;C-XC-Q
  174. )
  175.   (setup-current-buffer-read-only! argument))
  176.  
  177. (define-initial-command-key ("^R Buffer Not Modified" argument)
  178.   "Pretend that buffer has not been Modified."
  179. (
  180.  (define-initial-key (list meta-char #\~) procedure) ;; M-~
  181. )
  182.  (buffer-not-modified! (current-buffer)))
  183.  
  184.  
  185. ;;; Line Commands
  186.  
  187. (define-initial-command-key ("^R Open Line" (argument 1))
  188.   "Insert a newline at point. Cursor remains at its position."
  189. (
  190.  (define-initial-key (integer->char 15) procedure)     ;;;; C-O
  191. )
  192.  (let ((m* (mark-right-inserting (current-point))))
  193.    (insert-newlines argument )
  194.    (set-current-point! m*)))
  195.  
  196. (define-initial-command-key ("^R Set Goal Column" argument)
  197.   "Set (or flush) a permanent goal for vertical motion"
  198. (
  199.  (define-initial-key (list ctrl-x-char (integer->char 14)) procedure)
  200. )                                                  ;;; C-X C-N
  201.  (set! goal-column
  202.        (and (not argument)
  203.             (mark-column (current-point)))))
  204.  
  205. (define-initial-command-key ("^R Tab" (argument 1))
  206.   "Insert a tab character"
  207. (
  208.  (define-initial-key #\tab procedure)
  209.  (define-initial-key (integer->char 9) procedure)
  210.  (define-initial-key (list meta-char #\tab) procedure)
  211. )
  212.  (if *current-mode-scheme?* 
  213.      (lisp-indent-line (current-point))
  214.      (insert-chars #\tab argument (current-point))))
  215.  
  216. (define-initial-command-key ("^R Indent Sexp" (argument 1))
  217.   "Indent a sexp"
  218. (
  219.  (define-initial-key (list meta-char (integer->char 17)) procedure) ;;M C-Q
  220. )
  221.  (if *current-mode-scheme?* 
  222.      (lisp-indent-sexp (current-point))))
  223.  
  224. (define-initial-command-key ("^R Change Mode" argument)
  225. " Change mode to Scheme"
  226. (
  227.  (define-initial-key (list ctrl-x-char (integer->char 13)) procedure);;C-X C-M
  228. )
  229.  (set! *current-mode-scheme?* (if *current-mode-scheme?* #F #T))
  230.  (window-modeline-event! '() 'mode-changed))
  231.  
  232.  
  233. (define-initial-command-key ("^R Delete Horizontal Space" argument)
  234.   " delete all spaces and tab characters around point."
  235. (
  236.   (define-initial-key (list meta-char #\\) procedure)    ;;; M-\
  237. )
  238.   (delete-horizontal-space))
  239.  
  240. (define-initial-command-key ("^R Just One Space" argument)
  241.   " Delete all spaces and tabs around point, leaving one Space."
  242. (
  243.   (define-initial-key (list meta-char #\space) procedure) ;;; M-space
  244. )
  245.   (delete-horizontal-space)
  246.   (insert-chars #\space 1 (current-point)))
  247.  
  248. (define lisp-indent 2)
  249.  
  250. (define-initial-command-key ("^R Indent New Line" argument)
  251.   "Insert new line then indent the second line"
  252. (
  253.   (define-initial-key (integer->char 10) procedure) ;;; C-J
  254. )
  255.   (insert-newlines 1)
  256.   (if *current-mode-scheme?*
  257.       (lisp-indent-line (current-point))
  258.       (insert-chars #\tab 1 (current-point))))
  259.  
  260.  
  261. ;;; compile command
  262.  
  263. (define-initial-command-key ("^R Compile Region" argument)
  264.   " Compile the region"
  265.  (
  266.   (define-initial-key (list meta-char (integer->char 26)) procedure);;M C-Z
  267.  )
  268.   (if *current-mode-scheme?* 
  269.       (%compile-region
  270.          (make-region (current-point) (current-mark)))
  271.       (^r-bad-command argument)))
  272.  
  273. (define-initial-command-key ("^R Compile Buffer" argument)
  274.   " Compile the buffer"
  275.  (
  276.   (define-initial-key (list meta-char #\o) procedure)   ;;; M-O
  277.   (define-initial-key (list alt-char (integer->char 24)) procedure) ;;;alt O
  278.  )
  279.   (if *current-mode-scheme?* 
  280.       (%compile-region
  281.          (buffer-region (current-buffer)))
  282.       (^r-bad-command argument)))
  283.  
  284. (define-initial-command-key ("^R Compile Sexp" (argument 1))
  285.   " Compile the sexp"
  286.  (
  287.   (define-initial-key (list meta-char (integer->char 24)) procedure);;;M C-X
  288.  )
  289.   (if *current-mode-scheme?* 
  290.       (begin
  291.        (mark-thing forward-sexp argument)
  292.        (%compile-region (current-region)))
  293.       (^r-bad-command argument)))
  294.  
  295. (define (%compile-region region)
  296.   (region->file region "edwin.tmp")
  297.   (restore-console-contents)
  298.   (make-pcs-status-visible)
  299.   (reset-typein-window)
  300.   (gc)
  301.   (load "edwin.tmp")
  302.   (dos-delete "edwin.tmp")
  303.   ((fluid editor-continuation) 'OK))
  304.  
  305. (define-initial-command-key ("^R Toggle windows" argument)
  306.   " Display edwin window in upper half and scheme in the lower half"
  307.  (
  308.   (define-initial-key (list ctrl-x-char #\!) procedure)   ;;; C-X !
  309.  )
  310.   (if *split-screen-mode?*
  311.       (begin
  312.        (set! *split-screen-mode?* #F)
  313.        (move-editor-to-full)
  314.        (move-pcs-to-full)
  315.        (make-pcs-status-invisible)
  316.        (window-y-size-changed (current-window))
  317.        (update-display! (current-window))
  318.        (reset-modeline-window)
  319.        (reset-typein-window))
  320.       (begin
  321.        (set! *split-screen-mode?* #T)
  322.        (move-editor-to-upper-half)
  323.        (move-pcs-window-lower)
  324.        (window-y-size-changed (current-window))
  325.        (update-display! (current-window))
  326.        (reset-modeline-window)
  327.        (reset-typein-window)
  328.        (restore-console-contents)
  329.        (make-pcs-status-visible)
  330.        (gc))))
  331.  
  332. (define edwin-reset-windows
  333.   (lambda ()
  334.     (save-console-contents)
  335.     (make-pcs-status-visible)
  336.     (move-pcs-to-full)
  337.     (%clear-window blank-screen)
  338.     (restore-console-contents)
  339.     (gc)))
  340.  
  341.