Patch 8.1.2012
Problem:    More functions can be used as methods.
Solution:   Make terminal functions usable as a method.  Fix term_getattr().
Files:      runtime/doc/terminal.txt, src/evalfunc.c, src/terminal.c
            src/testdir/test_mksession.vim, src/testdir/test_terminal.vim


*** ../vim-8.1.2011/runtime/doc/terminal.txt    2019-07-04 17:11:16.799440884 
+0200
--- runtime/doc/terminal.txt    2019-09-08 20:53:07.058432163 +0200
***************
*** 479,484 ****
--- 479,487 ----
                Using the "s" key the top and bottom parts are swapped.  This
                makes it easy to spot a difference.
  
+               Can also be used as a |method|: >
+                       GetFilename()->term_dumpdiff(otherfile)
+ <
                                                        *term_dumpload()*
  term_dumpload({filename} [, {options}])
                Open a new window displaying the contents of {filename}
***************
*** 488,493 ****
--- 491,499 ----
  
                For {options} see |term_dumpdiff()|.
  
+               Can also be used as a |method|: >
+                       GetFilename()-> term_dumpload()
+ <
                                                        *term_dumpwrite()*
  term_dumpwrite({buf}, {filename} [, {options}])
                Dump the contents of the terminal screen of {buf} in the file
***************
*** 502,512 ****
                        "rows"          maximum number of rows to dump
                        "columns"       maximum number of columns to dump
  
  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_getansicolors({buf})                             *term_getansicolors()*
                Get the ANSI color palette in use by terminal {buf}.
--- 508,525 ----
                        "rows"          maximum number of rows to dump
                        "columns"       maximum number of columns to dump
  
+               Can also be used as a |method|, the base is used for the file
+               name: >
+                       GetFilename()-> term_dumpwrite(bufnr)
+ 
  term_getaltscreen({buf})                              *term_getaltscreen()*
                Returns 1 if the terminal of {buf} is using the alternate
                screen.
                {buf} is used as with |term_getsize()|.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_getaltscreen()
! 
  
  term_getansicolors({buf})                             *term_getansicolors()*
                Get the ANSI color palette in use by terminal {buf}.
***************
*** 517,524 ****
  
                {buf} is used as with |term_getsize()|.  If the buffer does not
                exist or is not a terminal window, an empty list is returned.
!               {only available when compiled with the |+terminal| feature and
!               with GUI enabled and/or the |+termguicolors| feature}
  
  term_getattr({attr}, {what})                          *term_getattr()*
                Given {attr}, a value returned by term_scrape() in the "attr"
--- 530,541 ----
  
                {buf} is used as with |term_getsize()|.  If the buffer does not
                exist or is not a terminal window, an empty list is returned.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_getansicolors()
! 
! <             {only available when compiled with GUI enabled and/or the
!               |+termguicolors| feature}
  
  term_getattr({attr}, {what})                          *term_getattr()*
                Given {attr}, a value returned by term_scrape() in the "attr"
***************
*** 528,534 ****
                        underline
                        strike
                        reverse
!               {only available when compiled with the |+terminal| feature}
  
  term_getcursor({buf})                                 *term_getcursor()*
                Get the cursor position of terminal {buf}. Returns a list with
--- 545,554 ----
                        underline
                        strike
                        reverse
! 
!               Can also be used as a |method|: >
!                       GetAttr()->term_getattr()
! 
  
  term_getcursor({buf})                                 *term_getcursor()*
                Get the cursor position of terminal {buf}. Returns a list with
***************
*** 550,562 ****
                {buf} must be the buffer number of a terminal window. If the
                buffer does not exist or is not a terminal window, an empty
                list is returned.
!               {only available when compiled with the |+terminal| feature}
  
  term_getjob({buf})                                    *term_getjob()*
                Get the Job associated with terminal window {buf}.
                {buf} is used as with |term_getsize()|.
                Returns |v:null| when there is no job.
!               {only available when compiled with the |+terminal| feature}
  
  term_getline({buf}, {row})                            *term_getline()*
                Get a line of text from the terminal window of {buf}.
--- 570,587 ----
                {buf} must be the buffer number of a terminal window. If the
                buffer does not exist or is not a terminal window, an empty
                list is returned.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_getcursor()
  
  term_getjob({buf})                                    *term_getjob()*
                Get the Job associated with terminal window {buf}.
                {buf} is used as with |term_getsize()|.
                Returns |v:null| when there is no job.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_getjob()
! 
  
  term_getline({buf}, {row})                            *term_getline()*
                Get a line of text from the terminal window of {buf}.
***************
*** 567,573 ****
                returned.
  
                To get attributes of each character use |term_scrape()|.
!               {only available when compiled with the |+terminal| feature}
  
  term_getscrolled({buf})                                       
*term_getscrolled()*
                Return the number of lines that scrolled to above the top of
--- 592,601 ----
                returned.
  
                To get attributes of each character use |term_scrape()|.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_getline(row)
! 
  
  term_getscrolled({buf})                                       
*term_getscrolled()*
                Return the number of lines that scrolled to above the top of
***************
*** 579,585 ****
  <             (if that line exists).
  
                {buf} is used as with |term_getsize()|.
!               {only available when compiled with the |+terminal| feature}
  
  term_getsize({buf})                                   *term_getsize()*
                Get the size of terminal {buf}. Returns a list with two
--- 607,616 ----
  <             (if that line exists).
  
                {buf} is used as with |term_getsize()|.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_getscrolled()
! 
  
  term_getsize({buf})                                   *term_getsize()*
                Get the size of terminal {buf}. Returns a list with two
***************
*** 589,595 ****
                {buf} must be the buffer number of a terminal window.  Use an
                empty string for the current buffer.  If the buffer does not
                exist or is not a terminal window, an empty list is returned.
!               {only available when compiled with the |+terminal| feature}
  
  term_getstatus({buf})                                 *term_getstatus()*
                Get the status of terminal {buf}. This returns a comma
--- 620,629 ----
                {buf} must be the buffer number of a terminal window.  Use an
                empty string for the current buffer.  If the buffer does not
                exist or is not a terminal window, an empty list is returned.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_getsize()
! 
  
  term_getstatus({buf})                                 *term_getstatus()*
                Get the status of terminal {buf}. This returns a comma
***************
*** 602,608 ****
                {buf} must be the buffer number of a terminal window. If the
                buffer does not exist or is not a terminal window, an empty
                string is returned.
!               {only available when compiled with the |+terminal| feature}
  
  term_gettitle({buf})                                  *term_gettitle()*
                Get the title of terminal {buf}. This is the title that the
--- 636,645 ----
                {buf} must be the buffer number of a terminal window. If the
                buffer does not exist or is not a terminal window, an empty
                string is returned.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_getstatus()
! 
  
  term_gettitle({buf})                                  *term_gettitle()*
                Get the title of terminal {buf}. This is the title that the
***************
*** 611,617 ****
                {buf} must be the buffer number of a terminal window. If the
                buffer does not exist or is not a terminal window, an empty
                string is returned.
!               {only available when compiled with the |+terminal| feature}
  
  term_gettty({buf} [, {input}])                                *term_gettty()*
                Get the name of the controlling terminal associated with
--- 648,657 ----
                {buf} must be the buffer number of a terminal window. If the
                buffer does not exist or is not a terminal window, an empty
                string is returned.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_gettitle()
! 
  
  term_gettty({buf} [, {input}])                                *term_gettty()*
                Get the name of the controlling terminal associated with
***************
*** 620,631 ****
                When {input} is omitted or 0, return the name for writing
                (stdout). When {input} is 1 return the name for reading
                (stdin). On UNIX, both return same name.
!               {only available when compiled with the |+terminal| feature}
  
  term_list()                                           *term_list()*
                Return a list with the buffer numbers of all buffers for
                terminal windows.
!               {only available when compiled with the |+terminal| feature}
  
  term_scrape({buf}, {row})                             *term_scrape()*
                Get the contents of {row} of terminal screen of {buf}.
--- 660,674 ----
                When {input} is omitted or 0, return the name for writing
                (stdout). When {input} is 1 return the name for reading
                (stdin). On UNIX, both return same name.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_gettty()
! 
  
  term_list()                                           *term_list()*
                Return a list with the buffer numbers of all buffers for
                terminal windows.
! 
  
  term_scrape({buf}, {row})                             *term_scrape()*
                Get the contents of {row} of terminal screen of {buf}.
***************
*** 642,648 ****
                    "attr"      attributes of the cell, use |term_getattr()|
                                to get the individual flags
                    "width"     cell width: 1 or 2
!               {only available when compiled with the |+terminal| feature}
  
  term_sendkeys({buf}, {keys})                          *term_sendkeys()*
                Send keystrokes {keys} to terminal {buf}.
--- 685,694 ----
                    "attr"      attributes of the cell, use |term_getattr()|
                                to get the individual flags
                    "width"     cell width: 1 or 2
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_scrape(row)
! 
  
  term_sendkeys({buf}, {keys})                          *term_sendkeys()*
                Send keystrokes {keys} to terminal {buf}.
***************
*** 650,656 ****
  
                {keys} are translated as key sequences. For example, "\<c-x>"
                means the character CTRL-X.
!               {only available when compiled with the |+terminal| feature}
  
  term_setansicolors({buf}, {colors})                   *term_setansicolors()*
                Set the ANSI color palette used by terminal {buf}.
--- 696,705 ----
  
                {keys} are translated as key sequences. For example, "\<c-x>"
                means the character CTRL-X.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_sendkeys(keys)
! 
  
  term_setansicolors({buf}, {colors})                   *term_setansicolors()*
                Set the ANSI color palette used by terminal {buf}.
***************
*** 680,687 ****
                'termguicolors' is set.  When not using GUI colors (GUI mode
                or 'termguicolors'), the terminal window always uses the 16
                ANSI colors of the underlying terminal.
!               {only available when compiled with the |+terminal| feature and
!               with GUI enabled and/or the |+termguicolors| feature}
  
  term_setkill({buf}, {how})                            *term_setkill()*
                When exiting Vim or trying to close the terminal window in
--- 729,740 ----
                'termguicolors' is set.  When not using GUI colors (GUI mode
                or 'termguicolors'), the terminal window always uses the 16
                ANSI colors of the underlying terminal.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_setansicolors(colors)
! 
! <             {only available with GUI enabled and/or the |+termguicolors|
!               feature}
  
  term_setkill({buf}, {how})                            *term_setkill()*
                When exiting Vim or trying to close the terminal window in
***************
*** 695,700 ****
--- 748,757 ----
                After sending the signal Vim will wait for up to a second to
                check that the job actually stopped.
  
+               Can also be used as a |method|: >
+                       GetBufnr()->term_setkill(how)
+ 
+ 
  term_setrestore({buf}, {command})                     *term_setrestore()*
                Set the command to write in a session file to restore the job
                in this terminal.  The line written in the session file is: >
***************
*** 703,709 ****
  
                Use an empty {command} to run 'shell'.
                Use "NONE" to not restore this window.
!               {only available when compiled with the |+terminal| feature}
  
  term_setsize({buf}, {rows}, {cols})           *term_setsize()* *E955*
                Set the size of terminal {buf}. The size of the window
--- 760,769 ----
  
                Use an empty {command} to run 'shell'.
                Use "NONE" to not restore this window.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_setrestore(command)
! 
  
  term_setsize({buf}, {rows}, {cols})           *term_setsize()* *E955*
                Set the size of terminal {buf}. The size of the window
***************
*** 714,720 ****
                {buf} must be the buffer number of a terminal window.  Use an
                empty string for the current buffer.  If the buffer does not
                exist or is not a terminal window, an error is given.
!               {only available when compiled with the |+terminal| feature}
  
  term_start({cmd} [, {options}])                       *term_start()*
                Open a terminal window and run {cmd} in it.
--- 774,783 ----
                {buf} must be the buffer number of a terminal window.  Use an
                empty string for the current buffer.  If the buffer does not
                exist or is not a terminal window, an error is given.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_setsize(rows, cols)
! 
  
  term_start({cmd} [, {options}])                       *term_start()*
                Open a terminal window and run {cmd} in it.
***************
*** 781,794 ****
                   "tty_type"        (MS-Windows only): Specify which pty to
                                     use.  See 'termwintype' for the values.
  
!               {only available when compiled with the |+terminal| feature}
  
  term_wait({buf} [, {time}])                                   *term_wait()*
                Wait for pending updates of {buf} to be handled.
                {buf} is used as with |term_getsize()|.
                {time} is how long to wait for updates to arrive in msec.  If
                not set then 10 msec will be used.
!               {only available when compiled with the |+terminal| feature}
  
  ==============================================================================
  3. Terminal communication                      *terminal-communication*
--- 844,863 ----
                   "tty_type"        (MS-Windows only): Specify which pty to
                                     use.  See 'termwintype' for the values.
  
!               Can also be used as a |method|: >
!                       GetCommand()->term_start()
! 
! <             {only available when compiled with the |+terminal| feature}
! 
  
  term_wait({buf} [, {time}])                                   *term_wait()*
                Wait for pending updates of {buf} to be handled.
                {buf} is used as with |term_getsize()|.
                {time} is how long to wait for updates to arrive in msec.  If
                not set then 10 msec will be used.
! 
!               Can also be used as a |method|: >
!                       GetBufnr()->term_wait()
  
  ==============================================================================
  3. Terminal communication                      *terminal-communication*
*** ../vim-8.1.2011/src/evalfunc.c      2019-09-08 18:58:39.557952948 +0200
--- src/evalfunc.c      2019-09-08 20:52:45.406498448 +0200
***************
*** 765,797 ****
  #endif
      {"tempname",      0, 0, 0,          f_tempname},
  #ifdef FEAT_TERMINAL
!     {"term_dumpdiff", 2, 3, 0,          f_term_dumpdiff},
!     {"term_dumpload", 1, 2, 0,          f_term_dumpload},
!     {"term_dumpwrite",        2, 3, 0,          f_term_dumpwrite},
!     {"term_getaltscreen", 1, 1, 0,      f_term_getaltscreen},
  # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
!     {"term_getansicolors", 1, 1, 0,     f_term_getansicolors},
  # endif
!     {"term_getattr",  2, 2, 0,          f_term_getattr},
!     {"term_getcursor",        1, 1, 0,          f_term_getcursor},
!     {"term_getjob",   1, 1, 0,          f_term_getjob},
!     {"term_getline",  2, 2, 0,          f_term_getline},
!     {"term_getscrolled", 1, 1, 0,       f_term_getscrolled},
!     {"term_getsize",  1, 1, 0,          f_term_getsize},
!     {"term_getstatus",        1, 1, 0,          f_term_getstatus},
!     {"term_gettitle", 1, 1, 0,          f_term_gettitle},
!     {"term_gettty",   1, 2, 0,          f_term_gettty},
      {"term_list",     0, 0, 0,          f_term_list},
!     {"term_scrape",   2, 2, 0,          f_term_scrape},
!     {"term_sendkeys", 2, 2, 0,          f_term_sendkeys},
  # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
!     {"term_setansicolors", 2, 2, 0,     f_term_setansicolors},
  # endif
!     {"term_setkill",  2, 2, 0,          f_term_setkill},
!     {"term_setrestore",       2, 2, 0,          f_term_setrestore},
!     {"term_setsize",  3, 3, 0,          f_term_setsize},
!     {"term_start",    1, 2, 0,          f_term_start},
!     {"term_wait",     1, 2, 0,          f_term_wait},
  #endif
      {"test_alloc_fail",       3, 3, FEARG_1,    f_test_alloc_fail},
      {"test_autochdir",        0, 0, 0,          f_test_autochdir},
--- 765,797 ----
  #endif
      {"tempname",      0, 0, 0,          f_tempname},
  #ifdef FEAT_TERMINAL
!     {"term_dumpdiff", 2, 3, FEARG_1,    f_term_dumpdiff},
!     {"term_dumpload", 1, 2, FEARG_1,    f_term_dumpload},
!     {"term_dumpwrite",        2, 3, FEARG_2,    f_term_dumpwrite},
!     {"term_getaltscreen", 1, 1, FEARG_1,  f_term_getaltscreen},
  # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
!     {"term_getansicolors", 1, 1, FEARG_1, f_term_getansicolors},
  # endif
!     {"term_getattr",  2, 2, FEARG_1,    f_term_getattr},
!     {"term_getcursor",        1, 1, FEARG_1,    f_term_getcursor},
!     {"term_getjob",   1, 1, FEARG_1,    f_term_getjob},
!     {"term_getline",  2, 2, FEARG_1,    f_term_getline},
!     {"term_getscrolled", 1, 1, FEARG_1,         f_term_getscrolled},
!     {"term_getsize",  1, 1, FEARG_1,    f_term_getsize},
!     {"term_getstatus",        1, 1, FEARG_1,    f_term_getstatus},
!     {"term_gettitle", 1, 1, FEARG_1,    f_term_gettitle},
!     {"term_gettty",   1, 2, FEARG_1,    f_term_gettty},
      {"term_list",     0, 0, 0,          f_term_list},
!     {"term_scrape",   2, 2, FEARG_1,    f_term_scrape},
!     {"term_sendkeys", 2, 2, FEARG_1,    f_term_sendkeys},
  # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
!     {"term_setansicolors", 2, 2, FEARG_1, f_term_setansicolors},
  # endif
!     {"term_setkill",  2, 2, FEARG_1,    f_term_setkill},
!     {"term_setrestore",       2, 2, FEARG_1,    f_term_setrestore},
!     {"term_setsize",  3, 3, FEARG_1,    f_term_setsize},
!     {"term_start",    1, 2, FEARG_1,    f_term_start},
!     {"term_wait",     1, 2, FEARG_1,    f_term_wait},
  #endif
      {"test_alloc_fail",       3, 3, FEARG_1,    f_test_alloc_fail},
      {"test_autochdir",        0, 0, 0,          f_test_autochdir},
*** ../vim-8.1.2011/src/terminal.c      2019-08-15 20:58:49.818081278 +0200
--- src/terminal.c      2019-09-08 20:14:53.393623768 +0200
***************
*** 5055,5060 ****
--- 5055,5062 ----
      if (name == NULL)
        return;
  
+     if (attr > HL_ALL)
+       attr = syn_attr2attr(attr);
      for (i = 0; i < sizeof(attrs)/sizeof(attrs[0]); ++i)
        if (STRCMP(name, attrs[i].name) == 0)
        {
*** ../vim-8.1.2011/src/testdir/test_mksession.vim      2019-08-01 
23:05:45.914059813 +0200
--- src/testdir/test_mksession.vim      2019-09-08 20:50:21.374932519 +0200
***************
*** 408,414 ****
  
  func Test_mksession_terminal_restore_other()
    terminal
!   call term_setrestore(bufnr('%'), 'other')
    mksession! Xtest_mks.out
    let lines = readfile('Xtest_mks.out')
    let term_cmd = ''
--- 408,414 ----
  
  func Test_mksession_terminal_restore_other()
    terminal
!   eval bufnr('%')->term_setrestore('other')
    mksession! Xtest_mks.out
    let lines = readfile('Xtest_mks.out')
    let term_cmd = ''
*** ../vim-8.1.2011/src/testdir/test_terminal.vim       2019-08-31 
19:13:27.839704613 +0200
--- src/testdir/test_terminal.vim       2019-09-08 20:52:40.434513633 +0200
***************
*** 25,31 ****
    let g:job = term_getjob(buf)
    call assert_equal(v:t_job, type(g:job))
  
!   let string = string({'job': term_getjob(buf)})
    call assert_match("{'job': 'process \\d\\+ run'}", string)
  
    return buf
--- 25,31 ----
    let g:job = term_getjob(buf)
    call assert_equal(v:t_job, type(g:job))
  
!   let string = string({'job': buf->term_getjob()})
    call assert_match("{'job': 'process \\d\\+ run'}", string)
  
    return buf
***************
*** 42,48 ****
      " ConPTY works on anonymous pipe.
      if !has('conpty')
        call assert_match('^\\\\.\\pipe\\', job_info(g:job).tty_out)
!       call assert_match('^\\\\.\\pipe\\', term_gettty(''))
      endif
    endif
    call assert_equal('t', mode())
--- 42,48 ----
      " ConPTY works on anonymous pipe.
      if !has('conpty')
        call assert_match('^\\\\.\\pipe\\', job_info(g:job).tty_out)
!       call assert_match('^\\\\.\\pipe\\', ''->term_gettty())
      endif
    endif
    call assert_equal('t', mode())
***************
*** 91,97 ****
  
    call feedkeys("echo \<C-W>\"\" \<C-W>\"=37 + 5\<CR>\<CR>", 'xt')
    call WaitForAssert({-> assert_match("echo text to paste 42$", getline(1))})
!   call WaitForAssert({-> assert_equal('text to paste 42',       getline(2))})
  
    exe buf . 'bwipe!'
    unlet g:job
--- 91,97 ----
  
    call feedkeys("echo \<C-W>\"\" \<C-W>\"=37 + 5\<CR>\<CR>", 'xt')
    call WaitForAssert({-> assert_match("echo text to paste 42$", getline(1))})
!   call WaitForAssert({-> assert_equal('text to paste 42',       
2->getline())})
  
    exe buf . 'bwipe!'
    unlet g:job
***************
*** 176,187 ****
    call assert_true(len(l) == 0)
    let l = term_scrape(a:buf, 999)
    call assert_true(len(l) == 0)
!   let l = term_scrape(a:buf, 1)
    call assert_true(len(l) > 0)
    call assert_equal('1', l[0].chars)
    call assert_equal('2', l[1].chars)
    call assert_equal('3', l[2].chars)
    call assert_equal('#00e000', l[0].fg)
    if has('win32')
      " On Windows 'background' always defaults to dark, even though the 
terminal
      " may use a light background.  Therefore accept both white and black.
--- 176,189 ----
    call assert_true(len(l) == 0)
    let l = term_scrape(a:buf, 999)
    call assert_true(len(l) == 0)
!   let l = a:buf->term_scrape(1)
    call assert_true(len(l) > 0)
    call assert_equal('1', l[0].chars)
    call assert_equal('2', l[1].chars)
    call assert_equal('3', l[2].chars)
    call assert_equal('#00e000', l[0].fg)
+   call assert_equal(0, term_getattr(l[0].attr, 'bold'))
+   call assert_equal(0, l[0].attr->term_getattr('italic'))
    if has('win32')
      " On Windows 'background' always defaults to dark, even though the 
terminal
      " may use a light background.  Therefore accept both white and black.
***************
*** 238,244 ****
      " multibyte characters.
      let buf = term_start("cmd /K chcp 65001")
      call term_sendkeys(buf, "type Xtext\<CR>")
!     call term_sendkeys(buf, "exit\<CR>")
      let line = 4
    else
      let buf = term_start("cat Xtext")
--- 240,246 ----
      " multibyte characters.
      let buf = term_start("cmd /K chcp 65001")
      call term_sendkeys(buf, "type Xtext\<CR>")
!     eval buf->term_sendkeys("exit\<CR>")
      let line = 4
    else
      let buf = term_start("cat Xtext")
***************
*** 283,289 ****
      sleep 100m
    endif
  
!   let scrolled = term_getscrolled(buf)
    call assert_equal('1', getline(1))
    call assert_equal('1', term_getline(buf, 1 - scrolled))
    call assert_equal('49', getline(49))
--- 285,292 ----
      sleep 100m
    endif
  
!   let scrolled = buf->term_getscrolled()
!   call assert_equal(scrolled, term_getscrolled(buf))
    call assert_equal('1', getline(1))
    call assert_equal('1', term_getline(buf, 1 - scrolled))
    call assert_equal('49', getline(49))
***************
*** 383,394 ****
  
    vsplit
    exe 'terminal ++rows=5 ++cols=33 ' . cmd
!   call assert_equal([5, 33], term_getsize(''))
  
    call term_setsize('', 6, 0)
    call assert_equal([6, 33], term_getsize(''))
  
!   call term_setsize('', 0, 35)
    call assert_equal([6, 35], term_getsize(''))
  
    call term_setsize('', 7, 30)
--- 386,397 ----
  
    vsplit
    exe 'terminal ++rows=5 ++cols=33 ' . cmd
!   call assert_equal([5, 33], ''->term_getsize())
  
    call term_setsize('', 6, 0)
    call assert_equal([6, 33], term_getsize(''))
  
!   eval ''->term_setsize(0, 35)
    call assert_equal([6, 35], term_getsize(''))
  
    call term_setsize('', 7, 30)
***************
*** 407,413 ****
    bwipe!
    call assert_equal(20, size[1])
  
!   call term_start(cmd, {'vertical': 1, 'term_cols': 26})
    let size = term_getsize('')
    bwipe!
    call assert_equal(26, size[1])
--- 410,416 ----
    bwipe!
    call assert_equal(20, size[1])
  
!   eval cmd->term_start({'vertical': 1, 'term_cols': 26})
    let size = term_getsize('')
    bwipe!
    call assert_equal(26, size[1])
***************
*** 618,624 ****
    else
      call term_sendkeys(buf, "echo $TESTENV\r")
    endif
!   call term_wait(buf)
    call StopShellInTerminal(buf)
    call WaitForAssert({-> assert_equal('correct', getline(2))})
  
--- 621,627 ----
    else
      call term_sendkeys(buf, "echo $TESTENV\r")
    endif
!   eval buf->term_wait()
    call StopShellInTerminal(buf)
    call WaitForAssert({-> assert_equal('correct', getline(2))})
  
***************
*** 1006,1012 ****
  " Run Vim, start a terminal in that Vim, set the kill argument with
  " term_setkill(), check that :qall works.
  func Test_terminal_qall_kill_func()
!   call Run_terminal_qall_kill('term', 'call term_setkill(buf, "kill")')
  endfunc
  
  " Run Vim, start a terminal in that Vim without the kill argument,
--- 1009,1015 ----
  " Run Vim, start a terminal in that Vim, set the kill argument with
  " term_setkill(), check that :qall works.
  func Test_terminal_qall_kill_func()
!   call Run_terminal_qall_kill('term', 'eval buf->term_setkill("kill")')
  endfunc
  
  " Run Vim, start a terminal in that Vim without the kill argument,
***************
*** 1107,1113 ****
    call writefile([text], 'Xcomposing')
    let buf = RunVimInTerminal('--cmd "set encoding=utf-8" Xcomposing', {})
    call WaitForAssert({-> assert_match(text, term_getline(buf, 1))})
!   call term_dumpwrite(buf, 'Xdump')
    let dumpline = readfile('Xdump')[0]
    call assert_match('|à| |ê| |ö', dumpline)
  
--- 1110,1116 ----
    call writefile([text], 'Xcomposing')
    let buf = RunVimInTerminal('--cmd "set encoding=utf-8" Xcomposing', {})
    call WaitForAssert({-> assert_match(text, term_getline(buf, 1))})
!   eval 'Xdump'->term_dumpwrite(buf)
    let dumpline = readfile('Xdump')[0]
    call assert_match('|à| |ê| |ö', dumpline)
  
***************
*** 1127,1133 ****
    call Check_dump01(0)
  
    " Load another dump in the same window
!   let buf2 = term_dumpload('dumps/Test_diff_01.dump', {'bufnr': buf})
    call assert_equal(buf, buf2)
    call assert_notequal('one two three four five', trim(getline(1)))
  
--- 1130,1136 ----
    call Check_dump01(0)
  
    " Load another dump in the same window
!   let buf2 = 'dumps/Test_diff_01.dump'->term_dumpload({'bufnr': buf})
    call assert_equal(buf, buf2)
    call assert_notequal('one two three four five', trim(getline(1)))
  
***************
*** 1148,1154 ****
  
  func Test_terminal_dumpdiff()
    call assert_equal(1, winnr('$'))
!   call term_dumpdiff('dumps/Test_popup_command_01.dump', 
'dumps/Test_popup_command_02.dump')
    call assert_equal(2, winnr('$'))
    call assert_equal(62, line('$'))
    call Check_dump01(0)
--- 1151,1157 ----
  
  func Test_terminal_dumpdiff()
    call assert_equal(1, winnr('$'))
!   eval 
'dumps/Test_popup_command_01.dump'->term_dumpdiff('dumps/Test_popup_command_02.dump')
    call assert_equal(2, winnr('$'))
    call assert_equal(62, line('$'))
    call Check_dump01(0)
***************
*** 1490,1496 ****
    call assert_equal(s:test_colors, term_getansicolors(buf))
  
    call term_setansicolors(buf, g:terminal_ansi_colors)
!   call assert_equal(g:terminal_ansi_colors, term_getansicolors(buf))
  
    let colors = [
        \ 'ivory', 'AliceBlue',
--- 1493,1499 ----
    call assert_equal(s:test_colors, term_getansicolors(buf))
  
    call term_setansicolors(buf, g:terminal_ansi_colors)
!   call assert_equal(g:terminal_ansi_colors, buf->term_getansicolors())
  
    let colors = [
        \ 'ivory', 'AliceBlue',
***************
*** 1502,1508 ****
        \ 'grey47', 'gray97',
        \ 'MistyRose2', 'DodgerBlue4',
        \]
!   call term_setansicolors(buf, colors)
  
    let colors[4] = 'Invalid'
    call assert_fails('call term_setansicolors(buf, colors)', 'E474:')
--- 1505,1511 ----
        \ 'grey47', 'gray97',
        \ 'MistyRose2', 'DodgerBlue4',
        \]
!   eval buf->term_setansicolors(colors)
  
    let colors[4] = 'Invalid'
    call assert_fails('call term_setansicolors(buf, colors)', 'E474:')
***************
*** 1856,1862 ****
    call term_sendkeys(bnr, "asdf\<CR>")
    call WaitForAssert({-> assert_match('asdf', term_getline(bnr, 2))})
    call term_sendkeys(bnr, "\<C-D>")
!   call WaitForAssert({-> assert_equal('finished', term_getstatus(bnr))})
    bwipe!
  endfunc
  
--- 1859,1865 ----
    call term_sendkeys(bnr, "asdf\<CR>")
    call WaitForAssert({-> assert_match('asdf', term_getline(bnr, 2))})
    call term_sendkeys(bnr, "\<C-D>")
!   call WaitForAssert({-> assert_equal('finished', bnr->term_getstatus())})
    bwipe!
  endfunc
  
***************
*** 1944,1950 ****
  
    " Show the cursor.
    call term_sendkeys(buf, "echo -e '\\033[?25h'\r")
!   call WaitForAssert({-> assert_equal(1, term_getcursor(buf)[2].visible)})
  
    " Change color of cursor.
    call WaitForAssert({-> assert_equal('', term_getcursor(buf)[2].color)})
--- 1947,1953 ----
  
    " Show the cursor.
    call term_sendkeys(buf, "echo -e '\\033[?25h'\r")
!   call WaitForAssert({-> assert_equal(1, buf->term_getcursor()[2].visible)})
  
    " Change color of cursor.
    call WaitForAssert({-> assert_equal('', term_getcursor(buf)[2].color)})
***************
*** 1989,1995 ****
  func Test_term_gettitle()
    " term_gettitle() returns an empty string for a non-terminal buffer
    " and for a non-existing buffer.
!   call assert_equal('', term_gettitle(bufnr('%')))
    call assert_equal('', term_gettitle(bufnr('$') + 1))
  
    if !has('title') || &title == 0 || empty(&t_ts)
--- 1992,1998 ----
  func Test_term_gettitle()
    " term_gettitle() returns an empty string for a non-terminal buffer
    " and for a non-existing buffer.
!   call assert_equal('', bufnr('%')->term_gettitle())
    call assert_equal('', term_gettitle(bufnr('$') + 1))
  
    if !has('title') || &title == 0 || empty(&t_ts)
***************
*** 2083,2085 ****
--- 2086,2104 ----
    set splitright&
    only!
  endfunc
+ 
+ func Test_terminal_altscreen()
+   CheckUnix
+ 
+   let buf = term_start(&shell, {})
+ 
+   call term_sendkeys(buf, 'echo "\e[?1047h"' .. "\r")
+   call term_wait(buf)
+   call assert_equal(1, term_getaltscreen(buf))
+   call term_sendkeys(buf, 'echo "\e[?1047l"' .. "\r")
+   call term_wait(buf)
+   call assert_equal(0, buf->term_getaltscreen())
+ 
+   call term_sendkeys(buf, "exit\r")
+   exe buf . "bwipe!"
+ endfunc
*** ../vim-8.1.2011/src/version.c       2019-09-08 18:58:39.557952948 +0200
--- src/version.c       2019-09-08 19:06:29.392448479 +0200
***************
*** 759,760 ****
--- 759,762 ----
  {   /* Add new patch number below this line */
+ /**/
+     2012,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
221. Your wife melts your keyboard in the oven.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201909081856.x88IuBvd018617%40masaka.moolenaar.net.

Raspunde prin e-mail lui