diff options
| author | Per Bothner | 1995-02-06 21:56:37 +0000 |
|---|---|---|
| committer | Per Bothner | 1995-02-06 21:56:37 +0000 |
| commit | bfda79ab492aacc0d384bf8d7da63101707d940b (patch) | |
| tree | 65d74568aafe6f9c130d403a37901c56b28df4f4 | |
| parent | a3324470da1097287e3fd94ae2ad3029f7818446 (diff) | |
| download | emacs-bfda79ab492aacc0d384bf8d7da63101707d940b.tar.gz emacs-bfda79ab492aacc0d384bf8d7da63101707d940b.zip | |
Version 0.95. Numerous small fixes. See ChangeLog.
| -rw-r--r-- | lisp/term.el | 340 |
1 files changed, 183 insertions, 157 deletions
diff --git a/lisp/term.el b/lisp/term.el index 275c3b2b7da..e4d1e87abd2 100644 --- a/lisp/term.el +++ b/lisp/term.el | |||
| @@ -82,7 +82,7 @@ | |||
| 82 | 82 | ||
| 83 | ;;; This is passed to the inferior in the EMACS environment variable, | 83 | ;;; This is passed to the inferior in the EMACS environment variable, |
| 84 | ;;; so it is important to increase it if there are protocol-relevant changes. | 84 | ;;; so it is important to increase it if there are protocol-relevant changes. |
| 85 | (defconst term-version "0.94") | 85 | (defconst term-version "0.95") |
| 86 | 86 | ||
| 87 | (require 'ring) | 87 | (require 'ring) |
| 88 | (require 'ehelp) | 88 | (require 'ehelp) |
| @@ -94,8 +94,10 @@ | |||
| 94 | ;;; term-delimiter-argument-list - list For delimiters and arguments | 94 | ;;; term-delimiter-argument-list - list For delimiters and arguments |
| 95 | ;;; term-last-input-start - marker Handy if inferior always echoes | 95 | ;;; term-last-input-start - marker Handy if inferior always echoes |
| 96 | ;;; term-last-input-end - marker For term-kill-output command | 96 | ;;; term-last-input-end - marker For term-kill-output command |
| 97 | ;;; term-input-ring-size - integer For the input history | 97 | ;; For the input history mechanism: |
| 98 | ;;; term-input-ring - ring mechanism | 98 | (defvar term-input-ring-size 32 "Size of input history ring.") |
| 99 | ;;; term-input-ring-size - integer | ||
| 100 | ;;; term-input-ring - ring | ||
| 99 | ;;; term-input-ring-index - number ... | 101 | ;;; term-input-ring-index - number ... |
| 100 | ;;; term-input-autoexpand - symbol ... | 102 | ;;; term-input-autoexpand - symbol ... |
| 101 | ;;; term-input-ignoredups - boolean ... | 103 | ;;; term-input-ignoredups - boolean ... |
| @@ -108,6 +110,49 @@ | |||
| 108 | ;;; term-input-send - function | 110 | ;;; term-input-send - function |
| 109 | ;;; term-scroll-to-bottom-on-output - symbol ... | 111 | ;;; term-scroll-to-bottom-on-output - symbol ... |
| 110 | ;;; term-scroll-show-maximum-output - boolean... | 112 | ;;; term-scroll-show-maximum-output - boolean... |
| 113 | (defvar term-height) ;; Number of lines in window. | ||
| 114 | (defvar term-width) ;; Number of columns in window. | ||
| 115 | (defvar term-home-marker) ;; Marks the "home" position for cursor addressing. | ||
| 116 | (defvar term-saved-home-marker nil) ;; When using alternate sub-buffer, | ||
| 117 | ;; contains saved term-home-marker from original sub-buffer . | ||
| 118 | (defvar term-start-line-column 0) ;; (current-column) at start of screen line, | ||
| 119 | ;; or nil if unknown. | ||
| 120 | (defvar term-current-column 0) ;; If non-nil, is cache for (current-column). | ||
| 121 | (defvar term-current-row 0) ;; Current vertical row (relative to home-marker) | ||
| 122 | ;; or nil if unknown. | ||
| 123 | (defvar term-insert-mode nil) | ||
| 124 | (defvar term-vertical-motion) | ||
| 125 | (defvar term-terminal-state 0) ;; State of the terminal emulator: | ||
| 126 | ;; state 0: Normal state | ||
| 127 | ;; state 1: Last character was a graphic in the last column. | ||
| 128 | ;; If next char is graphic, first move one column right | ||
| 129 | ;; (and line warp) before displaying it. | ||
| 130 | ;; This emulates (more or less) the behavior of xterm. | ||
| 131 | ;; state 2: seen ESC | ||
| 132 | ;; state 3: seen ESC [ (or ESC [ ?) | ||
| 133 | ;; state 4: term-terminal-parameter contains pending output. | ||
| 134 | (defvar term-kill-echo-list nil) ;; A queue of strings whose echo | ||
| 135 | ;; we want suppressed. | ||
| 136 | (defvar term-terminal-parameter) | ||
| 137 | (defvar term-terminal-previous-parameter) | ||
| 138 | (defvar term-current-face 'default) | ||
| 139 | (defvar term-scroll-start 0) ;; Top-most line (inclusive) of scrolling region. | ||
| 140 | (defvar term-scroll-end) ;; Number of line (zero-based) after scrolling region. | ||
| 141 | (defvar term-pager-count nil) ;; If nil, paging is disabled. | ||
| 142 | ;; Otherwise, number of lines before we need to page. | ||
| 143 | (defvar term-saved-cursor nil) | ||
| 144 | (defvar term-command-hook) | ||
| 145 | (defvar term-log-buffer nil) | ||
| 146 | (defvar term-scroll-with-delete nil) ;; term-scroll-with-delete is t if | ||
| 147 | ;; forward scrolling should be implemented by delete to | ||
| 148 | ;; top-most line(s); and nil if scrolling should be implemented | ||
| 149 | ;; by moving term-home-marker. It is set to t iff there is a | ||
| 150 | ;; (non-default) scroll-region OR the alternate buffer is used. | ||
| 151 | (defvar term-pending-delete-marker) | ||
| 152 | (defvar term-old-mode-map nil) ;; Saves the old keymap when in char mode. | ||
| 153 | (defvar term-old-mode-line-format) ;; Saves old mode-line-format while paging. | ||
| 154 | (defvar term-pager-old-local-map nil) ;; Saves old keymap while paging. | ||
| 155 | (defvar term-pager-old-filter) ;; Saved process-filter while paging. | ||
| 111 | 156 | ||
| 112 | (defvar explicit-shell-file-name nil | 157 | (defvar explicit-shell-file-name nil |
| 113 | "*If non-nil, is file name to use for explicitly requested inferior shell.") | 158 | "*If non-nil, is file name to use for explicitly requested inferior shell.") |
| @@ -178,9 +223,6 @@ If non-nil, then show the maximum output when the window is scrolled. | |||
| 178 | See variable `term-scroll-to-bottom-on-output'. | 223 | See variable `term-scroll-to-bottom-on-output'. |
| 179 | This variable is buffer-local.") | 224 | This variable is buffer-local.") |
| 180 | 225 | ||
| 181 | (defvar term-input-ring-size 32 | ||
| 182 | "Size of input history ring.") | ||
| 183 | |||
| 184 | ;; Where gud-display-frame should put the debugging arrow. This is | 226 | ;; Where gud-display-frame should put the debugging arrow. This is |
| 185 | ;; set by the marker-filter, which scans the debugger's output for | 227 | ;; set by the marker-filter, which scans the debugger's output for |
| 186 | ;; indications of the current pc. | 228 | ;; indications of the current pc. |
| @@ -282,6 +324,13 @@ Buffer local variable.") | |||
| 282 | 324 | ||
| 283 | (defmacro term-in-char-mode () '(eq (current-local-map) term-raw-map)) | 325 | (defmacro term-in-char-mode () '(eq (current-local-map) term-raw-map)) |
| 284 | (defmacro term-in-line-mode () '(not (term-in-char-mode))) | 326 | (defmacro term-in-line-mode () '(not (term-in-char-mode))) |
| 327 | ;; True if currently doing PAGER handling. | ||
| 328 | (defmacro term-pager-enabled () 'term-pager-count) | ||
| 329 | (defmacro term-handling-pager () 'term-pager-old-local-map) | ||
| 330 | (defmacro term-using-alternate-sub-buffer () 'term-saved-home-marker) | ||
| 331 | |||
| 332 | (defvar term-signals-menu) | ||
| 333 | (defvar term-terminal-menu) | ||
| 285 | 334 | ||
| 286 | (term-if-xemacs | 335 | (term-if-xemacs |
| 287 | (defvar term-terminal-menu | 336 | (defvar term-terminal-menu |
| @@ -327,19 +376,16 @@ Entry to this mode runs the hooks on term-mode-hook" | |||
| 327 | (kill-all-local-variables) | 376 | (kill-all-local-variables) |
| 328 | (setq major-mode 'term-mode) | 377 | (setq major-mode 'term-mode) |
| 329 | (setq mode-name "Term") | 378 | (setq mode-name "Term") |
| 330 | (setq mode-line-process '(": line %s")) | ||
| 331 | (use-local-map term-mode-map) | 379 | (use-local-map term-mode-map) |
| 332 | (make-local-variable 'term-home-marker) | 380 | (make-local-variable 'term-home-marker) |
| 333 | (setq term-home-marker (copy-marker 0)) | 381 | (setq term-home-marker (copy-marker 0)) |
| 334 | (make-local-variable 'term-saved-home-marker) | 382 | (make-local-variable 'term-saved-home-marker) |
| 335 | (setq term-saved-home-marker nil) | ||
| 336 | (make-local-variable 'term-height) | 383 | (make-local-variable 'term-height) |
| 337 | (make-local-variable 'term-width) | 384 | (make-local-variable 'term-width) |
| 338 | (setq term-width (1- (window-width))) | 385 | (setq term-width (1- (window-width))) |
| 339 | (setq term-height (1- (window-height))) | 386 | (setq term-height (1- (window-height))) |
| 340 | (make-local-variable 'term-terminal-parameter) | 387 | (make-local-variable 'term-terminal-parameter) |
| 341 | (make-local-variable 'term-saved-cursor) | 388 | (make-local-variable 'term-saved-cursor) |
| 342 | (setq term-saved-cursor nil) | ||
| 343 | (make-local-variable 'term-last-input-start) | 389 | (make-local-variable 'term-last-input-start) |
| 344 | (setq term-last-input-start (make-marker)) | 390 | (setq term-last-input-start (make-marker)) |
| 345 | (make-local-variable 'term-last-input-end) | 391 | (make-local-variable 'term-last-input-end) |
| @@ -359,54 +405,20 @@ Entry to this mode runs the hooks on term-mode-hook" | |||
| 359 | (make-local-variable 'term-command-hook) | 405 | (make-local-variable 'term-command-hook) |
| 360 | (setq term-command-hook (symbol-function 'term-command-hook)) | 406 | (setq term-command-hook (symbol-function 'term-command-hook)) |
| 361 | 407 | ||
| 362 | ;; state 0: Normal state | ||
| 363 | ;; state 1: Last character was a graphic in the last column. | ||
| 364 | ;; If next char is graphic, first move one column right | ||
| 365 | ;; (and line warp) before displaying it. | ||
| 366 | ;; This emulates (more or less) the behavior of xterm. | ||
| 367 | ;; state 2: seen ESC | ||
| 368 | ;; state 3: seen ESC [ (or ESC [ ?) | ||
| 369 | ;; state 4: term-terminal-parameter contains pending output. | ||
| 370 | (make-local-variable 'term-terminal-state) | 408 | (make-local-variable 'term-terminal-state) |
| 371 | (setq term-terminal-state 0) | ||
| 372 | |||
| 373 | ;; A queue of strings whose echo we want suppressed. | ||
| 374 | (make-local-variable 'term-kill-echo-list) | 409 | (make-local-variable 'term-kill-echo-list) |
| 375 | (setq term-kill-echo-list nil) | ||
| 376 | |||
| 377 | ;; (current-column) at start of screen line, or nil if unknown. | ||
| 378 | (make-local-variable 'term-start-line-column) | 410 | (make-local-variable 'term-start-line-column) |
| 379 | (setq term-start-line-column 0) | ||
| 380 | ;; Cache for (current-column), or nil if unknown. | ||
| 381 | (make-local-variable 'term-current-column) | 411 | (make-local-variable 'term-current-column) |
| 382 | (setq term-current-column 0) | ||
| 383 | ;; Current vertical row (from home-marker) or nil if unknown. | ||
| 384 | (make-local-variable 'term-current-row) | 412 | (make-local-variable 'term-current-row) |
| 385 | (setq term-current-row 0) | ||
| 386 | (make-local-variable 'term-log-buffer) | 413 | (make-local-variable 'term-log-buffer) |
| 387 | (setq term-log-buffer nil) | ||
| 388 | (make-local-variable 'term-scroll-start) | 414 | (make-local-variable 'term-scroll-start) |
| 389 | (setq term-scroll-start 0) | ||
| 390 | (make-local-variable 'term-scroll-end) | 415 | (make-local-variable 'term-scroll-end) |
| 391 | (setq term-scroll-end term-height) | 416 | (setq term-scroll-end term-height) |
| 392 | ;; term-scroll-with-delete is t if forward scrolling should | ||
| 393 | ;; be implemented by delete to top-most line(s); and nil if | ||
| 394 | ;; scrolling should be implemented by moving term-home-marker. | ||
| 395 | ;; It is set to t iff there is a (non-default) scroll-region | ||
| 396 | ;; OR the alternate buffer is used. | ||
| 397 | (make-local-variable 'term-scroll-with-delete) | 417 | (make-local-variable 'term-scroll-with-delete) |
| 398 | (setq term-scroll-with-delete nil) | ||
| 399 | (make-local-variable 'term-pager-count) | 418 | (make-local-variable 'term-pager-count) |
| 400 | ;;(setq term-pager-count 0) | ||
| 401 | (setq term-pager-count nil) | ||
| 402 | ;; Used to save the old keymap when doing PAGER processing. | ||
| 403 | (make-local-variable 'term-pager-old-local-map) | 419 | (make-local-variable 'term-pager-old-local-map) |
| 404 | (setq term-pager-old-local-map nil) | ||
| 405 | ;; Used to save the old keymap when in char mode. | ||
| 406 | (make-local-variable 'term-old-mode-map) | 420 | (make-local-variable 'term-old-mode-map) |
| 407 | (setq term-old-mode-map nil) | ||
| 408 | (make-local-variable 'term-insert-mode) | 421 | (make-local-variable 'term-insert-mode) |
| 409 | (setq term-insert-mode nil) | ||
| 410 | (make-local-variable 'term-dynamic-complete-functions) | 422 | (make-local-variable 'term-dynamic-complete-functions) |
| 411 | (make-local-variable 'term-completion-fignore) | 423 | (make-local-variable 'term-completion-fignore) |
| 412 | (make-local-variable 'term-get-old-input) | 424 | (make-local-variable 'term-get-old-input) |
| @@ -425,17 +437,15 @@ Entry to this mode runs the hooks on term-mode-hook" | |||
| 425 | (make-local-variable 'term-pending-delete-marker) | 437 | (make-local-variable 'term-pending-delete-marker) |
| 426 | (setq term-pending-delete-marker (make-marker)) | 438 | (setq term-pending-delete-marker (make-marker)) |
| 427 | (make-local-variable 'term-current-face) | 439 | (make-local-variable 'term-current-face) |
| 428 | (setq term-current-face 'default) | ||
| 429 | (make-local-variable 'term-pending-frame) | 440 | (make-local-variable 'term-pending-frame) |
| 430 | (setq term-pending-frame nil) | 441 | (setq term-pending-frame nil) |
| 431 | (make-local-variable 'term-chars-mode) | ||
| 432 | (setq term-chars-mode nil) | ||
| 433 | (run-hooks 'term-mode-hook) | 442 | (run-hooks 'term-mode-hook) |
| 434 | (term-if-xemacs | 443 | (term-if-xemacs |
| 435 | (set-buffer-menubar | 444 | (set-buffer-menubar |
| 436 | (append current-menubar (list term-terminal-menu)))) | 445 | (append current-menubar (list term-terminal-menu)))) |
| 437 | (or term-input-ring | 446 | (or term-input-ring |
| 438 | (setq term-input-ring (make-ring term-input-ring-size)))) | 447 | (setq term-input-ring (make-ring term-input-ring-size))) |
| 448 | (term-update-mode-line)) | ||
| 439 | 449 | ||
| 440 | (if term-mode-map | 450 | (if term-mode-map |
| 441 | nil | 451 | nil |
| @@ -490,82 +500,84 @@ Entry to this mode runs the hooks on term-mode-hook" | |||
| 490 | ;; Menu bars: | 500 | ;; Menu bars: |
| 491 | (term-ifnot-xemacs | 501 | (term-ifnot-xemacs |
| 492 | (term-if-emacs19 | 502 | (term-if-emacs19 |
| 493 | ;; terminal: | 503 | |
| 494 | (defvar term-terminal-menu (make-sparse-keymap "Terminal")) | 504 | ;; terminal: |
| 495 | (define-key term-terminal-menu [terminal-pager-enable] | 505 | (let (newmap) |
| 496 | '("Enable paging" . term-fake-pager-enable)) | 506 | (setq newmap (make-sparse-keymap "Terminal")) |
| 497 | (define-key term-terminal-menu [terminal-pager-disable] | 507 | (define-key newmap [terminal-pager-enable] |
| 498 | '("Disable paging" . term-fake-pager-disable)) | 508 | '("Enable paging" . term-fake-pager-enable)) |
| 499 | (define-key term-terminal-menu [terminal-char-mode] | 509 | (define-key newmap [terminal-pager-disable] |
| 500 | '("Character mode" . term-char-mode)) | 510 | '("Disable paging" . term-fake-pager-disable)) |
| 501 | (define-key term-terminal-menu [terminal-line-mode] | 511 | (define-key newmap [terminal-char-mode] |
| 502 | '("Line mode" . term-line-mode)) | 512 | '("Character mode" . term-char-mode)) |
| 503 | (define-key term-mode-map [menu-bar terminal] | 513 | (define-key newmap [terminal-line-mode] |
| 504 | (setq term-terminal-menu (cons "Terminal" term-terminal-menu))) | 514 | '("Line mode" . term-line-mode)) |
| 505 | 515 | (define-key newmap [menu-bar terminal] | |
| 506 | ;; completion: (line mode only) | 516 | (setq term-terminal-menu (cons "Terminal" newmap))) |
| 507 | (defvar term-completion-menu (make-sparse-keymap "Complete")) | 517 | |
| 508 | (define-key term-mode-map [menu-bar completion] | 518 | ;; completion: (line mode only) |
| 509 | (cons "Complete" term-completion-menu)) | 519 | (defvar term-completion-menu (make-sparse-keymap "Complete")) |
| 510 | (define-key term-completion-menu [complete-expand] | 520 | (define-key term-mode-map [menu-bar completion] |
| 511 | '("Expand File Name" . term-replace-by-expanded-filename)) | 521 | (cons "Complete" term-completion-menu)) |
| 512 | (define-key term-completion-menu [complete-listing] | 522 | (define-key term-completion-menu [complete-expand] |
| 513 | '("File Completion Listing" . term-dynamic-list-filename-completions)) | 523 | '("Expand File Name" . term-replace-by-expanded-filename)) |
| 514 | (define-key term-completion-menu [menu-bar completion complete-file] | 524 | (define-key term-completion-menu [complete-listing] |
| 515 | '("Complete File Name" . term-dynamic-complete-filename)) | 525 | '("File Completion Listing" . term-dynamic-list-filename-completions)) |
| 516 | (define-key term-completion-menu [menu-bar completion complete] | 526 | (define-key term-completion-menu [menu-bar completion complete-file] |
| 517 | '("Complete Before Point" . term-dynamic-complete)) | 527 | '("Complete File Name" . term-dynamic-complete-filename)) |
| 518 | 528 | (define-key term-completion-menu [menu-bar completion complete] | |
| 519 | ;; Input history: (line mode only) | 529 | '("Complete Before Point" . term-dynamic-complete)) |
| 520 | (defvar term-inout-menu (make-sparse-keymap "In/Out")) | 530 | |
| 521 | (define-key term-mode-map [menu-bar inout] | 531 | ;; Input history: (line mode only) |
| 522 | (cons "In/Out" term-inout-menu)) | 532 | (defvar term-inout-menu (make-sparse-keymap "In/Out")) |
| 523 | (define-key term-inout-menu [kill-output] | 533 | (define-key term-mode-map [menu-bar inout] |
| 524 | '("Kill Current Output Group" . term-kill-output)) | 534 | (cons "In/Out" term-inout-menu)) |
| 525 | (define-key term-inout-menu [next-prompt] | 535 | (define-key term-inout-menu [kill-output] |
| 526 | '("Forward Output Group" . term-next-prompt)) | 536 | '("Kill Current Output Group" . term-kill-output)) |
| 527 | (define-key term-inout-menu [previous-prompt] | 537 | (define-key term-inout-menu [next-prompt] |
| 528 | '("Backward Output Group" . term-previous-prompt)) | 538 | '("Forward Output Group" . term-next-prompt)) |
| 529 | (define-key term-inout-menu [show-maximum-output] | 539 | (define-key term-inout-menu [previous-prompt] |
| 530 | '("Show Maximum Output" . term-show-maximum-output)) | 540 | '("Backward Output Group" . term-previous-prompt)) |
| 531 | (define-key term-inout-menu [show-output] | 541 | (define-key term-inout-menu [show-maximum-output] |
| 532 | '("Show Current Output Group" . term-show-output)) | 542 | '("Show Maximum Output" . term-show-maximum-output)) |
| 533 | (define-key term-inout-menu [kill-input] | 543 | (define-key term-inout-menu [show-output] |
| 534 | '("Kill Current Input" . term-kill-input)) | 544 | '("Show Current Output Group" . term-show-output)) |
| 535 | (define-key term-inout-menu [copy-input] | 545 | (define-key term-inout-menu [kill-input] |
| 536 | '("Copy Old Input" . term-copy-old-input)) | 546 | '("Kill Current Input" . term-kill-input)) |
| 537 | (define-key term-inout-menu [forward-matching-history] | 547 | (define-key term-inout-menu [copy-input] |
| 538 | '("Forward Matching Input..." . term-forward-matching-input)) | 548 | '("Copy Old Input" . term-copy-old-input)) |
| 539 | (define-key term-inout-menu [backward-matching-history] | 549 | (define-key term-inout-menu [forward-matching-history] |
| 540 | '("Backward Matching Input..." . term-backward-matching-input)) | 550 | '("Forward Matching Input..." . term-forward-matching-input)) |
| 541 | (define-key term-inout-menu [next-matching-history] | 551 | (define-key term-inout-menu [backward-matching-history] |
| 542 | '("Next Matching Input..." . term-next-matching-input)) | 552 | '("Backward Matching Input..." . term-backward-matching-input)) |
| 543 | (define-key term-inout-menu [previous-matching-history] | 553 | (define-key term-inout-menu [next-matching-history] |
| 544 | '("Previous Matching Input..." . term-previous-matching-input)) | 554 | '("Next Matching Input..." . term-next-matching-input)) |
| 545 | (define-key term-inout-menu [next-matching-history-from-input] | 555 | (define-key term-inout-menu [previous-matching-history] |
| 546 | '("Next Matching Current Input" . term-next-matching-input-from-input)) | 556 | '("Previous Matching Input..." . term-previous-matching-input)) |
| 547 | (define-key term-inout-menu [previous-matching-history-from-input] | 557 | (define-key term-inout-menu [next-matching-history-from-input] |
| 548 | '("Previous Matching Current Input" . term-previous-matching-input-from-input)) | 558 | '("Next Matching Current Input" . term-next-matching-input-from-input)) |
| 549 | (define-key term-inout-menu [next-history] | 559 | (define-key term-inout-menu [previous-matching-history-from-input] |
| 550 | '("Next Input" . term-next-input)) | 560 | '("Previous Matching Current Input" . term-previous-matching-input-from-input)) |
| 551 | (define-key term-inout-menu [previous-history] | 561 | (define-key term-inout-menu [next-history] |
| 552 | '("Previous Input" . term-previous-input)) | 562 | '("Next Input" . term-next-input)) |
| 553 | (define-key term-inout-menu [list-history] | 563 | (define-key term-inout-menu [previous-history] |
| 554 | '("List Input History" . term-dynamic-list-input-ring)) | 564 | '("Previous Input" . term-previous-input)) |
| 555 | (define-key term-inout-menu [expand-history] | 565 | (define-key term-inout-menu [list-history] |
| 556 | '("Expand History Before Point" . term-replace-by-expanded-history)) | 566 | '("List Input History" . term-dynamic-list-input-ring)) |
| 557 | 567 | (define-key term-inout-menu [expand-history] | |
| 558 | ;; Signals | 568 | '("Expand History Before Point" . term-replace-by-expanded-history)) |
| 559 | (defvar term-signals-menu (make-sparse-keymap "Signals")) | 569 | |
| 560 | (define-key term-signals-menu [eof] '("EOF" . term-send-eof)) | 570 | ;; Signals |
| 561 | (define-key term-signals-menu [kill] '("KILL" . term-kill-subjob)) | 571 | (setq newmap (make-sparse-keymap "Signals")) |
| 562 | (define-key term-signals-menu [quit] '("QUIT" . term-quit-subjob)) | 572 | (define-key newmap [eof] '("EOF" . term-send-eof)) |
| 563 | (define-key term-signals-menu [cont] '("CONT" . term-continue-subjob)) | 573 | (define-key newmap [kill] '("KILL" . term-kill-subjob)) |
| 564 | (define-key term-signals-menu [stop] '("STOP" . term-stop-subjob)) | 574 | (define-key newmap [quit] '("QUIT" . term-quit-subjob)) |
| 565 | (define-key term-signals-menu [] '("BREAK" . term-interrupt-subjob)) | 575 | (define-key newmap [cont] '("CONT" . term-continue-subjob)) |
| 566 | (define-key term-mode-map [menu-bar signals] | 576 | (define-key newmap [stop] '("STOP" . term-stop-subjob)) |
| 567 | (setq term-signals-menu (cons "Signals" term-signals-menu))) | 577 | (define-key newmap [] '("BREAK" . term-interrupt-subjob)) |
| 568 | )) | 578 | (define-key term-mode-map [menu-bar signals] |
| 579 | (setq term-signals-menu (cons "Signals" newmap))) | ||
| 580 | ))) | ||
| 569 | 581 | ||
| 570 | (defun term-reset-size (height width) | 582 | (defun term-reset-size (height width) |
| 571 | (setq term-height height) | 583 | (setq term-height height) |
| @@ -617,7 +629,7 @@ Entry to this mode runs the hooks on term-mode-hook" | |||
| 617 | ;; Note that (term-current-row) must be called *after* | 629 | ;; Note that (term-current-row) must be called *after* |
| 618 | ;; (point) has been updated to (process-mark proc). | 630 | ;; (point) has been updated to (process-mark proc). |
| 619 | (goto-char (process-mark proc)) | 631 | (goto-char (process-mark proc)) |
| 620 | (if term-pager-count | 632 | (if (term-pager-enabled) |
| 621 | (setq term-pager-count (term-current-row))) | 633 | (setq term-pager-count (term-current-row))) |
| 622 | (send-string proc chars)))) | 634 | (send-string proc chars)))) |
| 623 | 635 | ||
| @@ -633,11 +645,18 @@ without any interpretation." | |||
| 633 | 645 | ||
| 634 | (defun term-send-raw-meta () | 646 | (defun term-send-raw-meta () |
| 635 | (interactive) | 647 | (interactive) |
| 636 | ;; Convert `return' to C-m, etc. | 648 | (if (symbolp last-input-char) |
| 637 | (if (and (symbolp last-input-char) | 649 | ;; Convert `return' to C-m, etc. |
| 638 | (get last-input-char 'ascii-character)) | 650 | (let ((tmp (get last-input-char 'event-symbol-elements))) |
| 639 | (setq last-input-char (get last-input-char 'ascii-character))) | 651 | (if tmp |
| 640 | (term-send-raw-string (if (> last-input-char 127) | 652 | (setq last-input-char (car tmp))) |
| 653 | (if (symbolp last-input-char) | ||
| 654 | (progn | ||
| 655 | (setq tmp (get last-input-char 'ascii-character)) | ||
| 656 | (if tmp (setq last-input-char tmp)))))) | ||
| 657 | (term-send-raw-string (if (and (numberp last-input-char) | ||
| 658 | (> last-input-char 127) | ||
| 659 | (< last-input-char 256)) | ||
| 641 | (make-string 1 last-input-char) | 660 | (make-string 1 last-input-char) |
| 642 | (format "\e%c" last-input-char)))) | 661 | (format "\e%c" last-input-char)))) |
| 643 | 662 | ||
| @@ -721,9 +740,7 @@ intervention from emacs, except for the escape character (usually C-c)." | |||
| 721 | (end-of-line) | 740 | (end-of-line) |
| 722 | (term-send-input)) | 741 | (term-send-input)) |
| 723 | (setq term-input-sender save-input-sender)))) | 742 | (setq term-input-sender save-input-sender)))) |
| 724 | 743 | (term-update-mode-line)))) | |
| 725 | (setq mode-line-process '(": char %s")) | ||
| 726 | (set-buffer-modified-p (buffer-modified-p))))) ;; Updates mode line. | ||
| 727 | 744 | ||
| 728 | (defun term-line-mode () | 745 | (defun term-line-mode () |
| 729 | "Switch to line (\"cooked\") sub-mode of term mode. | 746 | "Switch to line (\"cooked\") sub-mode of term mode. |
| @@ -733,8 +750,14 @@ you type \\[term-send-input] which sends the current line to the inferior." | |||
| 733 | (if (term-in-char-mode) | 750 | (if (term-in-char-mode) |
| 734 | (progn | 751 | (progn |
| 735 | (use-local-map term-old-mode-map) | 752 | (use-local-map term-old-mode-map) |
| 736 | (setq mode-line-process '(": line %s")) | 753 | (term-update-mode-line)))) |
| 737 | (set-buffer-modified-p (buffer-modified-p))))) ;; Updates mode line. | 754 | |
| 755 | (defun term-update-mode-line () | ||
| 756 | (setq mode-line-process | ||
| 757 | (if (term-in-char-mode) | ||
| 758 | (if (term-pager-enabled) '(": char page %s") '(": char %s")) | ||
| 759 | (if (term-pager-enabled) '(": line page %s") '(": line %s")))) | ||
| 760 | (set-buffer-modified-p (buffer-modified-p))) ;; Force mode line update. | ||
| 738 | 761 | ||
| 739 | (defun term-check-proc (buffer) | 762 | (defun term-check-proc (buffer) |
| 740 | "True if there is a process associated w/buffer BUFFER, and | 763 | "True if there is a process associated w/buffer BUFFER, and |
| @@ -1434,7 +1457,7 @@ Similarly for Soar, Scheme, etc." | |||
| 1434 | (delete-region pmark (point)) | 1457 | (delete-region pmark (point)) |
| 1435 | (insert input) | 1458 | (insert input) |
| 1436 | copy)))) | 1459 | copy)))) |
| 1437 | (if term-pager-count | 1460 | (if (term-pager-enabled) |
| 1438 | (save-excursion | 1461 | (save-excursion |
| 1439 | (goto-char (process-mark proc)) | 1462 | (goto-char (process-mark proc)) |
| 1440 | (setq term-pager-count (term-current-row)))) | 1463 | (setq term-pager-count (term-current-row)))) |
| @@ -1574,7 +1597,6 @@ Then send it to the process running in the current buffer. A new-line | |||
| 1574 | is additionally sent. String is not saved on term input history list. | 1597 | is additionally sent. String is not saved on term input history list. |
| 1575 | Security bug: your string can still be temporarily recovered with | 1598 | Security bug: your string can still be temporarily recovered with |
| 1576 | \\[view-lossage]." | 1599 | \\[view-lossage]." |
| 1577 | (interactive (list (term-read-noecho "Enter non-echoed text"))) | ||
| 1578 | (interactive "P") ; Defeat snooping via C-x esc | 1600 | (interactive "P") ; Defeat snooping via C-x esc |
| 1579 | (if (not (stringp str)) | 1601 | (if (not (stringp str)) |
| 1580 | (setq str (term-read-noecho "Non-echoed text: " t))) | 1602 | (setq str (term-read-noecho "Non-echoed text: " t))) |
| @@ -2007,15 +2029,10 @@ See `term-prompt-regexp'." | |||
| 2007 | (if term-current-row | 2029 | (if term-current-row |
| 2008 | (setq term-current-row (+ term-current-row delta)))) | 2030 | (setq term-current-row (+ term-current-row delta)))) |
| 2009 | 2031 | ||
| 2010 | ;; True if currently doing PAGER handling. | ||
| 2011 | (defmacro term-handling-pager () 'term-pager-old-local-map) | ||
| 2012 | |||
| 2013 | (defmacro term-using-alternate-sub-buffer () 'term-saved-home-marker) | ||
| 2014 | |||
| 2015 | (defun term-terminal-pos () | 2032 | (defun term-terminal-pos () |
| 2016 | (save-excursion ; save-restriction | 2033 | (save-excursion ; save-restriction |
| 2017 | (let ((save-col (term-current-column)) | 2034 | (let ((save-col (term-current-column)) |
| 2018 | (x)) | 2035 | x y) |
| 2019 | (term-vertical-motion 0) | 2036 | (term-vertical-motion 0) |
| 2020 | (setq x (- save-col (current-column))) | 2037 | (setq x (- save-col (current-column))) |
| 2021 | (setq y (term-vertical-motion term-height)) | 2038 | (setq y (term-vertical-motion term-height)) |
| @@ -2190,7 +2207,7 @@ See `term-prompt-regexp'." | |||
| 2190 | (setq term-terminal-parameter 0)) | 2207 | (setq term-terminal-parameter 0)) |
| 2191 | ((eq char ??)) ; Ignore ? | 2208 | ((eq char ??)) ; Ignore ? |
| 2192 | (t | 2209 | (t |
| 2193 | (term-handle-ansi-escape char) | 2210 | (term-handle-ansi-escape proc char) |
| 2194 | (setq term-terminal-state 0))))) | 2211 | (setq term-terminal-state 0))))) |
| 2195 | (if (term-handling-pager) | 2212 | (if (term-handling-pager) |
| 2196 | ;; Finish stuff to get ready to handle PAGER. | 2213 | ;; Finish stuff to get ready to handle PAGER. |
| @@ -2266,13 +2283,17 @@ See `term-prompt-regexp'." | |||
| 2266 | ;;; Handle a character assuming (eq terminal-state 2) - | 2283 | ;;; Handle a character assuming (eq terminal-state 2) - |
| 2267 | ;;; i.e. we have previousely seen Escape followed by ?[. | 2284 | ;;; i.e. we have previousely seen Escape followed by ?[. |
| 2268 | 2285 | ||
| 2269 | (defun term-handle-ansi-escape (char) | 2286 | (defun term-handle-ansi-escape (proc char) |
| 2270 | (cond | 2287 | (cond |
| 2271 | ((eq char ?H) ; cursor motion | 2288 | ((eq char ?H) ; cursor motion |
| 2272 | (if (<= term-terminal-parameter 0) | 2289 | (if (<= term-terminal-parameter 0) |
| 2273 | (setq term-terminal-parameter 1)) | 2290 | (setq term-terminal-parameter 1)) |
| 2274 | (if (<= term-terminal-previous-parameter 0) | 2291 | (if (<= term-terminal-previous-parameter 0) |
| 2275 | (setq term-terminal-previous-parameter 1)) | 2292 | (setq term-terminal-previous-parameter 1)) |
| 2293 | (if (> term-terminal-previous-parameter term-height) | ||
| 2294 | (setq term-terminal-previous-parameter term-height)) | ||
| 2295 | (if (> term-terminal-parameter term-width) | ||
| 2296 | (setq term-terminal-parameter term-width)) | ||
| 2276 | (term-goto | 2297 | (term-goto |
| 2277 | (1- term-terminal-previous-parameter) | 2298 | (1- term-terminal-previous-parameter) |
| 2278 | (1- term-terminal-parameter))) | 2299 | (1- term-terminal-parameter))) |
| @@ -2327,6 +2348,12 @@ See `term-prompt-regexp'." | |||
| 2327 | ((eq term-terminal-parameter 1) | 2348 | ((eq term-terminal-parameter 1) |
| 2328 | (setq term-current-face 'bold)) | 2349 | (setq term-current-face 'bold)) |
| 2329 | (t (setq term-current-face 'default)))) | 2350 | (t (setq term-current-face 'default)))) |
| 2351 | ;; \E[6n - Report cursor position | ||
| 2352 | ((eq char ?n) | ||
| 2353 | (process-send-string proc | ||
| 2354 | (format "\e[%s;%sR" | ||
| 2355 | (1+ (term-current-row)) | ||
| 2356 | (1+ (term-horizontal-column))))) | ||
| 2330 | ;; \E[r - Set scrolling region | 2357 | ;; \E[r - Set scrolling region |
| 2331 | ((eq char ?r) | 2358 | ((eq char ?r) |
| 2332 | (term-scroll-region | 2359 | (term-scroll-region |
| @@ -2344,7 +2371,7 @@ The top-most line is line 0." | |||
| 2344 | 0 | 2371 | 0 |
| 2345 | top)) | 2372 | top)) |
| 2346 | (setq term-scroll-end | 2373 | (setq term-scroll-end |
| 2347 | (if (or (< bottom term-scroll-start) (> bottom term-height)) | 2374 | (if (or (<= bottom term-scroll-start) (> bottom term-height)) |
| 2348 | term-height | 2375 | term-height |
| 2349 | bottom)) | 2376 | bottom)) |
| 2350 | (setq term-scroll-with-delete | 2377 | (setq term-scroll-with-delete |
| @@ -2375,7 +2402,6 @@ The top-most line is line 0." | |||
| 2375 | (setq term-saved-home-marker nil) | 2402 | (setq term-saved-home-marker nil) |
| 2376 | (goto-char term-home-marker))) | 2403 | (goto-char term-home-marker))) |
| 2377 | (setq term-current-column nil) | 2404 | (setq term-current-column nil) |
| 2378 | (setq term-line-start-column nil) | ||
| 2379 | (setq term-current-row 0) | 2405 | (setq term-current-row 0) |
| 2380 | (term-goto row col)))) | 2406 | (term-goto row col)))) |
| 2381 | 2407 | ||
| @@ -2558,17 +2584,19 @@ The top-most line is line 0." | |||
| 2558 | (interactive) | 2584 | (interactive) |
| 2559 | (if (term-handling-pager) | 2585 | (if (term-handling-pager) |
| 2560 | (term-pager-continue nil) | 2586 | (term-pager-continue nil) |
| 2561 | (setq term-pager-count nil))) | 2587 | (setq term-pager-count nil)) |
| 2588 | (term-update-mode-line)) | ||
| 2562 | 2589 | ||
| 2563 | ; Enable pager processing. | 2590 | ; Enable pager processing. |
| 2564 | (defun term-pager-enable () | 2591 | (defun term-pager-enable () |
| 2565 | (interactive) | 2592 | (interactive) |
| 2566 | (or term-pager-count | 2593 | (or (term-pager-enabled) |
| 2567 | (setq term-pager-count 0))) ;; Or maybe set to (term-current-row) ?? | 2594 | (setq term-pager-count 0)) ;; Or maybe set to (term-current-row) ?? |
| 2595 | (term-update-mode-line)) | ||
| 2568 | 2596 | ||
| 2569 | (defun term-pager-toggle () | 2597 | (defun term-pager-toggle () |
| 2570 | (interactive) | 2598 | (interactive) |
| 2571 | (if term-pager-count (term-pager-disable) (term-pager-enable))) | 2599 | (if (term-pager-enabled) (term-pager-disable) (term-pager-enable))) |
| 2572 | 2600 | ||
| 2573 | (term-ifnot-xemacs | 2601 | (term-ifnot-xemacs |
| 2574 | (defalias 'term-fake-pager-enable 'term-pager-toggle) | 2602 | (defalias 'term-fake-pager-enable 'term-pager-toggle) |
| @@ -2645,7 +2673,6 @@ all pending output has been dealt with.")) | |||
| 2645 | (goto-char save-point) | 2673 | (goto-char save-point) |
| 2646 | (set-marker save-point nil) | 2674 | (set-marker save-point nil) |
| 2647 | (setq term-current-column nil) | 2675 | (setq term-current-column nil) |
| 2648 | (setq term-line-start-column nil) | ||
| 2649 | (setq term-current-row nil)))) | 2676 | (setq term-current-row nil)))) |
| 2650 | down) | 2677 | down) |
| 2651 | 2678 | ||
| @@ -2670,10 +2697,10 @@ all pending output has been dealt with.")) | |||
| 2670 | 2697 | ||
| 2671 | (defun term-erase-in-line (kind) | 2698 | (defun term-erase-in-line (kind) |
| 2672 | (if (> kind 1) ;; erase left of point | 2699 | (if (> kind 1) ;; erase left of point |
| 2673 | (let ((cols (term-horizontal-column)) (saved-point (point)) | 2700 | (let ((cols (term-horizontal-column)) (saved-point (point))) |
| 2674 | (term-vertical-motion 0) | 2701 | (term-vertical-motion 0) |
| 2675 | (delete-region (point) saved-point) | 2702 | (delete-region (point) saved-point) |
| 2676 | (term-insert-char ?\n cols)))) | 2703 | (term-insert-char ?\n cols))) |
| 2677 | (if (not (eq kind 1)) ;; erase right of point | 2704 | (if (not (eq kind 1)) ;; erase right of point |
| 2678 | (let ((saved-point (point)) | 2705 | (let ((saved-point (point)) |
| 2679 | (wrapped (and (zerop (term-horizontal-column)) | 2706 | (wrapped (and (zerop (term-horizontal-column)) |
| @@ -2710,9 +2737,8 @@ Should only be called when point is at the start of a screen line." | |||
| 2710 | (delete-region start-region end-region) | 2737 | (delete-region start-region end-region) |
| 2711 | (term-unwrap-line) | 2738 | (term-unwrap-line) |
| 2712 | (if (eq kind 1) | 2739 | (if (eq kind 1) |
| 2713 | (term-insert-char \?n row)) | 2740 | (term-insert-char ?\n row)) |
| 2714 | (setq term-current-column nil) | 2741 | (setq term-current-column nil) |
| 2715 | (setq term-line-start-column nil) | ||
| 2716 | (setq term-current-row nil) | 2742 | (setq term-current-row nil) |
| 2717 | (term-goto row col))))) | 2743 | (term-goto row col))))) |
| 2718 | 2744 | ||