diff options
| author | jixiuf <jixiuf@qq.com> | 2020-02-03 21:22:07 +0800 |
|---|---|---|
| committer | jixiuf <jixiuf@qq.com> | 2020-02-03 22:03:22 +0800 |
| commit | 8fbc00a4ca193c66a8880198cd3872e9955ed697 (patch) | |
| tree | c6d2414eadf0d2be2dd83871ecf5ef679560a07e | |
| parent | d80c3934ad946055a30905a5aaa4d4f6dbb452e3 (diff) | |
Revert "fix adjust_topline fix #222"
This reverts commit 855976e2283551db53617d4abb4c1399579a560d.
| -rw-r--r-- | elisp.c | 9 | ||||
| -rw-r--r-- | elisp.h | 6 | ||||
| -rw-r--r-- | vterm-module.c | 34 |
3 files changed, 20 insertions, 29 deletions
@@ -55,7 +55,8 @@ void insert(emacs_env *env, emacs_value string) { env->funcall(env, Finsert, 1, (emacs_value[]){string}); } -void goto_char(emacs_env *env, emacs_value point) { +void goto_char(emacs_env *env, int pos) { + emacs_value point = env->make_integer(env, pos); env->funcall(env, Fgoto_char, 1, (emacs_value[]){point}); } @@ -85,12 +86,6 @@ emacs_value point(emacs_env *env) { return env->funcall(env, Fpoint, 0, NULL); } void set_window_point(emacs_env *env, emacs_value win, emacs_value point) { env->funcall(env, Fset_window_point, 2, (emacs_value[]){win, point}); } -void set_window_start(emacs_env *env, emacs_value win, emacs_value point) { - env->funcall(env, Fset_window_start, 2, (emacs_value[]){win, point}); -} -emacs_value window_body_height(emacs_env *env, emacs_value win) { - return env->funcall(env, Fwindow_body_height, 1, (emacs_value[]){win}); -} bool eq(emacs_env *env, emacs_value e1, emacs_value e2) { emacs_value Qeq = env->funcall(env, Feq, 2, (emacs_value[]){e1, e2}); @@ -37,8 +37,6 @@ emacs_value Fgoto_line; emacs_value Fdelete_lines; emacs_value Frecenter; emacs_value Fset_window_point; -emacs_value Fset_window_start; -emacs_value Fwindow_body_height; emacs_value Fpoint; emacs_value Fput_text_property; @@ -65,15 +63,13 @@ void put_text_property(emacs_env *env, emacs_value string, emacs_value property, emacs_value value); void erase_buffer(emacs_env *env); void insert(emacs_env *env, emacs_value string); -void goto_char(emacs_env *env, emacs_value point); +void goto_char(emacs_env *env, int pos); void forward_line(emacs_env *env, int n); void goto_line(emacs_env *env, int n); void set_cursor_type(emacs_env *env, emacs_value cursor_type); void delete_lines(emacs_env *env, int linenum, int count, bool del_whole_line); void recenter(emacs_env *env, emacs_value pos); void set_window_point(emacs_env *env, emacs_value win, emacs_value point); -void set_window_start(emacs_env *env, emacs_value win, emacs_value point); -emacs_value window_body_height(emacs_env *env, emacs_value win); emacs_value point(emacs_env *env); bool eq(emacs_env *env, emacs_value e1, emacs_value e2); void forward_char(emacs_env *env, emacs_value n); diff --git a/vterm-module.c b/vterm-module.c index 439df20..367761e 100644 --- a/vterm-module.c +++ b/vterm-module.c @@ -427,24 +427,29 @@ static void adjust_topline(Term *term, emacs_env *env) { size_t offset = get_col_offset(term, pos.row, pos.col); forward_char(env, env->make_integer(env, pos.col - offset)); - emacs_value cursor_point = point(env); + bool following = + term->height == 1 + pos.row + term->linenum_added; // cursor at end? + emacs_value windows = get_buffer_window_list(env); + emacs_value swindow = selected_window(env); int winnum = env->extract_integer(env, length(env, windows)); for (int i = 0; i < winnum; i++) { emacs_value window = nth(env, i, windows); - if (env->is_not_nil(env, window)) { - int win_height = - env->extract_integer(env, window_body_height(env, window)); - /* - -win_height is negative,so we backward win_height lines from end of - buffer - */ - goto_line(env, -win_height); - set_window_start(env, window, point(env)); - set_window_point(env, window, cursor_point); + if (eq(env, window, swindow)) { + if (following) { + // "Follow" the terminal output + recenter(env, + env->make_integer( + env, -1)); /* make current line at the screen bottom */ + } else { + recenter(env, env->make_integer(env, pos.row)); + } + } else { + if (env->is_not_nil(env, window)) { + set_window_point(env, window, point(env)); + } } } - goto_char(env, cursor_point); } static void invalidate_terminal(Term *term, int start_row, int end_row) { @@ -1094,11 +1099,6 @@ int emacs_module_init(struct emacs_runtime *ert) { Frecenter = env->make_global_ref(env, env->intern(env, "recenter")); Fset_window_point = env->make_global_ref(env, env->intern(env, "set-window-point")); - Fset_window_start = - env->make_global_ref(env, env->intern(env, "set-window-start")); - Fwindow_body_height = - env->make_global_ref(env, env->intern(env, "window-body-height")); - Fpoint = env->make_global_ref(env, env->intern(env, "point")); Fforward_char = env->make_global_ref(env, env->intern(env, "forward-char")); Fget_buffer_window_list = |
