Mercurial > vim
comparison src/terminal.c @ 13501:a4a559e08798 v8.0.1624
patch 8.0.1624: options for term_dumpdiff() and term_dumpload() not implemented
commit https://github.com/vim/vim/commit/5a3a49ed592e8300553590392721a5e55fede6e7
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Mar 20 18:35:53 2018 +0100
patch 8.0.1624: options for term_dumpdiff() and term_dumpload() not implemented
Problem: Options for term_dumpdiff() and term_dumpload() not implemented
yet.
Solution: Implement the relevant options.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 20 Mar 2018 18:45:07 +0100 |
parents | f7ef5d579758 |
children | a784ef72b617 |
comparison
equal
deleted
inserted
replaced
13500:8579d5f3da4b | 13501:a4a559e08798 |
---|---|
340 win_T *old_curwin = curwin; | 340 win_T *old_curwin = curwin; |
341 term_T *term; | 341 term_T *term; |
342 buf_T *old_curbuf = NULL; | 342 buf_T *old_curbuf = NULL; |
343 int res; | 343 int res; |
344 buf_T *newbuf; | 344 buf_T *newbuf; |
345 int vertical = opt->jo_vertical || (cmdmod.split & WSP_VERT); | |
345 | 346 |
346 if (check_restricted() || check_secure()) | 347 if (check_restricted() || check_secure()) |
347 return NULL; | 348 return NULL; |
348 | 349 |
349 if ((opt->jo_set & (JO_IN_IO + JO_OUT_IO + JO_ERR_IO)) | 350 if ((opt->jo_set & (JO_IN_IO + JO_OUT_IO + JO_ERR_IO)) |
409 { | 410 { |
410 /* Open a new window or tab. */ | 411 /* Open a new window or tab. */ |
411 split_ea.cmdidx = CMD_new; | 412 split_ea.cmdidx = CMD_new; |
412 split_ea.cmd = (char_u *)"new"; | 413 split_ea.cmd = (char_u *)"new"; |
413 split_ea.arg = (char_u *)""; | 414 split_ea.arg = (char_u *)""; |
414 if (opt->jo_term_rows > 0 && !(cmdmod.split & WSP_VERT)) | 415 if (opt->jo_term_rows > 0 && !vertical) |
415 { | 416 { |
416 split_ea.line2 = opt->jo_term_rows; | 417 split_ea.line2 = opt->jo_term_rows; |
417 split_ea.addr_count = 1; | 418 split_ea.addr_count = 1; |
418 } | 419 } |
419 if (opt->jo_term_cols > 0 && (cmdmod.split & WSP_VERT)) | 420 if (opt->jo_term_cols > 0 && vertical) |
420 { | 421 { |
421 split_ea.line2 = opt->jo_term_cols; | 422 split_ea.line2 = opt->jo_term_cols; |
422 split_ea.addr_count = 1; | 423 split_ea.addr_count = 1; |
423 } | 424 } |
424 | 425 |
426 if (vertical) | |
427 cmdmod.split |= WSP_VERT; | |
425 ex_splitview(&split_ea); | 428 ex_splitview(&split_ea); |
426 if (curwin == old_curwin) | 429 if (curwin == old_curwin) |
427 { | 430 { |
428 /* split failed */ | 431 /* split failed */ |
429 vim_free(term); | 432 vim_free(term); |
435 | 438 |
436 if (!opt->jo_hidden) | 439 if (!opt->jo_hidden) |
437 { | 440 { |
438 /* Only one size was taken care of with :new, do the other one. With | 441 /* Only one size was taken care of with :new, do the other one. With |
439 * "curwin" both need to be done. */ | 442 * "curwin" both need to be done. */ |
440 if (opt->jo_term_rows > 0 && (opt->jo_curwin | 443 if (opt->jo_term_rows > 0 && (opt->jo_curwin || vertical)) |
441 || (cmdmod.split & WSP_VERT))) | |
442 win_setheight(opt->jo_term_rows); | 444 win_setheight(opt->jo_term_rows); |
443 if (opt->jo_term_cols > 0 && (opt->jo_curwin | 445 if (opt->jo_term_cols > 0 && (opt->jo_curwin || !vertical)) |
444 || !(cmdmod.split & WSP_VERT))) | |
445 win_setwidth(opt->jo_term_cols); | 446 win_setwidth(opt->jo_term_cols); |
446 } | 447 } |
447 | 448 |
448 /* Link the new terminal in the list of active terminals. */ | 449 /* Link the new terminal in the list of active terminals. */ |
449 term->tl_next = first_term; | 450 term->tl_next = first_term; |
3730 buf_T *buf; | 3731 buf_T *buf; |
3731 char_u buf1[NUMBUFLEN]; | 3732 char_u buf1[NUMBUFLEN]; |
3732 char_u buf2[NUMBUFLEN]; | 3733 char_u buf2[NUMBUFLEN]; |
3733 char_u *fname1; | 3734 char_u *fname1; |
3734 char_u *fname2 = NULL; | 3735 char_u *fname2 = NULL; |
3736 char_u *fname_tofree = NULL; | |
3735 FILE *fd1; | 3737 FILE *fd1; |
3736 FILE *fd2 = NULL; | 3738 FILE *fd2 = NULL; |
3737 char_u *textline = NULL; | 3739 char_u *textline = NULL; |
3738 | 3740 |
3739 /* First open the files. If this fails bail out. */ | 3741 /* First open the files. If this fails bail out. */ |
3761 return; | 3763 return; |
3762 } | 3764 } |
3763 } | 3765 } |
3764 | 3766 |
3765 init_job_options(&opt); | 3767 init_job_options(&opt); |
3766 /* TODO: use the {options} argument */ | 3768 if (argvars[do_diff ? 2 : 1].v_type != VAR_UNKNOWN |
3767 | 3769 && get_job_options(&argvars[do_diff ? 2 : 1], &opt, 0, |
3768 /* TODO: use the file name arguments for the buffer name */ | 3770 JO2_TERM_NAME + JO2_TERM_COLS + JO2_TERM_ROWS |
3769 opt.jo_term_name = (char_u *)"dump diff"; | 3771 + JO2_VERTICAL + JO2_CURWIN + JO2_NORESTORE) == FAIL) |
3772 goto theend; | |
3773 | |
3774 if (opt.jo_term_name == NULL) | |
3775 { | |
3776 int len = STRLEN(fname1) + 12; | |
3777 | |
3778 fname_tofree = alloc(len); | |
3779 if (fname_tofree != NULL) | |
3780 { | |
3781 vim_snprintf((char *)fname_tofree, len, "dump diff %s", fname1); | |
3782 opt.jo_term_name = fname_tofree; | |
3783 } | |
3784 } | |
3770 | 3785 |
3771 buf = term_start(&argvars[0], NULL, &opt, TERM_START_NOJOB); | 3786 buf = term_start(&argvars[0], NULL, &opt, TERM_START_NOJOB); |
3772 if (buf != NULL && buf->b_term != NULL) | 3787 if (buf != NULL && buf->b_term != NULL) |
3773 { | 3788 { |
3774 int i; | 3789 int i; |
3935 term->tl_cols = width; | 3950 term->tl_cols = width; |
3936 } | 3951 } |
3937 | 3952 |
3938 theend: | 3953 theend: |
3939 vim_free(textline); | 3954 vim_free(textline); |
3955 vim_free(fname_tofree); | |
3940 fclose(fd1); | 3956 fclose(fd1); |
3941 if (fd2 != NULL) | 3957 if (fd2 != NULL) |
3942 fclose(fd2); | 3958 fclose(fd2); |
3943 } | 3959 } |
3944 | 3960 |
4539 + JO2_TERM_COLS + JO2_TERM_ROWS + JO2_VERTICAL + JO2_CURWIN | 4555 + JO2_TERM_COLS + JO2_TERM_ROWS + JO2_VERTICAL + JO2_CURWIN |
4540 + JO2_CWD + JO2_ENV + JO2_EOF_CHARS | 4556 + JO2_CWD + JO2_ENV + JO2_EOF_CHARS |
4541 + JO2_NORESTORE + JO2_TERM_KILL) == FAIL) | 4557 + JO2_NORESTORE + JO2_TERM_KILL) == FAIL) |
4542 return; | 4558 return; |
4543 | 4559 |
4544 if (opt.jo_vertical) | |
4545 cmdmod.split = WSP_VERT; | |
4546 buf = term_start(&argvars[0], NULL, &opt, 0); | 4560 buf = term_start(&argvars[0], NULL, &opt, 0); |
4547 | 4561 |
4548 if (buf != NULL && buf->b_term != NULL) | 4562 if (buf != NULL && buf->b_term != NULL) |
4549 rettv->vval.v_number = buf->b_fnum; | 4563 rettv->vval.v_number = buf->b_fnum; |
4550 } | 4564 } |