diff options
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 77 |
1 files changed, 56 insertions, 21 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index a3b1efeaaa..6ce095f976 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -375,7 +375,7 @@ newwindow: /* set current window height */ case Ctrl__: case '_': - win_setheight(Prenum ? (int)Prenum : 9999); + win_setheight(Prenum ? (int)Prenum : Rows-1); break; /* increase current window width */ @@ -390,7 +390,7 @@ newwindow: /* set current window width */ case '|': - win_setwidth(Prenum != 0 ? (int)Prenum : 9999); + win_setwidth(Prenum != 0 ? (int)Prenum : Columns); break; /* jump to tag and split window if tag exists (in preview window) */ @@ -584,15 +584,43 @@ win_T *win_new_float(win_T *wp, FloatConfig fconfig, Error *err) wp->w_status_height = 0; wp->w_vsep_width = 0; - // TODO(bfredl): use set_option_to() after merging #9110 ? - wp->w_p_nu = false; - wp->w_allbuf_opt.wo_nu = false; win_config_float(wp, fconfig); wp->w_pos_changed = true; redraw_win_later(wp, VALID); return wp; } +void win_set_minimal_style(win_T *wp) +{ + wp->w_p_nu = false; + wp->w_p_rnu = false; + wp->w_p_cul = false; + wp->w_p_cuc = false; + wp->w_p_spell = false; + wp->w_p_list = false; + + // Hide EOB region: use " " fillchar and cleared highlighting + if (wp->w_p_fcs_chars.eob != ' ') { + char_u *old = wp->w_p_fcs; + wp->w_p_fcs = ((*old == NUL) + ? (char_u *)xstrdup("eob: ") + : concat_str(old, (char_u *)",eob: ")); + xfree(old); + } + if (wp->w_hl_ids[HLF_EOB] != -1) { + char_u *old = wp->w_p_winhl; + wp->w_p_winhl = ((*old == NUL) + ? (char_u *)xstrdup("EndOfBuffer:") + : concat_str(old, (char_u *)",EndOfBuffer:")); + xfree(old); + } + + if (wp->w_p_scl[0] != 'a') { + xfree(wp->w_p_scl); + wp->w_p_scl = (char_u *)xstrdup("auto"); + } +} + void win_config_float(win_T *wp, FloatConfig fconfig) { wp->w_width = MAX(fconfig.width, 1); @@ -666,6 +694,7 @@ static void ui_ext_win_position(win_T *wp) bool on_top = (curwin == wp) || !curwin->w_floating; ui_comp_put_grid(&wp->w_grid, comp_row, comp_col, wp->w_height, wp->w_width, valid, on_top); + ui_check_cursor_grid(wp->w_grid.handle); if (!valid) { wp->w_grid.valid = false; redraw_win_later(wp, NOT_VALID); @@ -821,6 +850,20 @@ bool parse_float_config(Dictionary config, FloatConfig *fconfig, bool reconf, "'focusable' key must be Boolean"); return false; } + } else if (!strcmp(key, "style")) { + if (val.type != kObjectTypeString) { + api_set_error(err, kErrorTypeValidation, + "'style' key must be String"); + return false; + } + if (val.data.string.data[0] == NUL) { + fconfig->style = kWinStyleUnused; + } else if (striequal(val.data.string.data, "minimal")) { + fconfig->style = kWinStyleMinimal; + } else { + api_set_error(err, kErrorTypeValidation, + "Invalid value of 'style' key"); + } } else { api_set_error(err, kErrorTypeValidation, "Invalid key '%s'", key); @@ -4823,13 +4866,9 @@ void win_setheight_win(int height, win_T *win) } if (win->w_floating) { - if (win->w_float_config.external) { - win->w_float_config.height = height; - win_config_float(win, win->w_float_config); - } else { - beep_flush(); - return; - } + win->w_float_config.height = height; + win_config_float(win, win->w_float_config); + redraw_win_later(win, NOT_VALID); } else { frame_setheight(win->w_frame, height + win->w_status_height); @@ -4844,9 +4883,9 @@ void win_setheight_win(int height, win_T *win) cmdline_row = row; msg_row = row; msg_col = 0; + redraw_all_later(NOT_VALID); } - redraw_all_later(NOT_VALID); } @@ -5029,21 +5068,17 @@ void win_setwidth_win(int width, win_T *wp) width = 1; } if (wp->w_floating) { - if (wp->w_float_config.external) { - wp->w_float_config.width = width; - win_config_float(wp, wp->w_float_config); - } else { - beep_flush(); - return; - } + wp->w_float_config.width = width; + win_config_float(wp, wp->w_float_config); + redraw_win_later(wp, NOT_VALID); } else { frame_setwidth(wp->w_frame, width + wp->w_vsep_width); // recompute the window positions (void)win_comp_pos(); + redraw_all_later(NOT_VALID); } - redraw_all_later(NOT_VALID); } /* |