#include #include "../include/editor_op.h" #include "../include/row_op.h" extern struct editorConfig E; /** * @brief Sets a temporary status message for display * @details Formats and stores a message that will be displayed in the message * bar for 5 seconds. Uses printf-style variable argument formatting. * @param fmt Printf-style format string * @param ... Variable arguments for format string * @note Updates global editor state E (status_msg, status_msg_time) * @see editorDrawMessageBar() */ void editorSetStatusMessage(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vsnprintf(E.status_msg, sizeof(E.status_msg), fmt, ap); va_end(ap); E.status_msg_time = time(NULL); } void editorInsertChar(int c) { if (E.cursor_y == E.numrows) { editorInsertRow(E.numrows, "", 0); } editorRowInsertChar(&E.row[E.cursor_y], E.cursor_x, c); E.cursor_x++; } void editorInsertNewLine() { /* * Add new line and place the cursor at the beginning of it */ fprintf(stderr, "Inserting new line\n"); erow *row; if (!E.cursor_x) { editorInsertRow(E.cursor_y, "", 0); } else { row = &E.row[E.cursor_y]; editorInsertRow(E.cursor_y + 1, &row->chars[E.cursor_x], row->size - E.cursor_x); row = &E.row[E.cursor_y]; row->size = E.cursor_x; row->chars[row->size] = '\0'; editorUpdateRow(row); } ++E.cursor_y; E.cursor_x = 0; fprintf(stderr, "Insert new line done\n"); } void editorDelChar() { erow *row; if (E.cursor_y == E.numrows || !(E.cursor_x || E.cursor_y)) { return; } row = &E.row[E.cursor_y]; if (E.cursor_x > 0) { editorRowDelchar(row, E.cursor_x - 1); --E.cursor_x; } else { E.cursor_x = E.row[E.cursor_y - 1].size; editorRowAppendString(&E.row[E.cursor_y - 1], row->chars, row->size); editorDelRow(E.cursor_y); --E.cursor_y; } }