ze
Loading...
Searching...
No Matches
Files | Functions
Collaboration diagram for Rows:

Files

file  row.c
 Row manipulation and conversion implementations.
 

Functions

int editorRowCxToRx (erow *row, int cx)
 Convert an index in characters (cx) to a render index (rx).
 
int editorRowRxToCx (erow *row, int rx)
 Convert a render index (rx) to a character index (cx).
 
void editorUpdateRow (erow *row)
 Recompute render, rsize, and syntax highlighting for a row.
 
void editorInsertRow (int at, char *s, size_t len)
 Insert a new row at position at initialized from a string.
 
void editorFreeRow (erow *row)
 Free dynamic memory associated with a row.
 
void editorDelRow (int at)
 Delete row at index at.
 
void editorRowInsertChar (erow *row, int at, int c)
 Insert a character into a row at index at.
 
void editorRowAppendString (erow *row, char *s, size_t len)
 Append a byte sequence to the end of a row.
 
void editorRowDelChar (erow *row, int at)
 Delete a character at index at in a row.
 
void editorDelRowAtChar (erow *row, int at)
 Delete from a row starting at a character index to the end of the line.
 

Detailed Description

Function Documentation

◆ editorDelRow()

void editorDelRow ( int  at)

Delete row at index at.

Frees the row, compacts the array, updates indices, and marks the buffer dirty.

Parameters
[in]atIndex of the row to delete in [0, E.numrows).
See also
editorInsertRow()

◆ editorDelRowAtChar()

void editorDelRowAtChar ( erow row,
int  at 
)

Delete from a row starting at a character index to the end of the line.

Deletes characters from at (exclusive) to the end, effectively trimming the line at at. Updates render and marks dirty.

Parameters
[in,out]rowTarget row.
[in]atIndex after which characters are removed. Must be in range.

◆ editorFreeRow()

void editorFreeRow ( erow row)

Free dynamic memory associated with a row.

Releases render, chars, and hl arrays if allocated.

Parameters
[in,out]rowRow whose buffers to free.

◆ editorInsertRow()

void editorInsertRow ( int  at,
char *  s,
size_t  len 
)

Insert a new row at position at initialized from a string.

Shifts rows after at, initializes the new row's fields, and updates indexes and dirty state. Copies exactly len bytes from s and appends a NUL terminator.

Ownership: s is not owned and is not modified. The new row holds its own NUL-terminated copy.

Parameters
[in]atDestination index in [0, E.numrows]. Out-of-range is ignored.
[in]sPointer to bytes (may contain non-printables; no NUL required).
[in]lenNumber of bytes from s to copy.
See also
editorDelRow(), editorInsertNewline(), editorRowAppendString()

◆ editorRowAppendString()

void editorRowAppendString ( erow row,
char *  s,
size_t  len 
)

Append a byte sequence to the end of a row.

Extends row->chars by len bytes from s, appends a NUL terminator, updates render and dirty state.

Parameters
[in,out]rowTarget row.
[in]sBytes to append; need not be NUL-terminated.
[in]lenNumber of bytes from s to append.
See also
editorRowInsertChar(), editorUpdateRow()

◆ editorRowCxToRx()

int editorRowCxToRx ( erow row,
int  cx 
)

Convert an index in characters (cx) to a render index (rx).

Accounts for tabs expanding to ZE_TAB_STOP columns.

Parameters
[in]rowRow whose data to measure. Must be non-NULL.
[in]cxCharacter index within row (0..size).
Returns
Render column index corresponding to cx.
See also
editorRowRxToCx()

◆ editorRowDelChar()

void editorRowDelChar ( erow row,
int  at 
)

Delete a character at index at in a row.

Removes the byte at at, shifts the tail left, updates render and marks dirty.

Parameters
[in,out]rowTarget row.
[in]atIndex to delete in [0, size).
See also
editorRowInsertChar(), editorUpdateRow()

◆ editorRowInsertChar()

void editorRowInsertChar ( erow row,
int  at,
int  c 
)

Insert a character into a row at index at.

Reallocates the row text, shifts tail, inserts c, updates render and marks dirty.

Parameters
[in,out]rowTarget row. Must be non-NULL.
[in]atInsertion index; values outside [0, size] clamp to end.
[in]cCharacter code to insert (low 8 bits used).
See also
editorRowDelChar(), editorUpdateRow()

◆ editorRowRxToCx()

int editorRowRxToCx ( erow row,
int  rx 
)

Convert a render index (rx) to a character index (cx).

Inverse of editorRowCxToRx(), handling tab expansion.

Parameters
[in]rowRow whose data to measure. Must be non-NULL.
[in]rxRender column index (0..rsize).
Returns
Character index corresponding to rx.
See also
editorRowCxToRx()

◆ editorUpdateRow()

void editorUpdateRow ( erow row)

Recompute render, rsize, and syntax highlighting for a row.

Allocates/updates row->render from row->chars expanding tabs, updates row->rsize, and recomputes syntax highlighting. Propagates multi-line comment state to the next row when it changes.

Parameters
[in,out]rowRow to update. Its render buffer is reallocated.
See also
editorUpdateSyntax(), editorRowInsertChar(), editorRowDelChar()