mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Merge branch 'master' into inp-utf8
Conflicts: src/ui/inputwin.c
This commit is contained in:
commit
9083bfdb5c
@ -1772,9 +1772,10 @@ cmd_process_input(char *inp)
|
|||||||
void
|
void
|
||||||
cmd_execute_connect(const char * const account)
|
cmd_execute_connect(const char * const account)
|
||||||
{
|
{
|
||||||
char inp[INP_WIN_MAX];
|
GString *command = g_string_new("/connect ");
|
||||||
snprintf(inp, sizeof(inp), "%s %s", "/connect", account);
|
g_string_append(command, account);
|
||||||
cmd_process_input(inp);
|
cmd_process_input(command->str);
|
||||||
|
g_string_free(command, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -97,7 +97,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
|
|||||||
}
|
}
|
||||||
cmd_result = cmd_process_input(line);
|
cmd_result = cmd_process_input(line);
|
||||||
ui_input_clear();
|
ui_input_clear();
|
||||||
line = NULL;
|
FREE_SET_NULL(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,6 @@
|
|||||||
|
|
||||||
static char *win_title;
|
static char *win_title;
|
||||||
|
|
||||||
static char line[INP_WIN_MAX];
|
|
||||||
static int inp_size;
|
static int inp_size;
|
||||||
|
|
||||||
#ifdef HAVE_LIBXSS
|
#ifdef HAVE_LIBXSS
|
||||||
@ -183,8 +182,8 @@ ui_readline(void)
|
|||||||
{
|
{
|
||||||
int key_type;
|
int key_type;
|
||||||
wint_t ch;
|
wint_t ch;
|
||||||
inp_get_char(line, &key_type, &ch);
|
|
||||||
|
|
||||||
|
char *line = inp_get_char(&key_type, &ch);
|
||||||
_win_handle_switch(ch);
|
_win_handle_switch(ch);
|
||||||
|
|
||||||
ProfWin *current = wins_get_current();
|
ProfWin *current = wins_get_current();
|
||||||
@ -201,11 +200,7 @@ ui_readline(void)
|
|||||||
ui_input_nonblocking(FALSE);
|
ui_input_nonblocking(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch == '\n') {
|
return line;
|
||||||
return line;
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -72,9 +72,12 @@
|
|||||||
#define KEY_CTRL_U 0025
|
#define KEY_CTRL_U 0025
|
||||||
#define KEY_CTRL_W 0027
|
#define KEY_CTRL_W 0027
|
||||||
|
|
||||||
|
#define INP_WIN_MAX 1000
|
||||||
|
|
||||||
static WINDOW *inp_win;
|
static WINDOW *inp_win;
|
||||||
static int pad_start = 0;
|
static int pad_start = 0;
|
||||||
static int rows, cols;
|
static int rows, cols;
|
||||||
|
static char line[INP_WIN_MAX];
|
||||||
static int inp_size;
|
static int inp_size;
|
||||||
|
|
||||||
static int _handle_edit(int result, const wint_t ch, char *input);
|
static int _handle_edit(int result, const wint_t ch, char *input);
|
||||||
@ -133,17 +136,17 @@ inp_block(void)
|
|||||||
wtimeout(inp_win, -1);
|
wtimeout(inp_win, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
char *
|
||||||
inp_get_char(char *result, int *key_type, wint_t *ch)
|
inp_get_char(int *key_type, wint_t *ch)
|
||||||
{
|
{
|
||||||
int display_size = _get_display_length(input);
|
int display_size = _get_display_length(line);
|
||||||
|
|
||||||
// echo off, and get some more input
|
// echo off, and get some more input
|
||||||
noecho();
|
noecho();
|
||||||
*key_type = wget_wch(inp_win, ch);
|
*key_type = wget_wch(inp_win, ch);
|
||||||
|
|
||||||
gboolean in_command = FALSE;
|
gboolean in_command = FALSE;
|
||||||
if ((display_size > 0 && result[0] == '/') ||
|
if ((display_size > 0 && line[0] == '/') ||
|
||||||
(display_size == 0 && *ch == '/')) {
|
(display_size == 0 && *ch == '/')) {
|
||||||
in_command = TRUE;
|
in_command = TRUE;
|
||||||
}
|
}
|
||||||
@ -156,11 +159,11 @@ inp_get_char(char *result, int *key_type, wint_t *ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if it wasn't an arrow key etc
|
// if it wasn't an arrow key etc
|
||||||
if (!_handle_edit(*key_type, *ch, result)) {
|
if (!_handle_edit(*key_type, *ch, line)) {
|
||||||
if (_printable(*ch) && *key_type != KEY_CODE_YES) {
|
if (_printable(*ch) && *key_type != KEY_CODE_YES) {
|
||||||
if (inp_size >= INP_WIN_MAX) {
|
if (inp_size >= INP_WIN_MAX) {
|
||||||
*ch = ERR;
|
*ch = ERR;
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int inp_x = getcurx(inp_win);
|
int inp_x = getcurx(inp_win);
|
||||||
@ -170,9 +173,9 @@ inp_get_char(char *result, int *key_type, wint_t *ch)
|
|||||||
char bytes[MB_CUR_MAX];
|
char bytes[MB_CUR_MAX];
|
||||||
size_t utf_len = wcrtomb(bytes, *ch, NULL);
|
size_t utf_len = wcrtomb(bytes, *ch, NULL);
|
||||||
|
|
||||||
char *next_ch = g_utf8_offset_to_pointer(result, inp_x);
|
char *next_ch = g_utf8_offset_to_pointer(line, inp_x);
|
||||||
char *offset;
|
char *offset;
|
||||||
for (offset = &result[inp_size - 1]; offset >= next_ch; offset--) {
|
for (offset = &line[inp_size - 1]; offset >= next_ch; offset--) {
|
||||||
*(offset + utf_len) = *offset;
|
*(offset + utf_len) = *offset;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
@ -181,7 +184,7 @@ inp_get_char(char *result, int *key_type, wint_t *ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inp_size += utf_len;
|
inp_size += utf_len;
|
||||||
result[inp_size] = '\0';
|
line[inp_size] = '\0';
|
||||||
waddstr(inp_win, next_ch);
|
waddstr(inp_win, next_ch);
|
||||||
wmove(inp_win, 0, inp_x + 1);
|
wmove(inp_win, 0, inp_x + 1);
|
||||||
|
|
||||||
@ -199,9 +202,9 @@ inp_get_char(char *result, int *key_type, wint_t *ch)
|
|||||||
if (utf_len < MB_CUR_MAX) {
|
if (utf_len < MB_CUR_MAX) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0 ; i < utf_len; i++) {
|
for (i = 0 ; i < utf_len; i++) {
|
||||||
result[inp_size++] = bytes[i];
|
line[inp_size++] = bytes[i];
|
||||||
}
|
}
|
||||||
result[inp_size] = '\0';
|
line[inp_size] = '\0';
|
||||||
|
|
||||||
bytes[utf_len] = '\0';
|
bytes[utf_len] = '\0';
|
||||||
waddstr(inp_win, bytes);
|
waddstr(inp_win, bytes);
|
||||||
@ -224,8 +227,11 @@ inp_get_char(char *result, int *key_type, wint_t *ch)
|
|||||||
echo();
|
echo();
|
||||||
|
|
||||||
if (*ch == '\n') {
|
if (*ch == '\n') {
|
||||||
result[inp_size++] = '\0';
|
line[inp_size++] = '\0';
|
||||||
inp_size = 0;
|
inp_size = 0;
|
||||||
|
return strdup(line);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#define UI_INPUTWIN_H
|
#define UI_INPUTWIN_H
|
||||||
|
|
||||||
void create_input_window(void);
|
void create_input_window(void);
|
||||||
void inp_get_char(char *result, int *key_type, wint_t *ch);
|
char* inp_get_char(int *key_type, wint_t *ch);
|
||||||
void inp_win_reset(void);
|
void inp_win_reset(void);
|
||||||
void inp_win_resize(void);
|
void inp_win_resize(void);
|
||||||
void inp_put_back(void);
|
void inp_put_back(void);
|
||||||
|
@ -51,8 +51,6 @@
|
|||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
|
|
||||||
#define INP_WIN_MAX 1000
|
|
||||||
|
|
||||||
// ui startup and control
|
// ui startup and control
|
||||||
void ui_init(void);
|
void ui_init(void);
|
||||||
void ui_load_colours(void);
|
void ui_load_colours(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user