Commit 9af90947 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Add the possibility to get user data point with terminal_resize callback

parent 8abe24bf
......@@ -125,7 +125,7 @@ int blc_stderr_ansi_detect();
///Get the size of the terminal windows in characters.
void blc_terminal_get_size(int *columns, int *lines);
///Set a callback to be called each time the terminal window is resized.
void blc_terminal_set_resize_callback(void (*callback)(int columns_nb, int rows_nb));
void blc_terminal_set_resize_callback(void (*callback)(int columns_nb, int rows_nb, void* user_data), void *user_data);
///Send an escape command on the terminal.
void fprintf_escape_command(FILE *file, char const *format, ...);
///Set a new color for the terminal.
......@@ -34,7 +34,8 @@ int blc_stdout_ansi = 1;
int blc_stderr_ansi = 1;
static char *lookup_bar_colors=NULL;
static void (*resize_callback)(int columns_nb, int rows_nb);
static void (*resize_callback)(int columns_nb, int rows_nb, void*);
static void *resize_callback_user_data;
static struct termios blc_initial_tty_mode={0};
//This is for graph
......@@ -48,7 +49,7 @@ static void signal_callback(int signal_id)
blc_terminal_get_size(&columns_nb, &rows_nb);
resize_callback(columns_nb, rows_nb);
resize_callback(columns_nb, rows_nb, resize_callback_user_data);
......@@ -122,11 +123,12 @@ void blc_terminal_get_size(int *columns, int *lines)
///A signal SIGWINCH is associated to the callback. It is not yet reversible.
void blc_terminal_set_resize_callback(void (*callback)(int , int ))
void blc_terminal_set_resize_callback(void (*callback)(int , int, void* ), void *user_data)
struct sigaction signal_action;
resize_callback = callback;
signal_action.sa_flags = 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment