comparison lisp/term.el @ 36763:00b03757e45b

These changes are based on a patch sent from Yong Lu <lyongu@yahoo.com>. (term-set-escape-char): Bind M-x to execute-extended-command in term-raw-escape-map. (term-move-columns): Don't try to move to negagive column. (term-emulate-terminal): Insert a string before deleting a text to overwrite.
author Kenichi Handa <handa@m17n.org>
date Tue, 13 Mar 2001 11:21:52 +0000
parents 3ce84dcc97d3
children 67b464da13ec
comparison
equal deleted inserted replaced
36762:39edfdf3170b 36763:00b03757e45b
20 20
21 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA. 24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Marck 13 2001
27 ;;; Fixes for CJK support by Yong Lu <lyongu@yahoo.com>.
25 28
26 ;;; Dir/Hostname tracking and ANSI colorization by 29 ;;; Dir/Hostname tracking and ANSI colorization by
27 ;;; Marco Melgazzi <marco@techie.com>. 30 ;;; Marco Melgazzi <marco@techie.com>.
28 31
29 ;;; To see what I've modified and where it came from search for '-mm' 32 ;;; To see what I've modified and where it came from search for '-mm'
1267 (lookup-key (current-global-map) "\C-u")) 1270 (lookup-key (current-global-map) "\C-u"))
1268 (define-key term-raw-escape-map c 'term-send-raw) 1271 (define-key term-raw-escape-map c 'term-send-raw)
1269 (define-key term-raw-escape-map "\C-q" 'term-pager-toggle) 1272 (define-key term-raw-escape-map "\C-q" 'term-pager-toggle)
1270 ;; The keybinding for term-char-mode is needed by the menubar code. 1273 ;; The keybinding for term-char-mode is needed by the menubar code.
1271 (define-key term-raw-escape-map "\C-k" 'term-char-mode) 1274 (define-key term-raw-escape-map "\C-k" 'term-char-mode)
1272 (define-key term-raw-escape-map "\C-j" 'term-line-mode)) 1275 (define-key term-raw-escape-map "\C-j" 'term-line-mode)
1276 ;; It's convenient to have execute-extended-command here.
1277 (define-key term-raw-escape-map [?\M-x] 'execute-extended-command))
1273 1278
1274 (defun term-char-mode () 1279 (defun term-char-mode ()
1275 "Switch to char (\"raw\") sub-mode of term mode. 1280 "Switch to char (\"raw\") sub-mode of term mode.
1276 Each character you type is sent directly to the inferior without 1281 Each character you type is sent directly to the inferior without
1277 intervention from Emacs, except for the escape character (usually C-c)." 1282 intervention from Emacs, except for the escape character (usually C-c)."
2604 ;;; Same as (current-column), but uses term-current-column as a cache. 2609 ;;; Same as (current-column), but uses term-current-column as a cache.
2605 (defun term-current-column () 2610 (defun term-current-column ()
2606 (cond (term-current-column) 2611 (cond (term-current-column)
2607 ((setq term-current-column (current-column))))) 2612 ((setq term-current-column (current-column)))))
2608 2613
2609 ;;; Move DELTA column right (or left if delta < 0). 2614 ;;; Move DELTA column right (or left if delta < 0 limiting at column 0).
2610 2615
2611 (defun term-move-columns (delta) 2616 (defun term-move-columns (delta)
2612 (setq term-current-column (+ (term-current-column) delta)) 2617 (setq term-current-column (max 0 (+ (term-current-column) delta)))
2613 (move-to-column term-current-column t)) 2618 (move-to-column term-current-column t))
2614 2619
2615 ;; Insert COUNT copies of CHAR in the default face. 2620 ;; Insert COUNT copies of CHAR in the default face.
2616 (defun term-insert-char (char count) 2621 (defun term-insert-char (char count)
2617 (let ((old-point (point))) 2622 (let ((old-point (point)))
2784 (t ;; Doing PAGER processing. 2789 (t ;; Doing PAGER processing.
2785 (setq count 0 funny i) 2790 (setq count 0 funny i)
2786 (setq term-current-column nil) 2791 (setq term-current-column nil)
2787 (setq term-start-line-column nil))) 2792 (setq term-start-line-column nil)))
2788 (setq old-point (point)) 2793 (setq old-point (point))
2789 ;; In the common case that we're at the end of 2794
2790 ;; the buffer, we can save a little work. 2795 ;; Insert a string, check how many columns
2791 (cond ((/= (point) (point-max)) 2796 ;; we moved, then delete that many columns
2792 (if term-insert-mode 2797 ;; following point if not eob nor insert-mode.
2793 ;; Inserting spaces, then deleting them, 2798 (let ((old-column (current-column))
2794 ;; then inserting the actual text is 2799 columns pos)
2795 ;; inefficient, but it is simple, and 2800 (insert (substring str i funny))
2796 ;; the actual overhead is miniscule. 2801 (setq term-current-column (current-column)
2797 (term-insert-spaces count)) 2802 columns (- term-current-column old-column))
2798 (term-move-columns count) 2803 (when (not (or (eobp) term-insert-mode))
2799 (delete-region old-point (point))) 2804 (setq pos (point))
2800 (t (setq term-current-column (+ (term-current-column) count)))) 2805 (term-move-columns columns)
2801 (insert (substring str i funny)) 2806 (delete-region pos (point))))
2807 (setq term-current-column nil)
2808
2802 (put-text-property old-point (point) 2809 (put-text-property old-point (point)
2803 'face term-current-face) 2810 'face term-current-face)
2804 ;; If the last char was written in last column, 2811 ;; If the last char was written in last column,
2805 ;; back up one column, but remember we did so. 2812 ;; back up one column, but remember we did so.
2806 ;; Thus we emulate xterm/vt100-style line-wrapping. 2813 ;; Thus we emulate xterm/vt100-style line-wrapping.