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/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/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"

Data Structures

struct  LineState
 

Macros

#define MB_FILLER_CHAR
 
#define W_ENDCOL(wp)   (wp->w_wincol + wp->w_width)
 
#define W_ENDROW(wp)   (wp->w_winrow + wp->w_height)
 
#define LINE_STATE(p)   { p, 0, 0 }
 
#define SEARCH_HL_PRIORITY   0
 
#define DID_NONE   1
 
#define DID_LINE   2
 
#define DID_FOLD   3
 
#define FDC_OFF   n
 
#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 FIX_FOR_BOGUSCOLS
 
#define L_MATCH(m)   (showtail ? sm_gettail(matches[m]) : matches[m])
 
#define RULER_BUF_LEN   70
 

Functions

void redraw_later (int type)
 
void redraw_win_later (win_T *wp, int type)
 
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 redrawWinline (win_T *wp, linenr_T lnum)
 
void update_curbuf (int type)
 
void update_screen (int type)
 
int conceal_cursor_line (win_T *wp)
 
void conceal_check_cursor_line (void)
 
bool win_cursorline_standout (win_T *wp)
 
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 (frame_T *frp)
 
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 screen_puts_line_start (int row)
 
void grid_puts_len (ScreenGrid *grid, char_u *text, int textlen, int row, int col, int attr)
 
void grid_puts_line_flush (ScreenGrid *grid, 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_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 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)
 

Variables

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

Macro Definition Documentation

#define DID_FOLD   3
#define DID_LINE   2
#define DID_NONE   1
#define FDC_OFF   n
#define FIX_FOR_BOGUSCOLS
Value:
{ \
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]) : matches[m])
#define LINE_STATE (   p)    { p, 0, 0 }
#define MB_FILLER_CHAR
Value:
'<' /* character used when a double-width character
* doesn't fit. */
#define RL_MEMSET (   p,
  v,
  l 
)
Value:
if (wp->w_p_rl) { \
for (ri = 0; ri < l; ri++) { \
linebuf_attr[off + (wp->w_grid.Columns - (p) - (l)) + ri] = v; \
} \
} else { \
for (ri = 0; ri < l; ri++) { \
linebuf_attr[off + (p) + ri] = v; \
} \
}
for(size_t i=1;i< ARRAY_SIZE(argv);i++)
Definition: typval.c:1215
v
Definition: eval.c:2083
char_u * p
Definition: eval.c:2043
list_T *const l
Definition: eval.c:14776
#define RULER_BUF_LEN   70
#define SEARCH_HL_PRIORITY   0
#define SPWORDLEN   150
#define VCOL_HLC   (vcol - vcol_off)
#define W_ENDCOL (   wp)    (wp->w_wincol + wp->w_width)
#define W_ENDROW (   wp)    (wp->w_winrow + wp->w_height)
#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

Parameters
[out]tpcdTable to clear.
[in]tpcd_sizeSize of the table.
void clearmode ( void  )
void conceal_check_cursor_line ( void  )
int conceal_cursor_line ( win_T wp)
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_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 ( ScreenGrid grid,
bool  set_cursor 
)

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

Parameters
gridThe grid which contains the buffer.
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 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_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_puts_line_start ( int  row)

Start a group of screen_puts_len calls that builds a single screen line.

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

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

Parameters
typeset to a NOT_VALID to force redraw of entire screen
bool win_cursorline_standout ( win_T wp)

Whether cursorline is drawn in a special way

If true, both old and new cursorline will need need to be redrawn when moving cursor within windows.

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

Parameters
wpwindow we want signcolumn width from
Returns
max width of signcolumn (cell unit)
Note
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

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.