progress on drawing the screen
This commit is contained in:
parent
d7dfb7a751
commit
c6bdbe1676
20
src/draw.c
20
src/draw.c
@ -12,8 +12,28 @@ extern screen_buffer_t screen_buffer;
|
||||
|
||||
void refresh_screen(void)
|
||||
{
|
||||
/**
|
||||
* TODO: need to move the cursor back at the end
|
||||
* also need to draw the cusor coords at the bottom
|
||||
* and need to implement controls
|
||||
*/
|
||||
|
||||
int cur_x, cur_y;
|
||||
|
||||
cur_x = editor.cx;
|
||||
cur_y = editor.cy;
|
||||
|
||||
// hide the cursor to prevent flickering
|
||||
screen_buffer_append(&screen_buffer, HIDE_CURSOR_STR, HIDE_CURSOR_STR_LEN);
|
||||
|
||||
screen_buffer_append(&screen_buffer, MOVE_CURSOR_HOME_STR, MOVE_CURSOR_HOME_STR_LEN);
|
||||
|
||||
screen_buffer_append(&screen_buffer, CLEAR_SCREEN_STR, CLEAR_SCREEN_STR_LEN);
|
||||
|
||||
draw_editor_rows();
|
||||
|
||||
screen_buffer_append(&screen_buffer, SHOW_CURSOR_STR, SHOW_CURSOR_STR_LEN);
|
||||
|
||||
write(STDOUT_FILENO, screen_buffer.text, screen_buffer.len);
|
||||
}
|
||||
|
||||
|
15
src/draw.h
15
src/draw.h
@ -1,6 +1,21 @@
|
||||
#ifndef DRAW_H
|
||||
#define DRAW_H
|
||||
|
||||
/** BEGIN ASCII ESCAPE STRINGS **/
|
||||
|
||||
#define CLEAR_SCREEN_STR "\e[2J"
|
||||
#define CLEAR_SCREEN_STR_LEN 4
|
||||
|
||||
#define MOVE_CURSOR_HOME_STR "\e[H"
|
||||
#define MOVE_CURSOR_HOME_STR_LEN 3
|
||||
|
||||
#define HIDE_CURSOR_STR "\e[?25l"
|
||||
#define HIDE_CURSOR_STR_LEN 6
|
||||
#define SHOW_CURSOR_STR "\e[?25h"
|
||||
#define SHOW_CURSOR_STR_LEN 6
|
||||
|
||||
/** END ASCII ESCAPE STRINGS SECTION **/
|
||||
|
||||
void refresh_screen(void);
|
||||
|
||||
void draw_editor_rows(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user