2013-03-11 00:24:15 -04:00
|
|
|
;;; xterm.el --- define function key sequences and standard colors for xterm -*- lexical-binding: t -*-
|
1995-06-09 02:31:33 +00:00
|
|
|
|
2022-01-01 02:45:51 -05:00
|
|
|
;; Copyright (C) 1995, 2001-2022 Free Software Foundation, Inc.
|
1996-01-14 09:58:28 +00:00
|
|
|
|
1995-06-09 02:31:33 +00:00
|
|
|
;; Author: FSF
|
|
|
|
;; Keywords: terminals
|
|
|
|
|
1996-01-14 09:58:28 +00:00
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 04:34:22 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1996-01-14 09:58:28 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 04:34:22 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1996-01-14 09:58:28 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1995-06-09 02:31:33 +00:00
|
|
|
|
2001-07-16 11:39:42 +00:00
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
1995-06-09 02:31:33 +00:00
|
|
|
|
2011-06-09 11:58:18 -05:00
|
|
|
(defgroup xterm nil
|
|
|
|
"XTerm support."
|
|
|
|
:version "24.1"
|
2013-05-15 19:55:41 -04:00
|
|
|
:group 'terminals)
|
2011-06-09 11:58:18 -05:00
|
|
|
|
2015-05-03 22:24:20 -04:00
|
|
|
(defconst xterm--extra-capabilities-type
|
|
|
|
;; NOTE: If you add entries here, make sure to update
|
|
|
|
;; `terminal-init-xterm' as well.
|
|
|
|
'(set (const :tag "modifyOtherKeys support" modifyOtherKeys)
|
|
|
|
(const :tag "report background" reportBackground)
|
2015-05-25 17:03:50 -04:00
|
|
|
(const :tag "get X selection" getSelection)
|
2015-05-03 22:24:20 -04:00
|
|
|
(const :tag "set X selection" setSelection)))
|
|
|
|
|
2011-06-09 11:58:18 -05:00
|
|
|
(defcustom xterm-extra-capabilities 'check
|
2012-03-31 13:22:04 -07:00
|
|
|
"Whether Xterm supports some additional, more modern, features.
|
|
|
|
If nil, just assume that it does not.
|
|
|
|
If `check', try to check if it does.
|
|
|
|
If a list, assume that the listed features are supported, without checking.
|
|
|
|
|
|
|
|
The relevant features are:
|
2013-02-12 09:36:54 -08:00
|
|
|
modifyOtherKeys -- if supported, more key bindings work (e.g., \"\\C-,\")
|
2015-04-13 10:48:47 -04:00
|
|
|
reportBackground -- if supported, Xterm reports its background color
|
2015-05-25 17:03:50 -04:00
|
|
|
getSelection -- if supported, Xterm yanks text from the X selection
|
|
|
|
setSelection -- if supported, Xterm saves killed text to the X selection"
|
Add missing :version tags to new defgroups and defcustoms
* window.el (window-sides-slots):
* tool-bar.el (tool-bar-position):
* term/xterm.el (xterm-extra-capabilities):
* ses.el (ses-self-reference-early-detection):
* progmodes/verilog-mode.el (verilog-auto-declare-nettype)
(verilog-auto-wire-type)
(verilog-auto-delete-trailing-whitespace)
(verilog-auto-reset-blocking-in-non, verilog-auto-inst-sort)
(verilog-auto-tieoff-declaration):
* progmodes/sql.el (sql-login-hook, sql-ansi-statement-starters)
(sql-oracle-statement-starters, sql-oracle-scan-on):
* progmodes/prolog.el (prolog-align-comments-flag)
(prolog-indent-mline-comments-flag, prolog-object-end-to-0-flag)
(prolog-left-indent-regexp, prolog-paren-indent-p)
(prolog-paren-indent, prolog-parse-mode, prolog-keywords)
(prolog-types, prolog-mode-specificators)
(prolog-determinism-specificators, prolog-directives)
(prolog-electric-newline-flag, prolog-hungry-delete-key-flag)
(prolog-electric-dot-flag)
(prolog-electric-dot-full-predicate-template)
(prolog-electric-underscore-flag, prolog-electric-tab-flag)
(prolog-electric-if-then-else-flag, prolog-electric-colon-flag)
(prolog-electric-dash-flag, prolog-old-sicstus-keys-flag)
(prolog-program-switches, prolog-prompt-regexp)
(prolog-debug-on-string, prolog-debug-off-string)
(prolog-trace-on-string, prolog-trace-off-string)
(prolog-zip-on-string, prolog-zip-off-string)
(prolog-use-standard-consult-compile-method-flag)
(prolog-use-prolog-tokenizer-flag, prolog-imenu-flag)
(prolog-imenu-max-lines, prolog-info-predicate-index)
(prolog-underscore-wordchar-flag, prolog-use-sicstus-sd)
(prolog-char-quote-workaround):
* progmodes/cc-vars.el (c-defun-tactic):
* net/tramp.el (tramp-encoding-command-interactive)
(tramp-local-end-of-line):
* net/soap-client.el (soap-client):
* net/netrc.el (netrc-file):
* net/gnutls.el (gnutls):
* minibuffer.el (completion-category-overrides)
(completion-cycle-threshold)
(completion-pcm-complete-word-inserts-delimiters):
* man.el (Man-name-local-regexp):
* mail/feedmail.el (feedmail-display-full-frame):
* international/characters.el (glyphless-char-display-control):
* eshell/em-ls.el (eshell-ls-date-format):
* emacs-lisp/cl-indent.el (lisp-lambda-list-keyword-alignment)
(lisp-lambda-list-keyword-parameter-indentation)
(lisp-lambda-list-keyword-parameter-alignment):
* doc-view.el (doc-view-image-width, doc-view-unoconv-program):
* dired-x.el (dired-omit-verbose):
* cus-theme.el (custom-theme-allow-multiple-selections):
* calc/calc.el (calc-highlight-selections-with-faces)
(calc-lu-field-reference, calc-lu-power-reference)
(calc-note-threshold):
* battery.el (battery-mode-line-limit):
* arc-mode.el (archive-7z-extract, archive-7z-expunge)
(archive-7z-update):
* allout.el (allout-prefixed-keybindings)
(allout-unprefixed-keybindings)
(allout-inhibit-auto-fill-on-headline)
(allout-flattened-numbering-abbreviation):
* allout-widgets.el (allout-widgets-auto-activation)
(allout-widgets-icons-dark-subdir)
(allout-widgets-icons-light-subdir, allout-widgets-icon-types)
(allout-widgets-theme-dark-background)
(allout-widgets-theme-light-background)
(allout-widgets-item-image-properties-emacs)
(allout-widgets-item-image-properties-xemacs)
(allout-widgets-run-unit-tests-on-load)
(allout-widgets-time-decoration-activity)
(allout-widgets-hook-error-post-time)
(allout-widgets-track-decoration):
* gnus/sieve-manage.el (sieve-manage-default-stream):
* gnus/shr.el (shr):
* gnus/nnir.el (nnir-ignored-newsgroups, nnir-summary-line-format)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-notmuch-program)
(nnir-notmuch-additional-switches, nnir-notmuch-remove-prefix)
(nnir-method-default-engines):
* gnus/message.el (message-cite-reply-position):
* gnus/gssapi.el (gssapi-program):
* gnus/gravatar.el (gravatar):
* gnus/gnus-sum.el (gnus-refer-thread-use-nnir):
* gnus/gnus-registry.el (gnus-registry-unfollowed-addresses)
(gnus-registry-max-pruned-entries):
* gnus/gnus-picon.el (gnus-picon-inhibit-top-level-domains):
* gnus/gnus-int.el (gnus-after-set-mark-hook)
(gnus-before-update-mark-hook):
* gnus/gnus-async.el (gnus-async-post-fetch-function):
* gnus/auth-source.el (auth-source-cache-expiry):
Add missing :version tags to new defcustoms and defgroups.
2012-02-11 14:13:29 -08:00
|
|
|
:version "24.1"
|
2015-05-03 22:24:20 -04:00
|
|
|
:type `(choice (const :tag "Check" check)
|
|
|
|
,xterm--extra-capabilities-type))
|
2015-04-13 10:48:47 -04:00
|
|
|
|
|
|
|
(defcustom xterm-max-cut-length 100000
|
|
|
|
"Maximum number of bytes to cut into xterm using the OSC 52 sequence.
|
|
|
|
|
|
|
|
The OSC 52 sequence requires a terminator byte. Some terminals will ignore or
|
|
|
|
mistreat a terminated sequence that is longer than a certain size, usually to
|
|
|
|
protect users from runaway sequences.
|
|
|
|
|
|
|
|
This variable allows you to tweak the maximum number of bytes that will be sent
|
|
|
|
using the OSC 52 sequence.
|
|
|
|
|
|
|
|
If you select a region larger than this size, it won't be copied to your system
|
|
|
|
clipboard. Since clipboard data is base 64 encoded, the actual number of
|
|
|
|
string bytes that can be copied is 3/4 of this value."
|
2016-01-12 20:06:49 -05:00
|
|
|
:version "25.1"
|
2015-04-13 10:48:47 -04:00
|
|
|
:type 'integer)
|
2011-06-09 11:58:18 -05:00
|
|
|
|
2017-10-09 08:12:46 -04:00
|
|
|
(defcustom xterm-set-window-title nil
|
2017-09-20 11:39:37 -04:00
|
|
|
"Whether Emacs should set window titles to an Emacs frame in an XTerm."
|
|
|
|
:version "27.1"
|
|
|
|
:type 'boolean)
|
|
|
|
|
2021-09-03 09:45:32 +02:00
|
|
|
(defcustom xterm-store-paste-on-kill-ring t
|
|
|
|
"If non-nil, pasting text into Emacs will put the text onto the kill ring.
|
|
|
|
This user option is only heeded when using a terminal using xterm
|
|
|
|
capabilities, and only when that terminal understands bracketed paste."
|
|
|
|
:version "28.1"
|
|
|
|
:type 'boolean)
|
|
|
|
|
2014-04-17 00:54:23 -07:00
|
|
|
(defconst xterm-paste-ending-sequence "\e[201~"
|
2018-06-09 13:43:05 -07:00
|
|
|
"Characters sent by the terminal to end a bracketed paste.")
|
2014-04-17 00:54:23 -07:00
|
|
|
|
2016-05-22 13:38:53 -07:00
|
|
|
(defun xterm--pasted-text ()
|
|
|
|
"Handle the rest of a terminal paste operation.
|
|
|
|
Return the pasted text as a string."
|
|
|
|
(let ((end-marker-length (length xterm-paste-ending-sequence)))
|
|
|
|
(with-temp-buffer
|
|
|
|
(set-buffer-multibyte nil)
|
|
|
|
(while (not (search-backward xterm-paste-ending-sequence
|
|
|
|
(- (point) end-marker-length) t))
|
|
|
|
(let ((event (read-event nil nil
|
|
|
|
;; Use finite timeout to avoid glomming the
|
|
|
|
;; event onto this-command-keys.
|
|
|
|
most-positive-fixnum)))
|
|
|
|
(when (eql event ?\r)
|
|
|
|
(setf event ?\n))
|
|
|
|
(insert event)))
|
|
|
|
(let ((last-coding-system-used))
|
|
|
|
(decode-coding-region (point-min) (point) (keyboard-coding-system)
|
|
|
|
t)))))
|
|
|
|
|
2018-06-09 13:14:11 -07:00
|
|
|
(defun xterm-paste (event)
|
2014-04-17 00:54:23 -07:00
|
|
|
"Handle the start of a terminal paste operation."
|
2018-06-09 13:14:11 -07:00
|
|
|
(interactive "e")
|
|
|
|
(unless (eq (car-safe event) 'xterm-paste)
|
|
|
|
(error "xterm-paste must be found to xterm-paste event"))
|
2021-09-03 09:45:32 +02:00
|
|
|
(let ((pasted-text (nth 1 event)))
|
|
|
|
(if xterm-store-paste-on-kill-ring
|
|
|
|
;; Put the text onto the kill ring and then insert it into the
|
|
|
|
;; buffer.
|
|
|
|
(let ((interprogram-paste-function (lambda () pasted-text)))
|
|
|
|
(yank))
|
|
|
|
;; Insert the text without putting it onto the kill ring.
|
|
|
|
(push-mark)
|
|
|
|
(insert-for-yank pasted-text))))
|
2014-04-17 00:54:23 -07:00
|
|
|
|
2018-06-09 13:14:11 -07:00
|
|
|
;; Put xterm-paste itself in global-map because, after translation,
|
|
|
|
;; it's just a normal input event.
|
2014-04-17 00:54:23 -07:00
|
|
|
(define-key global-map [xterm-paste] #'xterm-paste)
|
|
|
|
|
2018-06-09 13:14:11 -07:00
|
|
|
;; By returning an empty key sequence, these two functions perform the
|
|
|
|
;; moral equivalent of the kind of transparent event processing done
|
|
|
|
;; by read-event's handling of special-event-map, but inside
|
|
|
|
;; read-key-sequence (which can recognize multi-character terminal
|
|
|
|
;; notifications) instead of read-event (which can't).
|
2018-06-08 22:47:27 -07:00
|
|
|
|
2018-06-09 13:14:11 -07:00
|
|
|
(defun xterm-translate-focus-in (_prompt)
|
2018-06-11 14:58:09 -07:00
|
|
|
(setf (terminal-parameter nil 'tty-focus-state) 'focused)
|
|
|
|
(funcall after-focus-change-function)
|
2018-06-09 13:14:11 -07:00
|
|
|
[])
|
|
|
|
|
|
|
|
(defun xterm-translate-focus-out (_prompt)
|
2018-06-11 14:58:09 -07:00
|
|
|
(setf (terminal-parameter nil 'tty-focus-state) 'defocused)
|
|
|
|
(funcall after-focus-change-function)
|
2018-06-09 13:14:11 -07:00
|
|
|
[])
|
|
|
|
|
2018-06-11 14:58:09 -07:00
|
|
|
(defun xterm--suspend-tty-function (_tty)
|
|
|
|
;; We can't know what happens to the tty after we're suspended
|
|
|
|
(setf (terminal-parameter nil 'tty-focus-state) nil)
|
|
|
|
(funcall after-focus-change-function))
|
|
|
|
|
2018-06-09 13:14:11 -07:00
|
|
|
;; Similarly, we want to transparently slurp the entirety of a
|
|
|
|
;; bracketed paste and encapsulate it into a single event. We used to
|
|
|
|
;; just slurp up the bracketed paste content in the event handler, but
|
|
|
|
;; this strategy can produce unexpected results in a caller manually
|
|
|
|
;; looping on read-key and buffering input for later processing.
|
|
|
|
|
|
|
|
(defun xterm-translate-bracketed-paste (_prompt)
|
|
|
|
(vector (list 'xterm-paste (xterm--pasted-text))))
|
2018-06-08 22:47:27 -07:00
|
|
|
|
2015-05-11 17:23:36 -04:00
|
|
|
(defvar xterm-rxvt-function-map
|
2007-09-07 19:47:46 +00:00
|
|
|
(let ((map (make-sparse-keymap)))
|
2015-05-11 17:23:36 -04:00
|
|
|
(define-key map "\e[2~" [insert])
|
|
|
|
(define-key map "\e[3~" [delete])
|
|
|
|
(define-key map "\e[4~" [select])
|
|
|
|
(define-key map "\e[5~" [prior])
|
|
|
|
(define-key map "\e[6~" [next])
|
2007-09-07 19:47:46 +00:00
|
|
|
|
|
|
|
(define-key map "\e[15~" [f5])
|
|
|
|
(define-key map "\e[17~" [f6])
|
|
|
|
(define-key map "\e[18~" [f7])
|
|
|
|
(define-key map "\e[19~" [f8])
|
|
|
|
(define-key map "\e[20~" [f9])
|
|
|
|
(define-key map "\e[21~" [f10])
|
2015-05-11 17:23:36 -04:00
|
|
|
|
|
|
|
(define-key map "\e[2;2~" [S-insert])
|
|
|
|
|
|
|
|
;; Other versions of xterm might emit these.
|
|
|
|
(define-key map "\e[A" [up])
|
|
|
|
(define-key map "\e[B" [down])
|
|
|
|
(define-key map "\e[C" [right])
|
|
|
|
(define-key map "\e[D" [left])
|
|
|
|
|
|
|
|
(define-key map "\e[11~" [f1])
|
|
|
|
(define-key map "\e[12~" [f2])
|
|
|
|
(define-key map "\e[13~" [f3])
|
|
|
|
(define-key map "\e[14~" [f4])
|
|
|
|
|
2018-06-09 13:14:11 -07:00
|
|
|
;; Recognize the start of a bracketed paste sequence.
|
|
|
|
;; The translation function internally recognizes the end.
|
|
|
|
(define-key map "\e[200~" #'xterm-translate-bracketed-paste)
|
2015-05-11 17:23:36 -04:00
|
|
|
|
2018-06-09 13:14:11 -07:00
|
|
|
;; These translation functions actually call the focus handlers
|
|
|
|
;; internally and return an empty sequence, causing us to go on to
|
|
|
|
;; read the next event.
|
|
|
|
(define-key map "\e[I" #'xterm-translate-focus-in)
|
|
|
|
(define-key map "\e[O" #'xterm-translate-focus-out)
|
2018-06-08 22:47:27 -07:00
|
|
|
|
2015-05-11 17:23:36 -04:00
|
|
|
map)
|
|
|
|
"Keymap of escape sequences, shared between xterm and rxvt support.")
|
|
|
|
|
|
|
|
(defvar xterm-function-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(set-keymap-parent map xterm-rxvt-function-map)
|
|
|
|
|
|
|
|
;; xterm from X.org 6.8.2 uses these key definitions.
|
|
|
|
(define-key map "\eOP" [f1])
|
|
|
|
(define-key map "\eOQ" [f2])
|
|
|
|
(define-key map "\eOR" [f3])
|
|
|
|
(define-key map "\eOS" [f4])
|
2007-09-07 19:47:46 +00:00
|
|
|
(define-key map "\e[23~" [f11])
|
|
|
|
(define-key map "\e[24~" [f12])
|
|
|
|
|
|
|
|
(define-key map "\eO2P" [S-f1])
|
|
|
|
(define-key map "\eO2Q" [S-f2])
|
|
|
|
(define-key map "\eO2R" [S-f3])
|
|
|
|
(define-key map "\eO2S" [S-f4])
|
|
|
|
(define-key map "\e[1;2P" [S-f1])
|
|
|
|
(define-key map "\e[1;2Q" [S-f2])
|
|
|
|
(define-key map "\e[1;2R" [S-f3])
|
|
|
|
(define-key map "\e[1;2S" [S-f4])
|
|
|
|
(define-key map "\e[15;2~" [S-f5])
|
|
|
|
(define-key map "\e[17;2~" [S-f6])
|
|
|
|
(define-key map "\e[18;2~" [S-f7])
|
|
|
|
(define-key map "\e[19;2~" [S-f8])
|
|
|
|
(define-key map "\e[20;2~" [S-f9])
|
|
|
|
(define-key map "\e[21;2~" [S-f10])
|
|
|
|
(define-key map "\e[23;2~" [S-f11])
|
|
|
|
(define-key map "\e[24;2~" [S-f12])
|
|
|
|
|
|
|
|
(define-key map "\eO5P" [C-f1])
|
|
|
|
(define-key map "\eO5Q" [C-f2])
|
|
|
|
(define-key map "\eO5R" [C-f3])
|
|
|
|
(define-key map "\eO5S" [C-f4])
|
|
|
|
(define-key map "\e[15;5~" [C-f5])
|
|
|
|
(define-key map "\e[17;5~" [C-f6])
|
|
|
|
(define-key map "\e[18;5~" [C-f7])
|
|
|
|
(define-key map "\e[19;5~" [C-f8])
|
|
|
|
(define-key map "\e[20;5~" [C-f9])
|
|
|
|
(define-key map "\e[21;5~" [C-f10])
|
|
|
|
(define-key map "\e[23;5~" [C-f11])
|
|
|
|
(define-key map "\e[24;5~" [C-f12])
|
|
|
|
|
|
|
|
(define-key map "\eO6P" [C-S-f1])
|
|
|
|
(define-key map "\eO6Q" [C-S-f2])
|
|
|
|
(define-key map "\eO6R" [C-S-f3])
|
|
|
|
(define-key map "\eO6S" [C-S-f4])
|
|
|
|
(define-key map "\e[15;6~" [C-S-f5])
|
|
|
|
(define-key map "\e[17;6~" [C-S-f6])
|
|
|
|
(define-key map "\e[18;6~" [C-S-f7])
|
|
|
|
(define-key map "\e[19;6~" [C-S-f8])
|
|
|
|
(define-key map "\e[20;6~" [C-S-f9])
|
|
|
|
(define-key map "\e[21;6~" [C-S-f10])
|
|
|
|
(define-key map "\e[23;6~" [C-S-f11])
|
|
|
|
(define-key map "\e[24;6~" [C-S-f12])
|
|
|
|
|
2007-10-12 15:32:23 +00:00
|
|
|
(define-key map "\eO3P" [M-f1])
|
|
|
|
(define-key map "\eO3Q" [M-f2])
|
|
|
|
(define-key map "\eO3R" [M-f3])
|
|
|
|
(define-key map "\eO3S" [M-f4])
|
|
|
|
(define-key map "\e[15;3~" [M-f5])
|
|
|
|
(define-key map "\e[17;3~" [M-f6])
|
|
|
|
(define-key map "\e[18;3~" [M-f7])
|
|
|
|
(define-key map "\e[19;3~" [M-f8])
|
|
|
|
(define-key map "\e[20;3~" [M-f9])
|
|
|
|
(define-key map "\e[21;3~" [M-f10])
|
|
|
|
(define-key map "\e[23;3~" [M-f11])
|
|
|
|
(define-key map "\e[24;3~" [M-f12])
|
2007-09-07 19:47:46 +00:00
|
|
|
|
2007-09-12 18:58:26 +00:00
|
|
|
(define-key map "\eO4P" [M-S-f1])
|
|
|
|
(define-key map "\eO4Q" [M-S-f2])
|
|
|
|
(define-key map "\eO4R" [M-S-f3])
|
|
|
|
(define-key map "\eO4S" [M-S-f4])
|
|
|
|
(define-key map "\e[15;4~" [M-S-f5])
|
|
|
|
(define-key map "\e[17;4~" [M-S-f6])
|
|
|
|
(define-key map "\e[18;4~" [M-S-f7])
|
|
|
|
(define-key map "\e[19;4~" [M-S-f8])
|
|
|
|
(define-key map "\e[20;4~" [M-S-f9])
|
|
|
|
(define-key map "\e[21;4~" [M-S-f10])
|
|
|
|
(define-key map "\e[23;4~" [M-S-f11])
|
|
|
|
(define-key map "\e[24;4~" [M-S-f12])
|
|
|
|
|
2007-09-07 19:47:46 +00:00
|
|
|
(define-key map "\eOA" [up])
|
|
|
|
(define-key map "\eOB" [down])
|
|
|
|
(define-key map "\eOC" [right])
|
|
|
|
(define-key map "\eOD" [left])
|
|
|
|
(define-key map "\eOF" [end])
|
|
|
|
(define-key map "\eOH" [home])
|
|
|
|
|
|
|
|
(define-key map "\e[1;2A" [S-up])
|
|
|
|
(define-key map "\e[1;2B" [S-down])
|
|
|
|
(define-key map "\e[1;2C" [S-right])
|
|
|
|
(define-key map "\e[1;2D" [S-left])
|
|
|
|
(define-key map "\e[1;2F" [S-end])
|
|
|
|
(define-key map "\e[1;2H" [S-home])
|
|
|
|
|
2007-09-12 18:58:26 +00:00
|
|
|
(define-key map "\e[1;4A" [M-S-up])
|
|
|
|
(define-key map "\e[1;4B" [M-S-down])
|
|
|
|
(define-key map "\e[1;4C" [M-S-right])
|
|
|
|
(define-key map "\e[1;4D" [M-S-left])
|
|
|
|
(define-key map "\e[1;4F" [M-S-end])
|
|
|
|
(define-key map "\e[1;4H" [M-S-home])
|
|
|
|
|
2007-09-07 19:47:46 +00:00
|
|
|
(define-key map "\e[1;5A" [C-up])
|
|
|
|
(define-key map "\e[1;5B" [C-down])
|
|
|
|
(define-key map "\e[1;5C" [C-right])
|
|
|
|
(define-key map "\e[1;5D" [C-left])
|
|
|
|
(define-key map "\e[1;5F" [C-end])
|
|
|
|
(define-key map "\e[1;5H" [C-home])
|
|
|
|
|
|
|
|
(define-key map "\e[1;6A" [C-S-up])
|
|
|
|
(define-key map "\e[1;6B" [C-S-down])
|
|
|
|
(define-key map "\e[1;6C" [C-S-right])
|
|
|
|
(define-key map "\e[1;6D" [C-S-left])
|
|
|
|
(define-key map "\e[1;6F" [C-S-end])
|
|
|
|
(define-key map "\e[1;6H" [C-S-home])
|
|
|
|
|
2007-09-14 02:09:19 +00:00
|
|
|
(define-key map "\e[1;7A" [C-M-up])
|
|
|
|
(define-key map "\e[1;7B" [C-M-down])
|
|
|
|
(define-key map "\e[1;7C" [C-M-right])
|
|
|
|
(define-key map "\e[1;7D" [C-M-left])
|
|
|
|
(define-key map "\e[1;7F" [C-M-end])
|
|
|
|
(define-key map "\e[1;7H" [C-M-home])
|
|
|
|
|
2007-09-12 18:58:26 +00:00
|
|
|
(define-key map "\e[1;8A" [C-M-S-up])
|
|
|
|
(define-key map "\e[1;8B" [C-M-S-down])
|
|
|
|
(define-key map "\e[1;8C" [C-M-S-right])
|
|
|
|
(define-key map "\e[1;8D" [C-M-S-left])
|
|
|
|
(define-key map "\e[1;8F" [C-M-S-end])
|
|
|
|
(define-key map "\e[1;8H" [C-M-S-home])
|
|
|
|
|
2007-10-12 15:32:23 +00:00
|
|
|
(define-key map "\e[1;3A" [M-up])
|
|
|
|
(define-key map "\e[1;3B" [M-down])
|
|
|
|
(define-key map "\e[1;3C" [M-right])
|
|
|
|
(define-key map "\e[1;3D" [M-left])
|
|
|
|
(define-key map "\e[1;3F" [M-end])
|
|
|
|
(define-key map "\e[1;3H" [M-home])
|
2007-09-07 19:47:46 +00:00
|
|
|
|
|
|
|
(define-key map "\e[3;2~" [S-delete])
|
|
|
|
(define-key map "\e[5;2~" [S-prior])
|
|
|
|
(define-key map "\e[6;2~" [S-next])
|
|
|
|
|
2007-09-12 18:58:26 +00:00
|
|
|
(define-key map "\e[2;4~" [M-S-insert])
|
|
|
|
(define-key map "\e[3;4~" [M-S-delete])
|
|
|
|
(define-key map "\e[5;4~" [M-S-prior])
|
|
|
|
(define-key map "\e[6;4~" [M-S-next])
|
|
|
|
|
2007-09-07 19:47:46 +00:00
|
|
|
(define-key map "\e[2;5~" [C-insert])
|
|
|
|
(define-key map "\e[3;5~" [C-delete])
|
|
|
|
(define-key map "\e[5;5~" [C-prior])
|
|
|
|
(define-key map "\e[6;5~" [C-next])
|
|
|
|
|
|
|
|
(define-key map "\e[2;6~" [C-S-insert])
|
|
|
|
(define-key map "\e[3;6~" [C-S-delete])
|
|
|
|
(define-key map "\e[5;6~" [C-S-prior])
|
|
|
|
(define-key map "\e[6;6~" [C-S-next])
|
|
|
|
|
2007-09-14 02:09:19 +00:00
|
|
|
(define-key map "\e[2;7~" [C-M-insert])
|
|
|
|
(define-key map "\e[3;7~" [C-M-delete])
|
|
|
|
(define-key map "\e[5;7~" [C-M-prior])
|
|
|
|
(define-key map "\e[6;7~" [C-M-next])
|
|
|
|
|
2007-09-12 18:58:26 +00:00
|
|
|
(define-key map "\e[2;8~" [C-M-S-insert])
|
|
|
|
(define-key map "\e[3;8~" [C-M-S-delete])
|
|
|
|
(define-key map "\e[5;8~" [C-M-S-prior])
|
|
|
|
(define-key map "\e[6;8~" [C-M-S-next])
|
|
|
|
|
2007-10-12 15:32:23 +00:00
|
|
|
(define-key map "\e[2;3~" [M-insert])
|
|
|
|
(define-key map "\e[3;3~" [M-delete])
|
|
|
|
(define-key map "\e[5;3~" [M-prior])
|
|
|
|
(define-key map "\e[6;3~" [M-next])
|
2007-09-07 19:47:46 +00:00
|
|
|
|
2021-08-25 18:27:35 -04:00
|
|
|
;; This escape sequence has a controversial story.
|
|
|
|
;; It was initially mapped to [print] (initial commit by Karl Heuer),
|
|
|
|
;; but we can't find any justification for it.
|
|
|
|
;; Xterm uses this escape sequence for both `F16' and `Menu' keys,
|
|
|
|
;; and the reason for it is that in the VT220 keyboard the key
|
|
|
|
;; placed logically at position where `F16' would be (and sending
|
|
|
|
;; the escape sequence that naturally belongs to `F16') was
|
|
|
|
;; labeled `Menu'. [ The story gets even more interesting if you
|
|
|
|
;; want to dig deeper, e.g. some terminals would send that same
|
|
|
|
;; escape sequence in response to `S-F4' (because they (ab)used
|
|
|
|
;; the escape sequence of `F<n+12>' for `S-F<n>'). ]
|
|
|
|
;; The current binding was chosen because current keyboards almost never
|
|
|
|
;; have an `F16' key, whereas many do have a `Menu' key.
|
|
|
|
(define-key map "\e[29~" [menu])
|
2007-09-07 19:47:46 +00:00
|
|
|
|
|
|
|
(define-key map "\eOj" [kp-multiply])
|
|
|
|
(define-key map "\eOk" [kp-add])
|
|
|
|
(define-key map "\eOl" [kp-separator])
|
|
|
|
(define-key map "\eOm" [kp-subtract])
|
|
|
|
(define-key map "\eOo" [kp-divide])
|
|
|
|
(define-key map "\eOp" [kp-0])
|
|
|
|
(define-key map "\eOq" [kp-1])
|
|
|
|
(define-key map "\eOr" [kp-2])
|
|
|
|
(define-key map "\eOs" [kp-3])
|
|
|
|
(define-key map "\eOt" [kp-4])
|
|
|
|
(define-key map "\eOu" [kp-5])
|
|
|
|
(define-key map "\eOv" [kp-6])
|
|
|
|
(define-key map "\eOw" [kp-7])
|
|
|
|
(define-key map "\eOx" [kp-8])
|
|
|
|
(define-key map "\eOy" [kp-9])
|
|
|
|
|
2021-09-08 09:24:11 +02:00
|
|
|
;; Some keypads have an equal key (for instance, most Apple keypads).
|
|
|
|
(define-key map "\eOX" [kp-equal])
|
|
|
|
|
2014-05-25 10:08:24 +02:00
|
|
|
(define-key map "\eO2j" [S-kp-multiply])
|
|
|
|
(define-key map "\eO2k" [S-kp-add])
|
|
|
|
(define-key map "\eO2l" [S-kp-separator])
|
|
|
|
(define-key map "\eO2m" [S-kp-subtract])
|
|
|
|
(define-key map "\eO2o" [S-kp-divide])
|
|
|
|
(define-key map "\eO2p" [S-kp-0])
|
|
|
|
(define-key map "\eO2q" [S-kp-1])
|
|
|
|
(define-key map "\eO2r" [S-kp-2])
|
|
|
|
(define-key map "\eO2s" [S-kp-3])
|
|
|
|
(define-key map "\eO2t" [S-kp-4])
|
|
|
|
(define-key map "\eO2u" [S-kp-5])
|
|
|
|
(define-key map "\eO2v" [S-kp-6])
|
|
|
|
(define-key map "\eO2w" [S-kp-7])
|
|
|
|
(define-key map "\eO2x" [S-kp-8])
|
|
|
|
(define-key map "\eO2y" [S-kp-9])
|
|
|
|
|
|
|
|
(define-key map "\eO4j" [M-S-kp-multiply])
|
|
|
|
(define-key map "\eO4k" [M-S-kp-add])
|
|
|
|
(define-key map "\eO4l" [M-S-kp-separator])
|
|
|
|
(define-key map "\eO4m" [M-S-kp-subtract])
|
|
|
|
(define-key map "\eO4o" [M-S-kp-divide])
|
|
|
|
(define-key map "\eO4p" [M-S-kp-0])
|
|
|
|
(define-key map "\eO4q" [M-S-kp-1])
|
|
|
|
(define-key map "\eO4r" [M-S-kp-2])
|
|
|
|
(define-key map "\eO4s" [M-S-kp-3])
|
|
|
|
(define-key map "\eO4t" [M-S-kp-4])
|
|
|
|
(define-key map "\eO4u" [M-S-kp-5])
|
|
|
|
(define-key map "\eO4v" [M-S-kp-6])
|
|
|
|
(define-key map "\eO4w" [M-S-kp-7])
|
|
|
|
(define-key map "\eO4x" [M-S-kp-8])
|
|
|
|
(define-key map "\eO4y" [M-S-kp-9])
|
|
|
|
|
|
|
|
(define-key map "\eO6j" [C-S-kp-multiply])
|
|
|
|
(define-key map "\eO6k" [C-S-kp-add])
|
|
|
|
(define-key map "\eO6l" [C-S-kp-separator])
|
|
|
|
(define-key map "\eO6m" [C-S-kp-subtract])
|
|
|
|
(define-key map "\eO6o" [C-S-kp-divide])
|
|
|
|
(define-key map "\eO6p" [C-S-kp-0])
|
|
|
|
(define-key map "\eO6q" [C-S-kp-1])
|
|
|
|
(define-key map "\eO6r" [C-S-kp-2])
|
|
|
|
(define-key map "\eO6s" [C-S-kp-3])
|
|
|
|
(define-key map "\eO6t" [C-S-kp-4])
|
|
|
|
(define-key map "\eO6u" [C-S-kp-5])
|
|
|
|
(define-key map "\eO6v" [C-S-kp-6])
|
|
|
|
(define-key map "\eO6w" [C-S-kp-7])
|
|
|
|
(define-key map "\eO6x" [C-S-kp-8])
|
|
|
|
(define-key map "\eO6y" [C-S-kp-9])
|
|
|
|
|
|
|
|
(define-key map "\eO8j" [C-M-S-kp-multiply])
|
|
|
|
(define-key map "\eO8k" [C-M-S-kp-add])
|
|
|
|
(define-key map "\eO8l" [C-M-S-kp-separator])
|
|
|
|
(define-key map "\eO8m" [C-M-S-kp-subtract])
|
|
|
|
(define-key map "\eO8o" [C-M-S-kp-divide])
|
|
|
|
(define-key map "\eO8p" [C-M-S-kp-0])
|
|
|
|
(define-key map "\eO8q" [C-M-S-kp-1])
|
|
|
|
(define-key map "\eO8r" [C-M-S-kp-2])
|
|
|
|
(define-key map "\eO8s" [C-M-S-kp-3])
|
|
|
|
(define-key map "\eO8t" [C-M-S-kp-4])
|
|
|
|
(define-key map "\eO8u" [C-M-S-kp-5])
|
|
|
|
(define-key map "\eO8v" [C-M-S-kp-6])
|
|
|
|
(define-key map "\eO8w" [C-M-S-kp-7])
|
|
|
|
(define-key map "\eO8x" [C-M-S-kp-8])
|
|
|
|
(define-key map "\eO8y" [C-M-S-kp-9])
|
|
|
|
|
2007-09-07 19:47:46 +00:00
|
|
|
;; These keys are available in xterm starting from version 216
|
|
|
|
;; if the modifyOtherKeys resource is set to 1.
|
2013-03-10 17:44:31 -04:00
|
|
|
(dolist (bind '((5 9 [C-tab])
|
|
|
|
(5 13 [C-return])
|
|
|
|
(5 39 [?\C-\'])
|
|
|
|
(5 44 [?\C-,])
|
|
|
|
(5 45 [?\C--])
|
|
|
|
(5 46 [?\C-.])
|
|
|
|
(5 47 [?\C-/])
|
|
|
|
(5 48 [?\C-0])
|
|
|
|
(5 49 [?\C-1])
|
|
|
|
;; Not all C-DIGIT keys have a distinct binding.
|
|
|
|
(5 57 [?\C-9])
|
|
|
|
(5 59 [?\C-\;])
|
|
|
|
(5 61 [?\C-=])
|
|
|
|
(5 92 [?\C-\\])
|
|
|
|
|
|
|
|
(6 33 [?\C-!])
|
|
|
|
(6 34 [?\C-\"])
|
|
|
|
(6 35 [?\C-#])
|
|
|
|
(6 36 [?\C-$])
|
|
|
|
(6 37 [?\C-%])
|
|
|
|
(6 38 [?\C-&])
|
|
|
|
(6 40 [?\C-\(])
|
|
|
|
(6 41 [?\C-\)])
|
|
|
|
(6 42 [?\C-*])
|
|
|
|
(6 43 [?\C-+])
|
|
|
|
(6 58 [?\C-:])
|
|
|
|
(6 60 [?\C-<])
|
|
|
|
(6 62 [?\C->])
|
|
|
|
(6 63 [(control ??)])
|
|
|
|
|
|
|
|
;; These are the strings emitted for various C-M-
|
|
|
|
;; combinations for keyboards whose Meta and Alt
|
|
|
|
;; modifiers are on the same key (usually labeled "Alt").
|
|
|
|
(13 9 [C-M-tab])
|
|
|
|
(13 13 [C-M-return])
|
|
|
|
|
|
|
|
(13 39 [?\C-\M-\'])
|
|
|
|
(13 44 [?\C-\M-,])
|
|
|
|
(13 45 [?\C-\M--])
|
|
|
|
(13 46 [?\C-\M-.])
|
|
|
|
(13 47 [?\C-\M-/])
|
|
|
|
(13 48 [?\C-\M-0])
|
|
|
|
(13 49 [?\C-\M-1])
|
|
|
|
(13 50 [?\C-\M-2])
|
|
|
|
(13 51 [?\C-\M-3])
|
|
|
|
(13 52 [?\C-\M-4])
|
|
|
|
(13 53 [?\C-\M-5])
|
|
|
|
(13 54 [?\C-\M-6])
|
|
|
|
(13 55 [?\C-\M-7])
|
|
|
|
(13 56 [?\C-\M-8])
|
|
|
|
(13 57 [?\C-\M-9])
|
|
|
|
(13 59 [?\C-\M-\;])
|
|
|
|
(13 61 [?\C-\M-=])
|
|
|
|
(13 92 [?\C-\M-\\])
|
|
|
|
|
|
|
|
(14 33 [?\C-\M-!])
|
|
|
|
(14 34 [?\C-\M-\"])
|
|
|
|
(14 35 [?\C-\M-#])
|
|
|
|
(14 36 [?\C-\M-$])
|
|
|
|
(14 37 [?\C-\M-%])
|
|
|
|
(14 38 [?\C-\M-&])
|
|
|
|
(14 40 [?\C-\M-\(])
|
|
|
|
(14 41 [?\C-\M-\)])
|
|
|
|
(14 42 [?\C-\M-*])
|
|
|
|
(14 43 [?\C-\M-+])
|
|
|
|
(14 58 [?\C-\M-:])
|
|
|
|
(14 60 [?\C-\M-<])
|
|
|
|
(14 62 [?\C-\M->])
|
|
|
|
(14 63 [(control meta ??)])
|
|
|
|
|
|
|
|
(7 9 [C-M-tab])
|
|
|
|
(7 13 [C-M-return])
|
|
|
|
|
|
|
|
(7 32 [?\C-\M-\s])
|
|
|
|
(7 39 [?\C-\M-\'])
|
|
|
|
(7 44 [?\C-\M-,])
|
|
|
|
(7 45 [?\C-\M--])
|
|
|
|
(7 46 [?\C-\M-.])
|
|
|
|
(7 47 [?\C-\M-/])
|
|
|
|
(7 48 [?\C-\M-0])
|
|
|
|
(7 49 [?\C-\M-1])
|
|
|
|
(7 50 [?\C-\M-2])
|
|
|
|
(7 51 [?\C-\M-3])
|
|
|
|
(7 52 [?\C-\M-4])
|
|
|
|
(7 53 [?\C-\M-5])
|
|
|
|
(7 54 [?\C-\M-6])
|
|
|
|
(7 55 [?\C-\M-7])
|
|
|
|
(7 56 [?\C-\M-8])
|
|
|
|
(7 57 [?\C-\M-9])
|
|
|
|
(7 59 [?\C-\M-\;])
|
|
|
|
(7 61 [?\C-\M-=])
|
|
|
|
(7 92 [?\C-\M-\\])
|
|
|
|
|
|
|
|
(8 33 [?\C-\M-!])
|
|
|
|
(8 34 [?\C-\M-\"])
|
|
|
|
(8 35 [?\C-\M-#])
|
|
|
|
(8 36 [?\C-\M-$])
|
|
|
|
(8 37 [?\C-\M-%])
|
|
|
|
(8 38 [?\C-\M-&])
|
|
|
|
(8 40 [?\C-\M-\(])
|
|
|
|
(8 41 [?\C-\M-\)])
|
|
|
|
(8 42 [?\C-\M-*])
|
|
|
|
(8 43 [?\C-\M-+])
|
|
|
|
(8 58 [?\C-\M-:])
|
|
|
|
(8 60 [?\C-\M-<])
|
|
|
|
(8 62 [?\C-\M->])
|
|
|
|
(8 63 [(control meta ??)])
|
|
|
|
|
|
|
|
(2 9 [S-tab])
|
|
|
|
(2 13 [S-return])
|
|
|
|
|
|
|
|
(6 9 [C-S-tab])
|
|
|
|
(6 13 [C-S-return])))
|
|
|
|
(define-key map
|
|
|
|
(format "\e[27;%d;%d~" (nth 0 bind) (nth 1 bind)) (nth 2 bind))
|
|
|
|
;; For formatOtherKeys=1, the sequence is a bit shorter (bug#13839).
|
|
|
|
(define-key map
|
|
|
|
(format "\e[%d;%du" (nth 1 bind) (nth 0 bind)) (nth 2 bind)))
|
2007-09-07 19:47:46 +00:00
|
|
|
|
|
|
|
;; Other versions of xterm might emit these.
|
|
|
|
(define-key map "\e[1~" [home])
|
|
|
|
|
2007-09-14 22:58:55 +00:00
|
|
|
(define-key map "\eO2A" [S-up])
|
|
|
|
(define-key map "\eO2B" [S-down])
|
|
|
|
(define-key map "\eO2C" [S-right])
|
|
|
|
(define-key map "\eO2D" [S-left])
|
|
|
|
(define-key map "\eO2F" [S-end])
|
|
|
|
(define-key map "\eO2H" [S-home])
|
|
|
|
|
|
|
|
(define-key map "\eO5A" [C-up])
|
|
|
|
(define-key map "\eO5B" [C-down])
|
|
|
|
(define-key map "\eO5C" [C-right])
|
|
|
|
(define-key map "\eO5D" [C-left])
|
|
|
|
(define-key map "\eO5F" [C-end])
|
|
|
|
(define-key map "\eO5H" [C-home])
|
|
|
|
|
2007-09-07 19:47:46 +00:00
|
|
|
map)
|
2005-05-03 01:38:40 +00:00
|
|
|
"Function key map overrides for xterm.")
|
|
|
|
|
2007-10-09 05:05:57 +00:00
|
|
|
(defvar xterm-alternatives-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
;; The terminal initialization C code file might have initialized
|
|
|
|
;; function keys F13->F60 from the termcap/terminfo information.
|
|
|
|
;; On a PC-style keyboard these keys correspond to
|
|
|
|
;; MODIFIER-FUNCTION_KEY, where modifier is S-, C, A-, C-S-. The code
|
|
|
|
;; here substitutes the corresponding definitions in function-key-map.
|
|
|
|
;; The mapping from escape sequences to Fn is done in input-decode-map
|
|
|
|
;; whereas this here mapping is done in local-function-key-map so that
|
|
|
|
;; bindings to f45 still work, in case your keyboard really has an f45
|
|
|
|
;; key rather than C-S-f9.
|
|
|
|
(define-key map [f13] [S-f1])
|
|
|
|
(define-key map [f14] [S-f2])
|
|
|
|
(define-key map [f15] [S-f3])
|
|
|
|
(define-key map [f16] [S-f4])
|
|
|
|
(define-key map [f17] [S-f5])
|
|
|
|
(define-key map [f18] [S-f6])
|
|
|
|
(define-key map [f19] [S-f7])
|
|
|
|
(define-key map [f20] [S-f8])
|
|
|
|
(define-key map [f21] [S-f9])
|
|
|
|
(define-key map [f22] [S-f10])
|
|
|
|
(define-key map [f23] [S-f11])
|
|
|
|
(define-key map [f24] [S-f12])
|
|
|
|
|
|
|
|
(define-key map [f25] [C-f1])
|
|
|
|
(define-key map [f26] [C-f2])
|
|
|
|
(define-key map [f27] [C-f3])
|
|
|
|
(define-key map [f28] [C-f4])
|
|
|
|
(define-key map [f29] [C-f5])
|
|
|
|
(define-key map [f30] [C-f6])
|
|
|
|
(define-key map [f31] [C-f7])
|
|
|
|
(define-key map [f32] [C-f8])
|
|
|
|
(define-key map [f33] [C-f9])
|
|
|
|
(define-key map [f34] [C-f10])
|
|
|
|
(define-key map [f35] [C-f11])
|
|
|
|
(define-key map [f36] [C-f12])
|
|
|
|
|
|
|
|
(define-key map [f37] [C-S-f1])
|
|
|
|
(define-key map [f38] [C-S-f2])
|
|
|
|
(define-key map [f39] [C-S-f3])
|
|
|
|
(define-key map [f40] [C-S-f4])
|
|
|
|
(define-key map [f41] [C-S-f5])
|
|
|
|
(define-key map [f42] [C-S-f6])
|
|
|
|
(define-key map [f43] [C-S-f7])
|
|
|
|
(define-key map [f44] [C-S-f8])
|
|
|
|
(define-key map [f45] [C-S-f9])
|
|
|
|
(define-key map [f46] [C-S-f10])
|
|
|
|
(define-key map [f47] [C-S-f11])
|
|
|
|
(define-key map [f48] [C-S-f12])
|
|
|
|
|
2007-10-12 15:32:23 +00:00
|
|
|
(define-key map [f49] [M-f1])
|
|
|
|
(define-key map [f50] [M-f2])
|
|
|
|
(define-key map [f51] [M-f3])
|
|
|
|
(define-key map [f52] [M-f4])
|
|
|
|
(define-key map [f53] [M-f5])
|
|
|
|
(define-key map [f54] [M-f6])
|
|
|
|
(define-key map [f55] [M-f7])
|
|
|
|
(define-key map [f56] [M-f8])
|
|
|
|
(define-key map [f57] [M-f9])
|
|
|
|
(define-key map [f58] [M-f10])
|
|
|
|
(define-key map [f59] [M-f11])
|
|
|
|
(define-key map [f60] [M-f12])
|
2007-10-09 05:05:57 +00:00
|
|
|
|
2016-02-29 17:07:59 +11:00
|
|
|
(define-key map [f61] [M-S-f1])
|
|
|
|
(define-key map [f62] [M-S-f2])
|
|
|
|
(define-key map [f63] [M-S-f3])
|
|
|
|
(define-key map [f64] [M-S-f4])
|
|
|
|
(define-key map [f65] [M-S-f5])
|
|
|
|
(define-key map [f66] [M-S-f6])
|
|
|
|
(define-key map [f67] [M-S-f7])
|
|
|
|
(define-key map [f68] [M-S-f8])
|
|
|
|
(define-key map [f69] [M-S-f9])
|
|
|
|
(define-key map [f70] [M-S-f10])
|
|
|
|
(define-key map [f71] [M-S-f11])
|
|
|
|
(define-key map [f72] [M-S-f12])
|
|
|
|
|
2007-10-09 05:05:57 +00:00
|
|
|
map)
|
|
|
|
"Keymap of possible alternative meanings for some keys.")
|
|
|
|
|
2015-05-11 17:23:36 -04:00
|
|
|
;; Set up colors, for those versions of xterm that support it.
|
|
|
|
(defvar xterm-standard-colors
|
|
|
|
;; The names in the comments taken from XTerm-col.ad in the xterm
|
2017-09-13 15:52:52 -07:00
|
|
|
;; distribution, see https://invisible-island.net/xterm/. RGB values are
|
2015-05-11 17:23:36 -04:00
|
|
|
;; from rgb.txt.
|
|
|
|
'(("black" 0 ( 0 0 0)) ; black
|
|
|
|
("red" 1 (205 0 0)) ; red3
|
|
|
|
("green" 2 ( 0 205 0)) ; green3
|
|
|
|
("yellow" 3 (205 205 0)) ; yellow3
|
|
|
|
("blue" 4 ( 0 0 238)) ; blue2
|
|
|
|
("magenta" 5 (205 0 205)) ; magenta3
|
|
|
|
("cyan" 6 ( 0 205 205)) ; cyan3
|
|
|
|
("white" 7 (229 229 229)) ; gray90
|
|
|
|
("brightblack" 8 (127 127 127)) ; gray50
|
|
|
|
("brightred" 9 (255 0 0)) ; red
|
|
|
|
("brightgreen" 10 ( 0 255 0)) ; green
|
|
|
|
("brightyellow" 11 (255 255 0)) ; yellow
|
|
|
|
("brightblue" 12 (92 92 255)) ; rgb:5c/5c/ff
|
|
|
|
("brightmagenta" 13 (255 0 255)) ; magenta
|
|
|
|
("brightcyan" 14 ( 0 255 255)) ; cyan
|
|
|
|
("brightwhite" 15 (255 255 255))) ; white
|
|
|
|
"Names of 16 standard xterm/aixterm colors, their numbers, and RGB values.")
|
|
|
|
|
2013-03-11 00:24:15 -04:00
|
|
|
(defun xterm--report-background-handler ()
|
|
|
|
(let ((str "")
|
|
|
|
chr)
|
|
|
|
;; The reply should be: \e ] 11 ; rgb: NUMBER1 / NUMBER2 / NUMBER3 \e \\
|
2018-06-08 23:22:23 -07:00
|
|
|
(while (and (setq chr (xterm--read-event-for-query)) (not (equal chr ?\\)))
|
2013-03-11 00:24:15 -04:00
|
|
|
(setq str (concat str (string chr))))
|
|
|
|
(when (string-match
|
|
|
|
"rgb:\\([a-f0-9]+\\)/\\([a-f0-9]+\\)/\\([a-f0-9]+\\)" str)
|
|
|
|
(let ((recompute-faces
|
|
|
|
(xterm-maybe-set-dark-background-mode
|
|
|
|
(string-to-number (match-string 1 str) 16)
|
|
|
|
(string-to-number (match-string 2 str) 16)
|
|
|
|
(string-to-number (match-string 3 str) 16))))
|
|
|
|
|
|
|
|
;; Recompute faces here in case the background mode was
|
|
|
|
;; set to dark. We used to call
|
|
|
|
;; `tty-set-up-initial-frame-faces' only once, but that
|
|
|
|
;; caused the light background faces to be computed
|
|
|
|
;; incorrectly. See:
|
|
|
|
;; http://permalink.gmane.org/gmane.emacs.devel/119627
|
|
|
|
(when recompute-faces
|
|
|
|
(tty-set-up-initial-frame-faces))))))
|
|
|
|
|
2013-03-11 10:08:44 -04:00
|
|
|
(defun xterm--version-handler ()
|
|
|
|
(let ((str "")
|
|
|
|
chr)
|
|
|
|
;; The reply should be: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c
|
|
|
|
;; If the timeout is completely removed for read-event, this
|
|
|
|
;; might hang for terminals that pretend to be xterm, but don't
|
|
|
|
;; respond to this escape sequence. RMS' opinion was to remove
|
|
|
|
;; it completely. That might be right, but let's first try to
|
|
|
|
;; see if by using a longer timeout we get rid of most issues.
|
2018-06-08 23:22:23 -07:00
|
|
|
(while (and (setq chr (xterm--read-event-for-query)) (not (equal chr ?c)))
|
2013-03-11 10:08:44 -04:00
|
|
|
(setq str (concat str (string chr))))
|
2014-02-19 23:45:19 -05:00
|
|
|
;; Since xterm-280, the terminal type (NUMBER1) is now 41 instead of 0.
|
2020-12-28 04:09:51 +01:00
|
|
|
(when (string-match "\\([0-9]+\\);\\([0-9]+\\);[01]" str)
|
2014-02-19 23:45:19 -05:00
|
|
|
(let ((version (string-to-number (match-string 2 str))))
|
2020-12-28 04:09:51 +01:00
|
|
|
(when (and (> version 2000)
|
|
|
|
(or (equal (match-string 1 str) "1")
|
|
|
|
(equal (match-string 1 str) "65")))
|
2014-04-22 16:35:33 -04:00
|
|
|
;; Hack attack! bug#16988: gnome-terminal reports "1;NNNN;0"
|
|
|
|
;; with a large NNNN but is based on a rather old xterm code.
|
|
|
|
;; Gnome terminal 2.32.1 reports 1;2802;0
|
2017-12-14 21:42:56 -05:00
|
|
|
;; Gnome terminal 3.6.1 reports 1;3406;0
|
|
|
|
;; Gnome terminal 3.22.2 reports 1;4601;0 and *does* support
|
|
|
|
;; background color querying (Bug#29716).
|
2020-12-28 04:09:51 +01:00
|
|
|
;; Gnome terminal 3.38.0 reports 65;6200;1.
|
2017-12-14 21:42:56 -05:00
|
|
|
(when (> version 4000)
|
|
|
|
(xterm--query "\e]11;?\e\\"
|
|
|
|
'(("\e]11;" . xterm--report-background-handler))))
|
2014-04-22 16:35:33 -04:00
|
|
|
(setq version 200))
|
2014-06-13 11:06:29 -04:00
|
|
|
(when (equal (match-string 1 str) "83")
|
2014-06-19 21:05:40 -04:00
|
|
|
;; `screen' (which returns 83;40003;0) seems to also lack support for
|
2015-05-03 22:24:20 -04:00
|
|
|
;; some of these (bug#17607, bug#20356).
|
|
|
|
;; Note: this code path should normally not be used any more
|
|
|
|
;; since term/screen.el now binds xterm-extra-capabilities
|
|
|
|
;; to a fixed value, rather than using the dynamic checking.
|
|
|
|
(setq version 200))
|
2013-03-11 10:08:44 -04:00
|
|
|
;; If version is 242 or higher, assume the xterm supports
|
|
|
|
;; reporting the background color (TODO: maybe earlier
|
|
|
|
;; versions do too...)
|
|
|
|
(when (>= version 242)
|
|
|
|
(xterm--query "\e]11;?\e\\"
|
|
|
|
'(("\e]11;" . xterm--report-background-handler))))
|
|
|
|
|
|
|
|
;; If version is 216 (the version when modifyOtherKeys was
|
|
|
|
;; introduced) or higher, initialize the
|
|
|
|
;; modifyOtherKeys support.
|
|
|
|
(when (>= version 216)
|
2015-05-25 17:03:50 -04:00
|
|
|
(xterm--init-modify-other-keys))
|
2015-04-13 10:48:47 -04:00
|
|
|
;; In version 203 support for accessing the X selection was
|
|
|
|
;; added. Hterm reports itself as version 256 and supports it
|
|
|
|
;; as well. gnome-terminal doesn't and is excluded by this
|
|
|
|
;; test.
|
|
|
|
(when (>= version 203)
|
2015-05-25 17:03:50 -04:00
|
|
|
;; Most xterms seem to have it disabled by default, and if it's
|
|
|
|
;; disabled, C-y will incur a timeout, so we only use it if the user
|
|
|
|
;; explicitly requests it.
|
|
|
|
;;(xterm--init-activate-get-selection)
|
|
|
|
(xterm--init-activate-set-selection))))))
|
2013-03-11 10:08:44 -04:00
|
|
|
|
2015-06-30 23:20:29 -04:00
|
|
|
(defvar xterm-query-timeout 2
|
|
|
|
"Seconds to wait for an answer from the terminal.
|
|
|
|
Can be nil to mean \"no timeout\".")
|
|
|
|
|
2018-06-08 23:22:23 -07:00
|
|
|
(defvar xterm-query-redisplay-timeout 0.2
|
2021-09-14 08:43:18 +02:00
|
|
|
"Seconds to wait before allowing redisplay during terminal query." )
|
2018-06-08 23:22:23 -07:00
|
|
|
|
|
|
|
(defun xterm--read-event-for-query ()
|
2021-09-14 08:43:18 +02:00
|
|
|
"Like `read-event', but inhibit redisplay.
|
2018-06-08 23:22:23 -07:00
|
|
|
|
|
|
|
By not redisplaying right away for xterm queries, we can avoid
|
2021-09-14 08:43:18 +02:00
|
|
|
unsightly flashing during initialization. Give up and redisplay
|
2018-06-08 23:22:23 -07:00
|
|
|
anyway if we've been waiting a little while."
|
2021-05-15 20:15:59 +00:00
|
|
|
(let ((start-time (current-time)))
|
2018-06-08 23:22:23 -07:00
|
|
|
(or (let ((inhibit-redisplay t))
|
|
|
|
(read-event nil nil xterm-query-redisplay-timeout))
|
|
|
|
(read-event nil nil
|
|
|
|
(and xterm-query-timeout
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-22 18:32:31 -08:00
|
|
|
(max 0 (float-time
|
|
|
|
(time-subtract
|
|
|
|
xterm-query-timeout
|
|
|
|
(time-since start-time)))))))))
|
2018-06-08 23:22:23 -07:00
|
|
|
|
2015-05-25 17:03:50 -04:00
|
|
|
(defun xterm--query (query handlers &optional no-async)
|
2013-06-14 14:37:38 -04:00
|
|
|
"Send QUERY string to the terminal and watch for a response.
|
|
|
|
HANDLERS is an alist with elements of the form (STRING . FUNCTION).
|
|
|
|
We run the first FUNCTION whose STRING matches the input events."
|
2013-03-11 00:24:15 -04:00
|
|
|
;; We used to query synchronously, but the need to use `discard-input' is
|
|
|
|
;; rather annoying (bug#6758). Maybe we could always use the asynchronous
|
|
|
|
;; approach, but it's less tested.
|
|
|
|
;; FIXME: Merge the two branches.
|
2015-06-30 23:20:29 -04:00
|
|
|
(let ((register
|
|
|
|
(lambda (handlers)
|
|
|
|
(dolist (handler handlers)
|
|
|
|
(define-key input-decode-map (car handler)
|
|
|
|
(lambda (&optional _prompt)
|
|
|
|
;; Unregister the handler, since we don't expect
|
|
|
|
;; further answers.
|
|
|
|
(dolist (handler handlers)
|
|
|
|
(define-key input-decode-map (car handler) nil))
|
|
|
|
(funcall (cdr handler))
|
|
|
|
[]))))))
|
|
|
|
(if (and (or (null xterm-query-timeout) (input-pending-p))
|
|
|
|
(not no-async))
|
|
|
|
(progn
|
|
|
|
(funcall register handlers)
|
|
|
|
(send-string-to-terminal query))
|
|
|
|
;; Pending input can be mistakenly returned by the calls to
|
|
|
|
;; read-event below: discard it.
|
|
|
|
(discard-input)
|
|
|
|
(send-string-to-terminal query)
|
|
|
|
(while handlers
|
|
|
|
(let ((handler (pop handlers))
|
|
|
|
(i 0))
|
|
|
|
(while (and (< i (length (car handler)))
|
2018-06-08 23:22:23 -07:00
|
|
|
(let ((evt (xterm--read-event-for-query)))
|
2015-06-30 23:20:29 -04:00
|
|
|
(if (and (null evt) (= i 0) (not no-async))
|
|
|
|
;; Timeout on the first event: fallback on async.
|
|
|
|
(progn
|
|
|
|
(funcall register (cons handler handlers))
|
|
|
|
(setq handlers nil)
|
|
|
|
nil)
|
|
|
|
(or (eq evt (aref (car handler) i))
|
|
|
|
(progn (if evt (push evt unread-command-events))
|
2015-07-02 10:49:09 -04:00
|
|
|
nil)))))
|
|
|
|
(setq i (1+ i)))
|
|
|
|
(if (= i (length (car handler)))
|
|
|
|
(progn (setq handlers nil)
|
|
|
|
(funcall (cdr handler)))
|
|
|
|
(while (> i 0)
|
|
|
|
(push (aref (car handler) (setq i (1- i)))
|
|
|
|
unread-command-events))))))))
|
2013-03-11 00:24:15 -04:00
|
|
|
|
2015-05-11 17:23:36 -04:00
|
|
|
(defun xterm--push-map (map basemap)
|
|
|
|
;; Use inheritance to let the main keymaps override those defaults.
|
|
|
|
;; This way we don't override terminfo-derived settings or settings
|
|
|
|
;; made in the init file.
|
|
|
|
(set-keymap-parent
|
|
|
|
basemap
|
|
|
|
(make-composed-keymap map (keymap-parent basemap))))
|
|
|
|
|
2021-05-15 20:15:59 +00:00
|
|
|
(defun xterm--init ()
|
|
|
|
"Initialize the terminal for xterm."
|
2005-07-27 18:02:08 +00:00
|
|
|
;; rxvt terminals sometimes set the TERM variable to "xterm", but
|
2006-05-20 17:02:47 +00:00
|
|
|
;; rxvt's keybindings are incompatible with xterm's. It is
|
2011-11-19 01:18:31 -08:00
|
|
|
;; better in that case to use rxvt's initialization function.
|
2007-05-16 07:12:33 +00:00
|
|
|
(if (and (getenv "COLORTERM" (selected-frame))
|
|
|
|
(string-match "\\`rxvt" (getenv "COLORTERM" (selected-frame))))
|
2006-05-20 17:02:47 +00:00
|
|
|
(tty-run-terminal-initialization (selected-frame) "rxvt")
|
|
|
|
|
2015-05-11 17:23:36 -04:00
|
|
|
(xterm--push-map xterm-alternatives-map local-function-key-map)
|
|
|
|
(xterm--push-map xterm-function-map input-decode-map))
|
2007-06-16 22:33:42 +00:00
|
|
|
|
2015-05-11 17:23:36 -04:00
|
|
|
(xterm-register-default-colors xterm-standard-colors)
|
2011-06-09 11:58:18 -05:00
|
|
|
(tty-set-up-initial-frame-faces)
|
2009-12-07 06:30:30 +00:00
|
|
|
|
2013-03-11 00:24:15 -04:00
|
|
|
(if (eq xterm-extra-capabilities 'check)
|
2011-06-12 12:58:32 -07:00
|
|
|
;; Try to find out the type of terminal by sending a "Secondary
|
|
|
|
;; Device Attributes (DA)" query.
|
2013-03-11 10:08:44 -04:00
|
|
|
(xterm--query "\e[>0c"
|
2016-11-06 00:33:43 -07:00
|
|
|
;; Some terminals (like macOS's Terminal.app) respond to
|
2013-03-11 10:08:44 -04:00
|
|
|
;; this query as if it were a "Primary Device Attributes"
|
|
|
|
;; query instead, so we should handle that too.
|
|
|
|
'(("\e[?" . xterm--version-handler)
|
|
|
|
("\e[>" . xterm--version-handler)))
|
2013-03-11 00:24:15 -04:00
|
|
|
|
|
|
|
(when (memq 'reportBackground xterm-extra-capabilities)
|
2013-03-11 10:08:44 -04:00
|
|
|
(xterm--query "\e]11;?\e\\"
|
|
|
|
'(("\e]11;" . xterm--report-background-handler))))
|
2013-03-11 00:24:15 -04:00
|
|
|
|
|
|
|
(when (memq 'modifyOtherKeys xterm-extra-capabilities)
|
2015-05-25 17:03:50 -04:00
|
|
|
(xterm--init-modify-other-keys))
|
2015-04-13 10:48:47 -04:00
|
|
|
|
2015-05-25 17:03:50 -04:00
|
|
|
(when (memq 'getSelection xterm-extra-capabilities)
|
|
|
|
(xterm--init-activate-get-selection))
|
2015-04-13 10:48:47 -04:00
|
|
|
(when (memq 'setSelection xterm-extra-capabilities)
|
2015-05-25 17:03:50 -04:00
|
|
|
(xterm--init-activate-set-selection)))
|
2013-03-11 00:24:15 -04:00
|
|
|
|
2017-09-20 11:39:37 -04:00
|
|
|
(when xterm-set-window-title
|
|
|
|
(xterm--init-frame-title))
|
2016-11-02 21:17:48 -07:00
|
|
|
;; Unconditionally enable bracketed paste mode: terminals that don't
|
|
|
|
;; support it just ignore the sequence.
|
|
|
|
(xterm--init-bracketed-paste-mode)
|
2018-06-08 22:47:27 -07:00
|
|
|
;; We likewise unconditionally enable support for focus tracking.
|
2021-05-15 20:15:59 +00:00
|
|
|
(xterm--init-focus-tracking))
|
2014-04-17 00:54:23 -07:00
|
|
|
|
2021-05-15 20:15:59 +00:00
|
|
|
(defun terminal-init-xterm ()
|
|
|
|
"Terminal initialization function for xterm."
|
|
|
|
(unwind-protect
|
|
|
|
(progn
|
|
|
|
(xterm--init)
|
|
|
|
;; If the terminal initialization completed without errors, clear
|
|
|
|
;; the lossage to discard the responses of the terminal emulator
|
|
|
|
;; during initialization; otherwise they appear in the recent keys.
|
|
|
|
(clear-this-command-keys))
|
|
|
|
(run-hooks 'terminal-init-xterm-hook)))
|
2005-06-26 03:19:45 +00:00
|
|
|
|
2015-05-25 17:03:50 -04:00
|
|
|
(defun xterm--init-modify-other-keys ()
|
2011-06-09 11:58:18 -05:00
|
|
|
"Terminal initialization for xterm's modifyOtherKeys support."
|
2014-04-17 00:54:23 -07:00
|
|
|
(send-string-to-terminal "\e[>4;1m")
|
|
|
|
(push "\e[>4m" (terminal-parameter nil 'tty-mode-reset-strings))
|
|
|
|
(push "\e[>4;1m" (terminal-parameter nil 'tty-mode-set-strings)))
|
|
|
|
|
2016-11-02 21:17:48 -07:00
|
|
|
(defun xterm--init-bracketed-paste-mode ()
|
|
|
|
"Terminal initialization for bracketed paste mode."
|
|
|
|
(send-string-to-terminal "\e[?2004h")
|
|
|
|
(push "\e[?2004l" (terminal-parameter nil 'tty-mode-reset-strings))
|
|
|
|
(push "\e[?2004h" (terminal-parameter nil 'tty-mode-set-strings)))
|
|
|
|
|
2018-06-08 22:47:27 -07:00
|
|
|
(defun xterm--init-focus-tracking ()
|
|
|
|
"Terminal initialization for focus tracking mode."
|
|
|
|
(send-string-to-terminal "\e[?1004h")
|
|
|
|
(push "\e[?1004l" (terminal-parameter nil 'tty-mode-reset-strings))
|
|
|
|
(push "\e[?1004h" (terminal-parameter nil 'tty-mode-set-strings)))
|
|
|
|
|
2015-05-25 17:03:50 -04:00
|
|
|
(defun xterm--init-activate-get-selection ()
|
|
|
|
"Terminal initialization for `gui-get-selection'."
|
|
|
|
(set-terminal-parameter nil 'xterm--get-selection t))
|
|
|
|
|
|
|
|
(defun xterm--init-activate-set-selection ()
|
2015-04-13 10:48:47 -04:00
|
|
|
"Terminal initialization for `gui-set-selection'."
|
2015-04-13 11:36:30 -04:00
|
|
|
(set-terminal-parameter nil 'xterm--set-selection t))
|
|
|
|
|
2017-09-20 11:39:37 -04:00
|
|
|
(defun xterm--init-frame-title ()
|
|
|
|
"Terminal initialization for XTerm frame titles."
|
|
|
|
(xterm-set-window-title)
|
|
|
|
(add-hook 'after-make-frame-functions 'xterm-set-window-title-flag)
|
|
|
|
(add-hook 'window-configuration-change-hook 'xterm-unset-window-title-flag)
|
|
|
|
(add-hook 'post-command-hook 'xterm-set-window-title)
|
|
|
|
(add-hook 'minibuffer-exit-hook 'xterm-set-window-title))
|
|
|
|
|
|
|
|
(defvar xterm-window-title-flag nil
|
|
|
|
"Whether a new frame has been created, calling for a title update.")
|
|
|
|
|
|
|
|
(defun xterm-set-window-title-flag (_frame)
|
|
|
|
"Set `xterm-window-title-flag'.
|
|
|
|
See `xterm--init-frame-title'"
|
|
|
|
(setq xterm-window-title-flag t))
|
|
|
|
|
|
|
|
(defun xterm-unset-window-title-flag ()
|
|
|
|
(when xterm-window-title-flag
|
|
|
|
(setq xterm-window-title-flag nil)
|
|
|
|
(xterm-set-window-title)))
|
|
|
|
|
|
|
|
(defun xterm-set-window-title (&optional terminal)
|
|
|
|
"Set the window title of the Xterm TERMINAL.
|
|
|
|
The title is constructed from `frame-title-format'."
|
2021-08-09 15:43:01 +02:00
|
|
|
(unless (display-graphic-p terminal)
|
|
|
|
(send-string-to-terminal
|
|
|
|
(format "\e]2;%s\a" (format-mode-line frame-title-format))
|
|
|
|
terminal)))
|
2017-09-20 11:39:37 -04:00
|
|
|
|
2015-05-25 17:03:50 -04:00
|
|
|
(defun xterm--selection-char (type)
|
|
|
|
(pcase type
|
|
|
|
('PRIMARY "p")
|
|
|
|
('CLIPBOARD "c")
|
|
|
|
(_ (error "Invalid selection type: %S" type))))
|
|
|
|
|
|
|
|
(cl-defmethod gui-backend-get-selection
|
|
|
|
(type data-type
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
&context (window-system nil)
|
2015-05-25 17:03:50 -04:00
|
|
|
;; Only applies to terminals which have it enabled.
|
2019-08-03 12:08:27 +02:00
|
|
|
((terminal-parameter nil 'xterm--get-selection) (eql t))
|
|
|
|
;; Doesn't work in screen; see bug#36879.
|
|
|
|
((eq (terminal-parameter nil 'terminal-initted)
|
|
|
|
'terminal-init-screen)
|
|
|
|
(eql nil)))
|
2015-05-25 17:03:50 -04:00
|
|
|
(unless (eq data-type 'STRING)
|
|
|
|
(error "Unsupported data type %S" data-type))
|
2019-08-03 12:08:27 +02:00
|
|
|
(let ((query (concat "\e]52;" (xterm--selection-char type) ";")))
|
2015-05-25 17:03:50 -04:00
|
|
|
(with-temp-buffer
|
|
|
|
(set-buffer-multibyte nil)
|
|
|
|
(xterm--query
|
2019-08-03 12:08:27 +02:00
|
|
|
;; Use ST as query terminator to get ST as reply terminator (bug#36879).
|
|
|
|
(concat query "?\e\\")
|
|
|
|
(list (cons query
|
|
|
|
(lambda ()
|
|
|
|
;; Read data up to the string terminator, ST.
|
|
|
|
(let (char last)
|
|
|
|
(while (and (setq char (read-char
|
|
|
|
nil nil
|
|
|
|
xterm-query-timeout))
|
|
|
|
(not (and (eq char ?\\)
|
|
|
|
(eq last ?\e))))
|
|
|
|
(when last
|
|
|
|
(insert last))
|
|
|
|
(setq last char))))))
|
2015-05-25 17:03:50 -04:00
|
|
|
'no-async)
|
|
|
|
(base64-decode-region (point-min) (point-max))
|
|
|
|
(decode-coding-region (point-min) (point-max) 'utf-8-unix t))))
|
|
|
|
|
|
|
|
(cl-defmethod gui-backend-set-selection
|
|
|
|
(type data
|
* lisp/emacs-lisp/cl-generic.el: Add (major-mode MODE) context
(cl--generic-derived-specializers): New function.
(cl--generic-derived-generalizer): New generalizer.
(cl-generic-generalizers): New specializer (derived-mode MODE).
(cl--generic-split-args): Apply the rewriter, if any.
(cl-generic-define-context-rewriter): New macro.
(major-mode): Use it to define a new context-rewriter, so we can write
`(major-mode MODE)' instead of `(major-mode (derived-mode MODE))'.
* lisp/frame.el (window-system): New context-rewriter so we can write
`(window-system VAL)' instead of (window-system (eql VAL)).
(cl--generic-split-args): Apply the rewriter, if any.
(frame-creation-function): Use the new syntax.
* lisp/term/x-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-owner-p)
(gui-backend-selection-exists-p, gui-backend-get-selection):
* lisp/term/w32-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-get-selection)
(gui-backend-selection-owner-p, gui-backend-selection-exists-p):
* lisp/term/pc-win.el (gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection, window-system-initialization)
(frame-creation-function, handle-args-function):
* lisp/term/ns-win.el (window-system-initialization)
(handle-args-function, frame-creation-function)
(gui-backend-set-selection, gui-backend-selection-exists-p)
(gui-backend-get-selection):
* lisp/startup.el (handle-args-function):
* lisp/term/xterm.el (gui-backend-get-selection)
(gui-backend-set-selection): Use the new syntax.
2015-10-29 11:06:31 -04:00
|
|
|
&context (window-system nil)
|
2015-05-25 17:03:50 -04:00
|
|
|
;; Only applies to terminals which have it enabled.
|
|
|
|
((terminal-parameter nil 'xterm--set-selection) (eql t)))
|
2015-04-13 10:48:47 -04:00
|
|
|
"Copy DATA to the X selection using the OSC 52 escape sequence.
|
|
|
|
|
|
|
|
TYPE specifies which selection to set; it must be either
|
|
|
|
`PRIMARY' or `CLIPBOARD'. DATA must be a string.
|
|
|
|
|
|
|
|
This can be used as a `gui-set-selection' method for
|
|
|
|
xterm-compatible terminal emulators. Then your system clipboard
|
|
|
|
will be updated whenever you copy a region of text in Emacs.
|
|
|
|
|
|
|
|
If the resulting OSC 52 sequence would be longer than
|
|
|
|
`xterm-max-cut-length', then the TEXT is not sent to the system
|
|
|
|
clipboard.
|
|
|
|
|
|
|
|
This function either sends a raw OSC 52 sequence or wraps the OSC
|
|
|
|
52 in a Device Control String sequence. This way, it will work
|
|
|
|
on a bare terminal emulators as well as inside the screen
|
|
|
|
program. When inside the screen program, this function also
|
|
|
|
chops long DCS sequences into multiple smaller ones to avoid
|
|
|
|
hitting screen's max DCS length."
|
2015-04-13 11:36:30 -04:00
|
|
|
(let* ((screen (eq (terminal-parameter nil 'terminal-initted)
|
2015-05-25 17:03:50 -04:00
|
|
|
'terminal-init-screen))
|
|
|
|
(bytes (encode-coding-string data 'utf-8-unix))
|
|
|
|
(base-64 (if screen
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 18:58:46 +02:00
|
|
|
(string-replace
|
2015-05-25 17:03:50 -04:00
|
|
|
"\n" "\e\\\eP"
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 18:58:46 +02:00
|
|
|
(base64-encode-string bytes))
|
2015-05-25 17:03:50 -04:00
|
|
|
(base64-encode-string bytes :no-line-break)))
|
|
|
|
(length (length base-64)))
|
|
|
|
(if (> length xterm-max-cut-length)
|
|
|
|
(progn
|
|
|
|
(warn "Selection too long to send to terminal: %d bytes" length)
|
|
|
|
(sit-for 2))
|
|
|
|
(send-string-to-terminal
|
|
|
|
(concat
|
|
|
|
(when screen "\eP")
|
|
|
|
"\e]52;" (xterm--selection-char type) ";" base-64 "\a"
|
|
|
|
(when screen "\e\\"))))))
|
2015-04-13 10:48:47 -04:00
|
|
|
|
2002-01-25 13:10:46 +00:00
|
|
|
(defun xterm-rgb-convert-to-16bit (prim)
|
|
|
|
"Convert an 8-bit primary color value PRIM to a corresponding 16-bit value."
|
Audit use of lsh and fix glitches
I audited use of lsh in the Lisp source code, and fixed the
glitches that I found. While I was at it, I replaced uses of lsh
with ash when either will do. Replacement is OK when either
argument is known to be nonnegative, or when only the low-order
bits of the result matter, and is a (minor) win since ash is a bit
more solid than lsh nowadays, and is a bit faster.
* lisp/calc/calc-ext.el (math-check-fixnum):
Prefer most-positive-fixnum to (lsh -1 -1).
* lisp/vc/vc-hg.el (vc-hg-state-fast): When testing fixnum width,
prefer (zerop (ash most-positive-fixnum -32)) to (zerop (lsh -1
32)) (Bug#32485#11).
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode):
Tighten sanity-check for bytecode overflow, by checking that the
result of (ash pc -8) is nonnegative. Formerly this check was not
needed since lsh was used and the number overflowed differently.
* lisp/net/dns.el (dns-write): Fix some obvious sign typos in
shift counts. Evidently this part of the code has never been
exercised.
* lisp/progmodes/hideif.el (hif-shiftleft, hif-shiftright):
* lisp/term/common-win.el (x-setup-function-keys):
Simplify.
* admin/unidata/unidata-gen.el, admin/unidata/uvs.el:
* doc/lispref/keymaps.texi, doc/lispref/syntax.texi:
* doc/misc/calc.texi, doc/misc/cl.texi, etc/NEWS.19:
* lisp/arc-mode.el, lisp/calc/calc-bin.el, lisp/calc/calc-comb.el:
* lisp/calc/calc-ext.el, lisp/calc/calc-math.el:
* lisp/cedet/semantic/wisent/comp.el, lisp/composite.el:
* lisp/disp-table.el, lisp/dos-fns.el, lisp/edmacro.el:
* lisp/emacs-lisp/bindat.el, lisp/emacs-lisp/byte-opt.el:
* lisp/emacs-lisp/bytecomp.el, lisp/emacs-lisp/cl-extra.el:
* lisp/erc/erc-dcc.el, lisp/facemenu.el, lisp/gnus/message.el:
* lisp/gnus/nndoc.el, lisp/gnus/nnmaildir.el, lisp/image.el:
* lisp/international/ccl.el, lisp/international/fontset.el:
* lisp/international/mule-cmds.el, lisp/international/mule.el:
* lisp/json.el, lisp/mail/binhex.el, lisp/mail/rmail.el:
* lisp/mail/uudecode.el, lisp/md4.el, lisp/net/dns.el:
* lisp/net/ntlm.el, lisp/net/sasl.el, lisp/net/socks.el:
* lisp/net/tramp.el, lisp/obsolete/levents.el:
* lisp/obsolete/pgg-parse.el, lisp/org/org.el:
* lisp/org/ox-publish.el, lisp/progmodes/cc-defs.el:
* lisp/progmodes/ebnf2ps.el, lisp/progmodes/hideif.el:
* lisp/ps-bdf.el, lisp/ps-print.el, lisp/simple.el:
* lisp/tar-mode.el, lisp/term/common-win.el:
* lisp/term/tty-colors.el, lisp/term/xterm.el, lisp/vc/vc-git.el:
* lisp/vc/vc-hg.el, lisp/x-dnd.el, test/src/data-tests.el:
Prefer ash to lsh when either will do.
2018-08-21 13:44:03 -07:00
|
|
|
(logior prim (ash prim 8)))
|
2002-01-25 13:10:46 +00:00
|
|
|
|
2015-05-11 17:23:36 -04:00
|
|
|
(defun xterm-register-default-colors (colors)
|
2002-01-25 13:10:46 +00:00
|
|
|
"Register the default set of colors for xterm or compatible emulator.
|
|
|
|
|
|
|
|
This function registers the number of colors returned by `display-color-cells'
|
2015-05-11 17:23:36 -04:00
|
|
|
for the currently selected frame. The first (16) colors are taken from
|
|
|
|
COLORS, which see, while the rest are computed assuming
|
2002-01-25 13:10:46 +00:00
|
|
|
either the 88- or 256-color standard color scheme supported by latest
|
|
|
|
versions of xterm."
|
2015-05-11 17:23:36 -04:00
|
|
|
(let* ((ncolors (display-color-cells))
|
2002-01-25 13:10:46 +00:00
|
|
|
(color (car colors)))
|
|
|
|
(if (> ncolors 0)
|
|
|
|
;; Clear the 8 default tty colors registered by startup.el
|
|
|
|
(tty-color-clear))
|
|
|
|
;; Only register as many colors as are supported by the display.
|
|
|
|
(while (and (> ncolors 0) colors)
|
|
|
|
(tty-color-define (car color) (cadr color)
|
2015-05-11 17:23:36 -04:00
|
|
|
(mapcar #'xterm-rgb-convert-to-16bit
|
2002-01-25 13:10:46 +00:00
|
|
|
(car (cddr color))))
|
|
|
|
(setq colors (cdr colors)
|
|
|
|
color (car colors)
|
|
|
|
ncolors (1- ncolors)))
|
2015-05-11 17:23:36 -04:00
|
|
|
;; We've exhausted the colors from `colors'. If there
|
2002-01-25 13:10:46 +00:00
|
|
|
;; are more colors to support, compute them now.
|
|
|
|
(when (> ncolors 0)
|
|
|
|
(cond
|
2017-02-18 13:04:55 +02:00
|
|
|
((= ncolors 16777200) ; 24-bit xterm
|
|
|
|
;; all named tty colors
|
|
|
|
(let ((idx (length xterm-standard-colors)))
|
|
|
|
(mapc (lambda (color)
|
|
|
|
(unless (assoc (car color) xterm-standard-colors)
|
|
|
|
(tty-color-define (car color) idx (cdr color))
|
|
|
|
(setq idx (1+ idx))))
|
|
|
|
color-name-rgb-alist)))
|
2002-01-25 13:10:46 +00:00
|
|
|
((= ncolors 240) ; 256-color xterm
|
|
|
|
;; 216 non-gray colors first
|
|
|
|
(let ((r 0) (g 0) (b 0))
|
|
|
|
(while (> ncolors 24)
|
2011-12-05 00:55:25 -08:00
|
|
|
;; This and other formulas taken from 256colres.pl and
|
2002-01-25 13:10:46 +00:00
|
|
|
;; 88colres.pl in the xterm distribution.
|
|
|
|
(tty-color-define (format "color-%d" (- 256 ncolors))
|
|
|
|
(- 256 ncolors)
|
2015-05-11 17:23:36 -04:00
|
|
|
(mapcar #'xterm-rgb-convert-to-16bit
|
2005-04-09 15:25:50 +00:00
|
|
|
(list (if (zerop r) 0 (+ (* r 40) 55))
|
|
|
|
(if (zerop g) 0 (+ (* g 40) 55))
|
|
|
|
(if (zerop b) 0 (+ (* b 40) 55)))))
|
|
|
|
|
2002-01-25 13:10:46 +00:00
|
|
|
(setq b (1+ b))
|
|
|
|
(if (> b 5)
|
|
|
|
(setq g (1+ g)
|
|
|
|
b 0))
|
|
|
|
(if (> g 5)
|
|
|
|
(setq r (1+ r)
|
|
|
|
g 0))
|
|
|
|
(setq ncolors (1- ncolors))))
|
|
|
|
;; Now the 24 gray colors
|
|
|
|
(while (> ncolors 0)
|
|
|
|
(setq color (xterm-rgb-convert-to-16bit (+ 8 (* (- 24 ncolors) 10))))
|
|
|
|
(tty-color-define (format "color-%d" (- 256 ncolors))
|
|
|
|
(- 256 ncolors)
|
|
|
|
(list color color color))
|
|
|
|
(setq ncolors (1- ncolors))))
|
|
|
|
((= ncolors 72) ; 88-color xterm
|
|
|
|
;; 64 non-gray colors
|
|
|
|
(let ((levels '(0 139 205 255))
|
|
|
|
(r 0) (g 0) (b 0))
|
|
|
|
(while (> ncolors 8)
|
|
|
|
(tty-color-define (format "color-%d" (- 88 ncolors))
|
|
|
|
(- 88 ncolors)
|
2015-05-11 17:23:36 -04:00
|
|
|
(mapcar #'xterm-rgb-convert-to-16bit
|
2002-01-25 13:10:46 +00:00
|
|
|
(list (nth r levels)
|
|
|
|
(nth g levels)
|
|
|
|
(nth b levels))))
|
|
|
|
(setq b (1+ b))
|
|
|
|
(if (> b 3)
|
|
|
|
(setq g (1+ g)
|
|
|
|
b 0))
|
|
|
|
(if (> g 3)
|
|
|
|
(setq r (1+ r)
|
|
|
|
g 0))
|
|
|
|
(setq ncolors (1- ncolors))))
|
|
|
|
;; Now the 8 gray colors
|
|
|
|
(while (> ncolors 0)
|
|
|
|
(setq color (xterm-rgb-convert-to-16bit
|
2005-04-09 15:25:50 +00:00
|
|
|
(floor
|
2002-01-25 13:10:46 +00:00
|
|
|
(if (= ncolors 8)
|
|
|
|
46.36363636
|
|
|
|
(+ (* (- 8 ncolors) 23.18181818) 69.54545454)))))
|
|
|
|
(tty-color-define (format "color-%d" (- 88 ncolors))
|
|
|
|
(- 88 ncolors)
|
|
|
|
(list color color color))
|
|
|
|
(setq ncolors (1- ncolors))))
|
|
|
|
(t (error "Unsupported number of xterm colors (%d)" (+ 16 ncolors)))))
|
|
|
|
;; Modifying color mappings means realized faces don't use the
|
|
|
|
;; right colors, so clear them.
|
|
|
|
(clear-face-cache)))
|
|
|
|
|
2010-01-24 13:08:53 -08:00
|
|
|
(defun xterm-maybe-set-dark-background-mode (redc greenc bluec)
|
2009-12-07 06:30:30 +00:00
|
|
|
;; Use the heuristic in `frame-set-background-mode' to decide if a
|
|
|
|
;; frame is dark.
|
|
|
|
(when (< (+ redc greenc bluec) (* .6 (+ 65535 65535 65535)))
|
2010-01-24 13:08:53 -08:00
|
|
|
(set-terminal-parameter nil 'background-mode 'dark)
|
|
|
|
t))
|
2009-12-07 06:30:30 +00:00
|
|
|
|
2015-05-03 22:24:20 -04:00
|
|
|
(provide 'xterm) ;Backward compatibility.
|
|
|
|
(provide 'term/xterm)
|
2001-07-16 11:39:42 +00:00
|
|
|
;;; xterm.el ends here
|