Mercurial > vim
comparison src/terminal.c @ 13579:486ad9fd9038 v8.0.1662
patch 8.0.1662: showing dump diff doesn't mention both file names
commit https://github.com/vim/vim/commit/4a69634b1b55e06c4bf7f05b54125b1669b1c363
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 5 18:45:26 2018 +0200
patch 8.0.1662: showing dump diff doesn't mention both file names
Problem: Showing dump diff doesn't mention both file names.
Solution: Add the file name in the separator line.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 05 Apr 2018 19:00:08 +0200 |
parents | 4cb743db55b3 |
children | 200ef826e7dd |
comparison
equal
deleted
inserted
replaced
13578:0dcc9ad68a6f | 13579:486ad9fd9038 |
---|---|
39 * | 39 * |
40 * TODO: | 40 * TODO: |
41 * - Add a way to set the 16 ANSI colors, to be used for 'termguicolors' and in | 41 * - Add a way to set the 16 ANSI colors, to be used for 'termguicolors' and in |
42 * the GUI. | 42 * the GUI. |
43 * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for | 43 * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for |
44 * redirection. | 44 * redirection. Probably in call to channel_set_pipes(). |
45 * - implement term_setsize() | 45 * - implement term_setsize() |
46 * - Copy text in the vterm to the Vim buffer once in a while, so that | 46 * - Copy text in the vterm to the Vim buffer once in a while, so that |
47 * completion works. | 47 * completion works. |
48 * - Adding WinBar to terminal window doesn't display, text isn't shifted down. | 48 * - Adding WinBar to terminal window doesn't display, text isn't shifted down. |
49 * a job that uses 16 colors while Vim is using > 256. | 49 * a job that uses 16 colors while Vim is using > 256. |
3915 | 3915 |
3916 return max_cells; | 3916 return max_cells; |
3917 } | 3917 } |
3918 | 3918 |
3919 /* | 3919 /* |
3920 * Return an allocated string with at least "text_width" "=" characters and | |
3921 * "fname" inserted in the middle. | |
3922 */ | |
3923 static char_u * | |
3924 get_separator(int text_width, char_u *fname) | |
3925 { | |
3926 int width = MAX(text_width, curwin->w_width); | |
3927 char_u *textline; | |
3928 int fname_size; | |
3929 char_u *p = fname; | |
3930 int i; | |
3931 int off; | |
3932 | |
3933 textline = alloc(width + STRLEN(fname) + 1); | |
3934 if (textline == NULL) | |
3935 return NULL; | |
3936 | |
3937 fname_size = vim_strsize(fname); | |
3938 if (fname_size < width - 8) | |
3939 { | |
3940 /* enough room, don't use the full window width */ | |
3941 width = MAX(text_width, fname_size + 8); | |
3942 } | |
3943 else if (fname_size > width - 8) | |
3944 { | |
3945 /* full name doesn't fit, use only the tail */ | |
3946 p = gettail(fname); | |
3947 fname_size = vim_strsize(p); | |
3948 } | |
3949 /* skip characters until the name fits */ | |
3950 while (fname_size > width - 8) | |
3951 { | |
3952 p += (*mb_ptr2len)(p); | |
3953 fname_size = vim_strsize(p); | |
3954 } | |
3955 | |
3956 for (i = 0; i < (width - fname_size) / 2 - 1; ++i) | |
3957 textline[i] = '='; | |
3958 textline[i++] = ' '; | |
3959 | |
3960 STRCPY(textline + i, p); | |
3961 off = STRLEN(textline); | |
3962 textline[off] = ' '; | |
3963 for (i = 1; i < (width - fname_size) / 2; ++i) | |
3964 textline[off + i] = '='; | |
3965 textline[off + i] = NUL; | |
3966 | |
3967 return textline; | |
3968 } | |
3969 | |
3970 /* | |
3920 * Common for "term_dumpdiff()" and "term_dumpload()". | 3971 * Common for "term_dumpdiff()" and "term_dumpload()". |
3921 */ | 3972 */ |
3922 static void | 3973 static void |
3923 term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff) | 3974 term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff) |
3924 { | 3975 { |
4011 if (!do_diff) | 4062 if (!do_diff) |
4012 goto theend; | 4063 goto theend; |
4013 | 4064 |
4014 term->tl_top_diff_rows = curbuf->b_ml.ml_line_count; | 4065 term->tl_top_diff_rows = curbuf->b_ml.ml_line_count; |
4015 | 4066 |
4016 textline = alloc(width + 1); | 4067 textline = get_separator(width, fname1); |
4017 if (textline == NULL) | 4068 if (textline == NULL) |
4018 goto theend; | 4069 goto theend; |
4019 for (i = 0; i < width; ++i) | |
4020 textline[i] = '='; | |
4021 textline[width] = NUL; | |
4022 if (add_empty_scrollback(term, &term->tl_default_color, 0) == OK) | 4070 if (add_empty_scrollback(term, &term->tl_default_color, 0) == OK) |
4023 ml_append(curbuf->b_ml.ml_line_count, textline, 0, FALSE); | 4071 ml_append(curbuf->b_ml.ml_line_count, textline, 0, FALSE); |
4072 vim_free(textline); | |
4073 | |
4074 textline = get_separator(width, fname2); | |
4075 if (textline == NULL) | |
4076 goto theend; | |
4024 if (add_empty_scrollback(term, &term->tl_default_color, 0) == OK) | 4077 if (add_empty_scrollback(term, &term->tl_default_color, 0) == OK) |
4025 ml_append(curbuf->b_ml.ml_line_count, textline, 0, FALSE); | 4078 ml_append(curbuf->b_ml.ml_line_count, textline, 0, FALSE); |
4079 textline[width] = NUL; | |
4026 | 4080 |
4027 bot_lnum = curbuf->b_ml.ml_line_count; | 4081 bot_lnum = curbuf->b_ml.ml_line_count; |
4028 width2 = read_dump_file(fd2, &cursor_pos2); | 4082 width2 = read_dump_file(fd2, &cursor_pos2); |
4029 if (width2 > width) | 4083 if (width2 > width) |
4030 { | 4084 { |
4141 ++lnum; | 4195 ++lnum; |
4142 ++bot_lnum; | 4196 ++bot_lnum; |
4143 } | 4197 } |
4144 | 4198 |
4145 term->tl_cols = width; | 4199 term->tl_cols = width; |
4200 | |
4201 /* looks better without wrapping */ | |
4202 curwin->w_p_wrap = 0; | |
4146 } | 4203 } |
4147 | 4204 |
4148 theend: | 4205 theend: |
4149 vim_free(textline); | 4206 vim_free(textline); |
4150 vim_free(fname_tofree); | 4207 vim_free(fname_tofree); |