aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2003-02-04 11:43:01 +0000
committerRichard M. Stallman2003-02-04 11:43:01 +0000
commitc2f0944a1e74fa595a43864ccd316f75d58f1e78 (patch)
tree71cab478f9c5745f5c58abde546c9ea1f4e7899b
parent37d4a06e710581b016602f9583657b9aa69fbe72 (diff)
downloademacs-c2f0944a1e74fa595a43864ccd316f75d58f1e78.tar.gz
emacs-c2f0944a1e74fa595a43864ccd316f75d58f1e78.zip
(term-raw-map): Set it up at load time.
(term-char-mode): Don't set up term-raw-map here. (term-set-escape-char): Don't set up C-x subcommand. (term-ansi-face-already-done): Renamed from term-ansi-face-alredy-done. (term-command-hook): Avoid error if STRING is empty. (term, term-mode): Doc fixes. Redesign handling of colors and faces. Delete all the faces that this mode used to make. (ansi-term-color-vector): New variable. (ansi-term-fg-faces-vector, ansi-term-bg-faces-vector) (ansi-term-inv-bg-faces-vector, ansi-term-inv-fg-faces-vector): Variables deleted. (term-default-fg-color, term-default-bg-color): Use defcustom. (term-handle-colors-array): Use ansi-term-color-vector, and specify face attributes rather than faces in `face' property. (term-ansi-fg-faces-vector, term-ansi-bg-faces-vector) (term-ansi-inv-fg-faces-vector, term-ansi-inv-bg-faces-vector) (term-ansi-reverse-faces-vector): Unused variables deleted. (term-ignore-error): Macro deleted.
-rw-r--r--lisp/term.el640
1 files changed, 281 insertions, 359 deletions
diff --git a/lisp/term.el b/lisp/term.el
index eecd2abdf6e..bb3c9cb9e53 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -688,7 +688,7 @@ Buffer local variable.")
688(defvar term-ansi-at-save-anon nil) 688(defvar term-ansi-at-save-anon nil)
689(defvar term-ansi-current-bold 0) 689(defvar term-ansi-current-bold 0)
690(defvar term-ansi-current-color 0) 690(defvar term-ansi-current-color 0)
691(defvar term-ansi-face-alredy-done 0) 691(defvar term-ansi-face-already-done 0)
692(defvar term-ansi-current-bg-color 0) 692(defvar term-ansi-current-bg-color 0)
693(defvar term-ansi-current-underline 0) 693(defvar term-ansi-current-underline 0)
694(defvar term-ansi-current-highlight 0) 694(defvar term-ansi-current-highlight 0)
@@ -697,11 +697,6 @@ Buffer local variable.")
697(defvar term-ansi-default-fg 0) 697(defvar term-ansi-default-fg 0)
698(defvar term-ansi-default-bg 0) 698(defvar term-ansi-default-bg 0)
699(defvar term-ansi-current-temp 0) 699(defvar term-ansi-current-temp 0)
700(defvar term-ansi-fg-faces-vector nil)
701(defvar term-ansi-bg-faces-vector nil)
702(defvar term-ansi-inv-fg-faces-vector nil)
703(defvar term-ansi-inv-bg-faces-vector nil)
704(defvar term-ansi-reverse-faces-vector nil)
705 700
706;;; Four should be enough, if you want more, just add. -mm 701;;; Four should be enough, if you want more, just add. -mm
707(defvar term-terminal-more-parameters 0) 702(defvar term-terminal-more-parameters 0)
@@ -712,118 +707,19 @@ Buffer local variable.")
712 707
713;;; faces -mm 708;;; faces -mm
714 709
715(defmacro term-ignore-error (&rest body) 710(defcustom term-default-fg-color nil
716 `(condition-case nil 711 "Default color for foreground in `term'."
717 (progn ,@body) 712 :group 'term
718 (error nil))) 713 :type 'string)
719 714
720(defvar term-default-fg-color nil) 715(defcustom term-default-bg-color nil
721(defvar term-default-bg-color nil) 716 "Default color for background in `term'."
722 717 :group 'term
723(when (fboundp 'make-face) 718 :type 'string)
724;;; --- Simple faces --- 719
725 (copy-face 'default 'term-default) 720(defvar ansi-term-color-vector
726 (make-face 'term-default-fg) 721 [nil "black" "red" "green" "yellow" "blue"
727 (make-face 'term-default-bg) 722 "magenta" "cyan" "white"])
728 (make-face 'term-default-fg-inv)
729 (make-face 'term-default-bg-inv)
730 (make-face 'term-bold)
731 (make-face 'term-underline)
732 (make-face 'term-invisible)
733 (make-face 'term-invisible-inv)
734
735 (term-ignore-error
736 (set-face-foreground 'term-default-fg term-default-fg-color))
737 (term-ignore-error
738 (set-face-background 'term-default-bg term-default-bg-color))
739
740 (term-ignore-error
741 (set-face-foreground 'term-default-fg-inv term-default-bg-color))
742 (term-ignore-error
743 (set-face-background 'term-default-bg-inv term-default-fg-color))
744
745 (term-ignore-error
746 (set-face-background 'term-invisible term-default-bg-color))
747
748 (term-ignore-error
749 (set-face-background 'term-invisible-inv term-default-fg-color))
750
751 ;; Set the colors of the new faces.
752 (term-ignore-error
753 (make-face-bold 'term-bold))
754
755 (term-ignore-error
756 (set-face-underline-p 'term-underline t))
757
758;;; --- Fg faces ---
759 (make-face 'term-black)
760 (make-face 'term-red)
761 (make-face 'term-green)
762 (make-face 'term-yellow)
763 (make-face 'term-blue)
764 (make-face 'term-magenta)
765 (make-face 'term-cyan)
766 (make-face 'term-white)
767
768 (term-ignore-error
769 (set-face-foreground 'term-black "black"))
770 (term-ignore-error
771 (set-face-foreground 'term-red "red"))
772 (term-ignore-error
773 (set-face-foreground 'term-green "green"))
774 (term-ignore-error
775 (set-face-foreground 'term-yellow "yellow"))
776 (term-ignore-error
777 (set-face-foreground 'term-blue "blue"))
778 (term-ignore-error
779 (set-face-foreground 'term-magenta "magenta"))
780 (term-ignore-error
781 (set-face-foreground 'term-cyan "cyan"))
782 (term-ignore-error
783 (set-face-foreground 'term-white "white"))
784
785;;; --- Bg faces ---
786 (make-face 'term-blackbg)
787 (make-face 'term-redbg)
788 (make-face 'term-greenbg)
789 (make-face 'term-yellowbg)
790 (make-face 'term-bluebg)
791 (make-face 'term-magentabg)
792 (make-face 'term-cyanbg)
793 (make-face 'term-whitebg)
794
795 (term-ignore-error
796 (set-face-background 'term-blackbg "black"))
797 (term-ignore-error
798 (set-face-background 'term-redbg "red"))
799 (term-ignore-error
800 (set-face-background 'term-greenbg "green"))
801 (term-ignore-error
802 (set-face-background 'term-yellowbg "yellow"))
803 (term-ignore-error
804 (set-face-background 'term-bluebg "blue"))
805 (term-ignore-error
806 (set-face-background 'term-magentabg "magenta"))
807 (term-ignore-error
808 (set-face-background 'term-cyanbg "cyan"))
809 (term-ignore-error
810 (set-face-background 'term-whitebg "white")))
811
812(defvar ansi-term-fg-faces-vector
813 [term-default-fg term-black term-red term-green term-yellow term-blue
814 term-magenta term-cyan term-white])
815
816(defvar ansi-term-bg-faces-vector
817 [term-default-bg term-blackbg term-redbg term-greenbg term-yellowbg
818 term-bluebg term-magentabg term-cyanbg term-whitebg])
819
820(defvar ansi-term-inv-bg-faces-vector
821 [term-default-fg-inv term-black term-red term-green term-yellow term-blue
822 term-magenta term-cyan term-white])
823
824(defvar ansi-term-inv-fg-faces-vector
825 [term-default-bg-inv term-blackbg term-redbg term-greenbg term-yellowbg
826 term-bluebg term-magentabg term-cyanbg term-whitebg])
827 723
828;;; Inspiration came from comint.el -mm 724;;; Inspiration came from comint.el -mm
829(defvar term-buffer-maximum-size 2048 725(defvar term-buffer-maximum-size 2048
@@ -832,7 +728,7 @@ Term buffers are truncated from the top to be no greater than this number.
832Notice that a setting of 0 means 'don't truncate anything'. This variable 728Notice that a setting of 0 means 'don't truncate anything'. This variable
833is buffer-local.") 729is buffer-local.")
834;;; 730;;;
835 731
836(term-if-xemacs 732(term-if-xemacs
837 (defvar term-terminal-menu 733 (defvar term-terminal-menu
838 '("Terminal" 734 '("Terminal"
@@ -841,149 +737,6 @@ is buffer-local.")
841 [ "Enable paging" term-pager-toggle (not term-pager-count)] 737 [ "Enable paging" term-pager-toggle (not term-pager-count)]
842 [ "Disable paging" term-pager-toggle term-pager-count]))) 738 [ "Disable paging" term-pager-toggle term-pager-count])))
843 739
844(put 'term-mode 'mode-class 'special)
845
846(defun term-mode ()
847 "Major mode for interacting with an inferior interpreter.
848Interpreter name is same as buffer name, sans the asterisks.
849In line sub-mode, return at end of buffer sends line as input,
850while return not at end copies rest of line to end and sends it.
851In char sub-mode, each character (except `term-escape-char`) is
852set immediately.
853
854This mode is typically customised to create inferior-lisp-mode,
855shell-mode, etc.. This can be done by setting the hooks
856term-input-filter-functions, term-input-filter, term-input-sender and
857term-get-old-input to appropriate functions, and the variable
858term-prompt-regexp to the appropriate regular expression.
859
860An input history is maintained of size `term-input-ring-size', and
861can be accessed with the commands \\[term-next-input],
862\\[term-previous-input], and \\[term-dynamic-list-input-ring].
863Input ring history expansion can be achieved with the commands
864\\[term-replace-by-expanded-history] or \\[term-magic-space].
865Input ring expansion is controlled by the variable `term-input-autoexpand',
866and addition is controlled by the variable `term-input-ignoredups'.
867
868Input to, and output from, the subprocess can cause the window to scroll to
869the end of the buffer. See variables `term-scroll-to-bottom-on-input',
870and `term-scroll-to-bottom-on-output'.
871
872If you accidentally suspend your process, use \\[term-continue-subjob]
873to continue it.
874
875\\{term-mode-map}
876
877Entry to this mode runs the hooks on term-mode-hook"
878 (interactive)
879 ;; Do not remove this. All major modes must do this.
880 (kill-all-local-variables)
881 (setq major-mode 'term-mode)
882 (setq mode-name "Term")
883 (use-local-map term-mode-map)
884 (make-local-variable 'term-home-marker)
885 (setq term-home-marker (copy-marker 0))
886 (make-local-variable 'term-saved-home-marker)
887 (make-local-variable 'term-height)
888 (make-local-variable 'term-width)
889 (setq term-width (1- (window-width)))
890 (setq term-height (1- (window-height)))
891 (make-local-variable 'term-terminal-parameter)
892 (make-local-variable 'term-saved-cursor)
893 (make-local-variable 'term-last-input-start)
894 (setq term-last-input-start (make-marker))
895 (make-local-variable 'term-last-input-end)
896 (setq term-last-input-end (make-marker))
897 (make-local-variable 'term-last-input-match)
898 (setq term-last-input-match "")
899 (make-local-variable 'term-prompt-regexp) ; Don't set; default
900 (make-local-variable 'term-input-ring-size) ; ...to global val.
901 (make-local-variable 'term-input-ring)
902 (make-local-variable 'term-input-ring-file-name)
903 (or (and (boundp 'term-input-ring) term-input-ring)
904 (setq term-input-ring (make-ring term-input-ring-size)))
905 (make-local-variable 'term-input-ring-index)
906 (or (and (boundp 'term-input-ring-index) term-input-ring-index)
907 (setq term-input-ring-index nil))
908
909 (make-local-variable 'term-command-hook)
910 (setq term-command-hook (symbol-function 'term-command-hook))
911
912;;; I'm not sure these saves are necessary but, since I
913;;; haven't tested the whole thing on a net connected machine with
914;;; a properly configured ange-ftp, I've decided to be conservative
915;;; and put them in. -mm
916
917 (make-local-variable 'term-ansi-at-host)
918 (setq term-ansi-at-host (system-name))
919
920 (make-local-variable 'term-ansi-at-dir)
921 (setq term-ansi-at-dir default-directory)
922
923 (make-local-variable 'term-ansi-at-message)
924 (setq term-ansi-at-message nil)
925
926;;; For user tracking purposes -mm
927 (make-local-variable 'ange-ftp-default-user)
928 (make-local-variable 'ange-ftp-default-password)
929 (make-local-variable 'ange-ftp-generate-anonymous-password)
930
931;;; You may want to have different scroll-back sizes -mm
932 (make-local-variable 'term-buffer-maximum-size)
933
934;;; Of course these have to be buffer-local -mm
935 (make-local-variable 'term-ansi-current-bold)
936 (make-local-variable 'term-ansi-current-color)
937 (make-local-variable 'term-ansi-face-alredy-done)
938 (make-local-variable 'term-ansi-current-bg-color)
939 (make-local-variable 'term-ansi-current-underline)
940 (make-local-variable 'term-ansi-current-highlight)
941 (make-local-variable 'term-ansi-current-reverse)
942 (make-local-variable 'term-ansi-current-invisible)
943
944 (make-local-variable 'term-terminal-state)
945 (make-local-variable 'term-kill-echo-list)
946 (make-local-variable 'term-start-line-column)
947 (make-local-variable 'term-current-column)
948 (make-local-variable 'term-current-row)
949 (make-local-variable 'term-log-buffer)
950 (make-local-variable 'term-scroll-start)
951 (make-local-variable 'term-scroll-end)
952 (setq term-scroll-end term-height)
953 (make-local-variable 'term-scroll-with-delete)
954 (make-local-variable 'term-pager-count)
955 (make-local-variable 'term-pager-old-local-map)
956 (make-local-variable 'term-old-mode-map)
957 (make-local-variable 'term-insert-mode)
958 (make-local-variable 'term-dynamic-complete-functions)
959 (make-local-variable 'term-completion-fignore)
960 (make-local-variable 'term-get-old-input)
961 (make-local-variable 'term-matching-input-from-input-string)
962 (make-local-variable 'term-input-autoexpand)
963 (make-local-variable 'term-input-ignoredups)
964 (make-local-variable 'term-delimiter-argument-list)
965 (make-local-variable 'term-input-filter-functions)
966 (make-local-variable 'term-input-filter)
967 (make-local-variable 'term-input-sender)
968 (make-local-variable 'term-eol-on-send)
969 (make-local-variable 'term-scroll-to-bottom-on-output)
970 (make-local-variable 'term-scroll-show-maximum-output)
971 (make-local-variable 'term-ptyp)
972 (make-local-variable 'term-exec-hook)
973 (make-local-variable 'term-vertical-motion)
974 (make-local-variable 'term-pending-delete-marker)
975 (setq term-pending-delete-marker (make-marker))
976 (make-local-variable 'term-current-face)
977 (make-local-variable 'term-pending-frame)
978 (setq term-pending-frame nil)
979 (run-hooks 'term-mode-hook)
980 (term-if-xemacs
981 (set-buffer-menubar
982 (append current-menubar (list term-terminal-menu))))
983 (or term-input-ring
984 (setq term-input-ring (make-ring term-input-ring-size)))
985 (term-update-mode-line))
986
987(if term-mode-map 740(if term-mode-map
988 nil 741 nil
989 (setq term-mode-map (make-sparse-keymap)) 742 (setq term-mode-map (make-sparse-keymap))
@@ -1016,7 +769,6 @@ Entry to this mode runs the hooks on term-mode-hook"
1016 (define-key term-mode-map "\C-c\C-j" 'term-line-mode) 769 (define-key term-mode-map "\C-c\C-j" 'term-line-mode)
1017 (define-key term-mode-map "\C-c\C-q" 'term-pager-toggle) 770 (define-key term-mode-map "\C-c\C-q" 'term-pager-toggle)
1018 771
1019
1020; ;; completion: 772; ;; completion:
1021; (define-key term-mode-map [menu-bar completion] 773; (define-key term-mode-map [menu-bar completion]
1022; (cons "Complete" (make-sparse-keymap "Complete"))) 774; (cons "Complete" (make-sparse-keymap "Complete")))
@@ -1114,7 +866,218 @@ Entry to this mode runs the hooks on term-mode-hook"
1114 (define-key term-mode-map [menu-bar signals] 866 (define-key term-mode-map [menu-bar signals]
1115 (setq term-signals-menu (cons "Signals" newmap))) 867 (setq term-signals-menu (cons "Signals" newmap)))
1116 ))) 868 )))
869
870;; Set up term-raw-map, etc.
871
872(defun term-set-escape-char (c)
873 "Change term-escape-char and keymaps that depend on it."
874 (if term-escape-char
875 (define-key term-raw-map term-escape-char 'term-send-raw))
876 (setq c (make-string 1 c))
877 (define-key term-raw-map c term-raw-escape-map)
878 ;; Define standard bindings in term-raw-escape-map
879 (define-key term-raw-escape-map "\C-v"
880 (lookup-key (current-global-map) "\C-v"))
881 (define-key term-raw-escape-map "\C-u"
882 (lookup-key (current-global-map) "\C-u"))
883 (define-key term-raw-escape-map c 'term-send-raw)
884 (define-key term-raw-escape-map "\C-q" 'term-pager-toggle)
885 ;; The keybinding for term-char-mode is needed by the menubar code.
886 (define-key term-raw-escape-map "\C-k" 'term-char-mode)
887 (define-key term-raw-escape-map "\C-j" 'term-line-mode)
888 ;; It's convenient to have execute-extended-command here.
889 (define-key term-raw-escape-map [?\M-x] 'execute-extended-command))
890
891(let* ((map (make-keymap))
892 (esc-map (make-keymap))
893 (i 0))
894 (while (< i 128)
895 (define-key map (make-string 1 i) 'term-send-raw)
896 (define-key esc-map (make-string 1 i) 'term-send-raw-meta)
897 (setq i (1+ i)))
898 (dolist (elm (generic-character-list))
899 (define-key map (vector elm) 'term-send-raw))
900 (define-key map "\e" esc-map)
901 (setq term-raw-map map)
902 (setq term-raw-escape-map
903 (copy-keymap (lookup-key (current-global-map) "\C-x")))
904
905;;; Added nearly all the 'grey keys' -mm
906
907 (progn
908 (term-if-xemacs
909 (define-key term-raw-map [button2] 'term-mouse-paste))
910 (term-ifnot-xemacs
911 (define-key term-raw-map [mouse-2] 'term-mouse-paste)
912 (define-key term-raw-map [menu-bar terminal] term-terminal-menu)
913 (define-key term-raw-map [menu-bar signals] term-signals-menu))
914 (define-key term-raw-map [up] 'term-send-up)
915 (define-key term-raw-map [down] 'term-send-down)
916 (define-key term-raw-map [right] 'term-send-right)
917 (define-key term-raw-map [left] 'term-send-left)
918 (define-key term-raw-map [delete] 'term-send-del)
919 (define-key term-raw-map [backspace] 'term-send-backspace)
920 (define-key term-raw-map [home] 'term-send-home)
921 (define-key term-raw-map [end] 'term-send-end)
922 (define-key term-raw-map [prior] 'term-send-prior)
923 (define-key term-raw-map [next] 'term-send-next)))
924
925(term-set-escape-char ?\C-c)
926
927(put 'term-mode 'mode-class 'special)
928
929(defun term-mode ()
930 "Major mode for interacting with an inferior interpreter.
931The interpreter name is same as buffer name, sans the asterisks.
932
933There are two submodes: line mode and char mode. By default, you are
934in char mode. In char sub-mode, each character (except
935`term-escape-char') is set immediately.
936
937In line mode, you send a line of input at a time; use
938\\[term-send-input] to send.
1117 939
940In line mode, this maintains an input history of size
941`term-input-ring-size', and you can access it with the commands
942\\[term-next-input], \\[term-previous-input], and
943\\[term-dynamic-list-input-ring]. Input ring history expansion can be
944achieved with the commands \\[term-replace-by-expanded-history] or
945\\[term-magic-space]. Input ring expansion is controlled by the
946variable `term-input-autoexpand', and addition is controlled by the
947variable `term-input-ignoredups'.
948
949Input to, and output from, the subprocess can cause the window to scroll to
950the end of the buffer. See variables `term-scroll-to-bottom-on-input',
951and `term-scroll-to-bottom-on-output'.
952
953If you accidentally suspend your process, use \\[term-continue-subjob]
954to continue it.
955
956This mode can be customised to create specific modes for running
957particular subprocesses. This can be done by setting the hooks
958`term-input-filter-functions', `term-input-filter',
959`term-input-sender' and `term-get-old-input' to appropriate functions,
960and the variable `term-prompt-regexp' to the appropriate regular
961expression.
962
963Commands in raw mode:
964
965\\{term-raw-map}
966
967Commands in line mode:
968
969\\{term-mode-map}
970
971Entry to this mode runs the hooks on `term-mode-hook'."
972 (interactive)
973 ;; Do not remove this. All major modes must do this.
974 (kill-all-local-variables)
975 (setq major-mode 'term-mode)
976 (setq mode-name "Term")
977 (use-local-map term-mode-map)
978 (make-local-variable 'term-home-marker)
979 (setq term-home-marker (copy-marker 0))
980 (make-local-variable 'term-saved-home-marker)
981 (make-local-variable 'term-height)
982 (make-local-variable 'term-width)
983 (setq term-width (1- (window-width)))
984 (setq term-height (1- (window-height)))
985 (make-local-variable 'term-terminal-parameter)
986 (make-local-variable 'term-saved-cursor)
987 (make-local-variable 'term-last-input-start)
988 (setq term-last-input-start (make-marker))
989 (make-local-variable 'term-last-input-end)
990 (setq term-last-input-end (make-marker))
991 (make-local-variable 'term-last-input-match)
992 (setq term-last-input-match "")
993 (make-local-variable 'term-prompt-regexp) ; Don't set; default
994 (make-local-variable 'term-input-ring-size) ; ...to global val.
995 (make-local-variable 'term-input-ring)
996 (make-local-variable 'term-input-ring-file-name)
997 (or (and (boundp 'term-input-ring) term-input-ring)
998 (setq term-input-ring (make-ring term-input-ring-size)))
999 (make-local-variable 'term-input-ring-index)
1000 (or (and (boundp 'term-input-ring-index) term-input-ring-index)
1001 (setq term-input-ring-index nil))
1002
1003 (make-local-variable 'term-command-hook)
1004 (setq term-command-hook (symbol-function 'term-command-hook))
1005
1006;;; I'm not sure these saves are necessary but, since I
1007;;; haven't tested the whole thing on a net connected machine with
1008;;; a properly configured ange-ftp, I've decided to be conservative
1009;;; and put them in. -mm
1010
1011 (make-local-variable 'term-ansi-at-host)
1012 (setq term-ansi-at-host (system-name))
1013
1014 (make-local-variable 'term-ansi-at-dir)
1015 (setq term-ansi-at-dir default-directory)
1016
1017 (make-local-variable 'term-ansi-at-message)
1018 (setq term-ansi-at-message nil)
1019
1020;;; For user tracking purposes -mm
1021 (make-local-variable 'ange-ftp-default-user)
1022 (make-local-variable 'ange-ftp-default-password)
1023 (make-local-variable 'ange-ftp-generate-anonymous-password)
1024
1025;;; You may want to have different scroll-back sizes -mm
1026 (make-local-variable 'term-buffer-maximum-size)
1027
1028;;; Of course these have to be buffer-local -mm
1029 (make-local-variable 'term-ansi-current-bold)
1030 (make-local-variable 'term-ansi-current-color)
1031 (make-local-variable 'term-ansi-face-already-done)
1032 (make-local-variable 'term-ansi-current-bg-color)
1033 (make-local-variable 'term-ansi-current-underline)
1034 (make-local-variable 'term-ansi-current-highlight)
1035 (make-local-variable 'term-ansi-current-reverse)
1036 (make-local-variable 'term-ansi-current-invisible)
1037
1038 (make-local-variable 'term-terminal-state)
1039 (make-local-variable 'term-kill-echo-list)
1040 (make-local-variable 'term-start-line-column)
1041 (make-local-variable 'term-current-column)
1042 (make-local-variable 'term-current-row)
1043 (make-local-variable 'term-log-buffer)
1044 (make-local-variable 'term-scroll-start)
1045 (make-local-variable 'term-scroll-end)
1046 (setq term-scroll-end term-height)
1047 (make-local-variable 'term-scroll-with-delete)
1048 (make-local-variable 'term-pager-count)
1049 (make-local-variable 'term-pager-old-local-map)
1050 (make-local-variable 'term-old-mode-map)
1051 (make-local-variable 'term-insert-mode)
1052 (make-local-variable 'term-dynamic-complete-functions)
1053 (make-local-variable 'term-completion-fignore)
1054 (make-local-variable 'term-get-old-input)
1055 (make-local-variable 'term-matching-input-from-input-string)
1056 (make-local-variable 'term-input-autoexpand)
1057 (make-local-variable 'term-input-ignoredups)
1058 (make-local-variable 'term-delimiter-argument-list)
1059 (make-local-variable 'term-input-filter-functions)
1060 (make-local-variable 'term-input-filter)
1061 (make-local-variable 'term-input-sender)
1062 (make-local-variable 'term-eol-on-send)
1063 (make-local-variable 'term-scroll-to-bottom-on-output)
1064 (make-local-variable 'term-scroll-show-maximum-output)
1065 (make-local-variable 'term-ptyp)
1066 (make-local-variable 'term-exec-hook)
1067 (make-local-variable 'term-vertical-motion)
1068 (make-local-variable 'term-pending-delete-marker)
1069 (setq term-pending-delete-marker (make-marker))
1070 (make-local-variable 'term-current-face)
1071 (make-local-variable 'term-pending-frame)
1072 (setq term-pending-frame nil)
1073 (run-hooks 'term-mode-hook)
1074 (term-if-xemacs
1075 (set-buffer-menubar
1076 (append current-menubar (list term-terminal-menu))))
1077 (or term-input-ring
1078 (setq term-input-ring (make-ring term-input-ring-size)))
1079 (term-update-mode-line))
1080
1118(defun term-reset-size (height width) 1081(defun term-reset-size (height width)
1119 (setq term-height height) 1082 (setq term-height height)
1120 (setq term-width width) 1083 (setq term-width width)
@@ -1227,70 +1190,12 @@ without any interpretation."
1227(defun term-send-next () (interactive) (term-send-raw-string "\e[6~")) 1190(defun term-send-next () (interactive) (term-send-raw-string "\e[6~"))
1228(defun term-send-del () (interactive) (term-send-raw-string "\C-?")) 1191(defun term-send-del () (interactive) (term-send-raw-string "\C-?"))
1229(defun term-send-backspace () (interactive) (term-send-raw-string "\C-H")) 1192(defun term-send-backspace () (interactive) (term-send-raw-string "\C-H"))
1230 1193
1231(defun term-set-escape-char (c)
1232 "Change term-escape-char and keymaps that depend on it."
1233 (if term-escape-char
1234 (define-key term-raw-map term-escape-char 'term-send-raw))
1235 (setq c (make-string 1 c))
1236 (define-key term-raw-map c term-raw-escape-map)
1237 ;; Define standard bindings in term-raw-escape-map
1238 (define-key term-raw-escape-map "\C-x"
1239 (lookup-key (current-global-map) "\C-x"))
1240 (define-key term-raw-escape-map "\C-v"
1241 (lookup-key (current-global-map) "\C-v"))
1242 (define-key term-raw-escape-map "\C-u"
1243 (lookup-key (current-global-map) "\C-u"))
1244 (define-key term-raw-escape-map c 'term-send-raw)
1245 (define-key term-raw-escape-map "\C-q" 'term-pager-toggle)
1246 ;; The keybinding for term-char-mode is needed by the menubar code.
1247 (define-key term-raw-escape-map "\C-k" 'term-char-mode)
1248 (define-key term-raw-escape-map "\C-j" 'term-line-mode)
1249 ;; It's convenient to have execute-extended-command here.
1250 (define-key term-raw-escape-map [?\M-x] 'execute-extended-command))
1251
1252(defun term-char-mode () 1194(defun term-char-mode ()
1253 "Switch to char (\"raw\") sub-mode of term mode. 1195 "Switch to char (\"raw\") sub-mode of term mode.
1254Each character you type is sent directly to the inferior without 1196Each character you type is sent directly to the inferior without
1255intervention from Emacs, except for the escape character (usually C-c)." 1197intervention from Emacs, except for the escape character (usually C-c)."
1256 (interactive) 1198 (interactive)
1257 (if (not term-raw-map)
1258 (let* ((map (make-keymap))
1259 (esc-map (make-keymap))
1260 (i 0))
1261 (while (< i 128)
1262 (define-key map (make-string 1 i) 'term-send-raw)
1263 (define-key esc-map (make-string 1 i) 'term-send-raw-meta)
1264 (setq i (1+ i)))
1265 (dolist (elm (generic-character-list))
1266 (define-key map (vector elm) 'term-send-raw))
1267 (define-key map "\e" esc-map)
1268 (setq term-raw-map map)
1269 (setq term-raw-escape-map
1270 (copy-keymap (lookup-key (current-global-map) "\C-x")))
1271
1272;;; Added nearly all the 'grey keys' -mm
1273
1274 (progn
1275 (term-if-xemacs
1276 (define-key term-raw-map [button2] 'term-mouse-paste))
1277 (term-ifnot-xemacs
1278 (define-key term-raw-map [mouse-2] 'term-mouse-paste)
1279 (define-key term-raw-map [menu-bar terminal] term-terminal-menu)
1280 (define-key term-raw-map [menu-bar signals] term-signals-menu))
1281 (define-key term-raw-map [up] 'term-send-up)
1282 (define-key term-raw-map [down] 'term-send-down)
1283 (define-key term-raw-map [right] 'term-send-right)
1284 (define-key term-raw-map [left] 'term-send-left)
1285 (define-key term-raw-map [delete] 'term-send-del)
1286 (define-key term-raw-map [backspace] 'term-send-backspace)
1287 (define-key term-raw-map [home] 'term-send-home)
1288 (define-key term-raw-map [end] 'term-send-end)
1289 (define-key term-raw-map [prior] 'term-send-prior)
1290 (define-key term-raw-map [next] 'term-send-next))
1291
1292
1293 (term-set-escape-char ?\C-c)))
1294 ;; FIXME: Emit message? Cfr ilisp-raw-message 1199 ;; FIXME: Emit message? Cfr ilisp-raw-message
1295 (if (term-in-line-mode) 1200 (if (term-in-line-mode)
1296 (progn 1201 (progn
@@ -1353,7 +1258,11 @@ the process. Any more args are arguments to PROGRAM."
1353 1258
1354;;;###autoload 1259;;;###autoload
1355(defun term (program) 1260(defun term (program)
1356 "Start a terminal-emulator in a new buffer." 1261 "Start a terminal-emulator in a new buffer.
1262The buffer is in Term mode; see `term-mode' for the
1263commands to use in that buffer.
1264
1265\\<term-raw-map>Type \\[switch-to-buffer] to switch to another buffer."
1357 (interactive (list (read-from-minibuffer "Run program: " 1266 (interactive (list (read-from-minibuffer "Run program: "
1358 (or explicit-shell-file-name 1267 (or explicit-shell-file-name
1359 (getenv "ESHELL") 1268 (getenv "ESHELL")
@@ -3046,14 +2955,13 @@ See `term-prompt-regexp'."
3046 2955
3047;;; 0 (Reset) or unknown (reset anyway) 2956;;; 0 (Reset) or unknown (reset anyway)
3048 (t 2957 (t
3049 (setq term-current-face 2958 (setq term-current-face nil)
3050 (list 'term-default-fg 'term-default-bg))
3051 (setq term-ansi-current-underline 0) 2959 (setq term-ansi-current-underline 0)
3052 (setq term-ansi-current-bold 0) 2960 (setq term-ansi-current-bold 0)
3053 (setq term-ansi-current-reverse 0) 2961 (setq term-ansi-current-reverse 0)
3054 (setq term-ansi-current-color 0) 2962 (setq term-ansi-current-color 0)
3055 (setq term-ansi-current-invisible 0) 2963 (setq term-ansi-current-invisible 0)
3056 (setq term-ansi-face-alredy-done 1) 2964 (setq term-ansi-face-already-done 1)
3057 (setq term-ansi-current-bg-color 0))) 2965 (setq term-ansi-current-bg-color 0)))
3058 2966
3059; (message "Debug: U-%d R-%d B-%d I-%d D-%d F-%d B-%d" 2967; (message "Debug: U-%d R-%d B-%d I-%d D-%d F-%d B-%d"
@@ -3061,53 +2969,65 @@ See `term-prompt-regexp'."
3061; term-ansi-current-reverse 2969; term-ansi-current-reverse
3062; term-ansi-current-bold 2970; term-ansi-current-bold
3063; term-ansi-current-invisible 2971; term-ansi-current-invisible
3064; term-ansi-face-alredy-done 2972; term-ansi-face-already-done
3065; term-ansi-current-color 2973; term-ansi-current-color
3066; term-ansi-current-bg-color) 2974; term-ansi-current-bg-color)
3067 2975
3068 2976
3069 (if (= term-ansi-face-alredy-done 0) 2977 (if (= term-ansi-face-already-done 0)
3070 (if (= term-ansi-current-reverse 1) 2978 (if (= term-ansi-current-reverse 1)
3071 (progn 2979 (if (= term-ansi-current-invisible 1)
3072 (if (= term-ansi-current-invisible 1) 2980 (setq term-current-face
3073 (if (= term-ansi-current-color 0) 2981 (if (= term-ansi-current-color 0)
3074 (setq term-current-face 2982 (list :background
3075 '(term-default-bg-inv term-default-fg)) 2983 term-default-fg-color
3076 (setq term-current-face 2984 :foreground
3077 (list (elt ansi-term-inv-fg-faces-vector term-ansi-current-color) 2985 term-default-fg-color)
3078 (elt ansi-term-inv-bg-faces-vector term-ansi-current-color)))) 2986 (list :background
3079 ;; No need to bother with anything else if it's invisible 2987 (elt ansi-term-color-vector term-ansi-current-color)
3080 (progn 2988 :foreground
2989 (elt ansi-term-color-vector term-ansi-current-color)))
2990 ;; No need to bother with anything else if it's invisible
2991 )
2992 (setq term-current-face
2993 (list :background
2994 (elt ansi-term-color-vector term-ansi-current-color)
2995 :foreground
2996 (elt ansi-term-color-vector term-ansi-current-bg-color)))
2997 (if (= term-ansi-current-bold 1)
3081 (setq term-current-face 2998 (setq term-current-face
3082 (list (elt ansi-term-inv-fg-faces-vector term-ansi-current-color) 2999 (append '(:weight bold) term-current-face)))
3083 (elt ansi-term-inv-bg-faces-vector term-ansi-current-bg-color))) 3000 (if (= term-ansi-current-underline 1)
3084 (if (= term-ansi-current-bold 1)
3085 (setq term-current-face
3086 (append '(term-bold) term-current-face)))
3087 (if (= term-ansi-current-underline 1)
3088 (setq term-current-face
3089 (append '(term-underline) term-current-face))))))
3090 (if (= term-ansi-current-invisible 1)
3091 (if (= term-ansi-current-bg-color 0)
3092 (setq term-current-face 3001 (setq term-current-face
3093 '(term-default-fg-inv term-default-bg)) 3002 (append '(:underline t) term-current-face))))
3094 (setq term-current-face 3003 (if (= term-ansi-current-invisible 1)
3095 (list (elt ansi-term-fg-faces-vector term-ansi-current-bg-color) 3004 (setq term-current-face
3096 (elt ansi-term-bg-faces-vector term-ansi-current-bg-color)))) 3005 (if (= term-ansi-current-bg-color 0)
3097 ;; No need to bother with anything else if it's invisible 3006 (list :background
3007 term-default-bg-color
3008 :foreground
3009 term-default-bg-color)
3010 (list :foreground
3011 (elt ansi-term-color-vector term-ansi-current-bg-color)
3012 :background
3013 (elt ansi-term-color-vector term-ansi-current-bg-color)))
3014 ;; No need to bother with anything else if it's invisible
3015 )
3098 (setq term-current-face 3016 (setq term-current-face
3099 (list (elt ansi-term-fg-faces-vector term-ansi-current-color) 3017 (list :foreground
3100 (elt ansi-term-bg-faces-vector term-ansi-current-bg-color))) 3018 (elt ansi-term-color-vector term-ansi-current-color)
3019 :background
3020 (elt ansi-term-color-vector term-ansi-current-bg-color)))
3101 (if (= term-ansi-current-bold 1) 3021 (if (= term-ansi-current-bold 1)
3102 (setq term-current-face 3022 (setq term-current-face
3103 (append '(term-bold) term-current-face))) 3023 (append '(:weight bold) term-current-face)))
3104 (if (= term-ansi-current-underline 1) 3024 (if (= term-ansi-current-underline 1)
3105 (setq term-current-face 3025 (setq term-current-face
3106 (append '(term-underline) term-current-face)))))) 3026 (append '(:underline t) term-current-face))))))
3107 3027
3108; (message "Debug %S" term-current-face) 3028; (message "Debug %S" term-current-face)
3109 3029
3110 (setq term-ansi-face-alredy-done 0)) 3030 (setq term-ansi-face-already-done 0))
3111 3031
3112 3032
3113;;; Handle a character assuming (eq terminal-state 2) - 3033;;; Handle a character assuming (eq terminal-state 2) -
@@ -3246,7 +3166,9 @@ The top-most line is line 0."
3246;; Default value for the symbol term-command-hook. 3166;; Default value for the symbol term-command-hook.
3247 3167
3248(defun term-command-hook (string) 3168(defun term-command-hook (string)
3249 (cond ((= (aref string 0) ?\032) 3169 (cond ((equal string "")
3170 t)
3171 ((= (aref string 0) ?\032)
3250 ;; gdb (when invoked with -fullname) prints: 3172 ;; gdb (when invoked with -fullname) prints:
3251 ;; \032\032FULLFILENAME:LINENUMBER:CHARPOS:BEG_OR_MIDDLE:PC\n 3173 ;; \032\032FULLFILENAME:LINENUMBER:CHARPOS:BEG_OR_MIDDLE:PC\n
3252 (let* ((first-colon (string-match ":" string 1)) 3174 (let* ((first-colon (string-match ":" string 1))