]> granicus.if.org Git - vim/commitdiff
patch 8.0.0898: can't use the alternate screen in a terminal window v8.0.0898
authorBram Moolenaar <Bram@vim.org>
Fri, 11 Aug 2017 14:24:50 +0000 (16:24 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 11 Aug 2017 14:24:50 +0000 (16:24 +0200)
Problem:    Can't use the alternate screen in a terminal window.
Solution:   Initialze the alternate screen. (Yasuhiro Matsumoto, closes
            #1957)  Add term_getaltscreen().

runtime/doc/eval.txt
src/evalfunc.c
src/libvterm/include/vterm.h
src/proto/terminal.pro
src/terminal.c
src/version.c

index a98958b15ce2fd84148643889b0a0d14d806357c..806f0cd684cef59087020405587bdfd4b0ca7675 100644 (file)
@@ -2369,6 +2369,7 @@ tagfiles()                        List    tags files used
 tan({expr})                    Float   tangent of {expr}
 tanh({expr})                   Float   hyperbolic tangent of {expr}
 tempname()                     String  name for a temporary file
+term_getaltscreen({buf})       Number  get the alternate screen flag
 term_getattr({attr}, {what})   Number  get the value of attribute {what}
 term_getcursor({buf})          List    get the cursor position of a terminal
 term_getjob({buf})             Job     get the job associated with a terminal
@@ -7914,6 +7915,12 @@ tempname()                                       *tempname()* *temp-file-name*
                For MS-Windows forward slashes are used when the 'shellslash'
                option is set or when 'shellcmdflag' starts with '-'.
 
+term_getaltscreen({buf})                               *term_getaltscreen()*
+               Returns 1 if the terminal of {buf} is using the alternate
+               screen.
+               {buf} is used as with |term_getsize()|.
+               {only available when compiled with the |+terminal| feature}
+
 term_getattr({attr}, {what})                           *term_getattr()*
                Given {attr}, a value returned by term_scrape() in the "attr"
                item, return whether {what} is on.  {what} can be one of:
index b5880c58d568edb6189251c30ca2c9c307c765b2..6cb0ed7d722251df50e37879f34ed84193c60d1d 100644 (file)
@@ -831,6 +831,7 @@ static struct fst
 #endif
     {"tempname",       0, 0, f_tempname},
 #ifdef FEAT_TERMINAL
+    {"term_getaltscreen", 1, 1, f_term_getaltscreen},
     {"term_getattr",   2, 2, f_term_getattr},
     {"term_getcursor", 1, 1, f_term_getcursor},
     {"term_getjob",    1, 1, f_term_getjob},
index e797dffbfa07b91594a4b3b84e7d0646d0c22021..cd7b1f77211ff0f9b648780392de336f01c10164 100644 (file)
@@ -188,6 +188,8 @@ void vterm_keyboard_start_paste(VTerm *vt);
 void vterm_keyboard_end_paste(VTerm *vt);
 
 void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod);
+/* "button" is 1 for left, 2 for middle, 3 for right.
+ * Button 4 is scroll wheel down, button 5 is scroll wheel up. */
 void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod);
 
 /* ------------
@@ -302,6 +304,9 @@ typedef struct {
   int (*settermprop)(VTermProp prop, VTermValue *val, void *user);
   int (*bell)(void *user);
   int (*resize)(int rows, int cols, void *user);
+  /* A line was pushed off the top of the window.
+   * "cells[cols]" contains the cells of that line.
+   * Return value is unused. */
   int (*sb_pushline)(int cols, const VTermScreenCell *cells, void *user);
   int (*sb_popline)(int cols, VTermScreenCell *cells, void *user);
 } VTermScreenCallbacks;
@@ -320,6 +325,9 @@ void *vterm_screen_get_cbdata(VTermScreen *screen);
 void  vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user);
 void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen);
 
+/* Enable support for using the alternate screen if "altscreen" is non-zero.
+ * Before that switching to the alternate screen won't work.
+ * Calling with "altscreen" zero has no effect. */
 void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen);
 
 typedef enum {
index 7b28c28624b23a3018824c17802f5c6d3dca7bce..a004d355ee6e5ee4e7ddea57df5414064de5e5d7 100644 (file)
@@ -17,6 +17,7 @@ void term_change_in_curbuf(void);
 int term_get_attr(buf_T *buf, linenr_T lnum, int col);
 char_u *term_get_status_text(term_T *term);
 int set_ref_in_term(int copyID);
+void f_term_getaltscreen(typval_T *argvars, typval_T *rettv);
 void f_term_getattr(typval_T *argvars, typval_T *rettv);
 void f_term_getcursor(typval_T *argvars, typval_T *rettv);
 void f_term_getjob(typval_T *argvars, typval_T *rettv);
index b1cb61fc09bf7b79b6c29b49fb8c81aa74146ae2..e22f7bcf755ce76db71341e534bade2a216d32ae 100644 (file)
@@ -146,6 +146,8 @@ struct terminal_S {
 
     VTermPos   tl_cursor_pos;
     int                tl_cursor_visible;
+
+    int                tl_using_altscreen;
 };
 
 #define TMODE_ONCE 1       /* CTRL-\ CTRL-N used */
@@ -1316,6 +1318,11 @@ handle_settermprop(
            out_flush();
            break;
 
+       case VTERM_PROP_ALTSCREEN:
+           /* TODO: do anything else? */
+           term->tl_using_altscreen = value->boolean;
+           break;
+
        default:
            break;
     }
@@ -1865,6 +1872,9 @@ create_vterm(term_T *term, int rows, int cols)
 
     /* Required to initialize most things. */
     vterm_screen_reset(screen, 1 /* hard */);
+
+    /* Allow using alternate screen. */
+    vterm_screen_enable_altscreen(screen, 1);
 }
 
 /*
@@ -1938,6 +1948,19 @@ term_get_buf(typval_T *argvars)
     return buf;
 }
 
+/*
+ * "term_getaltscreen(buf)" function
+ */
+    void
+f_term_getaltscreen(typval_T *argvars, typval_T *rettv)
+{
+    buf_T      *buf = term_get_buf(argvars);
+
+    if (buf == NULL)
+       return;
+    rettv->vval.v_number = buf->b_term->tl_using_altscreen;
+}
+
 /*
  * "term_getattr(attr, name)" function
  */
index 6a19bd14762cd64426c4eb6475fed699e4dd4729..8b112c600497d385d571249bd61a9703af19de40 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    898,
 /**/
     897,
 /**/