home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Editors / Emacs / Source / lisp / eterm-low.el < prev    next >
Encoding:
Text File  |  1992-11-15  |  5.0 KB  |  151 lines

  1. ;; Low-level subroutines for NeXT "Emacs" front end
  2. ;; Copyright (C) 1990 Free Software Foundation, Inc.
  3.  
  4. ;; This file is NOT part of the standard GNU Emacs distribution.
  5.  
  6. ;; GNU Emacs is distributed in the hope that it will be useful,
  7. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  8. ;; accepts responsibility to anyone for the consequences of using it
  9. ;; or for whether it serves any particular purpose or works at all,
  10. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  11. ;; License for full details.
  12.  
  13. ;; Everyone is granted permission to copy, modify and redistribute
  14. ;; GNU Emacs, but only under the conditions described in the
  15. ;; GNU Emacs General Public License.   A copy of this license is
  16. ;; supposed to have been given to you along with GNU Emacs so you
  17. ;; can know your rights and responsibilities.  It should be in a
  18. ;; file named COPYING.  Among other things, the copyright notice
  19. ;; and this notice must be preserved on all copies.
  20.  
  21. ;;; Apr 4 '90 jgm    Ripped off of sun-fns.el
  22.  
  23. ;;(provide 'eterm-low)
  24.  
  25. (defun eterm-send-terminal-string-function (string function)
  26.   "Send a \\C-q quoted string to the terminal, then send function"
  27.   (send-string-to-terminal (concat "\C-q" string "\377" function)))
  28.  
  29. (defun eterm-change-title (title)
  30.   "Change the wm title for the gnumacs window."
  31.   (interactive "sTitle: ")
  32.   (eterm-send-terminal-string-function title "t"))
  33.  
  34. ;(defun global-set-menu (item command)
  35. ;  "Add a command to the wm menus."
  36. ;  (interactive "sMenu item: \nCCommand: ")
  37. ;  (eterm-send-terminal-string-function
  38. ;   (concat item ":\C-[x" (prin1-to-string command) "\n") "m"))
  39. ;
  40. ;(defun global-unset-menu (item)
  41. ;  "Remove a menu item from the wm menus."
  42. ;  (interactive "sMenu item: ")
  43. ;  (eterm-send-terminal-string-function item "m"))
  44. ;
  45. ;(defun add-menu-item (item binding &optional page)
  46. ;  "Add a menu item to the menus.  (obsolete)"
  47. ;  (interactive "sItem: \nsBinding: \nsPage: ")
  48. ;  (eterm-send-terminal-string-function
  49. ;   (concat page (and page ", ")
  50. ;       item (and binding (not (string= binding "")) ":") binding)
  51. ;   "m"))
  52. ;
  53. ;(defun remove-menu-item (item &optional page)
  54. ;  "Remove ITEM from the wm menus.  (obsolete)"
  55. ;  (interactive "sItem: \nsPage:")
  56. ;  (add-menu-item item "" page))
  57.  
  58. ; something to hide without using the mouse
  59. ;(defun eterm-hide-emacs ()
  60. ;  "Ask the termulator to hide this window."
  61. ;  (interactive)
  62. ;  (send-string-to-terminal "\C-z"))
  63.  
  64. ; cut buffer stuff
  65.  
  66. (defun eterm-send-region-to-cut-buffer (start end)
  67.   "   Copy the region between point and mark to the NeXT cut buffer.
  68.    This will not happen if the region contains a \\377."
  69.   (interactive "r")
  70.   (save-excursion
  71.     (goto-char start)
  72.     (if (search-forward "\377" end t)
  73.     (error "Region contains illegal character for NeXT cut buffer.")
  74.         (eterm-send-terminal-string-function
  75.      (buffer-substring start end) "c"))))
  76.  
  77. (defun eterm-send-region-to-cut-buffer-and-wipe (start end)
  78.   "  As send-region-to-cut-buffer but also kill the text."
  79.   (interactive "r")
  80.   (barf-if-buffer-read-only)
  81.   (eterm-send-region-to-cut-buffer start end)
  82.   (kill-region start end))
  83.  
  84. ;
  85. ; Event server stuff
  86. ;
  87.  
  88. (defvar eserver nil 
  89.   "The event server process.")
  90.  
  91. (defun start-event-server ()
  92.   (interactive)
  93.   (eterm-change-title (concat "Emacs version " emacs-version))
  94.   (let ((host (or (getenv "EVENT_HOST")
  95.           (error "Can't find host for event server")))
  96.     (port (or (getenv "EVENT_PORT")
  97.           (error "Can't find port for event server"))))
  98.     (setq eserver 
  99.       (open-network-stream " event-server" nil host
  100.                    (string-to-int port))))
  101.   (set-process-filter eserver 'event-filter)
  102.   (set-process-sentinel eserver 'event-sentinel)
  103.   (global-set-key "\C-x\C-@" 'eterm-mouse-handler))
  104.  
  105. (defun event-sentinel (process change)
  106.   (message (concat  "The event handler has " change)))
  107.  
  108. (defvar event-partial-output ""
  109.   "Incomplete, unprocessed output from the event server")
  110.  
  111. ;;; Modified by J. Gregory 17-Oct-91.  Save match-end before match
  112. ;;; data gets crunched.
  113. (defun event-filter (process string)
  114.   ;; Add the incoming string to what we have:
  115.   (let ((events (concat event-partial-output string)))
  116.     ;; Each event is terminated with a newline.
  117.     ;; Process events until we run out of newlines.
  118.     (while (string-match "\n" events)    ;sets match-data
  119.       (let ((next (match-end 0)))
  120.     (eval (car (read-from-string events)))
  121.     (setq events (substring events next))))
  122.     ;; Set global to be what we have not yet processed
  123.     (setq event-partial-output events)))
  124.  
  125. ; Handlers for the events that get sent to us.
  126. ;
  127. (defun event-copy ()
  128.   (eterm-send-region-to-cut-buffer (region-beginning) (region-end)))
  129.  
  130. (defun event-cut ()
  131.   (eterm-send-region-to-cut-buffer-and-wipe (region-beginning) (region-end)))
  132.  
  133. (defun event-paste (str)
  134.   (barf-if-buffer-read-only)
  135.   (push-mark (point))
  136.   (insert str))
  137.  
  138. (defun event-quit ()
  139.   (save-buffers-kill-emacs)
  140.   (setq last-command 'save-buffers-kill-emacs))
  141.  
  142. ;(defun event-resize (newx newy)
  143. ;  (if (or (not (= (screen-width) newx))
  144. ;      (not (= (screen-height) newy)))
  145. ;      (progn
  146. ;    (set-screen-width newx)
  147. ;    (set-screen-height newy))
  148. ;    (redraw-display)))
  149.  
  150.  
  151.