mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Moved resize code to windows.c, reorder main loop
This commit is contained in:
parent
84c864663b
commit
32e025f5cd
44
input_win.c
44
input_win.c
@ -87,33 +87,29 @@ void inp_get_char(int *ch, char *input, int *size)
|
||||
noecho();
|
||||
*ch = wgetch(inp_win);
|
||||
|
||||
if (*ch == KEY_RESIZE) {
|
||||
win_resize();
|
||||
} else {
|
||||
// if it wasn't an arrow key etc
|
||||
if (!_handle_edit(*ch, input, size)) {
|
||||
if (_printable(*ch)) {
|
||||
getyx(inp_win, inp_y, inp_x);
|
||||
|
||||
// handle insert if not at end of input
|
||||
if (inp_x <= *size) {
|
||||
winsch(inp_win, *ch);
|
||||
wmove(inp_win, inp_y, inp_x+1);
|
||||
// if it wasn't an arrow key etc
|
||||
if (!_handle_edit(*ch, input, size)) {
|
||||
if (_printable(*ch)) {
|
||||
getyx(inp_win, inp_y, inp_x);
|
||||
|
||||
// handle insert if not at end of input
|
||||
if (inp_x <= *size) {
|
||||
winsch(inp_win, *ch);
|
||||
wmove(inp_win, inp_y, inp_x+1);
|
||||
|
||||
for (i = *size; i > inp_x -1; i--)
|
||||
input[i] = input[i-1];
|
||||
input[inp_x -1] = *ch;
|
||||
for (i = *size; i > inp_x -1; i--)
|
||||
input[i] = input[i-1];
|
||||
input[inp_x -1] = *ch;
|
||||
|
||||
(*size)++;
|
||||
(*size)++;
|
||||
|
||||
// otherwise just append
|
||||
} else {
|
||||
waddch(inp_win, *ch);
|
||||
input[(*size)++] = *ch;
|
||||
}
|
||||
|
||||
reset_search_attempts();
|
||||
// otherwise just append
|
||||
} else {
|
||||
waddch(inp_win, *ch);
|
||||
input[(*size)++] = *ch;
|
||||
}
|
||||
|
||||
reset_search_attempts();
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +250,7 @@ static int _printable(const int ch)
|
||||
ch != KEY_F(4) && ch != KEY_F(5) && ch != KEY_F(6) &&
|
||||
ch != KEY_F(7) && ch != KEY_F(8) && ch != KEY_F(9) &&
|
||||
ch != KEY_F(10) && ch!= KEY_F(11) && ch != KEY_F(12) &&
|
||||
ch != KEY_IC && ch != KEY_EIC);
|
||||
ch != KEY_IC && ch != KEY_EIC && ch != KEY_RESIZE);
|
||||
}
|
||||
|
||||
static void _replace_input(char *input, const char * const new_input, int *size)
|
||||
|
@ -47,8 +47,8 @@ void profanity_run(void)
|
||||
while(ch != '\n') {
|
||||
gui_refresh();
|
||||
jabber_process_events();
|
||||
win_handle_special_keys(&ch);
|
||||
inp_get_char(&ch, inp, &size);
|
||||
win_handle_special_keys(&ch);
|
||||
}
|
||||
|
||||
inp[size++] = '\0';
|
||||
|
22
windows.c
22
windows.c
@ -57,6 +57,7 @@ static void _cons_show_incoming_message(const char * const short_from,
|
||||
const int win_index);
|
||||
static void _win_handle_switch(const int * const ch);
|
||||
static void _win_handle_page(const int * const ch);
|
||||
static void _win_handle_resize(const int * const ch);
|
||||
|
||||
void gui_init(void)
|
||||
{
|
||||
@ -88,15 +89,6 @@ void gui_init(void)
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
void win_resize(void)
|
||||
{
|
||||
create_title_bar();
|
||||
create_status_bar();
|
||||
create_input_window();
|
||||
_current_window_refresh();
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
void gui_refresh(void)
|
||||
{
|
||||
title_bar_refresh();
|
||||
@ -325,6 +317,7 @@ void win_handle_special_keys(const int * const ch)
|
||||
{
|
||||
_win_handle_switch(ch);
|
||||
_win_handle_page(ch);
|
||||
_win_handle_resize(ch);
|
||||
}
|
||||
|
||||
void win_page_off(void)
|
||||
@ -521,6 +514,17 @@ static void _win_handle_switch(const int * const ch)
|
||||
}
|
||||
}
|
||||
|
||||
static void _win_handle_resize(const int * const ch)
|
||||
{
|
||||
if (*ch == KEY_RESIZE) {
|
||||
create_title_bar();
|
||||
create_status_bar();
|
||||
create_input_window();
|
||||
_current_window_refresh();
|
||||
dirty = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void _win_handle_page(const int * const ch)
|
||||
{
|
||||
int rows, cols, y, x;
|
||||
|
Loading…
Reference in New Issue
Block a user