update packages
This commit is contained in:
@@ -42,6 +42,7 @@ emacs_value Frecenter;
|
||||
emacs_value Fset_window_point;
|
||||
emacs_value Fwindow_body_height;
|
||||
emacs_value Fpoint;
|
||||
emacs_value Fapply;
|
||||
|
||||
emacs_value Fput_text_property;
|
||||
emacs_value Fadd_text_properties;
|
||||
@@ -182,9 +183,9 @@ void set_cursor_blink(emacs_env *env, bool blink) {
|
||||
(emacs_value[]){env->make_integer(env, blink)});
|
||||
}
|
||||
|
||||
emacs_value vterm_get_color(emacs_env *env, int index) {
|
||||
emacs_value vterm_get_color(emacs_env *env, int index, emacs_value args) {
|
||||
emacs_value idx = env->make_integer(env, index);
|
||||
return env->funcall(env, Fvterm_get_color, 1, (emacs_value[]){idx});
|
||||
return env->funcall(env, Fapply, 3, (emacs_value[]){ Fvterm_get_color, idx, args });
|
||||
}
|
||||
|
||||
void set_title(emacs_env *env, emacs_value string) {
|
||||
|
||||
@@ -29,6 +29,7 @@ extern emacs_value Qrear_nonsticky;
|
||||
extern emacs_value Qvterm_prompt;
|
||||
|
||||
// Emacs functions
|
||||
extern emacs_value Fapply;
|
||||
extern emacs_value Fblink_cursor_mode;
|
||||
extern emacs_value Fsymbol_value;
|
||||
extern emacs_value Flength;
|
||||
@@ -91,7 +92,7 @@ emacs_value selected_window(emacs_env *env);
|
||||
void set_title(emacs_env *env, emacs_value string);
|
||||
void set_directory(emacs_env *env, emacs_value string);
|
||||
void vterm_invalidate(emacs_env *env);
|
||||
emacs_value vterm_get_color(emacs_env *env, int index);
|
||||
emacs_value vterm_get_color(emacs_env *env, int index, emacs_value args);
|
||||
emacs_value vterm_eval(emacs_env *env, emacs_value string);
|
||||
emacs_value vterm_set_selection(emacs_env *env, emacs_value selection_target,
|
||||
emacs_value selection_data);
|
||||
|
||||
@@ -845,18 +845,26 @@ static emacs_value cell_rgb_color(emacs_env *env, Term *term,
|
||||
VTermScreenCell *cell, bool is_foreground) {
|
||||
VTermColor *color = is_foreground ? &cell->fg : &cell->bg;
|
||||
|
||||
int props_len = 0;
|
||||
emacs_value props[3];
|
||||
if (is_foreground)
|
||||
props[props_len++] = Qforeground;
|
||||
if (cell->attrs.underline)
|
||||
props[props_len++] = Qunderline;
|
||||
if (cell->attrs.reverse)
|
||||
props[props_len++] = Qreverse;
|
||||
|
||||
emacs_value args = list(env, props, props_len);
|
||||
|
||||
/** NOTE: -10 is used as index offset for special indexes,
|
||||
* see C-h f vterm--get-color RET
|
||||
*/
|
||||
if (VTERM_COLOR_IS_DEFAULT_FG(color)) {
|
||||
return vterm_get_color(env, -1 + (cell->attrs.underline ? -10 : 0));
|
||||
}
|
||||
if (VTERM_COLOR_IS_DEFAULT_BG(color)) {
|
||||
return vterm_get_color(env, -2 + (cell->attrs.reverse ? -10 : 0));
|
||||
if (VTERM_COLOR_IS_DEFAULT_FG(color) || VTERM_COLOR_IS_DEFAULT_BG(color)) {
|
||||
return vterm_get_color(env, -1, args);
|
||||
}
|
||||
if (VTERM_COLOR_IS_INDEXED(color)) {
|
||||
if (color->indexed.idx < 16) {
|
||||
return vterm_get_color(env, color->indexed.idx);
|
||||
return vterm_get_color(env, color->indexed.idx, args);
|
||||
} else {
|
||||
VTermState *state = vterm_obtain_state(term->vt);
|
||||
vterm_state_get_palette_color(state, color->indexed.idx, color);
|
||||
@@ -1337,12 +1345,14 @@ emacs_value Fvterm_write_input(emacs_env *env, ptrdiff_t nargs,
|
||||
emacs_value args[], void *data) {
|
||||
Term *term = env->get_user_ptr(env, args[0]);
|
||||
ptrdiff_t len = string_bytes(env, args[1]);
|
||||
char bytes[len];
|
||||
|
||||
env->copy_string_contents(env, args[1], bytes, &len);
|
||||
if (len > 0) {
|
||||
char bytes[len];
|
||||
env->copy_string_contents(env, args[1], bytes, &len);
|
||||
|
||||
vterm_input_write(term->vt, bytes, len);
|
||||
vterm_screen_flush_damage(term->vts);
|
||||
vterm_input_write(term->vt, bytes, len);
|
||||
vterm_screen_flush_damage(term->vts);
|
||||
}
|
||||
|
||||
return env->make_integer(env, 0);
|
||||
}
|
||||
@@ -1451,6 +1461,7 @@ int emacs_module_init(struct emacs_runtime *ert) {
|
||||
Qcursor_type = env->make_global_ref(env, env->intern(env, "cursor-type"));
|
||||
|
||||
// Functions
|
||||
Fapply = env->make_global_ref(env, env->intern(env, "apply"));
|
||||
Fblink_cursor_mode =
|
||||
env->make_global_ref(env, env->intern(env, "blink-cursor-mode"));
|
||||
Fsymbol_value = env->make_global_ref(env, env->intern(env, "symbol-value"));
|
||||
@@ -1526,7 +1537,7 @@ int emacs_module_init(struct emacs_runtime *ert) {
|
||||
"Get the working directory of at line n.", NULL);
|
||||
bind_function(env, "vterm--get-pwd-raw", fun);
|
||||
fun = env->make_function(env, 1, 1, Fvterm_reset_cursor_point,
|
||||
"Reset cursor postion.", NULL);
|
||||
"Reset cursor position.", NULL);
|
||||
bind_function(env, "vterm--reset-point", fun);
|
||||
|
||||
fun = env->make_function(env, 1, 1, Fvterm_get_icrnl,
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
|
||||
VTERM_EXPORT int plugin_is_GPL_compatible;
|
||||
|
||||
#ifndef SB_MAX
|
||||
#define SB_MAX 100000 // Maximum 'scrollback' value.
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(define-package "vterm" "20230417.424" "Fully-featured terminal emulator"
|
||||
(define-package "vterm" "20241218.331" "Fully-featured terminal emulator"
|
||||
'((emacs "25.1"))
|
||||
:commit "94e2b0b2b4a750e7907dacd5b4c0584900846dd1" :authors
|
||||
:commit "f64729ed8b59e46ce827d28222c4087c538de562" :authors
|
||||
'(("Lukas Fürmetz" . "fuermetz@mailbox.org"))
|
||||
:maintainers
|
||||
'(("Lukas Fürmetz" . "fuermetz@mailbox.org"))
|
||||
|
||||
@@ -172,11 +172,26 @@ the executable."
|
||||
:type 'string
|
||||
:group 'vterm)
|
||||
|
||||
(defcustom vterm-tramp-shells '(("docker" "/bin/sh"))
|
||||
(defcustom vterm-tramp-shells
|
||||
'(("ssh" login-shell) ("scp" login-shell) ("docker" "/bin/sh"))
|
||||
"The shell that gets run in the vterm for tramp.
|
||||
|
||||
`vterm-tramp-shells' has to be a list of pairs of the format:
|
||||
\(TRAMP-METHOD SHELL)"
|
||||
\(TRAMP-METHOD SHELL)
|
||||
|
||||
Use t as TRAMP-METHOD to specify a default shell for all methods.
|
||||
Specific methods always take precedence over t.
|
||||
|
||||
Set SHELL to \\='login-shell to use the user's login shell on the host.
|
||||
The login-shell detection currently works for POSIX-compliant remote
|
||||
hosts that have the getent command (regular GNU/Linux distros, *BSDs,
|
||||
but not MacOS X unfortunately).
|
||||
|
||||
You can specify an additional second SHELL command as a fallback
|
||||
that is used when the login-shell detection fails, e.g.,
|
||||
\\='((\"ssh\" login-shell \"/bin/bash\") ...)
|
||||
If no second SHELL command is specified with \\='login-shell, vterm will
|
||||
fall back to tramp's shell."
|
||||
:type '(alist :key-type string :value-type string)
|
||||
:group 'vterm)
|
||||
|
||||
@@ -425,58 +440,98 @@ copy-mode and set to nil on leaving."
|
||||
|
||||
(defface vterm-color-black
|
||||
`((t :inherit term-color-black))
|
||||
"Face used to render black color code.
|
||||
The foreground color is used as ANSI color 0 and the background
|
||||
color is used as ANSI color 8."
|
||||
"Face used to render black color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-red
|
||||
`((t :inherit term-color-red))
|
||||
"Face used to render red color code.
|
||||
The foreground color is used as ANSI color 1 and the background
|
||||
color is used as ANSI color 9."
|
||||
"Face used to render red color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-green
|
||||
`((t :inherit term-color-green))
|
||||
"Face used to render green color code.
|
||||
The foreground color is used as ANSI color 2 and the background
|
||||
color is used as ANSI color 10."
|
||||
"Face used to render green color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-yellow
|
||||
`((t :inherit term-color-yellow))
|
||||
"Face used to render yellow color code.
|
||||
The foreground color is used as ANSI color 3 and the background
|
||||
color is used as ANSI color 11."
|
||||
"Face used to render yellow color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-blue
|
||||
`((t :inherit term-color-blue))
|
||||
"Face used to render blue color code.
|
||||
The foreground color is used as ANSI color 4 and the background
|
||||
color is used as ANSI color 12."
|
||||
"Face used to render blue color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-magenta
|
||||
`((t :inherit term-color-magenta))
|
||||
"Face used to render magenta color code.
|
||||
The foreground color is used as ansi color 5 and the background
|
||||
color is used as ansi color 13."
|
||||
"Face used to render magenta color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-cyan
|
||||
`((t :inherit term-color-cyan))
|
||||
"Face used to render cyan color code.
|
||||
The foreground color is used as ansi color 6 and the background
|
||||
color is used as ansi color 14."
|
||||
"Face used to render cyan color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-white
|
||||
`((t :inherit term-color-white))
|
||||
"Face used to render white color code.
|
||||
The foreground color is used as ansi color 7 and the background
|
||||
color is used as ansi color 15."
|
||||
"Face used to render white color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-bright-black
|
||||
`((t :inherit ,(if (facep 'term-color-bright-black)
|
||||
'term-color-bright-black
|
||||
'term-color-black)))
|
||||
"Face used to render bright black color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-bright-red
|
||||
`((t :inherit ,(if (facep 'term-color-bright-red)
|
||||
'term-color-bright-red
|
||||
'term-color-red)))
|
||||
"Face used to render bright red color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-bright-green
|
||||
`((t :inherit ,(if (facep 'term-color-bright-green)
|
||||
'term-color-bright-green
|
||||
'term-color-green)))
|
||||
"Face used to render bright green color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-bright-yellow
|
||||
`((t :inherit ,(if (facep 'term-color-bright-yellow)
|
||||
'term-color-bright-yellow
|
||||
'term-color-yellow)))
|
||||
"Face used to render bright yellow color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-bright-blue
|
||||
`((t :inherit ,(if (facep 'term-color-bright-blue)
|
||||
'term-color-bright-blue
|
||||
'term-color-blue)))
|
||||
"Face used to render bright blue color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-bright-magenta
|
||||
`((t :inherit ,(if (facep 'term-color-bright-magenta)
|
||||
'term-color-bright-magenta
|
||||
'term-color-magenta)))
|
||||
"Face used to render bright magenta color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-bright-cyan
|
||||
`((t :inherit ,(if (facep 'term-color-bright-cyan)
|
||||
'term-color-bright-cyan
|
||||
'term-color-cyan)))
|
||||
"Face used to render bright cyan color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-bright-white
|
||||
`((t :inherit ,(if (facep 'term-color-bright-white)
|
||||
'term-color-bright-white
|
||||
'term-color-white)))
|
||||
"Face used to render bright white color code."
|
||||
:group 'vterm)
|
||||
|
||||
(defface vterm-color-underline
|
||||
@@ -501,7 +556,15 @@ Only background is used."
|
||||
vterm-color-blue
|
||||
vterm-color-magenta
|
||||
vterm-color-cyan
|
||||
vterm-color-white]
|
||||
vterm-color-white
|
||||
vterm-color-bright-black
|
||||
vterm-color-bright-red
|
||||
vterm-color-bright-green
|
||||
vterm-color-bright-yellow
|
||||
vterm-color-bright-blue
|
||||
vterm-color-bright-magenta
|
||||
vterm-color-bright-cyan
|
||||
vterm-color-bright-white]
|
||||
"Color palette for the foreground and background.")
|
||||
|
||||
(defvar-local vterm--term nil
|
||||
@@ -703,7 +766,7 @@ Exceptions are defined by `vterm-keymap-exceptions'."
|
||||
(inhibit-eol-conversion nil)
|
||||
(coding-system-for-read 'binary)
|
||||
(process-adaptive-read-buffering nil)
|
||||
(width (max (- (window-body-width) (vterm--get-margin-width))
|
||||
(width (max (- (window-max-chars-per-line) (vterm--get-margin-width))
|
||||
vterm-min-window-width)))
|
||||
(setq vterm--term (vterm--new (window-body-height)
|
||||
width vterm-max-scrollback
|
||||
@@ -765,16 +828,72 @@ Exceptions are defined by `vterm-keymap-exceptions'."
|
||||
(vterm--set-pty-name vterm--term (process-tty-name vterm--process))
|
||||
(process-put vterm--process 'adjust-window-size-function
|
||||
#'vterm--window-adjust-process-window-size)
|
||||
|
||||
;; Set the truncation slot for 'buffer-display-table' to the ASCII code for a
|
||||
;; space character (32) to make the vterm buffer display a space instead of
|
||||
;; the default truncation character ($) when a line is truncated.
|
||||
(let* ((display-table (or buffer-display-table (make-display-table))))
|
||||
(set-display-table-slot display-table 'truncation 32)
|
||||
(setq buffer-display-table display-table))
|
||||
|
||||
;; Support to compilation-shell-minor-mode
|
||||
;; Is this necessary? See vterm--compilation-setup
|
||||
(setq next-error-function 'vterm-next-error-function)
|
||||
(setq-local bookmark-make-record-function 'vterm--bookmark-make-record))
|
||||
|
||||
(defun vterm--tramp-get-shell (method)
|
||||
"Get the shell for a remote location as specified in `vterm-tramp-shells'.
|
||||
The argument METHOD is the method string (as used by tramp) to get the shell
|
||||
for, or t to get the default shell for all methods."
|
||||
(let* ((specs (cdr (assoc method vterm-tramp-shells)))
|
||||
(first (car specs))
|
||||
(second (cadr specs)))
|
||||
;; Allow '(... login-shell) or '(... 'login-shell).
|
||||
(if (or (eq first 'login-shell)
|
||||
(and (consp first) (eq (cadr first) 'login-shell)))
|
||||
;; If the first element is 'login-shell, try to determine the user's
|
||||
;; login shell on the remote host. This should work for all
|
||||
;; POSIX-compliant systems with the getent command in PATH. This
|
||||
;; includes regular GNU/Linux distros, *BSDs, but not MacOS X. If
|
||||
;; the login-shell determination fails at any point, the second
|
||||
;; element in the shell spec is used (if present, otherwise nil is
|
||||
;; returned).
|
||||
(let* ((entry (ignore-errors
|
||||
(with-output-to-string
|
||||
(with-current-buffer standard-output
|
||||
;; The getent command returns the passwd entry
|
||||
;; for the specified user independently of the
|
||||
;; used name service (i.e., not only for static
|
||||
;; passwd files, but also for LDAP, etc).
|
||||
;;
|
||||
;; Use a shell command here to get $LOGNAME.
|
||||
;; Using the tramp user does not always work as
|
||||
;; it can be nil, e.g., with ssh host configs.
|
||||
;; $LOGNAME is defined in all POSIX-compliant
|
||||
;; systems.
|
||||
(unless (= 0 (process-file-shell-command
|
||||
"getent passwd $LOGNAME"
|
||||
nil (current-buffer) nil))
|
||||
(error "Unexpected return value"))
|
||||
;; If we have more than one line, the output is
|
||||
;; not the expected single passwd entry.
|
||||
;; Most likely, $LOGNAME is not set.
|
||||
(when (> (count-lines (point-min) (point-max)) 1)
|
||||
(error "Unexpected output"))))))
|
||||
(shell (when entry
|
||||
;; The returned Unix passwd entry is a colon-
|
||||
;; separated line. The 6th (last) element specifies
|
||||
;; the user's shell.
|
||||
(nth 6 (split-string entry ":" nil "[ \t\n\r]+")))))
|
||||
(or shell second))
|
||||
first)))
|
||||
|
||||
(defun vterm--get-shell ()
|
||||
"Get the shell that gets run in the vterm."
|
||||
(if (ignore-errors (file-remote-p default-directory))
|
||||
(with-parsed-tramp-file-name default-directory nil
|
||||
(or (cadr (assoc method vterm-tramp-shells))
|
||||
(or (vterm--tramp-get-shell method)
|
||||
(vterm--tramp-get-shell t)
|
||||
(with-connection-local-variables shell-file-name)
|
||||
vterm-shell))
|
||||
vterm-shell))
|
||||
@@ -824,7 +943,8 @@ it to the bookmarked directory if needed."
|
||||
`'compilation-shell-minor-mode' would change the value of local
|
||||
variable `next-error-function', so we should call this function in
|
||||
`compilation-shell-minor-mode-hook'."
|
||||
(when (eq major-mode 'vterm-mode)
|
||||
(when (or (eq major-mode 'vterm-mode)
|
||||
(derived-mode-p 'vterm-mode))
|
||||
(setq next-error-function 'vterm-next-error-function)))
|
||||
|
||||
(add-hook 'compilation-shell-minor-mode-hook #'vterm--compilation-setup)
|
||||
@@ -880,7 +1000,8 @@ A conventient way to exit `vterm-copy-mode' is with
|
||||
:group 'vterm
|
||||
:lighter " VTermCopy"
|
||||
:keymap vterm-copy-mode-map
|
||||
(if (equal major-mode 'vterm-mode)
|
||||
(if (or (equal major-mode 'vterm-mode)
|
||||
(derived-mode-p 'vterm-mode))
|
||||
(if vterm-copy-mode
|
||||
(vterm--enter-copy-mode)
|
||||
(vterm--exit-copy-mode))
|
||||
@@ -1474,7 +1595,7 @@ Then triggers a redraw from the module."
|
||||
(- count 1 partial)))
|
||||
'eight-bit))
|
||||
(cl-incf partial))
|
||||
(when (> count partial 0)
|
||||
(when (> (1+ count) partial 0)
|
||||
(setq vterm--undecoded-bytes
|
||||
(substring decoded-substring (- partial)))
|
||||
(setq decoded-substring
|
||||
@@ -1501,7 +1622,8 @@ Argument EVENT process event."
|
||||
(defun vterm--text-scale-mode (&optional _argv)
|
||||
"Fix `line-number' height for scaled text."
|
||||
(and text-scale-mode
|
||||
(equal major-mode 'vterm-mode)
|
||||
(or (equal major-mode 'vterm-mode)
|
||||
(derived-mode-p 'vterm-mode))
|
||||
(boundp 'display-line-numbers)
|
||||
(let ((height (expt text-scale-mode-step
|
||||
text-scale-mode-amount)))
|
||||
@@ -1606,29 +1728,27 @@ If N is negative backward-line from end of buffer."
|
||||
(when raw-pwd
|
||||
(vterm--get-directory raw-pwd)))))
|
||||
|
||||
(defun vterm--get-color (index)
|
||||
"Get color by index from `vterm-color-palette'.
|
||||
Argument INDEX index of the terminal color.
|
||||
Special values for INDEX are:
|
||||
-11 foreground for cells with underline attribute, foreground of
|
||||
the `vterm-color-underline' face is used in this case.
|
||||
-12 background for cells with inverse video attribute, background
|
||||
of the `vterm-color-inverse-video' face is used in this case."
|
||||
(cond
|
||||
((and (>= index 0) (< index 8))
|
||||
(face-foreground
|
||||
(elt vterm-color-palette index)
|
||||
nil 'default))
|
||||
((and (>= index 8) (< index 16))
|
||||
(face-background
|
||||
(elt vterm-color-palette (% index 8))
|
||||
nil 'default))
|
||||
((= index -11)
|
||||
(face-foreground 'vterm-color-underline nil 'default))
|
||||
((= index -12)
|
||||
(face-background 'vterm-color-inverse-video nil 'default))
|
||||
(t
|
||||
nil)))
|
||||
(defun vterm--get-color (index &rest args)
|
||||
"Get color by INDEX from `vterm-color-palette'.
|
||||
|
||||
Special INDEX of -1 is used to represent default colors. ARGS
|
||||
may optionally contain `:underline' or `:inverse-video' for cells
|
||||
with underline or inverse video attribute. If ARGS contains
|
||||
`:foreground', use foreground color of the respective face
|
||||
instead of background."
|
||||
(let ((foreground (member :foreground args))
|
||||
(underline (member :underline args))
|
||||
(inverse-video (member :inverse-video args)))
|
||||
(funcall (if foreground #'face-foreground #'face-background)
|
||||
(cond
|
||||
((and (>= index 0) (< index 16))
|
||||
(elt vterm-color-palette index))
|
||||
((and (= index -1) foreground underline)
|
||||
'vterm-color-underline)
|
||||
((and (= index -1) (not foreground) inverse-video)
|
||||
'vterm-color-inverse-video)
|
||||
(t 'default))
|
||||
nil 'default)))
|
||||
|
||||
(defun vterm--eval (str)
|
||||
"Check if string STR is `vterm-eval-cmds' and execute command.
|
||||
|
||||
Reference in New Issue
Block a user