|
41 | 41 | * - Add a way to set the 16 ANSI colors, to be used for 'termguicolors' and in |
42 | 42 | * the GUI. |
43 | 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 | 45 | * - implement term_setsize() |
46 | 46 | * - Copy text in the vterm to the Vim buffer once in a while, so that |
47 | 47 | * completion works. |
@@ -3916,6 +3916,57 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos) |
3916 | 3916 | return max_cells; |
3917 | 3917 | } |
3918 | 3918 |
|
| 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 | + |
3919 | 3970 | /* |
3920 | 3971 | * Common for "term_dumpdiff()" and "term_dumpload()". |
3921 | 3972 | */ |
@@ -4013,16 +4064,19 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff) |
4013 | 4064 |
|
4014 | 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 | 4068 | if (textline == NULL) |
4018 | 4069 | goto theend; |
4019 | | - for (i = 0; i < width; ++i) |
4020 | | - textline[i] = '='; |
4021 | | - textline[width] = NUL; |
4022 | 4070 | if (add_empty_scrollback(term, &term->tl_default_color, 0) == OK) |
4023 | 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 | 4077 | if (add_empty_scrollback(term, &term->tl_default_color, 0) == OK) |
4025 | 4078 | ml_append(curbuf->b_ml.ml_line_count, textline, 0, FALSE); |
| 4079 | + textline[width] = NUL; |
4026 | 4080 |
|
4027 | 4081 | bot_lnum = curbuf->b_ml.ml_line_count; |
4028 | 4082 | width2 = read_dump_file(fd2, &cursor_pos2); |
@@ -4143,6 +4197,9 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff) |
4143 | 4197 | } |
4144 | 4198 |
|
4145 | 4199 | term->tl_cols = width; |
| 4200 | + |
| 4201 | + /* looks better without wrapping */ |
| 4202 | + curwin->w_p_wrap = 0; |
4146 | 4203 | } |
4147 | 4204 |
|
4148 | 4205 | theend: |
|
0 commit comments