Mercurial > emacs
annotate lisp/telnet.el @ 1717:aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Thu, 24 Dec 1992 06:17:18 +0000 |
| parents | a52da8d63ff3 |
| children | 2715e893d220 |
| rev | line source |
|---|---|
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; telnet.el --- run a telnet session from within an Emacs buffer |
|
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
707
diff
changeset
|
2 |
| 841 | 3 ;;; Copyright (C) 1985, 1988, 1992 Free Software Foundation, Inc. |
| 4 | |
|
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
707
diff
changeset
|
5 ;; Author: William F. Schelter |
|
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
707
diff
changeset
|
6 ;; Maintainer: FSF |
| 48 | 7 |
| 8 ;; This file is part of GNU Emacs. | |
| 9 | |
| 10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 11 ;; it under the terms of the GNU General Public License as published by | |
| 707 | 12 ;; the Free Software Foundation; either version 2, or (at your option) |
| 48 | 13 ;; any later version. |
| 14 | |
| 15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 ;; GNU General Public License for more details. | |
| 19 | |
| 20 ;; You should have received a copy of the GNU General Public License | |
| 21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
| 22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 23 | |
|
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
707
diff
changeset
|
24 ;;; Code: |
| 48 | 25 |
| 26 ;;to do fix software types for lispm: | |
| 27 ;;to eval current expression. Also to try to send escape keys correctly. | |
| 28 ;;essentially we'll want the rubout-handler off. | |
| 29 | |
| 30 ;; filter is simplistic but should be okay for typical shell usage. | |
| 31 ;; needs hacking if it is going to deal with asynchronous output in a sane | |
| 32 ;; manner | |
| 33 | |
| 34 (require 'comint) | |
| 707 | 35 |
| 48 | 36 (defvar telnet-new-line "\r") |
| 37 (defvar telnet-mode-map nil) | |
| 38 (defvar telnet-prompt-pattern "^[^#$%>]*[#$%>] *") | |
| 39 (defvar telnet-replace-c-g nil) | |
| 40 (make-variable-buffer-local | |
| 41 (defvar telnet-remote-echoes t | |
| 42 "True if the telnet process will echo input.")) | |
| 43 (make-variable-buffer-local | |
| 44 (defvar telnet-interrupt-string "\C-c" "String sent by C-c.")) | |
| 45 | |
| 46 (defvar telnet-count 0 | |
| 47 "Number of output strings read from the telnet process | |
| 48 while looking for the initial password.") | |
| 49 | |
| 50 (defvar telnet-initial-count -50 | |
| 1577 | 51 "Initial value of `telnet-count'. Should be set to the negative of the |
| 48 | 52 number of terminal writes telnet will make setting up the host connection.") |
| 53 | |
| 54 (defvar telnet-maximum-count 4 | |
| 1577 | 55 "Maximum value `telnet-count' can have. |
| 48 | 56 After this many passes, we stop looking for initial setup data. |
| 57 Should be set to the number of terminal writes telnet will make | |
| 58 rejecting one login and prompting for the again for a username and password.") | |
| 59 | |
| 60 (defun telnet-interrupt-subjob () | |
| 61 (interactive) | |
| 62 "Interrupt the program running through telnet on the remote host." | |
| 63 (send-string nil telnet-interrupt-string)) | |
| 64 | |
| 65 (defun telnet-c-z () | |
| 66 (interactive) | |
| 67 (send-string nil "\C-z")) | |
| 68 | |
| 69 (defun send-process-next-char () | |
| 70 (interactive) | |
| 71 (send-string nil | |
| 72 (char-to-string | |
| 73 (let ((inhibit-quit t)) | |
| 74 (prog1 (read-char) | |
| 75 (setq quit-flag nil)))))) | |
| 76 | |
| 77 ; initialization on first load. | |
| 78 (if telnet-mode-map | |
| 79 nil | |
| 80 (setq telnet-mode-map (copy-keymap comint-mode-map)) | |
| 81 (define-key telnet-mode-map "\C-m" 'telnet-send-input) | |
| 82 ; (define-key telnet-mode-map "\C-j" 'telnet-send-input) | |
| 83 (define-key telnet-mode-map "\C-c\C-q" 'send-process-next-char) | |
| 84 (define-key telnet-mode-map "\C-c\C-c" 'telnet-interrupt-subjob) | |
| 85 (define-key telnet-mode-map "\C-c\C-z" 'telnet-c-z)) | |
| 86 | |
| 87 ;;maybe should have a flag for when have found type | |
| 88 (defun telnet-check-software-type-initialize (string) | |
| 89 "Tries to put correct initializations in. Needs work." | |
| 90 (let ((case-fold-search t)) | |
| 91 (cond ((string-match "unix" string) | |
| 92 (setq telnet-prompt-pattern comint-prompt-regexp) | |
| 93 (setq telnet-new-line "\n")) | |
| 94 ((string-match "tops-20" string) ;;maybe add telnet-replace-c-g | |
| 95 (setq telnet-prompt-pattern "[@>]*")) | |
| 96 ((string-match "its" string) | |
| 97 (setq telnet-prompt-pattern "^[^*>]*[*>] *")) | |
| 98 ((string-match "explorer" string) ;;explorer telnet needs work | |
| 99 (setq telnet-replace-c-g ?\n)))) | |
| 100 (setq comint-prompt-regexp telnet-prompt-pattern)) | |
| 101 | |
| 102 (defun telnet-initial-filter (proc string) | |
| 103 ;For reading up to and including password; also will get machine type. | |
| 104 (cond ((string-match "No such host" string) | |
| 105 (kill-buffer (process-buffer proc)) | |
| 106 (error "No such host.")) | |
| 107 ((string-match "passw" string) | |
| 108 (telnet-filter proc string) | |
| 109 (let* ((echo-keystrokes 0) | |
| 110 (password (read-password))) | |
| 111 (setq telnet-count 0) | |
| 112 (send-string proc (concat password telnet-new-line)))) | |
| 113 (t (telnet-check-software-type-initialize string) | |
| 114 (telnet-filter proc string) | |
| 115 (cond ((> telnet-count telnet-maximum-count) | |
| 116 (set-process-filter proc 'telnet-filter)) | |
| 117 (t (setq telnet-count (1+ telnet-count))))))) | |
| 118 | |
| 119 (defun telnet-filter (proc string) | |
| 120 (let ((at-end | |
| 121 (and (eq (process-buffer proc) (current-buffer)) | |
| 122 (= (point) (point-max))))) | |
| 123 (save-excursion | |
| 124 (set-buffer (process-buffer proc)) | |
| 125 (goto-char (process-mark proc)) | |
| 126 (let ((now (point))) | |
| 707 | 127 ;; Insert STRING, omitting all C-m characters. |
| 48 | 128 (let ((index 0) c-m) |
| 129 (while (setq c-m (string-match "\C-m" string index)) | |
| 130 (insert-before-markers (substring string index c-m)) | |
| 131 (setq index (1+ c-m))) | |
| 132 (insert-before-markers (substring string index))) | |
| 133 (and telnet-replace-c-g | |
| 134 (subst-char-in-region now (point) ?\C-g telnet-replace-c-g))) | |
| 135 ; (if (and (integer-or-marker-p last-input-start) | |
| 136 ; (marker-position last-input-start) | |
| 137 ; telnet-remote-echoes) | |
| 138 ; (delete-region last-input-start last-input-end)) | |
| 139 ) | |
| 140 (if at-end | |
| 141 (goto-char (point-max))))) | |
| 142 | |
| 143 (defun telnet-send-input () | |
| 144 (interactive) | |
| 707 | 145 ; (comint-send-input telnet-new-line telnet-remote-echoes) |
| 146 (comint-send-input) | |
| 147 (if telnet-remote-echoes | |
| 148 (delete-region comint-last-input-start | |
| 149 comint-last-input-end))) | |
| 48 | 150 |
| 258 | 151 ;;;###autoload |
| 48 | 152 (defun telnet (arg) |
| 153 "Open a network login connection to host named HOST (a string). | |
| 154 Communication with HOST is recorded in a buffer *HOST-telnet*. | |
| 155 Normally input is edited in Emacs and sent a line at a time." | |
| 156 (interactive "sOpen telnet connection to host: ") | |
| 157 (let ((name (concat arg "-telnet" ))) | |
| 158 (switch-to-buffer (make-comint name "telnet")) | |
| 159 (set-process-filter (get-process name) 'telnet-initial-filter) | |
|
1414
2ba9b06d4247
(telnet): Wait for telnet output before sending `open'.
Richard M. Stallman <rms@gnu.org>
parents:
841
diff
changeset
|
160 ;; Don't send the `open' cmd till telnet is ready for it. |
|
2ba9b06d4247
(telnet): Wait for telnet output before sending `open'.
Richard M. Stallman <rms@gnu.org>
parents:
841
diff
changeset
|
161 (accept-process-output (get-process name)) |
|
1418
d8dc740867ee
(telnet): Do erase-buffer after the initial output.
Richard M. Stallman <rms@gnu.org>
parents:
1414
diff
changeset
|
162 (erase-buffer) |
| 48 | 163 (send-string name (concat "open " arg "\n")) |
| 164 (telnet-mode) | |
| 165 (setq telnet-count telnet-initial-count))) | |
| 166 | |
| 167 (defun telnet-mode () | |
| 1577 | 168 "This mode is for telnetting from a buffer to another host. |
| 169 It has most of the same commands as comint-mode. | |
| 48 | 170 There is a variable ``telnet-interrupt-string'' which is the character |
| 171 sent to try to stop execution of a job on the remote host. | |
| 172 Data is sent to the remote host when RET is typed. | |
| 173 | |
| 174 \\{telnet-mode-map} | |
| 175 | |
| 176 Bugs: | |
| 177 --Replaces by a space, really should remove." | |
| 178 (interactive) | |
| 179 (comint-mode) | |
| 180 (setq major-mode 'telnet-mode | |
| 181 mode-name "Telnet" | |
| 182 comint-prompt-regexp telnet-prompt-pattern) | |
| 183 (use-local-map telnet-mode-map) | |
| 184 (run-hooks 'telnet-mode-hook)) | |
| 185 | |
| 186 (defun read-password () | |
| 187 (let ((answ "") tem) | |
| 188 (message "Reading password...") | |
| 557 | 189 (while (prog1 (not (memq (setq tem (read-char)) '(?\C-m ?\n ?\C-g))) |
| 190 (setq quit-flag nil)) | |
| 48 | 191 (setq answ (concat answ (char-to-string tem)))) |
| 192 answ)) | |
| 584 | 193 |
| 194 (provide 'telnet) | |
| 195 | |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
196 ;;; telnet.el ends here |
