Data Structures | Macros | Functions | Variables
screen.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
#include "nvim/log.h"
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/arabic.h"
#include "nvim/screen.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/cursor_shape.h"
#include "nvim/diff.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_getln.h"
#include "nvim/edit.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/indent.h"
#include "nvim/getchar.h"
#include "nvim/highlight.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/extmark.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/garray.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/popupmnu.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.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/window.h"
#include "nvim/os/time.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
#include "nvim/lua/executor.h"

Data Structures

struct  LineState


#define LINE_STATE(p)   { p, 0, 0 }
#define DID_NONE   1
#define DID_LINE   2
#define DID_FOLD   3
#define RL_MEMSET(p, v, l)
#define SPWORDLEN   150
#define WL_START   0 /* nothing done yet */
#define WL_CMDLINE   WL_START + 1 /* cmdline window column */
#define WL_FOLD   WL_CMDLINE + 1 /* 'foldcolumn' */
#define WL_SIGN   WL_FOLD + 1 /* column for signs */
#define WL_NR   WL_SIGN + 1 /* line number */
#define WL_BRI   WL_NR + 1 /* 'breakindent' */
#define WL_SBR   WL_BRI + 1 /* 'showbreak' or 'diff' */
#define WL_LINE   WL_SBR + 1 /* text in the line */
#define VCOL_HLC   (vcol - vcol_off)
#define L_MATCH(m)   (showtail ? sm_gettail(matches[m], false) : matches[m])
#define RULER_BUF_LEN   70


void redraw_later (int type)
void redraw_win_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
void decorations_add_luahl_attr (int attr_id, int start_row, int start_col, int end_row, int end_col)
int win_signcol_width (win_T *wp)
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)
int stl_connected (win_T *wp)
int 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_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 (int 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 redrawing (void)
int messaging (void)
void showruler (int 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)


StlClickDefinitiontab_page_click_defs = NULL
 Array defining what should be done when tabline is clicked. More...
long tab_page_click_defs_size = 0
 Size of the tab_page_click_defs array. More...
bool decorations_active = false

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 RL_MEMSET (   p,
do { \
if (wp->w_p_rl) { \
for (int ri = 0; ri < l; ri++) { \
linebuf_attr[off + (wp->w_grid.Columns - (p) - (l)) + ri] = v; \
} \
} else { \
for (int ri = 0; ri < l; ri++) { \
linebuf_attr[off + (p) + ri] = v; \
} \
} \
} while (0)
Definition: encode.c:222
int off
Definition: regexp_nfa.c:3943
for(size_t i=1;i< ARRAY_SIZE(argv);i++)
Definition: typval.c:1217
Definition: eval.c:2141
char_u * p
Definition: eval.c:2101
list_T *const l
Definition: funcs.c:7975
#define RULER_BUF_LEN   70
#define SPWORDLEN   150
#define VCOL_HLC   (vcol - vcol_off)
#define WL_BRI   WL_NR + 1 /* 'breakindent' */
#define WL_CMDLINE   WL_START + 1 /* cmdline window column */
#define WL_FOLD   WL_CMDLINE + 1 /* 'foldcolumn' */
#define WL_LINE   WL_SBR + 1 /* text in the line */
#define WL_NR   WL_SIGN + 1 /* line number */
#define WL_SBR   WL_BRI + 1 /* 'showbreak' or 'diff' */
#define WL_SIGN   WL_FOLD + 1 /* column for signs */
#define WL_START   0 /* nothing done yet */

Function Documentation

void check_for_delay ( int  check_msg_scroll)
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.

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.
void clearmode ( void  )
void conceal_check_cursor_line ( void  )
bool conceal_cursor_line ( const win_T wp)
void decorations_add_luahl_attr ( int  attr_id,
int  start_row,
int  start_col,
int  end_row,
int  end_col 
void draw_tabline ( void  )
int get_keymap_str ( win_T wp,
char_u fmt,
char_u buf,
int  len 
void get_trans_bufname ( buf_T buf)
win_T* get_win_by_grid_handle ( handle_T  handle)
void grid_alloc ( ScreenGrid grid,
int  rows,
int  columns,
bool  copy,
bool  valid 
void grid_assign_handle ( ScreenGrid grid)

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

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.

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.

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'.

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.

void grid_free ( ScreenGrid grid)
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;

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.

bool grid_invalid_row ( ScreenGrid grid,
int  row 
void grid_invalidate ( ScreenGrid grid)
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!

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

output a single character directly to the grid

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.

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.

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.
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.

void limit_screen_size ( void  )
int messaging ( void  )
int number_width ( win_T wp)
void redraw_all_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 redraw_curbuf_later ( int  type)
void redraw_later ( int  type)
void redraw_statuslines ( void  )
void redraw_win_later ( win_T wp,
int  type 
int redrawing ( void  )
void redrawWinline ( win_T wp,
linenr_T  lnum 
void rl_mirror ( char_u str)
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.

void screen_free_all_mem ( void  )

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

void screen_invalidate_highlights ( void  )
void screen_resize ( int  width,
int  height 

Set dimensions of the Nvim application "shell".

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.

void screenclear ( void  )
void setcursor ( void  )
int showmode ( void  )
void showruler ( int  always)
void status_redraw_all ( void  )
void status_redraw_buf ( buf_T buf)

Marks all status lines of the specified buffer for redraw.

void status_redraw_curbuf ( void  )

Marks all status lines of the current buffer for redraw.

int stl_connected ( win_T wp)
void ui_ext_tabline_update ( void  )
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".

void update_curbuf ( int  type)
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
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.

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.

void win_new_shellsize ( void  )
void win_redr_status_matches ( expand_T xp,
int  num_matches,
char_u **  matches,
int  match,
int  showtail 
void win_redraw_last_status ( const frame_T frp)
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.

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

bool decorations_active = false
StlClickDefinition* tab_page_click_defs = NULL

Array defining what should be done when tabline is clicked.

long tab_page_click_defs_size = 0

Size of the tab_page_click_defs array.