+11
-17
@@ -8,6 +8,7 @@
|
||||
#include "../include/output.h"
|
||||
#include "../include/append_buffer.h"
|
||||
#include "../include/buffer.h"
|
||||
#include "../include/editor_op.h"
|
||||
#include "../include/data.h"
|
||||
#include "../include/define.h"
|
||||
#include "../include/row_op.h"
|
||||
@@ -29,14 +30,9 @@ static void editorDrawPane(struct abuf* ab, EditorPane* pane)
|
||||
int file_row;
|
||||
char pos_buf[32];
|
||||
int pos_len;
|
||||
int chars_printed;
|
||||
int start_offset;
|
||||
int byte_len_to_print;
|
||||
int bytes_to_print;
|
||||
char* highlighted;
|
||||
char welcome[80];
|
||||
int welcome_len;
|
||||
int padding;
|
||||
|
||||
if (pane == NULL || pane->buffer_id < 0)
|
||||
return;
|
||||
@@ -56,9 +52,8 @@ static void editorDrawPane(struct abuf* ab, EditorPane* pane)
|
||||
abAppend(ab, pos_buf, pos_len);
|
||||
|
||||
// Apply background color (6 bytes for RGB format)
|
||||
abAppend(ab, E.theme.BACKGROUND_COLOR, strlen(E.theme.BACKGROUND_COLOR));
|
||||
abAppend(ab, E.theme.BACKGROUND_COLOR, (int) strlen(E.theme.BACKGROUND_COLOR));
|
||||
|
||||
chars_printed = 0;
|
||||
|
||||
// pane line is out of buffer
|
||||
if (file_row >= buf->numrows)
|
||||
@@ -75,7 +70,7 @@ static void editorDrawPane(struct abuf* ab, EditorPane* pane)
|
||||
}
|
||||
else
|
||||
{
|
||||
start_offset = pane->x_offset;
|
||||
|
||||
|
||||
if (buf->filename[strlen(buf->filename) - 1] == 'c' || buf->filename[strlen(buf->filename) - 1] == 'h')
|
||||
{
|
||||
@@ -135,7 +130,7 @@ static void editorDrawAllPanes(struct abuf* ab)
|
||||
{
|
||||
char pos_buf[32];
|
||||
snprintf(pos_buf, sizeof(pos_buf), "\x1b[%d;%dH", y + 1, divider_col);
|
||||
abAppend(ab, pos_buf, strlen(pos_buf));
|
||||
abAppend(ab, pos_buf, (int) strlen(pos_buf));
|
||||
abAppend(ab, "\x1b[1m|\x1b[0m", 9); // Bold pipe divider
|
||||
}
|
||||
}
|
||||
@@ -145,7 +140,7 @@ static void editorDrawAllPanes(struct abuf* ab)
|
||||
int divider_row = layout->panes[0].height;
|
||||
char pos_buf[32];
|
||||
snprintf(pos_buf, sizeof(pos_buf), "\x1b[%d;%dH", divider_row + 1, 1);
|
||||
abAppend(ab, pos_buf, strlen(pos_buf));
|
||||
abAppend(ab, pos_buf, (int) strlen(pos_buf));
|
||||
for (int x = 0; x < E.screencols; x++)
|
||||
{
|
||||
abAppend(ab, "\x1b[1m-\x1b[0m", 9); // Bold dash divider
|
||||
@@ -231,15 +226,13 @@ void editorScroll()
|
||||
|
||||
char * basename(char *path)
|
||||
{
|
||||
int len = strlen(path);
|
||||
int flag=0;
|
||||
int len = (int) strlen(path);
|
||||
|
||||
|
||||
for(int i=len-1; i>0; i--)
|
||||
{
|
||||
if(path[i]=='/' )
|
||||
{
|
||||
flag=1;
|
||||
path = path+i+1;
|
||||
break;
|
||||
}
|
||||
@@ -323,7 +316,7 @@ void editorDrawStatusBar(struct abuf* ab)
|
||||
*/
|
||||
void editorDrawMessageBar(struct abuf* ab)
|
||||
{
|
||||
int msg_len = strlen(E.status_msg);
|
||||
int msg_len = (int) strlen(E.status_msg);
|
||||
abAppend(ab, ERASE_END_LINE, 3);
|
||||
if (msg_len > E.screencols)
|
||||
{
|
||||
@@ -335,6 +328,7 @@ void editorDrawMessageBar(struct abuf* ab)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Performs complete screen refresh and buffer synchronization
|
||||
* @details Clears screen, redraws all visible content (rows, status bar,
|
||||
@@ -354,7 +348,7 @@ void editorRefreshScreen()
|
||||
abAppend(&ab, HIDE_CURSOR, 6);
|
||||
abAppend(&ab, CURSOR_TOP_LEFT, 3);
|
||||
abAppend(&ab, E.theme.BACKGROUND_COLOR,
|
||||
strlen(E.theme.BACKGROUND_COLOR)); // RGB background is 12 bytes
|
||||
(int) strlen(E.theme.BACKGROUND_COLOR)); // RGB background is 12 bytes
|
||||
|
||||
// Draw all panes
|
||||
editorScroll();
|
||||
@@ -363,16 +357,16 @@ void editorRefreshScreen()
|
||||
// Draw status bar and message bar
|
||||
editorDrawStatusBar(&ab);
|
||||
editorDrawMessageBar(&ab);
|
||||
// editorDrawContextBuffer(&ab);
|
||||
|
||||
// Position cursor in active pane
|
||||
EditorPane* active = splitScreenGetActivePane();
|
||||
struct buffer_t* buffer = bufferGetCurrent();
|
||||
if (active != NULL)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "\x1b[%d;%dH",
|
||||
active->cursor_y + active->origin_y + 1,
|
||||
active->cursor_x + active->origin_x + 1);
|
||||
abAppend(&ab, buf, strlen(buf));
|
||||
abAppend(&ab, buf, (int) strlen(buf));
|
||||
}
|
||||
|
||||
abAppend(&ab, SHOW_CURSOR, 6);
|
||||
|
||||
Reference in New Issue
Block a user