Macros | Functions | Variables
screen.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
#include "nvim/api/extmark.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
#include "nvim/arabic.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/cursor_shape.h"
#include "nvim/decoration.h"
#include "nvim/diff.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_getln.h"
#include "nvim/extmark.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/highlight.h"
#include "nvim/indent.h"
#include "nvim/lib/kvec.h"
#include "nvim/log.h"
#include "nvim/lua/executor.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/menu.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
#include "nvim/os/time.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/plines.h"
#include "nvim/popupmnu.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/sign.h"
#include "nvim/spell.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/terminal.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/vim.h"
#include "nvim/window.h"


#define LINE_STATE(p)   { p, 0, 0 }
#define DID_NONE   1
#define DID_LINE   2
#define DID_FOLD   3
#define SPWORDLEN   150
#define WL_START   0
#define WL_CMDLINE   WL_START + 1
#define WL_FOLD   WL_CMDLINE + 1
#define WL_SIGN   WL_FOLD + 1
#define WL_NR   WL_SIGN + 1
#define WL_BRI   WL_NR + 1
#define WL_SBR   WL_BRI + 1
#define WL_LINE   WL_SBR + 1
#define VCOL_HLC   (vcol - vcol_off)
#define L_MATCH(m)   (showtail ? sm_gettail(matches[m], false) : matches[m])
#define RULER_BUF_LEN   70


typedef kvec_withinit_t (DecorProvider *, 4)
void redraw_later (win_T *wp, int type) FUNC_ATTR_NONNULL_ALL
void redraw_all_later (int type)
void screen_invalidate_highlights (void)
void redraw_curbuf_later (int type)
void redraw_buf_later (buf_T *buf, int type)
void redraw_buf_line_later (buf_T *buf, linenr_T line)
void redraw_buf_range_later (buf_T *buf, linenr_T firstline, linenr_T lastline)
void redrawWinline (win_T *wp, linenr_T lnum) FUNC_ATTR_NONNULL_ALL
void update_curbuf (int type)
int update_screen (int type)
bool conceal_cursor_line (const win_T *wp) FUNC_ATTR_NONNULL_ALL
void conceal_check_cursor_line (void)
bool win_cursorline_standout (const win_T *wp) FUNC_ATTR_NONNULL_ALL
int win_signcol_width (win_T *wp)
void draw_virt_text (buf_T *buf, int col_off, int *end_col, int max_col)
void screen_adjust_grid (ScreenGrid **grid, int *row_off, int *col_off)
void rl_mirror (char_u *str)
void status_redraw_all (void)
void status_redraw_curbuf (void)
 Marks all status lines of the current buffer for redraw. More...
void status_redraw_buf (buf_T *buf)
 Marks all status lines of the specified buffer for redraw. More...
void redraw_statuslines (void)
void win_redraw_last_status (const frame_T *frp) FUNC_ATTR_NONNULL_ARG(1)
void win_redr_status_matches (expand_T *xp, int num_matches, char_u **matches, int match, int showtail)
bool stl_connected (win_T *wp)
bool get_keymap_str (win_T *wp, char_u *fmt, char_u *buf, int len)
bool grid_lefthalve (ScreenGrid *grid, int row, int col)
int grid_fix_col (ScreenGrid *grid, int col, int row)
void grid_putchar (ScreenGrid *grid, int c, int row, int col, int attr)
 output a single character directly to the grid More...
void grid_getbytes (ScreenGrid *grid, int row, int col, char_u *bytes, int *attrp)
void grid_puts (ScreenGrid *grid, char_u *text, int row, int col, int attr)
void grid_puts_line_start (ScreenGrid *grid, int row)
void grid_put_schar (ScreenGrid *grid, int row, int col, char_u *schar, int attr)
void grid_puts_len (ScreenGrid *grid, char_u *text, int textlen, int row, int col, int attr)
void grid_puts_line_flush (bool set_cursor)
void grid_fill (ScreenGrid *grid, int start_row, int end_row, int start_col, int end_col, int c1, int c2, int attr)
void check_for_delay (bool check_msg_scroll)
void win_grid_alloc (win_T *wp)
void grid_assign_handle (ScreenGrid *grid)
 assign a handle to the grid. The grid need not be allocated. More...
void screenalloc (void)
void grid_alloc (ScreenGrid *grid, int rows, int columns, bool copy, bool valid)
void grid_free (ScreenGrid *grid)
void screen_free_all_mem (void)
 Doesn't allow reinit, so must only be called by free_all_mem! More...
void clear_tab_page_click_defs (StlClickDefinition *const tpcd, const long tpcd_size)
void screenclear (void)
void grid_clear_line (ScreenGrid *grid, unsigned off, int width, bool valid)
void grid_invalidate (ScreenGrid *grid)
bool grid_invalid_row (ScreenGrid *grid, int row)
void setcursor (void)
void win_scroll_lines (win_T *wp, int row, int line_count)
void grid_ins_lines (ScreenGrid *grid, int row, int line_count, int end, int col, int width)
 'row', 'col' and 'end' are relative to the start of the region. More...
void grid_del_lines (ScreenGrid *grid, int row, int line_count, int end, int col, int width)
int showmode (void)
void unshowmode (bool force)
void clearmode (void)
void draw_tabline (void)
void ui_ext_tabline_update (void)
void get_trans_bufname (buf_T *buf)
int fillchar_status (int *attr, win_T *wp)
int redrawing (void)
int messaging (void)
void showruler (bool always)
int number_width (win_T *wp)
void screen_resize (int width, int height)
 Set dimensions of the Nvim application "shell". More...
void check_shellsize (void)
void limit_screen_size (void)
void win_new_shellsize (void)
win_Tget_win_by_grid_handle (handle_T handle)



Macro Definition Documentation


#define DID_FOLD   3


#define DID_LINE   2


#define DID_NONE   1


{ \
n_extra += vcol_off; \
vcol -= vcol_off; \
vcol_off = 0; \
col -= boguscols; \
old_boguscols = boguscols; \
boguscols = 0; \


#define L_MATCH (   m)    (showtail ? sm_gettail(matches[m], false) : matches[m])


#define LINE_STATE (   p)    { p, 0, 0 }


'<' /* character used when a double-width character
* doesn't fit. */


#define RULER_BUF_LEN   70




#define SPWORDLEN   150


#define VCOL_HLC   (vcol - vcol_off)


#define WL_BRI   WL_NR + 1


#define WL_CMDLINE   WL_START + 1


#define WL_FOLD   WL_CMDLINE + 1


#define WL_LINE   WL_SBR + 1


#define WL_NR   WL_SIGN + 1


#define WL_SBR   WL_BRI + 1


#define WL_SIGN   WL_FOLD + 1


#define WL_START   0

Function Documentation

◆ check_for_delay()

void check_for_delay ( bool  check_msg_scroll)

Check if there should be a delay. Used before clearing or redrawing the screen or the command line.

◆ check_shellsize()

void check_shellsize ( void  )

Check if the new Nvim application "shell" dimensions are valid. Correct it if it's too small or way too big.

◆ clear_tab_page_click_defs()

void clear_tab_page_click_defs ( StlClickDefinition *const  tpcd,
const long  tpcd_size 

Clear tab_page_click_defs table

[out]tpcdTable to clear.
[in]tpcd_sizeSize of the table.

◆ clearmode()

void clearmode ( void  )

◆ conceal_check_cursor_line()

void conceal_check_cursor_line ( void  )

◆ conceal_cursor_line()

bool conceal_cursor_line ( const win_T wp)

◆ draw_tabline()

void draw_tabline ( void  )

◆ draw_virt_text()

void draw_virt_text ( buf_T buf,
int  col_off,
int *  end_col,
int  max_col 

◆ fillchar_status()

int fillchar_status ( int *  attr,
win_T wp 

◆ get_keymap_str()

bool get_keymap_str ( win_T wp,
char_u fmt,
char_u buf,
int  len 

Get the value to show for the language mappings, active 'keymap'.

fmtformat string containing one s item
bufbuffer for the result
lenlength of buffer

◆ get_trans_bufname()

void get_trans_bufname ( buf_T buf)

◆ get_win_by_grid_handle()

win_T* get_win_by_grid_handle ( handle_T  handle)

◆ grid_alloc()

void grid_alloc ( ScreenGrid grid,
int  rows,
int  columns,
bool  copy,
bool  valid 

◆ grid_assign_handle()

void grid_assign_handle ( ScreenGrid grid)

assign a handle to the grid. The grid need not be allocated.

◆ grid_clear_line()

void grid_clear_line ( ScreenGrid grid,
unsigned  off,
int  width,
bool  valid 

clear a line in the grid starting at "off" until "width" characters are cleared.

◆ grid_del_lines()

void grid_del_lines ( ScreenGrid grid,
int  row,
int  line_count,
int  end,
int  col,
int  width 

delete lines on the screen and move lines up. 'end' is the line after the scrolled part. Normally it is Rows. When scrolling region used 'off' is the offset from the top for the region. 'row' and 'end' are relative to the start of the region.

◆ grid_fill()

void grid_fill ( ScreenGrid grid,
int  start_row,
int  end_row,
int  start_col,
int  end_col,
int  c1,
int  c2,
int  attr 

Fill the grid from 'start_row' to 'end_row', from 'start_col' to 'end_col' with character 'c1' in first column followed by 'c2' in the other columns. Use attributes 'attr'.

◆ grid_fix_col()

int grid_fix_col ( ScreenGrid grid,
int  col,
int  row 

Correct a position on the screen, if it's the right half of a double-wide char move it to the left half. Returns the corrected column.

◆ grid_free()

void grid_free ( ScreenGrid grid)

◆ grid_getbytes()

void grid_getbytes ( ScreenGrid grid,
int  row,
int  col,
char_u bytes,
int *  attrp 

get a single character directly from grid.chars into "bytes[]". Also return its attribute in *attrp;

◆ grid_ins_lines()

void grid_ins_lines ( ScreenGrid grid,
int  row,
int  line_count,
int  end,
int  col,
int  width 

'row', 'col' and 'end' are relative to the start of the region.

insert lines on the screen and move the existing lines down 'line_count' is the number of lines to be inserted. 'end' is the line after the scrolled part. Normally it is Rows. 'col' is the column from with we start inserting.

◆ grid_invalid_row()

bool grid_invalid_row ( ScreenGrid grid,
int  row 

◆ grid_invalidate()

void grid_invalidate ( ScreenGrid grid)

◆ grid_lefthalve()

bool grid_lefthalve ( ScreenGrid grid,
int  row,
int  col 

Return true if the character at "row"/"col" on the screen is the left side of a double-width character.

Caller must make sure "row" and "col" are not invalid!

◆ grid_put_schar()

void grid_put_schar ( ScreenGrid grid,
int  row,
int  col,
char_u schar,
int  attr 

◆ grid_putchar()

void grid_putchar ( ScreenGrid grid,
int  c,
int  row,
int  col,
int  attr 

output a single character directly to the grid

◆ grid_puts()

void grid_puts ( ScreenGrid grid,
char_u text,
int  row,
int  col,
int  attr 

put string '*text' on the window grid at position 'row' and 'col', with attributes 'attr', and update chars[] and attrs[]. Note: only outputs within one row, message is truncated at grid boundary! Note: if grid, row and/or col is invalid, nothing is done.

◆ grid_puts_len()

void grid_puts_len ( ScreenGrid grid,
char_u text,
int  textlen,
int  row,
int  col,
int  attr 

like grid_puts(), but output "text[len]". When "len" is -1 output up to a NUL.

◆ grid_puts_line_flush()

void grid_puts_line_flush ( bool  set_cursor)

End a group of grid_puts_len calls and send the screen buffer to the UI layer.

set_cursorMove the visible cursor to the end of the changed region. This is a workaround for not yet refactored code paths and shouldn't be used in new code.

◆ grid_puts_line_start()

void grid_puts_line_start ( ScreenGrid grid,
int  row 

Start a group of grid_puts_len calls that builds a single grid line.

Must be matched with a grid_puts_line_flush call before moving to another line.

◆ kvec_withinit_t()

typedef kvec_withinit_t ( DecorProvider ,

◆ limit_screen_size()

void limit_screen_size ( void  )

◆ messaging()

int messaging ( void  )

◆ number_width()

int number_width ( win_T wp)

◆ redraw_all_later()

void redraw_all_later ( int  type)

◆ redraw_buf_later()

void redraw_buf_later ( buf_T buf,
int  type 

◆ redraw_buf_line_later()

void redraw_buf_line_later ( buf_T buf,
linenr_T  line 

◆ redraw_buf_range_later()

void redraw_buf_range_later ( buf_T buf,
linenr_T  firstline,
linenr_T  lastline 

◆ redraw_curbuf_later()

void redraw_curbuf_later ( int  type)

◆ redraw_later()

void redraw_later ( win_T wp,
int  type 

Redraw a window later, with update_screen(type).

Set must_redraw only if not already set to a higher value. e.g. if must_redraw is CLEAR, type NOT_VALID will do nothing.

◆ redraw_statuslines()

void redraw_statuslines ( void  )

◆ redrawing()

int redrawing ( void  )

◆ redrawWinline()

void redrawWinline ( win_T wp,
linenr_T  lnum 

◆ rl_mirror()

void rl_mirror ( char_u str)

◆ screen_adjust_grid()

void screen_adjust_grid ( ScreenGrid **  grid,
int *  row_off,
int *  col_off 

Determine if dedicated window grid should be used or the default_grid

If UI did not request multigrid support, draw all windows on the default_grid.

NB: this function can only been used with window grids in a context where win_grid_alloc already has been called!

If the default_grid is used, adjust window relative positions to global screen positions.

◆ screen_free_all_mem()

void screen_free_all_mem ( void  )

Doesn't allow reinit, so must only be called by free_all_mem!

◆ screen_invalidate_highlights()

void screen_invalidate_highlights ( void  )

◆ screen_resize()

void screen_resize ( int  width,
int  height 

Set dimensions of the Nvim application "shell".

◆ screenalloc()

void screenalloc ( void  )

Resize the screen to Rows and Columns.

Allocate default_grid.chars[] and other grid arrays.

There may be some time between setting Rows and Columns and (re)allocating default_grid arrays. This happens when starting up and when (manually) changing the shell size. Always use default_grid.Rows and default_grid.Columns to access items in default_grid.chars[]. Use Rows and Columns for positioning text etc. where the final size of the shell is needed.

◆ screenclear()

void screenclear ( void  )

◆ setcursor()

void setcursor ( void  )

◆ showmode()

int showmode ( void  )

◆ showruler()

void showruler ( bool  always)

Show current status info in ruler and various other places

alwaysif false, only show ruler if position has changed.

◆ status_redraw_all()

void status_redraw_all ( void  )

◆ status_redraw_buf()

void status_redraw_buf ( buf_T buf)

Marks all status lines of the specified buffer for redraw.

◆ status_redraw_curbuf()

void status_redraw_curbuf ( void  )

Marks all status lines of the current buffer for redraw.

◆ stl_connected()

bool stl_connected ( win_T wp)

Only call if (wp->w_vsep_width != 0).

true if the status line of window "wp" is connected to the status line of the window right of it. If not, then it's a vertical separator.

◆ ui_ext_tabline_update()

void ui_ext_tabline_update ( void  )

◆ unshowmode()

void unshowmode ( bool  force)

Delete mode message. Used when ESC is typed which is expected to end Insert mode (but Insert mode didn't end yet!). Caller should check "mode_displayed".

◆ update_curbuf()

void update_curbuf ( int  type)

◆ update_screen()

int update_screen ( int  type)

Redraw the parts of the screen that is marked for redraw.

Most code shouldn't call this directly, rather use redraw_later() and and redraw_all_later() to mark parts of the screen as needing a redraw.

typeset to a NOT_VALID to force redraw of entire screen

◆ win_cursorline_standout()

bool win_cursorline_standout ( const win_T wp)

Whether cursorline is drawn in a special way

If true, both old and new cursorline will need to be redrawn when moving cursor within windows. TODO(bfredl): VIsual_active shouldn't be needed, but is used to fix a glitch caused by scrolling.

◆ win_grid_alloc()

void win_grid_alloc ( win_T wp)

(Re)allocates a window grid if size changed while in ext_multigrid mode. Updates size, offsets and handle for the grid regardless.

If "doclear" is true, don't try to copy from the old grid rather clear the resized grid.

◆ win_new_shellsize()

void win_new_shellsize ( void  )

◆ win_redr_status_matches()

void win_redr_status_matches ( expand_T xp,
int  num_matches,
char_u **  matches,
int  match,
int  showtail 

Show wildchar matches in the status line. Show at least the "match" item. We start at item 'first_match' in the list and show all matches that fit.

If inversion is possible we use it. Else '=' characters are used.

matcheslist of matches

◆ win_redraw_last_status()

void win_redraw_last_status ( const frame_T frp)

◆ win_scroll_lines()

void win_scroll_lines ( win_T wp,
int  row,
int  line_count 

Scroll 'line_count' lines at 'row' in window 'wp'.

Positive ‘line_count’ means scrolling down, so that more space is available at 'row'. Negative line_count implies deleting lines at row.

◆ win_signcol_width()

int win_signcol_width ( win_T wp)

Returns width of the signcolumn that should be used for the whole window

wpwindow we want signcolumn width from
max width of signcolumn (cell unit)
Returns a constant for now but hopefully we can improve neovim so that the returned value width adapts to the maximum number of marks to draw for the window TODO(teto)

Variable Documentation

◆ LineState