Adding splitting screen and buffer switching

This commit is contained in:
Arthur Barraux
2026-01-24 19:29:46 +01:00
parent b039cf3ded
commit 5a7b073041
22 changed files with 1171 additions and 384 deletions
+51 -13
View File
@@ -13,12 +13,50 @@
* \param
* */
typedef struct erow {
typedef struct frow {
int size; /**< Size of the line */
int rsize; /**< Size of the render line */
char *chars; /**< Characters of the line */
char *render; /**< The actual line we will print */
} erow;
} frow;
/**
* @brief Split modes for screen layout
*/
typedef enum {
SPLIT_NONE = 0, // Single buffer fullscreen
SPLIT_VERTICAL, // Left-right split
SPLIT_HORIZONTAL // Top-bottom split
} SplitMode;
/**
* @brief Represents an editor viewport/pane
*/
typedef struct {
int buffer_id; // Which buffer this pane displays
int start_row; // Starting row on screen
int start_col; // Starting column on screen
int height; // Height of this pane
int width; // Width of this pane
int cursor_x; // Local cursor x in this pane
int cursor_y; // Local cursor y in this pane
int rx, ry;
int row_offset; // Scroll offset for rows
int col_offset; // Scroll offset for columns
int is_active; // Is this pane currently active
} EditorPane;
/**
* @brief Screen layout manager
*/
typedef struct {
SplitMode mode;
EditorPane *panes;
int num_panes;
int active_pane; // Index of active pane
} ScreenLayout;
typedef struct theme {
char *BACKGROUND_COLOR;
@@ -31,7 +69,7 @@ typedef struct theme {
} theme_t;
enum editorStatus_e {
enum bufferStatus_e {
IDLE,
READ_ONLY,
READ_AND_WRITE,
@@ -60,8 +98,14 @@ struct buffer_t {
enum buffer_type type;
int buffer_id;
int width, height;
int x, y; /**< Position of the buffer*/
int x, y; /**< Position in the buffer (cursor) */
frow *row;
int numrows;
char *filename;
enum bufferStatus_e state;
int dirty; /**< Has this buffer been modified since last save */
int row_offset; /**< Scroll offset for rows in this buffer */
int col_offset; /**< Scroll offset for columns in this buffer */
};
/**
@@ -69,17 +113,12 @@ struct buffer_t {
* \brief Containing our editor state.
*/
struct editorConfig {
int cursor_x, cursor_y; /**< Cursor position */
int rx; /**< Position in the render*/
int row_offset; /**< Position scroll of lines */
int col_offset; /**< Position scroll of colomns*/
int screenrows; /**< Terminal height*/
int screencols; /**< Terminal width*/
int numrows; /**< Number of rows contained */
erow *row; /**< Store all the rows printed */
ScreenLayout layout;
int dirty;
char *filename;
enum editorStatus_e state;
int prefix_state;
char status_msg[80];
time_t status_msg_time;
@@ -102,7 +141,6 @@ struct editorConfig {
int number_of_prefix;
struct buffer_t buffers[64];
struct buffer_t ***screen_layout; /**< Which buffer is the current cell*/
int number_of_buffer;
theme_t theme;