add new api for moving text cursor around

This commit is contained in:
Ray Strode 2008-06-19 09:38:34 -04:00
parent 6bda9aa4d1
commit 83a23fc456
2 changed files with 15 additions and 0 deletions

View file

@ -53,6 +53,8 @@
#define KEY_RETURN '\r'
#define KEY_BACKSPACE '\177'
#define MOVE_CURSOR_SEQUNCE(column,row) "\033[f"#row","#column
struct _ply_window
{
ply_event_loop_t *loop;
@ -438,6 +440,16 @@ ply_window_get_number_of_text_columns (ply_window_t *window)
return window->number_of_text_columns;
}
void
ply_window_set_text_cursor_position (ply_window_t *window,
int column,
int row)
{
write (window->tty_fd,
MOVE_CURSOR_SEQUNCE(row,column),
strlen (MOVE_CURSOR_SEQUNCE(row,column)));
}
static void
ply_window_detach_from_event_loop (ply_window_t *window)
{

View file

@ -74,6 +74,9 @@ bool ply_window_set_mode (ply_window_t *window,
ply_window_mode_t mode);
int ply_window_get_number_of_text_rows (ply_window_t *window);
int ply_window_get_number_of_text_columns (ply_window_t *window);
void ply_window_set_text_cursor_position (ply_window_t *window,
int column,
int row);
void ply_window_attach_to_event_loop (ply_window_t *window,
ply_event_loop_t *loop);