mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 20:56:22 +00:00
Merge branch 'master' into inp-utf8
This commit is contained in:
@@ -204,15 +204,15 @@ ui_readline(void)
|
||||
}
|
||||
|
||||
void
|
||||
ui_input_clear(void)
|
||||
ui_inp_history_append(char *inp)
|
||||
{
|
||||
inp_win_reset();
|
||||
inp_history_append(inp);
|
||||
}
|
||||
|
||||
void
|
||||
ui_replace_input(char *input, const char * const new_input, int *size)
|
||||
ui_input_clear(void)
|
||||
{
|
||||
inp_replace_input(input, new_input, size);
|
||||
inp_win_reset();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "config/accounts.h"
|
||||
#include "config/preferences.h"
|
||||
#include "config/theme.h"
|
||||
#include "tools/history.h"
|
||||
#include "log.h"
|
||||
#include "muc.h"
|
||||
#include "profanity.h"
|
||||
@@ -72,6 +73,7 @@
|
||||
#define KEY_CTRL_U 0025
|
||||
#define KEY_CTRL_W 0027
|
||||
|
||||
#define MAX_HISTORY 100
|
||||
#define INP_WIN_MAX 1000
|
||||
|
||||
static WINDOW *inp_win;
|
||||
@@ -79,6 +81,7 @@ static int pad_start = 0;
|
||||
static int rows, cols;
|
||||
static char line[INP_WIN_MAX];
|
||||
static int inp_size;
|
||||
static History history;
|
||||
|
||||
static int _handle_edit(int key_type, const wint_t ch);
|
||||
static int _handle_alt_key(int key);
|
||||
@@ -103,6 +106,7 @@ create_input_window(void)
|
||||
keypad(inp_win, TRUE);
|
||||
wmove(inp_win, 0, 0);
|
||||
_inp_win_update_virtual();
|
||||
history = history_new(MAX_HISTORY);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -227,7 +231,7 @@ inp_read(int *key_type, wint_t *ch)
|
||||
echo();
|
||||
|
||||
if (*ch == '\n') {
|
||||
line[inp_size++] = '\0';
|
||||
line[inp_size] = '\0';
|
||||
inp_size = 0;
|
||||
return strdup(line);
|
||||
} else {
|
||||
@@ -273,13 +277,13 @@ _get_display_length(void)
|
||||
}
|
||||
|
||||
void
|
||||
inp_replace_input(char *input, const char * const new_input, int *size)
|
||||
inp_replace_input(const char * const new_input)
|
||||
{
|
||||
strncpy(input, new_input, INP_WIN_MAX);
|
||||
*size = strlen(input);
|
||||
strncpy(line, new_input, INP_WIN_MAX);
|
||||
inp_size = strlen(line);
|
||||
inp_win_reset();
|
||||
input[*size] = '\0';
|
||||
waddstr(inp_win, input);
|
||||
line[inp_size] = '\0';
|
||||
waddstr(inp_win, line);
|
||||
_go_to_end();
|
||||
}
|
||||
|
||||
@@ -291,6 +295,12 @@ inp_win_reset(void)
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
void
|
||||
inp_history_append(char *inp)
|
||||
{
|
||||
history_append(history, inp);
|
||||
}
|
||||
|
||||
static void
|
||||
_clear_input(void)
|
||||
{
|
||||
@@ -514,9 +524,10 @@ _handle_edit(int key_type, const wint_t ch)
|
||||
return 0;
|
||||
}
|
||||
case KEY_CTRL_P:
|
||||
prev = cmd_history_previous(line, &inp_size);
|
||||
line[inp_size] = '\0';
|
||||
prev = history_previous(history, line);
|
||||
if (prev) {
|
||||
inp_replace_input(line, prev, &inp_size);
|
||||
inp_replace_input(prev);
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -525,13 +536,14 @@ _handle_edit(int key_type, const wint_t ch)
|
||||
return 0;
|
||||
}
|
||||
case KEY_CTRL_N:
|
||||
next = cmd_history_next(line, &inp_size);
|
||||
line[inp_size] = '\0';
|
||||
next = history_next(history, line);
|
||||
if (next) {
|
||||
inp_replace_input(line, next, &inp_size);
|
||||
inp_replace_input(next);
|
||||
} else if (inp_size != 0) {
|
||||
line[inp_size] = '\0';
|
||||
cmd_history_append(line);
|
||||
inp_replace_input(line, "", &inp_size);
|
||||
history_append(history, line);
|
||||
inp_replace_input("");
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -555,10 +567,21 @@ _handle_edit(int key_type, const wint_t ch)
|
||||
|
||||
case 9: // tab
|
||||
if (inp_size != 0) {
|
||||
line[inp_size] = '\0';
|
||||
if ((strncmp(line, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
|
||||
muc_autocomplete(line, &inp_size);
|
||||
char *result = muc_autocomplete(line);
|
||||
if (result) {
|
||||
cons_debug("ac result = %s", result);
|
||||
inp_replace_input(result);
|
||||
free(result);
|
||||
}
|
||||
} else if (strncmp(line, "/", 1) == 0) {
|
||||
cmd_autocomplete(line, &inp_size);
|
||||
char *result = cmd_autocomplete(line);
|
||||
if (result) {
|
||||
cons_debug("ac result = %s", result);
|
||||
inp_replace_input(result);
|
||||
free(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@@ -777,4 +800,4 @@ _printable(const wint_t ch)
|
||||
bytes[utf_len] = '\0';
|
||||
gunichar unichar = g_utf8_get_char(bytes);
|
||||
return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ void inp_put_back(void);
|
||||
void inp_non_block(gint);
|
||||
void inp_block(void);
|
||||
void inp_get_password(char *passwd);
|
||||
void inp_replace_input(char *input, const char * const new_input, int *size);
|
||||
void inp_replace_input(const char * const new_input);
|
||||
void inp_history_append(char *inp);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -230,7 +230,6 @@ void ui_statusbar_new(const int win);
|
||||
char * ui_readline(void);
|
||||
void ui_input_clear(void);
|
||||
void ui_input_nonblocking(gboolean);
|
||||
void ui_replace_input(char *input, const char * const new_input, int *size);
|
||||
|
||||
void ui_invalid_command_usage(const char * const usage, void (*setting_func)(void));
|
||||
|
||||
@@ -240,6 +239,8 @@ void ui_open_xmlconsole_win(void);
|
||||
|
||||
gboolean ui_win_has_unsaved_form(int num);
|
||||
|
||||
void ui_inp_history_append(char *inp);
|
||||
|
||||
// console window actions
|
||||
void cons_show(const char * const msg, ...);
|
||||
void cons_about(void);
|
||||
|
||||
Reference in New Issue
Block a user