]> granicus.if.org Git - vim/commitdiff
patch 8.0.1624: options for term_dumpdiff() and term_dumpload() not implemented v8.0.1624
authorBram Moolenaar <Bram@vim.org>
Tue, 20 Mar 2018 17:35:53 +0000 (18:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 20 Mar 2018 17:35:53 +0000 (18:35 +0100)
Problem:    Options for term_dumpdiff() and term_dumpload() not implemented
            yet.
Solution:   Implement the relevant options.

runtime/doc/eval.txt
src/terminal.c
src/version.c

index 0a26165194635ae31c2800a99f5fbd9ba25c2e6f..663f491df2b6fa13212dd1c6d0fd88ad99435549 100644 (file)
@@ -1,4 +1,4 @@
-*eval.txt*     For Vim version 8.0.  Last change: 2018 Mar 18
+*eval.txt*     For Vim version 8.0.  Last change: 2018 Mar 20
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -8190,7 +8190,20 @@ term_dumpdiff({filename}, {filename} [, {options}])
                the second file.  The middle part shows the differences.
                The parts are separated by a line of dashes.
 
-               {options} are not implemented yet.
+               If the {options} argument is present, it must be a Dict with
+               these possible members:
+                  "term_name"       name to use for the buffer name, instead
+                                    of the first file name.
+                  "term_rows"       vertical size to use for the terminal,
+                                    instead of using 'termsize'
+                  "term_cols"       horizontal size to use for the terminal,
+                                    instead of using 'termsize'
+                  "vertical"        split the window vertically
+                  "curwin"          use the current window, do not split the
+                                    window; fails if the current buffer
+                                    cannot be |abandon|ed
+                  "norestore"       do not add the terminal window to a
+                                    session file
 
                Each character in the middle part indicates a difference. If
                there are multiple differences only the first in this list is
@@ -8213,7 +8226,7 @@ term_dumpload({filename} [, {options}])
                Returns the buffer number or zero when it fails.
                Also see |terminal-diff|.
 
-               {options} are not implemented yet.
+               For {options} see |term_dumpdiff()|.
 
                                                        *term_dumpwrite()*
 term_dumpwrite({buf}, {filename} [, {options}])
@@ -9237,7 +9250,7 @@ visualextra               Compiled with extra Visual mode commands.
 vms                    VMS version of Vim.
 vreplace               Compiled with |gR| and |gr| commands.
 vtp                    Compiled for vcon support |+vtp| (check vcon to find
-                       out if it works in the current console)).
+                       out if it works in the current console).
 wildignore             Compiled with 'wildignore' option.
 wildmenu               Compiled with 'wildmenu' option.
 win32                  Win32 version of Vim (MS-Windows 95 and later, 32 or
index 4d747406e5b53f23979d8f150beab120057e296b..0d035ff969933b8bea41f57bad7ab89c9f2292ea 100644 (file)
@@ -342,6 +342,7 @@ term_start(
     buf_T      *old_curbuf = NULL;
     int                res;
     buf_T      *newbuf;
+    int                vertical = opt->jo_vertical || (cmdmod.split & WSP_VERT);
 
     if (check_restricted() || check_secure())
        return NULL;
@@ -411,17 +412,19 @@ term_start(
        split_ea.cmdidx = CMD_new;
        split_ea.cmd = (char_u *)"new";
        split_ea.arg = (char_u *)"";
-       if (opt->jo_term_rows > 0 && !(cmdmod.split & WSP_VERT))
+       if (opt->jo_term_rows > 0 && !vertical)
        {
            split_ea.line2 = opt->jo_term_rows;
            split_ea.addr_count = 1;
        }
-       if (opt->jo_term_cols > 0 && (cmdmod.split & WSP_VERT))
+       if (opt->jo_term_cols > 0 && vertical)
        {
            split_ea.line2 = opt->jo_term_cols;
            split_ea.addr_count = 1;
        }
 
+       if (vertical)
+           cmdmod.split |= WSP_VERT;
        ex_splitview(&split_ea);
        if (curwin == old_curwin)
        {
@@ -437,11 +440,9 @@ term_start(
     {
        /* Only one size was taken care of with :new, do the other one.  With
         * "curwin" both need to be done. */
-       if (opt->jo_term_rows > 0 && (opt->jo_curwin
-                                                || (cmdmod.split & WSP_VERT)))
+       if (opt->jo_term_rows > 0 && (opt->jo_curwin || vertical))
            win_setheight(opt->jo_term_rows);
-       if (opt->jo_term_cols > 0 && (opt->jo_curwin
-                                               || !(cmdmod.split & WSP_VERT)))
+       if (opt->jo_term_cols > 0 && (opt->jo_curwin || !vertical))
            win_setwidth(opt->jo_term_cols);
     }
 
@@ -3732,6 +3733,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
     char_u     buf2[NUMBUFLEN];
     char_u     *fname1;
     char_u     *fname2 = NULL;
+    char_u     *fname_tofree = NULL;
     FILE       *fd1;
     FILE       *fd2 = NULL;
     char_u     *textline = NULL;
@@ -3763,10 +3765,23 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
     }
 
     init_job_options(&opt);
-    /* TODO: use the {options} argument */
+    if (argvars[do_diff ? 2 : 1].v_type != VAR_UNKNOWN
+           && get_job_options(&argvars[do_diff ? 2 : 1], &opt, 0,
+                   JO2_TERM_NAME + JO2_TERM_COLS + JO2_TERM_ROWS
+                   + JO2_VERTICAL + JO2_CURWIN + JO2_NORESTORE) == FAIL)
+       goto theend;
 
-    /* TODO: use the file name arguments for the buffer name */
-    opt.jo_term_name = (char_u *)"dump diff";
+    if (opt.jo_term_name == NULL)
+    {
+       int len = STRLEN(fname1) + 12;
+
+       fname_tofree = alloc(len);
+       if (fname_tofree != NULL)
+       {
+           vim_snprintf((char *)fname_tofree, len, "dump diff %s", fname1);
+           opt.jo_term_name = fname_tofree;
+       }
+    }
 
     buf = term_start(&argvars[0], NULL, &opt, TERM_START_NOJOB);
     if (buf != NULL && buf->b_term != NULL)
@@ -3937,6 +3952,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
 
 theend:
     vim_free(textline);
+    vim_free(fname_tofree);
     fclose(fd1);
     if (fd2 != NULL)
        fclose(fd2);
@@ -4541,8 +4557,6 @@ f_term_start(typval_T *argvars, typval_T *rettv)
                    + JO2_NORESTORE + JO2_TERM_KILL) == FAIL)
        return;
 
-    if (opt.jo_vertical)
-       cmdmod.split = WSP_VERT;
     buf = term_start(&argvars[0], NULL, &opt, 0);
 
     if (buf != NULL && buf->b_term != NULL)
index e647c9bf432479672cff7bc7c1ab992c41143dab..bc0cff309e1dea703b8c23077e80e6e1db9184b2 100644 (file)
@@ -766,6 +766,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1624,
 /**/
     1623,
 /**/