[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/coterm ee37b4b 39/80: Initial support for char-mode and
From: |
ELPA Syncer |
Subject: |
[elpa] externals/coterm ee37b4b 39/80: Initial support for char-mode and scroll snapping |
Date: |
Wed, 13 Oct 2021 18:57:32 -0400 (EDT) |
branch: externals/coterm
commit ee37b4bcc6797afc8d1123dce1c40a40fc872a4c
Author: m <>
Commit: m <>
Initial support for char-mode and scroll snapping
---
coterm.el | 78 ++++++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 57 insertions(+), 21 deletions(-)
diff --git a/coterm.el b/coterm.el
index 3075077..2b37567 100644
--- a/coterm.el
+++ b/coterm.el
@@ -1,5 +1,7 @@
;; -*- lexical-binding: t; -*-
+(require 'term)
+
;;; Terminal emulation
(defconst coterm--t-control-seq-regexp
@@ -273,6 +275,8 @@ If `coterm--t-home-marker' is nil, initialize it sensibly."
(setq coterm--t-home-offset 0)
(setq coterm--t-row 0))))
+(defvar coterm-scroll-snap-mode)
+
(defun coterm--t-emulate-terminal (proc-filt process string)
(when-let ((fragment coterm--t-unhandled-fragment))
(setq string (concat fragment string))
@@ -521,18 +525,57 @@ If `coterm--t-home-marker' is nil, initialize it
sensibly."
(goto-char pmark)
(skip-chars-forward " \n")
(when (eobp)
- (delete-region pmark (point))))
+ (delete-region pmark (point)))
+
+ ;; Scroll window, but only if selected and if point is on pmark
+ (when (and coterm-scroll-snap-mode
+ (= restore-point pmark)
+ (eq buf (window-buffer (selected-window))))
+ (coterm--t-goto 0 0)
+ (recenter 0)))
(goto-char restore-point)
(unless (eq restore-point pmark)
(set-marker restore-point nil)))))))
-;;; Mode functions and configuration
+;;; Raw mode
+
+(defvar coterm-char-mode-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map term-raw-map)
+ (define-key map [remap term-char-mode] #'coterm-char-mode)
+ (define-key map [remap term-line-mode] #'coterm-char-mode)
+ map))
+
+(define-minor-mode coterm-char-mode
+ "Send characters you type directly to the inferior process.
+When this mode is enabled, the keymap `coterm-char-mode-map' is
+active, which inherits from `term-raw-map'. In this map, each
+character is sent to the process, except for the escape
+character (usually C-c). You can set `term-escape-char' to
+customize it."
+ :lighter " CHAR")
+
+(defvar coterm--char-old-scroll-margin nil)
+
+(define-minor-mode coterm-scroll-snap-mode
+ "Keep scroll synchronized.
+Usually enabled for full-screen terminal programs to keep them on
+screen."
+ :keymap nil
+ (if coterm-scroll-snap-mode
+ (unless coterm--char-old-scroll-margin
+ (setq coterm--char-old-scroll-margin
+ (cons scroll-margin
+ (local-variable-p 'scroll-margin)))
+ (setq-local scroll-margin 0))
+ (when-let ((margin coterm--char-old-scroll-margin))
+ (setq coterm--char-old-scroll-margin nil)
+ (if (cdr margin)
+ (setq scroll-margin (car margin))
+ (kill-local-variable 'scroll-margin)))))
-(defcustom coterm-term-name "eterm-color"
- "Name to use for TERM."
- :group 'comint
- :type 'string)
+;;; Mode functions and configuration
(defun coterm--comint-strip-CR (_)
"Remove all \\r characters from last output."
@@ -565,6 +608,14 @@ If `coterm--t-home-marker' is nil, initialize it sensibly."
(add-function :around (process-filter process)
#'coterm--t-emulate-terminal)))
+(defcustom coterm-term-name term-term-name
+ "Name to use for TERM."
+ :group 'comint
+ :type 'string)
+
+(defvar coterm-termcap-format term-termcap-format
+ "Termcap capabilities supported by coterm.")
+
(defvar coterm-term-environment-function #'comint-term-environment
"Function to calculate environment for comint processes.
If non-nil, it is called with zero arguments and should return a
@@ -576,21 +627,6 @@ subprocesses.")
It is called with the same arguments as `start-process' and
should return a process.")
-(defvar coterm-termcap-format
- "%s%s:li#%d:co#%d:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%%i%%d;%%dH\
-:nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt\
-:al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=^J\
-:dc=\\E[P:DC=\\E[%%dP:IC=\\E[%%d@:im=\\E[4h:ei=\\E[4l:mi:\
-:mb=\\E[5m:mh=\\E[2m:ZR=\\E[23m:ZH=\\E[3m\
-:so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m\
-:UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC\
-:kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\
-:mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#256:pa#32767\
-:AB=\\E[48;5;%%dm:AF=\\E[38;5;%%dm:cr=^M\
-:bl=^G:do=^J:le=^H:ta=^I:se=\\E[27m:ue=\\E[24m\
-:kb=^?:kD=^[[3~:sc=\\E7:rc=\\E8:r1=\\Ec:"
- "Termcap capabilities supported by coterm.")
-
(define-advice comint-exec-1 (:around (f &rest args) coterm-config)
"Make spawning processes for comint more configurable.
With this advice installed on `coterm-exec-1', you use the
- [elpa] externals/coterm 90823af 77/80: Revert "Inhibit Emacs from automatically decoding \r\n into \n", (continued)
- [elpa] externals/coterm 90823af 77/80: Revert "Inhibit Emacs from automatically decoding \r\n into \n", ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 066cd45 70/80: Explain how coterm does/doesn't do line-wrapping, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 08208f3 33/80: Handle \r\n sequence properly, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm f334168 24/80: Rename function, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 8b2836e 28/80: Fix incorrect handling of incomplete escape sequences, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 1ec97d2 29/80: \n doesn't go to column 0, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 9184a46 34/80: Always synchronize pmark at the end, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm e64027a 43/80: Restore 'window-point' of non-selected windows, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 8f0a13b 44/80: Refactor scroll snapping, snap in all windows, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm dc5f8db 38/80: Improve doc string, add autoload cookie, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm ee37b4b 39/80: Initial support for char-mode and scroll snapping,
ELPA Syncer <=
- [elpa] externals/coterm 6f42ba6 45/80: Initialize home marker properly, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 5e40af4 47/80: Prevent modification of user input harder, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm dc9466e 57/80: Implement \t (move cursor to tab stop), needed for "emacs -nw", ELPA Syncer, 2021/10/13
- [elpa] externals/coterm db17a99 62/80: Describe terminal emulation, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm c52f413 67/80: Keep char mode in less after pressing a digit, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm c717c84 75/80: Bind inhibit-read-only to t for terminal emulation, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 570ae6d 74/80: Mention auto char mode as a difference from term.el, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm c825746 27/80: Fix issue with ansi-color context marker, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 73aa1f3 31/80: Properly handle OSC and Emacs specific escape sequences, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm f4f69ab 32/80: Export TERMINFO environment variable, ELPA Syncer, 2021/10/13