From 7e8ab90d3995adc059de04f0475dd046a365aac6 Mon Sep 17 00:00:00 2001
From: Peter Vilim
Date: Wed, 14 Jan 2015 17:14:00 -0600
Subject: [PATCH 001/252] Strip quote chars from name autocomplete
---
src/command/command.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/command/command.c b/src/command/command.c
index 86185f59..f18191bc 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -98,6 +98,7 @@ static char * _role_autocomplete(char *input, int *size);
static char * _resource_autocomplete(char *input, int *size);
static char * _titlebar_autocomplete(char *input, int *size);
static char * _inpblock_autocomplete(char *input, int *size);
+static char * _strip_quotes_from_names(char *input, int *size);
GHashTable *commands = NULL;
@@ -1932,6 +1933,8 @@ _cmd_complete_parameters(char *input, int *size)
if (nick_ac != NULL) {
gchar *nick_choices[] = { "/msg", "/info", "/caps", "/status", "/software" } ;
+ // Remove quote character before and after names when doing autocomplete
+ input = _strip_quotes_from_names(input, size);
for (i = 0; i < ARRAY_SIZE(nick_choices); i++) {
result = autocomplete_param_with_ac(input, size, nick_choices[i],
nick_ac, TRUE);
@@ -1946,6 +1949,8 @@ _cmd_complete_parameters(char *input, int *size)
// otherwise autocomplete using roster
} else {
gchar *contact_choices[] = { "/msg", "/info", "/status" };
+ // Remove quote character before and after names when doing autocomplete
+ input = _strip_quotes_from_names(input, size);
for (i = 0; i < ARRAY_SIZE(contact_choices); i++) {
result = autocomplete_param_with_func(input, size, contact_choices[i],
roster_contact_autocomplete);
@@ -2984,3 +2989,21 @@ _account_autocomplete(char *input, int *size)
found = autocomplete_param_with_ac(input, size, "/account", account_ac, TRUE);
return found;
}
+
+static char *
+_strip_quotes_from_names(char *input, int *size) {
+ // Remove starting quote if it exists
+ if(strchr(input, '"') != NULL) {
+ if(strchr(input, ' ') + 1 == strchr(input, '"')) {
+ memmove(strchr(input, '"'), strchr(input, '"')+1, strchr(input, '\0') - strchr(input, '"'));
+ }
+ }
+
+ // Remove ending quote if it exists
+ if(strchr(input, '"') != NULL) {
+ if(strchr(input, '\0') - 1 == strchr(input, '"')) {
+ memmove(strchr(input, '"'), strchr(input, '"')+1, strchr(input, '\0') - strchr(input, '"'));
+ }
+ }
+ return input;
+}
From 89260280d13b8ae7166913affa5f973f260c8b7c Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 17 Jan 2015 22:03:22 +0000
Subject: [PATCH 002/252] Fix backspace for utf8 wide chars
---
src/ui/inputwin.c | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 85ddc79a..5279de7c 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -588,29 +588,21 @@ _handle_edit(int key_type, const wint_t ch)
static void
_handle_backspace(void)
{
- int inp_x = getcurx(inp_win);
+ int col = getcurx(inp_win);
int display_size = utf8_display_len(input);
+ int input_len_utf8 = g_utf8_strlen(input, -1);
roster_reset_search_attempts();
+
if (display_size > 0) {
-
// if at end, delete last char
- if (inp_x >= display_size) {
- gchar *start = g_utf8_substring(input, 0, inp_x-1);
- for (input_len_bytes = 0; input_len_bytes < strlen(start); input_len_bytes++) {
- input[input_len_bytes] = start[input_len_bytes];
- }
- input[input_len_bytes] = '\0';
-
- g_free(start);
-
- _clear_input();
- waddstr(inp_win, input);
- wmove(inp_win, 0, inp_x -1);
+ if (col >= display_size) {
+ gchar *new_input = g_utf8_substring(input, 0, input_len_utf8-1);
+ inp_replace_input(new_input);
// if in middle, delete and shift chars left
- } else if (inp_x > 0 && inp_x < display_size) {
- gchar *start = g_utf8_substring(input, 0, inp_x - 1);
- gchar *end = g_utf8_substring(input, inp_x, input_len_bytes);
+ } else if (col > 0 && col < display_size) {
+ gchar *start = g_utf8_substring(input, 0, col - 1);
+ gchar *end = g_utf8_substring(input, col, input_len_bytes);
GString *new = g_string_new(start);
g_string_append(new, end);
@@ -625,11 +617,11 @@ _handle_backspace(void)
_clear_input();
waddstr(inp_win, input);
- wmove(inp_win, 0, inp_x -1);
+ wmove(inp_win, 0, col -1);
}
// if gone off screen to left, jump left (half a screen worth)
- if (inp_x <= pad_start) {
+ if (col <= pad_start) {
pad_start = pad_start - (cols / 2);
if (pad_start < 0) {
pad_start = 0;
From 8954adc62019cd4147c0c05cb183326ee25ad546 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 18 Jan 2015 19:55:48 +0000
Subject: [PATCH 003/252] Handle wide chars for arrow keys and backspace
---
src/ui/inputwin.c | 350 ++++++++++++++++++++++++++--------------------
1 file changed, 199 insertions(+), 151 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 5279de7c..a482e292 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -61,7 +61,7 @@
#include "ui/windows.h"
#include "xmpp/xmpp.h"
-#define _inp_win_update_virtual() pnoutrefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1)
+#define _inp_win_update_virtual() pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-1)
#define KEY_CTRL_A 0001
#define KEY_CTRL_B 0002
@@ -79,11 +79,12 @@
static WINDOW *inp_win;
static History history;
-static char input[INP_WIN_MAX];
-static int input_len_bytes;
+static char line[INP_WIN_MAX];
+static int line_bytes_len;
+static int line_utf8_pos;
static int pad_start = 0;
-static int rows, cols;
+static int wrows, wcols;
static int _handle_edit(int key_type, const wint_t ch);
static int _handle_alt_key(int key);
@@ -101,25 +102,27 @@ create_input_window(void)
#else
ESCDELAY = 25;
#endif
- getmaxyx(stdscr, rows, cols);
+ getmaxyx(stdscr, wrows, wcols);
inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
keypad(inp_win, TRUE);
wmove(inp_win, 0, 0);
_inp_win_update_virtual();
history = history_new(MAX_HISTORY);
+ line_bytes_len = 0;
+ line_utf8_pos = 0;
}
void
inp_win_resize(void)
{
int inp_x;
- getmaxyx(stdscr, rows, cols);
+ getmaxyx(stdscr, wrows, wcols);
inp_x = getcurx(inp_win);
// if lost cursor off screen, move contents to show it
- if (inp_x >= pad_start + cols) {
- pad_start = inp_x - (cols / 2);
+ if (inp_x >= pad_start + wcols) {
+ pad_start = inp_x - (wcols / 2);
if (pad_start < 0) {
pad_start = 0;
}
@@ -144,15 +147,14 @@ inp_block(void)
char *
inp_read(int *key_type, wint_t *ch)
{
- int display_size = utf8_display_len(input);
-
// echo off, and get some more input
noecho();
*key_type = wget_wch(inp_win, ch);
+ int display_len = utf8_display_len(line);
gboolean in_command = FALSE;
- if ((display_size > 0 && input[0] == '/') ||
- (display_size == 0 && *ch == '/')) {
+ if ((display_len > 0 && line[0] == '/') ||
+ (display_len == 0 && *ch == '/')) {
in_command = TRUE;
}
@@ -166,59 +168,71 @@ inp_read(int *key_type, wint_t *ch)
// if it wasn't an arrow key etc
if (!_handle_edit(*key_type, *ch)) {
if (_printable(*ch) && *key_type != KEY_CODE_YES) {
- if (input_len_bytes >= INP_WIN_MAX) {
+ if (line_bytes_len >= INP_WIN_MAX) {
*ch = ERR;
return NULL;
}
- int inp_x = getcurx(inp_win);
+ int col = getcurx(inp_win);
+ int utf8_len = g_utf8_strlen(line, -1);
// handle insert if not at end of input
- if (inp_x < display_size) {
+ if (line_utf8_pos < utf8_len) {
char bytes[MB_CUR_MAX];
- size_t utf_len = wcrtomb(bytes, *ch, NULL);
+ size_t utf8_ch_len = wcrtomb(bytes, *ch, NULL);
+ bytes[utf8_ch_len] = '\0';
- char *next_ch = g_utf8_offset_to_pointer(input, inp_x);
- char *offset;
- for (offset = &input[input_len_bytes - 1]; offset >= next_ch; offset--) {
- *(offset + utf_len) = *offset;
- }
- int i;
- for (i = 0; i < utf_len; i++) {
- *(next_ch + i) = bytes[i];
- }
+ gchar *start = g_utf8_substring(line, 0, line_utf8_pos);
+ gchar *end = g_utf8_substring(line, line_utf8_pos, utf8_len);
+ GString *new_line = g_string_new(start);
+ g_string_append(new_line, bytes);
+ g_string_append(new_line, end);
- input_len_bytes += utf_len;
- input[input_len_bytes] = '\0';
- waddstr(inp_win, next_ch);
- wmove(inp_win, 0, inp_x + 1);
+ int old_pos = line_utf8_pos;
+ inp_replace_input(new_line->str);
+ line_utf8_pos = old_pos+1;
- if (inp_x - pad_start > cols-3) {
- pad_start++;
- _inp_win_update_virtual();
+ g_free(start);
+ g_free(end);
+ g_string_free(new_line, TRUE);
+
+ col++;
+ gunichar uni = g_utf8_get_char(bytes);
+ if (g_unichar_iswide(uni)) {
+ col++;
}
+ wmove(inp_win, 0, col);
// otherwise just append
} else {
+ int display_len = utf8_display_len(line);
char bytes[MB_CUR_MAX+1];
- size_t utf_len = wcrtomb(bytes, *ch, NULL);
+ size_t utf8_ch_len = wcrtomb(bytes, *ch, NULL);
// wcrtomb can return (size_t) -1
- if (utf_len < MB_CUR_MAX) {
+ if (utf8_ch_len < MB_CUR_MAX) {
int i;
- for (i = 0 ; i < utf_len; i++) {
- input[input_len_bytes++] = bytes[i];
+ for (i = 0 ; i < utf8_ch_len; i++) {
+ line[line_bytes_len++] = bytes[i];
}
- input[input_len_bytes] = '\0';
+ line[line_bytes_len] = '\0';
- bytes[utf_len] = '\0';
+ bytes[utf8_ch_len] = '\0';
waddstr(inp_win, bytes);
- display_size++;
+
+ line_utf8_pos++;
+
+ col++;
+ gunichar uni = g_utf8_get_char(bytes);
+ if (g_unichar_iswide(uni)) {
+ col++;
+ }
+ wmove(inp_win, 0, col);
// if gone over screen size follow input
- int rows, cols;
- getmaxyx(stdscr, rows, cols);
- if (display_size - pad_start > cols-2) {
+ int wrows, wcols;
+ getmaxyx(stdscr, wrows, wcols);
+ if (display_len - pad_start > wcols-2) {
pad_start++;
_inp_win_update_virtual();
}
@@ -231,13 +245,22 @@ inp_read(int *key_type, wint_t *ch)
echo();
+ char *result = NULL;
if (*ch == '\n') {
- input[input_len_bytes] = '\0';
- input_len_bytes = 0;
- return strdup(input);
- } else {
- return NULL;
+ line[line_bytes_len] = '\0';
+ result = strdup(line);
+ line[0] = '\0';
+ line_bytes_len = 0;
+ line_utf8_pos = 0;
}
+
+ if (*ch != ERR && *key_type != ERR) {
+ cons_debug("CURR COL = %d", getcurx(inp_win));
+ cons_debug("CURR UNI = %d", line_utf8_pos);
+ cons_debug("");
+ }
+
+ return result;
}
void
@@ -262,11 +285,11 @@ inp_put_back(void)
void
inp_replace_input(const char * const new_input)
{
- strncpy(input, new_input, INP_WIN_MAX);
- input_len_bytes = strlen(input);
+ strncpy(line, new_input, INP_WIN_MAX);
+ line_bytes_len = strlen(line);
inp_win_reset();
- input[input_len_bytes] = '\0';
- waddstr(inp_win, input);
+ waddstr(inp_win, line);
+
_go_to_end();
}
@@ -301,15 +324,16 @@ _handle_edit(int key_type, const wint_t ch)
{
char *prev = NULL;
char *next = NULL;
- int inp_x = getcurx(inp_win);
+ int col = getcurx(inp_win);
int next_ch;
- int display_size = utf8_display_len(input);
+ int display_size = utf8_display_len(line);
+ int utf8_len = g_utf8_strlen(line, -1);
// CTRL-LEFT
- if ((key_type == KEY_CODE_YES) && (ch == 547 || ch == 545 || ch == 544 || ch == 540 || ch == 539) && (inp_x > 0)) {
- input[input_len_bytes] = '\0';
- gchar *curr_ch = g_utf8_offset_to_pointer(input, inp_x);
- curr_ch = g_utf8_find_prev_char(input, curr_ch);
+ if ((key_type == KEY_CODE_YES) && (ch == 547 || ch == 545 || ch == 544 || ch == 540 || ch == 539) && (col > 0)) {
+ line[line_bytes_len] = '\0';
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, col);
+ curr_ch = g_utf8_find_prev_char(line, curr_ch);
gchar *prev_ch;
gunichar curr_uni;
gunichar prev_uni;
@@ -318,9 +342,9 @@ _handle_edit(int key_type, const wint_t ch)
curr_uni = g_utf8_get_char(curr_ch);
if (g_unichar_isspace(curr_uni)) {
- curr_ch = g_utf8_find_prev_char(input, curr_ch);
+ curr_ch = g_utf8_find_prev_char(line, curr_ch);
} else {
- prev_ch = g_utf8_find_prev_char(input, curr_ch);
+ prev_ch = g_utf8_find_prev_char(line, curr_ch);
if (prev_ch == NULL) {
curr_ch = NULL;
break;
@@ -336,17 +360,17 @@ _handle_edit(int key_type, const wint_t ch)
}
if (curr_ch == NULL) {
- inp_x = 0;
- wmove(inp_win, 0, inp_x);
+ col = 0;
+ wmove(inp_win, 0, col);
} else {
- glong offset = g_utf8_pointer_to_offset(input, curr_ch);
- inp_x = offset;
- wmove(inp_win, 0, inp_x);
+ glong offset = g_utf8_pointer_to_offset(line, curr_ch);
+ col = offset;
+ wmove(inp_win, 0, col);
}
// if gone off screen to left, jump left (half a screen worth)
- if (inp_x <= pad_start) {
- pad_start = pad_start - (cols / 2);
+ if (col <= pad_start) {
+ pad_start = pad_start - (wcols / 2);
if (pad_start < 0) {
pad_start = 0;
}
@@ -356,15 +380,15 @@ _handle_edit(int key_type, const wint_t ch)
return 1;
// CTRL-RIGHT
- } else if ((key_type == KEY_CODE_YES) && (ch == 562 || ch == 560 || ch == 555 || ch == 559 || ch == 554) && (inp_x < display_size)) {
- input[input_len_bytes] = '\0';
- gchar *curr_ch = g_utf8_offset_to_pointer(input, inp_x);
+ } else if ((key_type == KEY_CODE_YES) && (ch == 562 || ch == 560 || ch == 555 || ch == 559 || ch == 554) && (col < display_size)) {
+ line[line_bytes_len] = '\0';
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, col);
gchar *next_ch = g_utf8_find_next_char(curr_ch, NULL);
gunichar curr_uni;
gunichar next_uni;
gboolean moved = FALSE;
- while (g_utf8_pointer_to_offset(input, next_ch) < display_size) {
+ while (g_utf8_pointer_to_offset(line, next_ch) < display_size) {
curr_uni = g_utf8_get_char(curr_ch);
next_uni = g_utf8_get_char(next_ch);
curr_ch = next_ch;
@@ -378,21 +402,21 @@ _handle_edit(int key_type, const wint_t ch)
}
if (next_ch == NULL) {
- inp_x = display_size;
- wmove(inp_win, 0, inp_x);
+ col = display_size;
+ wmove(inp_win, 0, col);
} else {
- glong offset = g_utf8_pointer_to_offset(input, curr_ch);
+ glong offset = g_utf8_pointer_to_offset(line, curr_ch);
if (offset == display_size - 1) {
- inp_x = offset + 1;
+ col = offset + 1;
} else {
- inp_x = offset;
+ col = offset;
}
- wmove(inp_win, 0, inp_x);
+ wmove(inp_win, 0, col);
}
// if gone off screen to right, jump right (half a screen worth)
- if (inp_x > pad_start + cols) {
- pad_start = pad_start + (cols / 2);
+ if (col > pad_start + wcols) {
+ pad_start = pad_start + (wcols / 2);
_inp_win_update_virtual();
}
@@ -418,7 +442,7 @@ _handle_edit(int key_type, const wint_t ch)
if (next_ch != ERR) {
return _handle_alt_key(next_ch);
} else {
- input_len_bytes = 0;
+ line_bytes_len = 0;
inp_win_reset();
return 1;
}
@@ -438,35 +462,35 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_D:
- if (inp_x == display_size-1) {
- gchar *start = g_utf8_substring(input, 0, inp_x);
- for (input_len_bytes = 0; input_len_bytes < strlen(start); input_len_bytes++) {
- input[input_len_bytes] = start[input_len_bytes];
+ if (col == display_size-1) {
+ gchar *start = g_utf8_substring(line, 0, col);
+ for (line_bytes_len = 0; line_bytes_len < strlen(start); line_bytes_len++) {
+ line[line_bytes_len] = start[line_bytes_len];
}
- input[input_len_bytes] = '\0';
+ line[line_bytes_len] = '\0';
g_free(start);
_clear_input();
- waddstr(inp_win, input);
- } else if (inp_x < display_size-1) {
- gchar *start = g_utf8_substring(input, 0, inp_x);
- gchar *end = g_utf8_substring(input, inp_x+1, input_len_bytes);
+ waddstr(inp_win, line);
+ } else if (col < display_size-1) {
+ gchar *start = g_utf8_substring(line, 0, col);
+ gchar *end = g_utf8_substring(line, col+1, line_bytes_len);
GString *new = g_string_new(start);
g_string_append(new, end);
- for (input_len_bytes = 0; input_len_bytes < strlen(new->str); input_len_bytes++) {
- input[input_len_bytes] = new->str[input_len_bytes];
+ for (line_bytes_len = 0; line_bytes_len < strlen(new->str); line_bytes_len++) {
+ line[line_bytes_len] = new->str[line_bytes_len];
}
- input[input_len_bytes] = '\0';
+ line[line_bytes_len] = '\0';
g_free(start);
g_free(end);
g_string_free(new, FALSE);
_clear_input();
- waddstr(inp_win, input);
- wmove(inp_win, 0, inp_x);
+ waddstr(inp_win, line);
+ wmove(inp_win, 0, col);
}
return 1;
@@ -475,11 +499,21 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_B:
- if (inp_x > 0) {
- wmove(inp_win, 0, inp_x-1);
+ if (line_utf8_pos > 0) {
+ col--;
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
+ gchar *prev_ch = g_utf8_find_prev_char(line, curr_ch);
+ if (prev_ch) {
+ gunichar uni = g_utf8_get_char(prev_ch);
+ if (g_unichar_iswide(uni)) {
+ col--;
+ }
+ }
+ wmove(inp_win, 0, col);
+ line_utf8_pos--;
// current position off screen to left
- if (inp_x - 1 < pad_start) {
+ if (col - 1 < pad_start) {
pad_start--;
_inp_win_update_virtual();
}
@@ -491,11 +525,20 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_F:
- if (inp_x < display_size) {
- wmove(inp_win, 0, inp_x+1);
+ if (line_utf8_pos < utf8_len) {
+ col++;
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
+ if (curr_ch) {
+ gunichar uni = g_utf8_get_char(curr_ch);
+ if (g_unichar_iswide(uni)) {
+ col++;
+ }
+ }
+ wmove(inp_win, 0, col);
+ line_utf8_pos++;
// current position off screen to right
- if ((inp_x + 1 - pad_start) >= cols) {
+ if ((col + 1 - pad_start) >= wcols) {
pad_start++;
_inp_win_update_virtual();
}
@@ -507,8 +550,8 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_P:
- input[input_len_bytes] = '\0';
- prev = history_previous(history, input);
+ line[line_bytes_len] = '\0';
+ prev = history_previous(history, line);
if (prev) {
inp_replace_input(prev);
}
@@ -519,13 +562,13 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_N:
- input[input_len_bytes] = '\0';
- next = history_next(history, input);
+ line[line_bytes_len] = '\0';
+ next = history_next(history, line);
if (next) {
inp_replace_input(next);
- } else if (input_len_bytes != 0) {
- input[input_len_bytes] = '\0';
- history_append(history, input);
+ } else if (line_bytes_len != 0) {
+ line[line_bytes_len] = '\0';
+ history_append(history, line);
inp_replace_input("");
}
return 1;
@@ -549,16 +592,16 @@ _handle_edit(int key_type, const wint_t ch)
return 1;
case 9: // tab
- if (input_len_bytes != 0) {
- input[input_len_bytes] = '\0';
- if ((strncmp(input, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
- char *result = muc_autocomplete(input);
+ if (line_bytes_len != 0) {
+ line[line_bytes_len] = '\0';
+ if ((strncmp(line, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
+ char *result = muc_autocomplete(line);
if (result) {
inp_replace_input(result);
free(result);
}
- } else if (strncmp(input, "/", 1) == 0) {
- char *result = cmd_autocomplete(input);
+ } else if (strncmp(line, "/", 1) == 0) {
+ char *result = cmd_autocomplete(line);
if (result) {
inp_replace_input(result);
free(result);
@@ -589,40 +632,44 @@ static void
_handle_backspace(void)
{
int col = getcurx(inp_win);
- int display_size = utf8_display_len(input);
- int input_len_utf8 = g_utf8_strlen(input, -1);
+ int utf8_len = g_utf8_strlen(line, -1);
roster_reset_search_attempts();
- if (display_size > 0) {
+ if (utf8_len > 0) {
// if at end, delete last char
- if (col >= display_size) {
- gchar *new_input = g_utf8_substring(input, 0, input_len_utf8-1);
- inp_replace_input(new_input);
+ if (line_utf8_pos >= utf8_len) {
+ gchar *new_line = g_utf8_substring(line, 0, utf8_len-1);
+ inp_replace_input(new_line);
// if in middle, delete and shift chars left
- } else if (col > 0 && col < display_size) {
- gchar *start = g_utf8_substring(input, 0, col - 1);
- gchar *end = g_utf8_substring(input, col, input_len_bytes);
- GString *new = g_string_new(start);
- g_string_append(new, end);
+ } else if (line_utf8_pos > 0 && line_utf8_pos < utf8_len) {
+ gchar *del_char = g_utf8_offset_to_pointer(line, line_utf8_pos-1);
+ gunichar uni = g_utf8_get_char(del_char);
- for (input_len_bytes = 0; input_len_bytes < strlen(new->str); input_len_bytes++) {
- input[input_len_bytes] = new->str[input_len_bytes];
- }
- input[input_len_bytes] = '\0';
+ gchar *start = g_utf8_substring(line, 0, line_utf8_pos-1);
+ gchar *end = g_utf8_substring(line, line_utf8_pos, utf8_len);
+ GString *new_line = g_string_new(start);
+ g_string_append(new_line, end);
+
+ int old_pos = line_utf8_pos;
+ inp_replace_input(new_line->str);
+ line_utf8_pos = old_pos-1;
g_free(start);
g_free(end);
- g_string_free(new, FALSE);
+ g_string_free(new_line, TRUE);
- _clear_input();
- waddstr(inp_win, input);
- wmove(inp_win, 0, col -1);
+ col--;
+ if (g_unichar_iswide(uni)) {
+ col--;
+ }
+
+ wmove(inp_win, 0, col);
}
// if gone off screen to left, jump left (half a screen worth)
if (col <= pad_start) {
- pad_start = pad_start - (cols / 2);
+ pad_start = pad_start - (wcols / 2);
if (pad_start < 0) {
pad_start = 0;
}
@@ -690,9 +737,9 @@ _delete_previous_word(void)
int end_del = getcurx(inp_win);
int start_del = end_del;
- input[input_len_bytes] = '\0';
- gchar *curr_ch = g_utf8_offset_to_pointer(input, end_del);
- curr_ch = g_utf8_find_prev_char(input, curr_ch);
+ line[line_bytes_len] = '\0';
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, end_del);
+ curr_ch = g_utf8_find_prev_char(line, curr_ch);
gchar *prev_ch;
gunichar curr_uni;
gunichar prev_uni;
@@ -701,9 +748,9 @@ _delete_previous_word(void)
curr_uni = g_utf8_get_char(curr_ch);
if (g_unichar_isspace(curr_uni)) {
- curr_ch = g_utf8_find_prev_char(input, curr_ch);
+ curr_ch = g_utf8_find_prev_char(line, curr_ch);
} else {
- prev_ch = g_utf8_find_prev_char(input, curr_ch);
+ prev_ch = g_utf8_find_prev_char(line, curr_ch);
if (prev_ch == NULL) {
curr_ch = NULL;
break;
@@ -721,31 +768,31 @@ _delete_previous_word(void)
if (curr_ch == NULL) {
start_del = 0;
} else {
- start_del = g_utf8_pointer_to_offset(input, curr_ch);
+ start_del = g_utf8_pointer_to_offset(line, curr_ch);
}
- gint len = g_utf8_strlen(input, -1);
- gchar *start_string = g_utf8_substring(input, 0, start_del);
- gchar *end_string = g_utf8_substring(input, end_del, len);
+ gint len = g_utf8_strlen(line, -1);
+ gchar *start_string = g_utf8_substring(line, 0, start_del);
+ gchar *end_string = g_utf8_substring(line, end_del, len);
int i;
for (i = 0; i < strlen(start_string); i++) {
- input[i] = start_string[i];
+ line[i] = start_string[i];
}
for (i = 0; i < strlen(end_string); i++) {
- input[strlen(start_string)+i] = end_string[i];
+ line[strlen(start_string)+i] = end_string[i];
}
- input_len_bytes = strlen(start_string)+i;
- input[input_len_bytes] = '\0';
+ line_bytes_len = strlen(start_string)+i;
+ line[line_bytes_len] = '\0';
_clear_input();
- waddstr(inp_win, input);
+ waddstr(inp_win, line);
wmove(inp_win, 0, start_del);
// if gone off screen to left, jump left (half a screen worth)
if (start_del <= pad_start) {
- pad_start = pad_start - (cols / 2);
+ pad_start = pad_start - (wcols / 2);
if (pad_start < 0) {
pad_start = 0;
}
@@ -757,10 +804,11 @@ _delete_previous_word(void)
static void
_go_to_end(void)
{
- int display_size = utf8_display_len(input);
- wmove(inp_win, 0, display_size);
- if (display_size > cols-2) {
- pad_start = display_size - cols + 1;
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
}
}
From 9ecdb39433cdf5c32b6c0a02d45952ac258da44a Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 18 Jan 2015 22:55:51 +0000
Subject: [PATCH 004/252] Refactor inputwin.c
---
src/common.c | 12 +++
src/common.h | 8 ++
src/ui/inputwin.c | 226 +++++++++++++++++++++++++---------------------
3 files changed, 142 insertions(+), 104 deletions(-)
diff --git a/src/common.c b/src/common.c
index 7638da31..6c130798 100644
--- a/src/common.c
+++ b/src/common.c
@@ -224,6 +224,18 @@ utf8_display_len(const char * const str)
return len;
}
+gboolean
+utf8_is_printable(const wint_t ch)
+{
+ char bytes[MB_CUR_MAX+1];
+ size_t utf_len = wcrtomb(bytes, ch, NULL);
+ bytes[utf_len] = '\0';
+
+ gunichar unichar = g_utf8_get_char(bytes);
+
+ return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
+}
+
char *
prof_getline(FILE *stream)
{
diff --git a/src/common.h b/src/common.h
index 26d4a99a..8d35f99b 100644
--- a/src/common.h
+++ b/src/common.h
@@ -36,6 +36,13 @@
#define COMMON_H
#include
+#include
+
+#ifdef HAVE_NCURSESW_NCURSES_H
+#include
+#elif HAVE_NCURSES_H
+#include
+#endif
#include
@@ -105,6 +112,7 @@ char * str_replace(const char *string, const char *substr,
const char *replacement);
int str_contains(const char str[], int size, char ch);
int utf8_display_len(const char * const str);
+gboolean utf8_is_printable(const wint_t ch);
char * prof_getline(FILE *stream);
char* release_get_latest(void);
gboolean release_is_new(char *found_version);
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index a482e292..f91a5ef2 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -79,8 +79,9 @@
static WINDOW *inp_win;
static History history;
+// input line
static char line[INP_WIN_MAX];
-static int line_bytes_len;
+// current position in the utf8 string
static int line_utf8_pos;
static int pad_start = 0;
@@ -88,11 +89,15 @@ static int wrows, wcols;
static int _handle_edit(int key_type, const wint_t ch);
static int _handle_alt_key(int key);
+
+static void _handle_delete_previous_word(void);
static void _handle_backspace(void);
-static int _printable(const wint_t ch);
+
static void _clear_input(void);
static void _go_to_end(void);
-static void _delete_previous_word(void);
+
+static gboolean _is_ctrl_left(int key_type, const wint_t ch);
+static gboolean _is_ctrl_right(int key_type, const wint_t ch);
void
create_input_window(void)
@@ -109,20 +114,20 @@ create_input_window(void)
wmove(inp_win, 0, 0);
_inp_win_update_virtual();
history = history_new(MAX_HISTORY);
- line_bytes_len = 0;
line_utf8_pos = 0;
+ line[0] = '\0';
}
void
inp_win_resize(void)
{
- int inp_x;
+ int col;
getmaxyx(stdscr, wrows, wcols);
- inp_x = getcurx(inp_win);
+ col = getcurx(inp_win);
// if lost cursor off screen, move contents to show it
- if (inp_x >= pad_start + wcols) {
- pad_start = inp_x - (wcols / 2);
+ if (col >= pad_start + wcols) {
+ pad_start = col - (wcols / 2);
if (pad_start < 0) {
pad_start = 0;
}
@@ -151,24 +156,25 @@ inp_read(int *key_type, wint_t *ch)
noecho();
*key_type = wget_wch(inp_win, ch);
- int display_len = utf8_display_len(line);
+ int bytes_len = strlen(line);
+
gboolean in_command = FALSE;
- if ((display_len > 0 && line[0] == '/') ||
- (display_len == 0 && *ch == '/')) {
+ if ((bytes_len > 0 && line[0] == '/') ||
+ (bytes_len == 0 && *ch == '/')) {
in_command = TRUE;
}
if (*key_type == ERR) {
prof_handle_idle();
}
- if ((*key_type != ERR) && (*key_type != KEY_CODE_YES) && !in_command && _printable(*ch)) {
+ if ((*key_type != ERR) && (*key_type != KEY_CODE_YES) && !in_command && utf8_is_printable(*ch)) {
prof_handle_activity();
}
// if it wasn't an arrow key etc
if (!_handle_edit(*key_type, *ch)) {
- if (_printable(*ch) && *key_type != KEY_CODE_YES) {
- if (line_bytes_len >= INP_WIN_MAX) {
+ if (utf8_is_printable(*ch) && *key_type != KEY_CODE_YES) {
+ if (bytes_len >= INP_WIN_MAX) {
*ch = ERR;
return NULL;
}
@@ -205,7 +211,6 @@ inp_read(int *key_type, wint_t *ch)
// otherwise just append
} else {
- int display_len = utf8_display_len(line);
char bytes[MB_CUR_MAX+1];
size_t utf8_ch_len = wcrtomb(bytes, *ch, NULL);
@@ -213,9 +218,9 @@ inp_read(int *key_type, wint_t *ch)
if (utf8_ch_len < MB_CUR_MAX) {
int i;
for (i = 0 ; i < utf8_ch_len; i++) {
- line[line_bytes_len++] = bytes[i];
+ line[bytes_len++] = bytes[i];
}
- line[line_bytes_len] = '\0';
+ line[bytes_len] = '\0';
bytes[utf8_ch_len] = '\0';
waddstr(inp_win, bytes);
@@ -232,7 +237,7 @@ inp_read(int *key_type, wint_t *ch)
// if gone over screen size follow input
int wrows, wcols;
getmaxyx(stdscr, wrows, wcols);
- if (display_len - pad_start > wcols-2) {
+ if (col - pad_start > wcols-2) {
pad_start++;
_inp_win_update_virtual();
}
@@ -247,14 +252,14 @@ inp_read(int *key_type, wint_t *ch)
char *result = NULL;
if (*ch == '\n') {
- line[line_bytes_len] = '\0';
result = strdup(line);
line[0] = '\0';
- line_bytes_len = 0;
line_utf8_pos = 0;
}
if (*ch != ERR && *key_type != ERR) {
+ cons_debug("BYTE LEN = %d", bytes_len);
+ cons_debug("UTF8 LEN = %d", utf8_display_len(line));
cons_debug("CURR COL = %d", getcurx(inp_win));
cons_debug("CURR UNI = %d", line_utf8_pos);
cons_debug("");
@@ -285,11 +290,9 @@ inp_put_back(void)
void
inp_replace_input(const char * const new_input)
{
+ _clear_input();
strncpy(line, new_input, INP_WIN_MAX);
- line_bytes_len = strlen(line);
- inp_win_reset();
waddstr(inp_win, line);
-
_go_to_end();
}
@@ -297,7 +300,6 @@ void
inp_win_reset(void)
{
_clear_input();
- pad_start = 0;
_inp_win_update_virtual();
}
@@ -312,6 +314,10 @@ _clear_input(void)
{
werase(inp_win);
wmove(inp_win, 0, 0);
+ pad_start = 0;
+
+ line[0] = '\0';
+ line_utf8_pos = 0;
}
/*
@@ -322,27 +328,29 @@ _clear_input(void)
static int
_handle_edit(int key_type, const wint_t ch)
{
- char *prev = NULL;
- char *next = NULL;
int col = getcurx(inp_win);
- int next_ch;
- int display_size = utf8_display_len(line);
int utf8_len = g_utf8_strlen(line, -1);
// CTRL-LEFT
- if ((key_type == KEY_CODE_YES) && (ch == 547 || ch == 545 || ch == 544 || ch == 540 || ch == 539) && (col > 0)) {
- line[line_bytes_len] = '\0';
- gchar *curr_ch = g_utf8_offset_to_pointer(line, col);
- curr_ch = g_utf8_find_prev_char(line, curr_ch);
- gchar *prev_ch;
- gunichar curr_uni;
- gunichar prev_uni;
+ if (line_utf8_pos > 0 && _is_ctrl_left(key_type, ch)) {
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
+ gunichar curr_uni = g_utf8_get_char(curr_ch);
+ line_utf8_pos--;
+ col--;
+ if (g_unichar_iswide(curr_uni)) {
+ col--;
+ }
+ curr_ch = g_utf8_find_prev_char(line, curr_ch);
+
+ gchar *prev_ch;
+ gunichar prev_uni;
while (curr_ch != NULL) {
curr_uni = g_utf8_get_char(curr_ch);
-
if (g_unichar_isspace(curr_uni)) {
curr_ch = g_utf8_find_prev_char(line, curr_ch);
+ line_utf8_pos--;
+ col--;
} else {
prev_ch = g_utf8_find_prev_char(line, curr_ch);
if (prev_ch == NULL) {
@@ -350,6 +358,11 @@ _handle_edit(int key_type, const wint_t ch)
break;
} else {
prev_uni = g_utf8_get_char(prev_ch);
+ line_utf8_pos--;
+ col--;
+ if (g_unichar_iswide(prev_uni)) {
+ col--;
+ }
if (g_unichar_isspace(prev_uni)) {
break;
} else {
@@ -363,8 +376,8 @@ _handle_edit(int key_type, const wint_t ch)
col = 0;
wmove(inp_win, 0, col);
} else {
- glong offset = g_utf8_pointer_to_offset(line, curr_ch);
- col = offset;
+ col++;
+ line_utf8_pos++;
wmove(inp_win, 0, col);
}
@@ -380,39 +393,37 @@ _handle_edit(int key_type, const wint_t ch)
return 1;
// CTRL-RIGHT
- } else if ((key_type == KEY_CODE_YES) && (ch == 562 || ch == 560 || ch == 555 || ch == 559 || ch == 554) && (col < display_size)) {
- line[line_bytes_len] = '\0';
- gchar *curr_ch = g_utf8_offset_to_pointer(line, col);
- gchar *next_ch = g_utf8_find_next_char(curr_ch, NULL);
- gunichar curr_uni;
- gunichar next_uni;
- gboolean moved = FALSE;
+ } else if (line_utf8_pos < utf8_len && _is_ctrl_right(key_type, ch)) {
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
+ gunichar curr_uni = g_utf8_get_char(curr_ch);
- while (g_utf8_pointer_to_offset(line, next_ch) < display_size) {
- curr_uni = g_utf8_get_char(curr_ch);
- next_uni = g_utf8_get_char(next_ch);
- curr_ch = next_ch;
- next_ch = g_utf8_find_next_char(next_ch, NULL);
-
- if (!g_unichar_isspace(curr_uni) && g_unichar_isspace(next_uni) && moved) {
+ // find next word if in whitespace
+ while (g_unichar_isspace(curr_uni)) {
+ col++;
+ line_utf8_pos++;
+ curr_ch = g_utf8_find_next_char(curr_ch, NULL);
+ if (!curr_ch) {
break;
- } else {
- moved = TRUE;
+ }
+ curr_uni = g_utf8_get_char(curr_ch);
+ }
+
+ if (curr_ch) {
+ while (!g_unichar_isspace(curr_uni)) {
+ line_utf8_pos++;
+ col++;
+ if (g_unichar_iswide(curr_uni)) {
+ col++;
+ }
+ curr_ch = g_utf8_find_next_char(curr_ch, NULL);
+ if (!curr_ch || line_utf8_pos >= utf8_len) {
+ break;
+ }
+ curr_uni = g_utf8_get_char(curr_ch);
}
}
- if (next_ch == NULL) {
- col = display_size;
- wmove(inp_win, 0, col);
- } else {
- glong offset = g_utf8_pointer_to_offset(line, curr_ch);
- if (offset == display_size - 1) {
- col = offset + 1;
- } else {
- col = offset;
- }
- wmove(inp_win, 0, col);
- }
+ wmove(inp_win, 0, col);
// if gone off screen to right, jump right (half a screen worth)
if (col > pad_start + wcols) {
@@ -434,6 +445,9 @@ _handle_edit(int key_type, const wint_t ch)
// other editing keys
} else {
+ int bytes_len = strlen(line);
+ int next_ch;
+
switch(ch) {
case 27: // ESC
@@ -442,7 +456,6 @@ _handle_edit(int key_type, const wint_t ch)
if (next_ch != ERR) {
return _handle_alt_key(next_ch);
} else {
- line_bytes_len = 0;
inp_win_reset();
return 1;
}
@@ -462,27 +475,27 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_D:
- if (col == display_size-1) {
- gchar *start = g_utf8_substring(line, 0, col);
- for (line_bytes_len = 0; line_bytes_len < strlen(start); line_bytes_len++) {
- line[line_bytes_len] = start[line_bytes_len];
- }
- line[line_bytes_len] = '\0';
+ if (line_utf8_pos == utf8_len) {
+ return 1;
+ } else if (line_utf8_pos == utf8_len-1) {
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
+ int bytes_len_ch = strlen(curr_ch);
+ bytes_len -= bytes_len_ch;
+ line[bytes_len] = '\0';
+ line_utf8_pos--;
+ wdelch(inp_win);
- g_free(start);
-
- _clear_input();
- waddstr(inp_win, line);
- } else if (col < display_size-1) {
+ return 1;
+ } else if (line_utf8_pos < utf8_len-1) {
gchar *start = g_utf8_substring(line, 0, col);
- gchar *end = g_utf8_substring(line, col+1, line_bytes_len);
+ gchar *end = g_utf8_substring(line, col+1, bytes_len);
GString *new = g_string_new(start);
g_string_append(new, end);
- for (line_bytes_len = 0; line_bytes_len < strlen(new->str); line_bytes_len++) {
- line[line_bytes_len] = new->str[line_bytes_len];
+ for (bytes_len = 0; bytes_len < strlen(new->str); bytes_len++) {
+ line[bytes_len] = new->str[bytes_len];
}
- line[line_bytes_len] = '\0';
+ line[bytes_len] = '\0';
g_free(start);
g_free(end);
@@ -550,8 +563,8 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_P:
- line[line_bytes_len] = '\0';
- prev = history_previous(history, line);
+ line[bytes_len] = '\0';
+ char *prev = history_previous(history, line);
if (prev) {
inp_replace_input(prev);
}
@@ -562,12 +575,12 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_N:
- line[line_bytes_len] = '\0';
- next = history_next(history, line);
+ line[bytes_len] = '\0';
+ char *next = history_next(history, line);
if (next) {
inp_replace_input(next);
- } else if (line_bytes_len != 0) {
- line[line_bytes_len] = '\0';
+ } else if (bytes_len != 0) {
+ line[bytes_len] = '\0';
history_append(history, line);
inp_replace_input("");
}
@@ -580,6 +593,7 @@ _handle_edit(int key_type, const wint_t ch)
case KEY_CTRL_A:
wmove(inp_win, 0, 0);
pad_start = 0;
+ line_utf8_pos = 0;
_inp_win_update_virtual();
return 1;
@@ -592,8 +606,8 @@ _handle_edit(int key_type, const wint_t ch)
return 1;
case 9: // tab
- if (line_bytes_len != 0) {
- line[line_bytes_len] = '\0';
+ if (bytes_len != 0) {
+ line[bytes_len] = '\0';
if ((strncmp(line, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
char *result = muc_autocomplete(line);
if (result) {
@@ -611,13 +625,13 @@ _handle_edit(int key_type, const wint_t ch)
return 1;
case KEY_CTRL_W:
- _delete_previous_word();
+ _handle_delete_previous_word();
return 1;
break;
case KEY_CTRL_U:
while (getcurx(inp_win) > 0) {
- _delete_previous_word();
+ _handle_delete_previous_word();
}
return 1;
break;
@@ -723,7 +737,7 @@ _handle_alt_key(int key)
break;
case 263:
case 127:
- _delete_previous_word();
+ _handle_delete_previous_word();
break;
default:
break;
@@ -732,12 +746,11 @@ _handle_alt_key(int key)
}
static void
-_delete_previous_word(void)
+_handle_delete_previous_word(void)
{
int end_del = getcurx(inp_win);
int start_del = end_del;
- line[line_bytes_len] = '\0';
gchar *curr_ch = g_utf8_offset_to_pointer(line, end_del);
curr_ch = g_utf8_find_prev_char(line, curr_ch);
gchar *prev_ch;
@@ -783,8 +796,8 @@ _delete_previous_word(void)
line[strlen(start_string)+i] = end_string[i];
}
- line_bytes_len = strlen(start_string)+i;
- line[line_bytes_len] = '\0';
+ int bytes_len = strlen(start_string)+i;
+ line[bytes_len] = '\0';
_clear_input();
waddstr(inp_win, line);
@@ -807,18 +820,23 @@ _go_to_end(void)
int display_len = utf8_display_len(line);
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
}
}
-static int
-_printable(const wint_t ch)
+static gboolean
+_is_ctrl_left(int key_type, const wint_t ch)
{
- char bytes[MB_CUR_MAX+1];
- size_t utf_len = wcrtomb(bytes, ch, NULL);
- bytes[utf_len] = '\0';
- gunichar unichar = g_utf8_get_char(bytes);
- return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
+ return ((key_type == KEY_CODE_YES)
+ && (ch == 547 || ch == 545 || ch == 544 || ch == 540 || ch == 539));
}
+
+static gboolean
+_is_ctrl_right(int key_type, const wint_t ch)
+{
+ return ((key_type == KEY_CODE_YES)
+ && (ch == 562 || ch == 560 || ch == 555 || ch == 559 || ch == 554));
+}
\ No newline at end of file
From 0e8092afef2e6172fc1fc27cd5a7e4f216456095 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 19 Jan 2015 20:51:41 +0000
Subject: [PATCH 005/252] Inlined static functions in inputwin
---
src/ui/inputwin.c | 211 +++++++++++++++++++++++++++++++++++-----------
src/ui/inputwin.h | 1 -
2 files changed, 162 insertions(+), 50 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index f91a5ef2..dba2f9d5 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -93,9 +93,6 @@ static int _handle_alt_key(int key);
static void _handle_delete_previous_word(void);
static void _handle_backspace(void);
-static void _clear_input(void);
-static void _go_to_end(void);
-
static gboolean _is_ctrl_left(int key_type, const wint_t ch);
static gboolean _is_ctrl_right(int key_type, const wint_t ch);
@@ -195,7 +192,23 @@ inp_read(int *key_type, wint_t *ch)
g_string_append(new_line, end);
int old_pos = line_utf8_pos;
- inp_replace_input(new_line->str);
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ strncpy(line, new_line->str, INP_WIN_MAX);
+ waddstr(inp_win, line);
+
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
+
line_utf8_pos = old_pos+1;
g_free(start);
@@ -271,7 +284,11 @@ inp_read(int *key_type, wint_t *ch)
void
inp_get_password(char *passwd)
{
- _clear_input();
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
_inp_win_update_virtual();
doupdate();
noecho();
@@ -287,19 +304,14 @@ inp_put_back(void)
_inp_win_update_virtual();
}
-void
-inp_replace_input(const char * const new_input)
-{
- _clear_input();
- strncpy(line, new_input, INP_WIN_MAX);
- waddstr(inp_win, line);
- _go_to_end();
-}
-
void
inp_win_reset(void)
{
- _clear_input();
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
_inp_win_update_virtual();
}
@@ -309,17 +321,6 @@ inp_history_append(char *inp)
history_append(history, inp);
}
-static void
-_clear_input(void)
-{
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
-
- line[0] = '\0';
- line_utf8_pos = 0;
-}
-
/*
* Deal with command editing, return 1 if ch was an edit
* key press: up, down, left, right or backspace
@@ -445,6 +446,7 @@ _handle_edit(int key_type, const wint_t ch)
// other editing keys
} else {
+ int display_len;
int bytes_len = strlen(line);
int next_ch;
@@ -501,7 +503,11 @@ _handle_edit(int key_type, const wint_t ch)
g_free(end);
g_string_free(new, FALSE);
- _clear_input();
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
waddstr(inp_win, line);
wmove(inp_win, 0, col);
}
@@ -566,7 +572,22 @@ _handle_edit(int key_type, const wint_t ch)
line[bytes_len] = '\0';
char *prev = history_previous(history, line);
if (prev) {
- inp_replace_input(prev);
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ strncpy(line, prev, INP_WIN_MAX);
+ waddstr(inp_win, line);
+
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
}
return 1;
@@ -578,11 +599,41 @@ _handle_edit(int key_type, const wint_t ch)
line[bytes_len] = '\0';
char *next = history_next(history, line);
if (next) {
- inp_replace_input(next);
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ strncpy(line, next, INP_WIN_MAX);
+ waddstr(inp_win, line);
+
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
} else if (bytes_len != 0) {
line[bytes_len] = '\0';
history_append(history, line);
- inp_replace_input("");
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ strncpy(line, "", INP_WIN_MAX);
+ waddstr(inp_win, line);
+
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
}
return 1;
@@ -602,7 +653,14 @@ _handle_edit(int key_type, const wint_t ch)
return 0;
}
case KEY_CTRL_E:
- _go_to_end();
+ display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
return 1;
case 9: // tab
@@ -611,13 +669,45 @@ _handle_edit(int key_type, const wint_t ch)
if ((strncmp(line, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
char *result = muc_autocomplete(line);
if (result) {
- inp_replace_input(result);
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ strncpy(line, result, INP_WIN_MAX);
+ waddstr(inp_win, line);
+
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
+
free(result);
}
} else if (strncmp(line, "/", 1) == 0) {
char *result = cmd_autocomplete(line);
if (result) {
- inp_replace_input(result);
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ strncpy(line, result, INP_WIN_MAX);
+ waddstr(inp_win, line);
+
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
+
free(result);
}
}
@@ -653,7 +743,22 @@ _handle_backspace(void)
// if at end, delete last char
if (line_utf8_pos >= utf8_len) {
gchar *new_line = g_utf8_substring(line, 0, utf8_len-1);
- inp_replace_input(new_line);
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ strncpy(line, new_line, INP_WIN_MAX);
+ waddstr(inp_win, line);
+
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
// if in middle, delete and shift chars left
} else if (line_utf8_pos > 0 && line_utf8_pos < utf8_len) {
@@ -666,7 +771,23 @@ _handle_backspace(void)
g_string_append(new_line, end);
int old_pos = line_utf8_pos;
- inp_replace_input(new_line->str);
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ strncpy(line, new_line->str, INP_WIN_MAX);
+ waddstr(inp_win, line);
+
+ int display_len = utf8_display_len(line);
+ wmove(inp_win, 0, display_len);
+ line_utf8_pos = g_utf8_strlen(line, -1);
+
+ if (display_len > wcols-2) {
+ pad_start = display_len - wcols + 1;
+ _inp_win_update_virtual();
+ }
+
line_utf8_pos = old_pos-1;
g_free(start);
@@ -799,7 +920,12 @@ _handle_delete_previous_word(void)
int bytes_len = strlen(start_string)+i;
line[bytes_len] = '\0';
- _clear_input();
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+
waddstr(inp_win, line);
wmove(inp_win, 0, start_del);
@@ -814,19 +940,6 @@ _handle_delete_previous_word(void)
}
}
-static void
-_go_to_end(void)
-{
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
-}
-
static gboolean
_is_ctrl_left(int key_type, const wint_t ch)
{
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index 39fde720..ecca4d5b 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -43,7 +43,6 @@ void inp_put_back(void);
void inp_non_block(gint);
void inp_block(void);
void inp_get_password(char *passwd);
-void inp_replace_input(const char * const new_input);
void inp_history_append(char *inp);
#endif
From 2ed78fe5afaa0197de65a0edbf2423b5d7fe9792 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 20 Jan 2015 00:09:47 +0000
Subject: [PATCH 006/252] Extracted keyhandler for printable characters
---
Makefile.am | 3 +
src/ui/core.c | 2 +-
src/ui/inputwin.c | 129 +++++++++++----------------------
src/ui/inputwin.h | 6 +-
src/ui/keyhandlers.c | 123 ++++++++++++++++++++++++++++++++
src/ui/keyhandlers.h | 42 +++++++++++
tests/test_keyhandlers.c | 150 +++++++++++++++++++++++++++++++++++++++
tests/test_keyhandlers.h | 11 +++
tests/testsuite.c | 10 +++
9 files changed, 385 insertions(+), 91 deletions(-)
create mode 100644 src/ui/keyhandlers.c
create mode 100644 src/ui/keyhandlers.h
create mode 100644 tests/test_keyhandlers.c
create mode 100644 tests/test_keyhandlers.h
diff --git a/Makefile.am b/Makefile.am
index d9fa9729..abd1a1ff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@ core_sources = \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
src/ui/console.c src/ui/notifier.c \
src/ui/windows.c src/ui/windows.h \
+ src/ui/keyhandlers.c src/ui/keyhandlers.h \
src/ui/rosterwin.c src/ui/occupantswin.c \
src/ui/buffer.c src/ui/buffer.h \
src/command/command.h src/command/command.c \
@@ -58,6 +59,7 @@ tests_sources = \
src/config/theme.c src/config/theme.h \
src/ui/windows.c src/ui/windows.h \
src/ui/window.c src/ui/window.h \
+ src/ui/keyhandlers.c src/ui/keyhandlers.h \
src/ui/buffer.c \
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
@@ -92,6 +94,7 @@ tests_sources = \
tests/test_server_events.c tests/test_server_events.h \
tests/test_autocomplete.c tests/test_autocomplete.h \
tests/test_chat_session.c tests/test_chat_session.h \
+ tests/test_keyhandlers.c tests/test_keyhandlers.h \
tests/testsuite.c
main_source = src/main.c
diff --git a/src/ui/core.c b/src/ui/core.c
index 14ea2c17..e295a3ad 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -212,7 +212,7 @@ ui_inp_history_append(char *inp)
void
ui_input_clear(void)
{
- inp_win_reset();
+ inp_win_clear();
}
void
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index dba2f9d5..59292482 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -60,8 +60,7 @@
#include "ui/inputwin.h"
#include "ui/windows.h"
#include "xmpp/xmpp.h"
-
-#define _inp_win_update_virtual() pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-1)
+#include "ui/keyhandlers.h"
#define KEY_CTRL_A 0001
#define KEY_CTRL_B 0002
@@ -74,7 +73,6 @@
#define KEY_CTRL_W 0027
#define MAX_HISTORY 100
-#define INP_WIN_MAX 1000
static WINDOW *inp_win;
static History history;
@@ -85,7 +83,6 @@ static char line[INP_WIN_MAX];
static int line_utf8_pos;
static int pad_start = 0;
-static int wrows, wcols;
static int _handle_edit(int key_type, const wint_t ch);
static int _handle_alt_key(int key);
@@ -96,6 +93,8 @@ static void _handle_backspace(void);
static gboolean _is_ctrl_left(int key_type, const wint_t ch);
static gboolean _is_ctrl_right(int key_type, const wint_t ch);
+static void _inp_win_update_virtual(void);
+
void
create_input_window(void)
{
@@ -104,7 +103,6 @@ create_input_window(void)
#else
ESCDELAY = 25;
#endif
- getmaxyx(stdscr, wrows, wcols);
inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
keypad(inp_win, TRUE);
@@ -118,9 +116,8 @@ create_input_window(void)
void
inp_win_resize(void)
{
- int col;
- getmaxyx(stdscr, wrows, wcols);
- col = getcurx(inp_win);
+ int col = getcurx(inp_win);
+ int wcols = getmaxx(stdscr);
// if lost cursor off screen, move contents to show it
if (col >= pad_start + wcols) {
@@ -177,85 +174,13 @@ inp_read(int *key_type, wint_t *ch)
}
int col = getcurx(inp_win);
- int utf8_len = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, *ch, wcols);
- // handle insert if not at end of input
- if (line_utf8_pos < utf8_len) {
- char bytes[MB_CUR_MAX];
- size_t utf8_ch_len = wcrtomb(bytes, *ch, NULL);
- bytes[utf8_ch_len] = '\0';
-
- gchar *start = g_utf8_substring(line, 0, line_utf8_pos);
- gchar *end = g_utf8_substring(line, line_utf8_pos, utf8_len);
- GString *new_line = g_string_new(start);
- g_string_append(new_line, bytes);
- g_string_append(new_line, end);
-
- int old_pos = line_utf8_pos;
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- strncpy(line, new_line->str, INP_WIN_MAX);
- waddstr(inp_win, line);
-
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
-
- line_utf8_pos = old_pos+1;
-
- g_free(start);
- g_free(end);
- g_string_free(new_line, TRUE);
-
- col++;
- gunichar uni = g_utf8_get_char(bytes);
- if (g_unichar_iswide(uni)) {
- col++;
- }
- wmove(inp_win, 0, col);
-
- // otherwise just append
- } else {
- char bytes[MB_CUR_MAX+1];
- size_t utf8_ch_len = wcrtomb(bytes, *ch, NULL);
-
- // wcrtomb can return (size_t) -1
- if (utf8_ch_len < MB_CUR_MAX) {
- int i;
- for (i = 0 ; i < utf8_ch_len; i++) {
- line[bytes_len++] = bytes[i];
- }
- line[bytes_len] = '\0';
-
- bytes[utf8_ch_len] = '\0';
- waddstr(inp_win, bytes);
-
- line_utf8_pos++;
-
- col++;
- gunichar uni = g_utf8_get_char(bytes);
- if (g_unichar_iswide(uni)) {
- col++;
- }
- wmove(inp_win, 0, col);
-
- // if gone over screen size follow input
- int wrows, wcols;
- getmaxyx(stdscr, wrows, wcols);
- if (col - pad_start > wcols-2) {
- pad_start++;
- _inp_win_update_virtual();
- }
- }
- }
+ werase(inp_win);
+ waddstr(inp_win, line);
+ wmove(inp_win, 0, col);
+ _inp_win_update_virtual();
cmd_reset_autocomplete();
}
@@ -271,7 +196,7 @@ inp_read(int *key_type, wint_t *ch)
}
if (*ch != ERR && *key_type != ERR) {
- cons_debug("BYTE LEN = %d", bytes_len);
+ cons_debug("BYTE LEN = %d", strlen(line));
cons_debug("UTF8 LEN = %d", utf8_display_len(line));
cons_debug("CURR COL = %d", getcurx(inp_win));
cons_debug("CURR UNI = %d", line_utf8_pos);
@@ -305,7 +230,7 @@ inp_put_back(void)
}
void
-inp_win_reset(void)
+inp_win_clear(void)
{
werase(inp_win);
wmove(inp_win, 0, 0);
@@ -383,6 +308,7 @@ _handle_edit(int key_type, const wint_t ch)
}
// if gone off screen to left, jump left (half a screen worth)
+ int wcols = getmaxx(stdscr);
if (col <= pad_start) {
pad_start = pad_start - (wcols / 2);
if (pad_start < 0) {
@@ -427,6 +353,7 @@ _handle_edit(int key_type, const wint_t ch)
wmove(inp_win, 0, col);
// if gone off screen to right, jump right (half a screen worth)
+ int wcols = getmaxx(stdscr);
if (col > pad_start + wcols) {
pad_start = pad_start + (wcols / 2);
_inp_win_update_virtual();
@@ -458,7 +385,12 @@ _handle_edit(int key_type, const wint_t ch)
if (next_ch != ERR) {
return _handle_alt_key(next_ch);
} else {
- inp_win_reset();
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ line[0] = '\0';
+ line_utf8_pos = 0;
+ _inp_win_update_virtual();
return 1;
}
@@ -557,6 +489,7 @@ _handle_edit(int key_type, const wint_t ch)
line_utf8_pos++;
// current position off screen to right
+ int wcols = getmaxx(stdscr);
if ((col + 1 - pad_start) >= wcols) {
pad_start++;
_inp_win_update_virtual();
@@ -584,6 +517,7 @@ _handle_edit(int key_type, const wint_t ch)
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
@@ -611,6 +545,7 @@ _handle_edit(int key_type, const wint_t ch)
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
@@ -630,6 +565,7 @@ _handle_edit(int key_type, const wint_t ch)
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
@@ -657,6 +593,7 @@ _handle_edit(int key_type, const wint_t ch)
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
@@ -681,6 +618,7 @@ _handle_edit(int key_type, const wint_t ch)
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
@@ -703,6 +641,7 @@ _handle_edit(int key_type, const wint_t ch)
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
@@ -755,6 +694,7 @@ _handle_backspace(void)
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
@@ -783,6 +723,7 @@ _handle_backspace(void)
wmove(inp_win, 0, display_len);
line_utf8_pos = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
if (display_len > wcols-2) {
pad_start = display_len - wcols + 1;
_inp_win_update_virtual();
@@ -804,6 +745,7 @@ _handle_backspace(void)
// if gone off screen to left, jump left (half a screen worth)
if (col <= pad_start) {
+ int wcols = getmaxx(stdscr);
pad_start = pad_start - (wcols / 2);
if (pad_start < 0) {
pad_start = 0;
@@ -931,6 +873,7 @@ _handle_delete_previous_word(void)
// if gone off screen to left, jump left (half a screen worth)
if (start_del <= pad_start) {
+ int wcols = getmaxx(stdscr);
pad_start = pad_start - (wcols / 2);
if (pad_start < 0) {
pad_start = 0;
@@ -952,4 +895,12 @@ _is_ctrl_right(int key_type, const wint_t ch)
{
return ((key_type == KEY_CODE_YES)
&& (ch == 562 || ch == 560 || ch == 555 || ch == 559 || ch == 554));
+}
+
+static void
+_inp_win_update_virtual(void)
+{
+ int wrows, wcols;
+ getmaxyx(stdscr, wrows, wcols);
+ pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-1);
}
\ No newline at end of file
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index ecca4d5b..a4de16f0 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -35,9 +35,13 @@
#ifndef UI_INPUTWIN_H
#define UI_INPUTWIN_H
+#include
+
+#define INP_WIN_MAX 1000
+
void create_input_window(void);
char* inp_read(int *key_type, wint_t *ch);
-void inp_win_reset(void);
+void inp_win_clear(void);
void inp_win_resize(void);
void inp_put_back(void);
void inp_non_block(gint);
diff --git a/src/ui/keyhandlers.c b/src/ui/keyhandlers.c
new file mode 100644
index 00000000..513997ef
--- /dev/null
+++ b/src/ui/keyhandlers.c
@@ -0,0 +1,123 @@
+/*
+ * keyhandlers.c
+ *
+ * Copyright (C) 2012 - 2014 James Booth
+ *
+ * This file is part of Profanity.
+ *
+ * Profanity is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Profanity is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Profanity. If not, see .
+ *
+ * In addition, as a special exception, the copyright holders give permission to
+ * link the code of portions of this program with the OpenSSL library under
+ * certain conditions as described in each individual source file, and
+ * distribute linked combinations including the two.
+ *
+ * You must obey the GNU General Public License in all respects for all of the
+ * code used other than OpenSSL. If you modify file(s) with this exception, you
+ * may extend this exception to your version of the file(s), but you are not
+ * obligated to do so. If you do not wish to do so, delete this exception
+ * statement from your version. If you delete this exception statement from all
+ * source files in the program, then also delete it here.
+ *
+ */
+
+#include
+#include
+#include
+
+#include
+
+#include "ui/inputwin.h"
+#include "common.h"
+
+void
+key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int wcols)
+{
+ int utf8_len = g_utf8_strlen(line, -1);
+
+ // handle insert if not at end of input
+ if (*line_utf8_pos < utf8_len) {
+ // create new line
+ char bytes[MB_CUR_MAX];
+ size_t utf8_ch_len = wcrtomb(bytes, ch, NULL);
+ bytes[utf8_ch_len] = '\0';
+ gchar *start = g_utf8_substring(line, 0, *line_utf8_pos);
+ gchar *end = g_utf8_substring(line, *line_utf8_pos, utf8_len);
+ GString *new_line_str = g_string_new(start);
+ g_string_append(new_line_str, bytes);
+ g_string_append(new_line_str, end);
+ char *new_line = new_line_str->str;
+ g_free(start);
+ g_free(end);
+ g_string_free(new_line_str, FALSE);
+
+ // replace old line
+ strncpy(line, new_line, INP_WIN_MAX);
+ free(new_line);
+
+ // set utf8 position
+ (*line_utf8_pos)++;
+
+ // set col position
+ (*col)++;
+ gunichar uni = g_utf8_get_char(bytes);
+ if (g_unichar_iswide(uni)) {
+ (*col)++;
+ }
+
+ // set pad_start
+ int display_len = utf8_display_len(line);
+ (*pad_start) = 0;
+ if (display_len > wcols-2) {
+ (*pad_start) = display_len - wcols + 1;
+ }
+
+ // otherwise just append
+ } else {
+ char bytes[MB_CUR_MAX+1];
+ size_t utf8_ch_len = wcrtomb(bytes, ch, NULL);
+
+ // wcrtomb can return (size_t) -1
+ if (utf8_ch_len < MB_CUR_MAX) {
+ // update old line
+ int i;
+ int bytes_len = strlen(line);
+
+ for (i = 0 ; i < utf8_ch_len; i++) {
+ line[bytes_len++] = bytes[i];
+ }
+ line[bytes_len] = '\0';
+
+ // set utf8 position
+ (*line_utf8_pos)++;
+
+ // set col position
+ (*col)++;
+ bytes[utf8_ch_len] = '\0';
+ gunichar uni = g_utf8_get_char(bytes);
+ if (g_unichar_iswide(uni)) {
+ (*col)++;
+ }
+
+ // set pad_start
+ // if gone over screen size follow input
+ if (*col - *pad_start > wcols-2) {
+ (*pad_start)++;
+ if (g_unichar_iswide(uni)) {
+ (*pad_start)++;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ui/keyhandlers.h b/src/ui/keyhandlers.h
new file mode 100644
index 00000000..cb1b14d8
--- /dev/null
+++ b/src/ui/keyhandlers.h
@@ -0,0 +1,42 @@
+/*
+ * keyhandlers.c
+ *
+ * Copyright (C) 2012 - 2014 James Booth
+ *
+ * This file is part of Profanity.
+ *
+ * Profanity is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Profanity is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Profanity. If not, see .
+ *
+ * In addition, as a special exception, the copyright holders give permission to
+ * link the code of portions of this program with the OpenSSL library under
+ * certain conditions as described in each individual source file, and
+ * distribute linked combinations including the two.
+ *
+ * You must obey the GNU General Public License in all respects for all of the
+ * code used other than OpenSSL. If you modify file(s) with this exception, you
+ * may extend this exception to your version of the file(s), but you are not
+ * obligated to do so. If you do not wish to do so, delete this exception
+ * statement from your version. If you delete this exception statement from all
+ * source files in the program, then also delete it here.
+ *
+ */
+
+#ifndef UI_KEYHANDLERS_H
+#define UI_KEYHANDLERS_H
+
+#include
+
+void key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int wcols);
+
+#endif
diff --git a/tests/test_keyhandlers.c b/tests/test_keyhandlers.c
new file mode 100644
index 00000000..e01133e1
--- /dev/null
+++ b/tests/test_keyhandlers.c
@@ -0,0 +1,150 @@
+#include "ui/keyhandlers.h"
+#include "ui/inputwin.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+static char line[INP_WIN_MAX];
+
+void append_non_wide_to_empty(void **state)
+{
+ setlocale(LC_ALL, "");
+ line[0] = '\0';
+ int line_utf8_pos = 0;
+ int col = 0;
+ int pad_start = 0;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'a', 80);
+
+ assert_string_equal("a", line);
+ assert_int_equal(line_utf8_pos, 1);
+ assert_int_equal(col, 1);
+ assert_int_equal(pad_start, 0);
+}
+
+void append_wide_to_empty(void **state)
+{
+ setlocale(LC_ALL, "");
+ line[0] = '\0';
+ int line_utf8_pos = 0;
+ int col = 0;
+ int pad_start = 0;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x56DB, 80);
+
+ assert_string_equal("四", line);
+ assert_int_equal(line_utf8_pos, 1);
+ assert_int_equal(col, 2);
+ assert_int_equal(pad_start, 0);
+}
+
+void append_non_wide_to_non_wide(void **state)
+{
+ setlocale(LC_ALL, "");
+ strncpy(line, "a", 1);
+ line[1] = '\0';
+ int line_utf8_pos = 1;
+ int col = 1;
+ int pad_start = 0;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'b', 80);
+
+ assert_string_equal("ab", line);
+ assert_int_equal(line_utf8_pos, 2);
+ assert_int_equal(col, 2);
+ assert_int_equal(pad_start, 0);
+}
+
+void append_wide_to_non_wide(void **state)
+{
+ setlocale(LC_ALL, "");
+ strncpy(line, "a", 1);
+ line[1] = '\0';
+ int line_utf8_pos = 1;
+ int col = 1;
+ int pad_start = 0;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x56DB, 80);
+
+ assert_string_equal("a四", line);
+ assert_int_equal(line_utf8_pos, 2);
+ assert_int_equal(col, 3);
+ assert_int_equal(pad_start, 0);
+}
+
+void append_non_wide_to_wide(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "四", 1);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 1;
+ int col = 2;
+ int pad_start = 0;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'b', 80);
+
+ assert_string_equal("四b", line);
+ assert_int_equal(line_utf8_pos, 2);
+ assert_int_equal(col, 3);
+ assert_int_equal(pad_start, 0);
+}
+
+void append_wide_to_wide(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "四", 1);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 1;
+ int col = 2;
+ int pad_start = 0;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x4E09, 80);
+
+ assert_string_equal("四三", line);
+ assert_int_equal(line_utf8_pos, 2);
+ assert_int_equal(col, 4);
+ assert_int_equal(pad_start, 0);
+}
+
+void append_no_wide_when_overrun(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "0123456789四1234567", 18);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 18;
+ int col = 19;
+ int pad_start = 0;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'z', 20);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'z', 20);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'z', 20);
+
+ assert_string_equal("0123456789四1234567zzz", line);
+ assert_int_equal(line_utf8_pos, 21);
+ assert_int_equal(col, 22);
+ assert_int_equal(pad_start, 3);
+}
+
+void append_wide_when_overrun(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "0123456789四1234567", 18);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 18;
+ int col = 19;
+ int pad_start = 0;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x4E09, 20);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x4E09, 20);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x4E09, 20);
+
+ assert_string_equal("0123456789四1234567三三三", line);
+ assert_int_equal(line_utf8_pos, 21);
+ assert_int_equal(col, 25);
+ assert_int_equal(pad_start, 6);
+}
\ No newline at end of file
diff --git a/tests/test_keyhandlers.h b/tests/test_keyhandlers.h
new file mode 100644
index 00000000..142a05ef
--- /dev/null
+++ b/tests/test_keyhandlers.h
@@ -0,0 +1,11 @@
+void append_non_wide_to_empty(void **state);
+void append_wide_to_empty(void **state);
+
+void append_non_wide_to_non_wide(void **state);
+void append_wide_to_non_wide(void **state);
+
+void append_non_wide_to_wide(void **state);
+void append_wide_to_wide(void **state);
+
+void append_no_wide_when_overrun(void **state);
+void append_wide_when_overrun(void **state);
\ No newline at end of file
diff --git a/tests/testsuite.c b/tests/testsuite.c
index cf511c59..4964d99d 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -35,6 +35,7 @@
#include "test_cmd_win.h"
#include "test_cmd_disconnect.h"
#include "test_form.h"
+#include "test_keyhandlers.h"
int main(int argc, char* argv[]) {
const UnitTest all_tests[] = {
@@ -622,6 +623,15 @@ int main(int argc, char* argv[]) {
unit_test(remove_text_multi_value_removes_when_many),
unit_test(clears_chat_sessions),
+
+ unit_test(append_non_wide_to_empty),
+ unit_test(append_wide_to_empty),
+ unit_test(append_non_wide_to_non_wide),
+ unit_test(append_wide_to_non_wide),
+ unit_test(append_non_wide_to_wide),
+ unit_test(append_wide_to_wide),
+ unit_test(append_no_wide_when_overrun),
+ unit_test(append_wide_when_overrun),
};
return run_tests(all_tests);
From 58239244bb703d770aa423d8fcea19522771ae0d Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 20 Jan 2015 00:56:35 +0000
Subject: [PATCH 007/252] Added key insert handler tests
---
tests/test_keyhandlers.c | 117 +++++++++++++++++++++++++++++++++------
tests/test_keyhandlers.h | 7 ++-
tests/testsuite.c | 4 ++
3 files changed, 111 insertions(+), 17 deletions(-)
diff --git a/tests/test_keyhandlers.c b/tests/test_keyhandlers.c
index e01133e1..2e29ec6d 100644
--- a/tests/test_keyhandlers.c
+++ b/tests/test_keyhandlers.c
@@ -11,19 +11,36 @@
static char line[INP_WIN_MAX];
+static int utf8_pos_to_col(char *str, int utf8_pos)
+{
+ int col = 0;
+
+ int i = 0;
+ for (i = 0; i
Date: Tue, 20 Jan 2015 23:02:04 +0000
Subject: [PATCH 008/252] Added key insert tests, extracted key_ctrl_left
handler
---
src/ui/inputwin.c | 68 +-----
src/ui/keyhandlers.c | 94 ++++++--
src/ui/keyhandlers.h | 2 +
tests/test_keyhandlers.c | 452 ++++++++++++++++++++++++++++++++++++++-
tests/test_keyhandlers.h | 36 +++-
tests/testsuite.c | 29 ++-
6 files changed, 586 insertions(+), 95 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 59292482..7b5c33d0 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -256,67 +256,12 @@ _handle_edit(int key_type, const wint_t ch)
{
int col = getcurx(inp_win);
int utf8_len = g_utf8_strlen(line, -1);
+ int wcols = getmaxx(stdscr);
// CTRL-LEFT
- if (line_utf8_pos > 0 && _is_ctrl_left(key_type, ch)) {
- gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
- gunichar curr_uni = g_utf8_get_char(curr_ch);
- line_utf8_pos--;
- col--;
- if (g_unichar_iswide(curr_uni)) {
- col--;
- }
-
- curr_ch = g_utf8_find_prev_char(line, curr_ch);
-
- gchar *prev_ch;
- gunichar prev_uni;
- while (curr_ch != NULL) {
- curr_uni = g_utf8_get_char(curr_ch);
- if (g_unichar_isspace(curr_uni)) {
- curr_ch = g_utf8_find_prev_char(line, curr_ch);
- line_utf8_pos--;
- col--;
- } else {
- prev_ch = g_utf8_find_prev_char(line, curr_ch);
- if (prev_ch == NULL) {
- curr_ch = NULL;
- break;
- } else {
- prev_uni = g_utf8_get_char(prev_ch);
- line_utf8_pos--;
- col--;
- if (g_unichar_iswide(prev_uni)) {
- col--;
- }
- if (g_unichar_isspace(prev_uni)) {
- break;
- } else {
- curr_ch = prev_ch;
- }
- }
- }
- }
-
- if (curr_ch == NULL) {
- col = 0;
- wmove(inp_win, 0, col);
- } else {
- col++;
- line_utf8_pos++;
- wmove(inp_win, 0, col);
- }
-
- // if gone off screen to left, jump left (half a screen worth)
- int wcols = getmaxx(stdscr);
- if (col <= pad_start) {
- pad_start = pad_start - (wcols / 2);
- if (pad_start < 0) {
- pad_start = 0;
- }
-
- _inp_win_update_virtual();
- }
+ if (_is_ctrl_left(key_type, ch)) {
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, wcols);
+ wmove(inp_win, 0, col);
return 1;
// CTRL-RIGHT
@@ -353,7 +298,6 @@ _handle_edit(int key_type, const wint_t ch)
wmove(inp_win, 0, col);
// if gone off screen to right, jump right (half a screen worth)
- int wcols = getmaxx(stdscr);
if (col > pad_start + wcols) {
pad_start = pad_start + (wcols / 2);
_inp_win_update_virtual();
@@ -464,7 +408,7 @@ _handle_edit(int key_type, const wint_t ch)
line_utf8_pos--;
// current position off screen to left
- if (col - 1 < pad_start) {
+ if (col < pad_start) {
pad_start--;
_inp_win_update_virtual();
}
@@ -490,7 +434,7 @@ _handle_edit(int key_type, const wint_t ch)
// current position off screen to right
int wcols = getmaxx(stdscr);
- if ((col + 1 - pad_start) >= wcols) {
+ if ((col - pad_start) >= wcols) {
pad_start++;
_inp_win_update_virtual();
}
diff --git a/src/ui/keyhandlers.c b/src/ui/keyhandlers.c
index 513997ef..d7c3c616 100644
--- a/src/ui/keyhandlers.c
+++ b/src/ui/keyhandlers.c
@@ -48,7 +48,6 @@ key_printable(char * const line, int * const line_utf8_pos, int * const col, int
// handle insert if not at end of input
if (*line_utf8_pos < utf8_len) {
- // create new line
char bytes[MB_CUR_MAX];
size_t utf8_ch_len = wcrtomb(bytes, ch, NULL);
bytes[utf8_ch_len] = '\0';
@@ -62,35 +61,29 @@ key_printable(char * const line, int * const line_utf8_pos, int * const col, int
g_free(end);
g_string_free(new_line_str, FALSE);
- // replace old line
strncpy(line, new_line, INP_WIN_MAX);
free(new_line);
- // set utf8 position
- (*line_utf8_pos)++;
-
- // set col position
- (*col)++;
gunichar uni = g_utf8_get_char(bytes);
- if (g_unichar_iswide(uni)) {
- (*col)++;
+ if (*col == (*pad_start + wcols)) {
+ (*pad_start)++;
+ if (g_unichar_iswide(uni)) {
+ (*pad_start)++;
+ }
}
- // set pad_start
- int display_len = utf8_display_len(line);
- (*pad_start) = 0;
- if (display_len > wcols-2) {
- (*pad_start) = display_len - wcols + 1;
+ (*line_utf8_pos)++;
+
+ (*col)++;
+ if (g_unichar_iswide(uni)) {
+ (*col)++;
}
// otherwise just append
} else {
char bytes[MB_CUR_MAX+1];
size_t utf8_ch_len = wcrtomb(bytes, ch, NULL);
-
- // wcrtomb can return (size_t) -1
if (utf8_ch_len < MB_CUR_MAX) {
- // update old line
int i;
int bytes_len = strlen(line);
@@ -99,10 +92,8 @@ key_printable(char * const line, int * const line_utf8_pos, int * const col, int
}
line[bytes_len] = '\0';
- // set utf8 position
(*line_utf8_pos)++;
- // set col position
(*col)++;
bytes[utf8_ch_len] = '\0';
gunichar uni = g_utf8_get_char(bytes);
@@ -110,9 +101,7 @@ key_printable(char * const line, int * const line_utf8_pos, int * const col, int
(*col)++;
}
- // set pad_start
- // if gone over screen size follow input
- if (*col - *pad_start > wcols-2) {
+ if (*col - *pad_start > wcols-1) {
(*pad_start)++;
if (g_unichar_iswide(uni)) {
(*pad_start)++;
@@ -120,4 +109,63 @@ key_printable(char * const line, int * const line_utf8_pos, int * const col, int
}
}
}
-}
\ No newline at end of file
+}
+
+void
+key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int wcols)
+{
+ if (*line_utf8_pos == 0) {
+ return;
+ }
+
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, *line_utf8_pos);
+ gunichar curr_uni = g_utf8_get_char(curr_ch);
+ (*line_utf8_pos)--;
+ (*col)--;
+ if (g_unichar_iswide(curr_uni)) {
+ (*col)--;
+ }
+
+ curr_ch = g_utf8_find_prev_char(line, curr_ch);
+
+ gchar *prev_ch;
+ gunichar prev_uni;
+ while (curr_ch != NULL) {
+ curr_uni = g_utf8_get_char(curr_ch);
+ if (g_unichar_isspace(curr_uni)) {
+ curr_ch = g_utf8_find_prev_char(line, curr_ch);
+ (*line_utf8_pos)--;
+ (*col)--;
+ } else {
+ prev_ch = g_utf8_find_prev_char(line, curr_ch);
+ if (prev_ch == NULL) {
+ curr_ch = NULL;
+ break;
+ } else {
+ prev_uni = g_utf8_get_char(prev_ch);
+ (*line_utf8_pos)--;
+ (*col)--;
+ if (g_unichar_iswide(prev_uni)) {
+ (*col)--;
+ }
+ if (g_unichar_isspace(prev_uni)) {
+ break;
+ } else {
+ curr_ch = prev_ch;
+ }
+ }
+ }
+ }
+
+ if (curr_ch == NULL) {
+ (*col) = 0;
+ (*line_utf8_pos) = 0;
+ } else {
+ (*col)++;
+ (*line_utf8_pos)++;
+ }
+
+ if (*col < *pad_start) {
+ *pad_start = *col;
+ }
+}
diff --git a/src/ui/keyhandlers.h b/src/ui/keyhandlers.h
index cb1b14d8..d8153356 100644
--- a/src/ui/keyhandlers.h
+++ b/src/ui/keyhandlers.h
@@ -39,4 +39,6 @@
void key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int wcols);
+void key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int wcols);
+
#endif
diff --git a/tests/test_keyhandlers.c b/tests/test_keyhandlers.c
index 2e29ec6d..32582c2e 100644
--- a/tests/test_keyhandlers.c
+++ b/tests/test_keyhandlers.c
@@ -63,7 +63,7 @@ void append_wide_to_empty(void **state)
void append_non_wide_to_non_wide(void **state)
{
setlocale(LC_ALL, "");
- strncpy(line, "a", 1);
+ g_utf8_strncpy(line, "a", 1);
line[1] = '\0';
int line_utf8_pos = 1;
int col = utf8_pos_to_col(line, line_utf8_pos);
@@ -80,7 +80,7 @@ void append_non_wide_to_non_wide(void **state)
void append_wide_to_non_wide(void **state)
{
setlocale(LC_ALL, "");
- strncpy(line, "a", 1);
+ g_utf8_strncpy(line, "a", 1);
line[1] = '\0';
int line_utf8_pos = 1;
int col = utf8_pos_to_col(line, line_utf8_pos);
@@ -128,7 +128,7 @@ void append_wide_to_wide(void **state)
assert_int_equal(pad_start, 0);
}
-void append_no_wide_when_overrun(void **state)
+void append_non_wide_when_overrun(void **state)
{
setlocale(LC_ALL, "");
g_utf8_strncpy(line, "0123456789四1234567", 18);
@@ -232,4 +232,450 @@ void insert_wide_to_wide(void **state)
assert_int_equal(line_utf8_pos, 3);
assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
assert_int_equal(pad_start, 0);
+}
+
+void insert_single_non_wide_when_pad_scrolled(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "AAAAAAAAAAAAAAA", 15);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 2;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 2;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'B', 12);
+
+ assert_string_equal("AABAAAAAAAAAAAAA", line);
+ assert_int_equal(line_utf8_pos, 3);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 2);
+}
+
+void insert_many_non_wide_when_pad_scrolled(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "AAAAAAAAAAAAAAA", 15);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 2;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 2;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'B', 12);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'C', 12);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 'D', 12);
+
+ assert_string_equal("AABCDAAAAAAAAAAAAA", line);
+ assert_int_equal(line_utf8_pos, 5);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 2);
+}
+
+void insert_single_wide_when_pad_scrolled(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "AAAAAAAAAAAAAAA", 15);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 2;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 2;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x4E09, 12);
+
+ assert_string_equal("AA三AAAAAAAAAAAAA", line);
+ assert_int_equal(line_utf8_pos, 3);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 2);
+}
+
+void insert_many_wide_when_pad_scrolled(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "AAAAAAAAAAAAAAA", 15);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 2;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 2;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x304C, 12);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x304C, 12);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x4E09, 12);
+
+ assert_string_equal("AAがが三AAAAAAAAAAAAA", line);
+ assert_int_equal(line_utf8_pos, 5);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 2);
+}
+
+void insert_single_non_wide_last_column(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcdefghijklmno", 15);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 7;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 2;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, '1', 5);
+
+ assert_string_equal("abcdefg1hijklmno", line);
+ assert_int_equal(line_utf8_pos, 8);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 3);
+}
+
+void insert_many_non_wide_last_column(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcdefghijklmno", 15);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 7;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 2;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, '1', 5);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, '2', 5);
+
+ assert_string_equal("abcdefg12hijklmno", line);
+ assert_int_equal(line_utf8_pos, 9);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 4);
+}
+
+void insert_single_wide_last_column(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcdefghijklmno", 15);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 7;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 2;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x4E09, 5);
+
+ assert_string_equal("abcdefg三hijklmno", line);
+ assert_int_equal(line_utf8_pos, 8);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 4);
+}
+
+void insert_many_wide_last_column(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcdefghijklmno", 15);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 7;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 2;
+
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x4E09, 5);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, 0x304C, 5);
+
+ assert_string_equal("abcdefg三がhijklmno", line);
+ assert_int_equal(line_utf8_pos, 9);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 6);
+}
+
+void ctrl_left_when_at_start(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 0;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 0);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_in_first_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 2;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 0);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_in_first_space(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 4;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 0);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_at_start_of_second_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 5;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 0);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_in_second_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 8;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 5);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_at_end_of_second_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 10;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 5);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_in_second_space(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 11;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 5);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_at_start_of_third_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 12;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 5);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_in_third_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 14;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 12);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_at_end_of_third_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 15;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 12);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_in_third_space(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 16;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 12);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_at_end(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "abcd efghij klmn opqr", 21);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 20;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 17);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_in_only_whitespace(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, " ", 7);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 5;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 0);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_start_whitespace_start_of_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, " hello", 9);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 4;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 0);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_start_whitespace_middle_of_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, " hello", 9);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 7;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 4);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_in_whitespace_between_words(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "hey hello", 12);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 5;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 0);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_in_whitespace_between_words_start_of_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "hey hello", 12);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 7;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 0);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_in_whitespace_between_words_middle_of_word(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "hey hello", 12);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 9;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 0;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 7);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 0);
+}
+
+void ctrl_left_when_word_overrun_to_left(void **state)
+{
+ setlocale(LC_ALL, "");
+ g_utf8_strncpy(line, "someword anotherword", 20);
+ line[strlen(line)] = '\0';
+ int line_utf8_pos = 18;
+ int col = utf8_pos_to_col(line, line_utf8_pos);
+ int pad_start = 14;
+
+ key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, 80);
+
+ assert_int_equal(line_utf8_pos, 9);
+ assert_int_equal(col, utf8_pos_to_col(line, line_utf8_pos));
+ assert_int_equal(pad_start, 9);
}
\ No newline at end of file
diff --git a/tests/test_keyhandlers.h b/tests/test_keyhandlers.h
index f70ee81e..4db5f340 100644
--- a/tests/test_keyhandlers.h
+++ b/tests/test_keyhandlers.h
@@ -1,16 +1,40 @@
void append_non_wide_to_empty(void **state);
void append_wide_to_empty(void **state);
-
void append_non_wide_to_non_wide(void **state);
void append_wide_to_non_wide(void **state);
-
void append_non_wide_to_wide(void **state);
void append_wide_to_wide(void **state);
-
-void append_no_wide_when_overrun(void **state);
+void append_non_wide_when_overrun(void **state);
void append_wide_when_overrun(void **state);
-
void insert_non_wide_to_non_wide(void **state);
void insert_wide_to_non_wide(void **state);
void insert_non_wide_to_wide(void **state);
-void insert_wide_to_wide(void **state);
\ No newline at end of file
+void insert_wide_to_wide(void **state);
+void insert_single_non_wide_when_pad_scrolled(void **state);
+void insert_many_non_wide_when_pad_scrolled(void **state);
+void insert_single_wide_when_pad_scrolled(void **state);
+void insert_many_wide_when_pad_scrolled(void **state);
+void insert_single_non_wide_last_column(void **state);
+void insert_many_non_wide_last_column(void **state);
+void insert_single_wide_last_column(void **state);
+void insert_many_wide_last_column(void **state);
+
+void ctrl_left_when_at_start(void **state);
+void ctrl_left_when_in_first_word(void **state);
+void ctrl_left_when_in_first_space(void **state);
+void ctrl_left_when_at_start_of_second_word(void **state);
+void ctrl_left_when_in_second_word(void **state);
+void ctrl_left_when_at_end_of_second_word(void **state);
+void ctrl_left_when_in_second_space(void **state);
+void ctrl_left_when_at_start_of_third_word(void **state);
+void ctrl_left_when_in_third_word(void **state);
+void ctrl_left_when_at_end_of_third_word(void **state);
+void ctrl_left_when_in_third_space(void **state);
+void ctrl_left_when_at_end(void **state);
+void ctrl_left_when_in_only_whitespace(void **state);
+void ctrl_left_when_start_whitespace_start_of_word(void **state);
+void ctrl_left_when_start_whitespace_middle_of_word(void **state);
+void ctrl_left_in_whitespace_between_words(void **state);
+void ctrl_left_in_whitespace_between_words_start_of_word(void **state);
+void ctrl_left_in_whitespace_between_words_middle_of_word(void **state);
+void ctrl_left_when_word_overrun_to_left(void **state);
\ No newline at end of file
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 3a60317e..1a5e0f7e 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -630,12 +630,39 @@ int main(int argc, char* argv[]) {
unit_test(append_wide_to_non_wide),
unit_test(append_non_wide_to_wide),
unit_test(append_wide_to_wide),
- unit_test(append_no_wide_when_overrun),
+ unit_test(append_non_wide_when_overrun),
unit_test(append_wide_when_overrun),
unit_test(insert_non_wide_to_non_wide),
unit_test(insert_wide_to_non_wide),
unit_test(insert_non_wide_to_wide),
unit_test(insert_wide_to_wide),
+ unit_test(insert_single_non_wide_when_pad_scrolled),
+ unit_test(insert_many_non_wide_when_pad_scrolled),
+ unit_test(insert_single_wide_when_pad_scrolled),
+ unit_test(insert_many_wide_when_pad_scrolled),
+ unit_test(insert_single_non_wide_last_column),
+ unit_test(insert_many_non_wide_last_column),
+ unit_test(insert_single_wide_last_column),
+ unit_test(insert_many_wide_last_column),
+ unit_test(ctrl_left_when_at_start),
+ unit_test(ctrl_left_when_in_first_word),
+ unit_test(ctrl_left_when_in_first_space),
+ unit_test(ctrl_left_when_at_start_of_second_word),
+ unit_test(ctrl_left_when_in_second_word),
+ unit_test(ctrl_left_when_at_end_of_second_word),
+ unit_test(ctrl_left_when_in_second_space),
+ unit_test(ctrl_left_when_at_start_of_third_word),
+ unit_test(ctrl_left_when_in_third_word),
+ unit_test(ctrl_left_when_at_end_of_third_word),
+ unit_test(ctrl_left_when_in_third_space),
+ unit_test(ctrl_left_when_at_end),
+ unit_test(ctrl_left_when_in_only_whitespace),
+ unit_test(ctrl_left_when_start_whitespace_start_of_word),
+ unit_test(ctrl_left_when_start_whitespace_middle_of_word),
+ unit_test(ctrl_left_in_whitespace_between_words),
+ unit_test(ctrl_left_in_whitespace_between_words_start_of_word),
+ unit_test(ctrl_left_in_whitespace_between_words_middle_of_word),
+ unit_test(ctrl_left_when_word_overrun_to_left),
};
return run_tests(all_tests);
From 2cdbfc7eb7d90ed286c6c5f432990166cdec0b93 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 27 Jan 2015 22:13:09 +0000
Subject: [PATCH 009/252] Added gnu readline
---
configure.ac | 2 +
src/profanity.c | 62 +++++--
src/ui/core.c | 6 +
src/ui/inputwin.c | 80 ++++-----
src/ui/inputwin.h | 1 +
src/ui/keyhandlers.c | 55 +++++-
src/ui/keyhandlers.h | 5 +-
src/ui/ui.h | 1 +
tests/helpers.c | 18 ++
tests/helpers.h | 2 +
tests/test_keyhandlers.c | 365 ++++++++++++++++++++++-----------------
tests/test_keyhandlers.h | 35 ++--
tests/testsuite.c | 36 ++--
tests/ui/stub_ui.c | 3 +
14 files changed, 428 insertions(+), 243 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7369f112..2794ad43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,6 +133,8 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [],
[AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
PKG_CHECK_MODULES([curl], [libcurl], [],
[AC_MSG_ERROR([libcurl is required for profanity])])
+AC_CHECK_LIB([readline], [main], [],
+ [AC_MSG_ERROR([libreadline is required for profanity])])
AS_IF([test "x$PLATFORM" = xosx], [LIBS="-lcurl $LIBS"])
diff --git a/src/profanity.c b/src/profanity.c
index 13297124..c105d33f 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -43,6 +43,8 @@
#include
#include
+#include
+#include
#include "profanity.h"
#include "chat_session.h"
@@ -71,6 +73,20 @@ static void _create_directories(void);
static void _connect_default(const char * const account);
static gboolean idle = FALSE;
+static void cb_linehandler(char *);
+static gboolean cmd_result = TRUE;
+
+static void
+cb_linehandler(char *line)
+{
+ /* Can use ^D (stty eof) or `exit' to exit. */
+ if (*line) {
+ add_history(line);
+ }
+ rl_redisplay();
+ cmd_result = cmd_process_input(line);
+ free(line);
+}
void
prof_run(const int disable_tls, char *log_level, char *account_name)
@@ -79,26 +95,44 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
_connect_default(account_name);
ui_update();
- char *line = NULL;
- gboolean cmd_result = TRUE;
+ fd_set fds;
+ int r;
+ rl_callback_handler_install(NULL, cb_linehandler);
log_info("Starting main event loop");
+ struct timeval t;
+ t.tv_sec = 0;
+ t.tv_usec = 10000;
+
while(cmd_result) {
- while(!line) {
- _check_autoaway();
- line = ui_readline();
-#ifdef HAVE_LIBOTR
- otr_poll();
-#endif
- notify_remind();
- jabber_process_events();
- ui_update();
+ _check_autoaway();
+
+ FD_ZERO(&fds);
+ FD_SET(fileno (rl_instream), &fds);
+ r = select(FD_SETSIZE, &fds, NULL, NULL, &t);
+ if (r < 0) {
+ perror ("rltest: select");
+ rl_callback_handler_remove();
+ break;
}
- cmd_result = cmd_process_input(line);
- ui_input_clear();
- FREE_SET_NULL(line);
+
+ if (FD_ISSET (fileno (rl_instream), &fds)) {
+ rl_callback_read_char();
+ ui_write(rl_line_buffer, rl_point);
+ }
+
+
+// line = ui_readline();
+#ifdef HAVE_LIBOTR
+ otr_poll();
+#endif
+ notify_remind();
+ jabber_process_events();
+ ui_update();
}
+
+ rl_callback_handler_remove();
}
void
diff --git a/src/ui/core.c b/src/ui/core.c
index e295a3ad..efebdb5e 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -177,6 +177,12 @@ ui_close(void)
endwin();
}
+void
+ui_write(char *line, int offset)
+{
+ inp_write(line, offset);
+}
+
char*
ui_readline(void)
{
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 7b5c33d0..64c65a96 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -131,6 +131,43 @@ inp_win_resize(void)
_inp_win_update_virtual();
}
+static int
+offset_to_col(char *str, int offset)
+{
+ int i = 0;
+ int col = 0;
+ mbstate_t internal;
+
+ while (i != offset && str[i] != '\n') {
+ gunichar uni = g_utf8_get_char(&str[i]);
+ size_t ch_len = mbrlen(&str[i], 4, &internal);
+ i += ch_len;
+ col++;
+ if (g_unichar_iswide(uni)) {
+ col++;
+ }
+ }
+
+ return col;
+}
+
+void
+inp_write(char *line, int offset)
+{
+ int col = offset_to_col(line, offset);
+
+ cons_debug("LEN BYTES: %d", strlen(line));
+ cons_debug("LEN UTF8 : %d", g_utf8_strlen(line, -1));
+ cons_debug("OFFSET : %d", offset);
+ cons_debug("COL : %d", col);
+ cons_debug("");
+
+ werase(inp_win);
+ waddstr(inp_win, line);
+ wmove(inp_win, 0, col);
+ _inp_win_update_virtual();
+}
+
void
inp_non_block(gint timeout)
{
@@ -174,8 +211,8 @@ inp_read(int *key_type, wint_t *ch)
}
int col = getcurx(inp_win);
- int wcols = getmaxx(stdscr);
- key_printable(line, &line_utf8_pos, &col, &pad_start, *ch, wcols);
+ int maxx = getmaxx(stdscr);
+ key_printable(line, &line_utf8_pos, &col, &pad_start, *ch, maxx);
werase(inp_win);
waddstr(inp_win, line);
@@ -265,44 +302,9 @@ _handle_edit(int key_type, const wint_t ch)
return 1;
// CTRL-RIGHT
- } else if (line_utf8_pos < utf8_len && _is_ctrl_right(key_type, ch)) {
- gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
- gunichar curr_uni = g_utf8_get_char(curr_ch);
-
- // find next word if in whitespace
- while (g_unichar_isspace(curr_uni)) {
- col++;
- line_utf8_pos++;
- curr_ch = g_utf8_find_next_char(curr_ch, NULL);
- if (!curr_ch) {
- break;
- }
- curr_uni = g_utf8_get_char(curr_ch);
- }
-
- if (curr_ch) {
- while (!g_unichar_isspace(curr_uni)) {
- line_utf8_pos++;
- col++;
- if (g_unichar_iswide(curr_uni)) {
- col++;
- }
- curr_ch = g_utf8_find_next_char(curr_ch, NULL);
- if (!curr_ch || line_utf8_pos >= utf8_len) {
- break;
- }
- curr_uni = g_utf8_get_char(curr_ch);
- }
- }
-
+ } else if (_is_ctrl_right(key_type, ch)) {
+ key_ctrl_right(line, &line_utf8_pos, &col, &pad_start, wcols);
wmove(inp_win, 0, col);
-
- // if gone off screen to right, jump right (half a screen worth)
- if (col > pad_start + wcols) {
- pad_start = pad_start + (wcols / 2);
- _inp_win_update_virtual();
- }
-
return 1;
// ALT-LEFT
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index a4de16f0..d27bfef7 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -48,5 +48,6 @@ void inp_non_block(gint);
void inp_block(void);
void inp_get_password(char *passwd);
void inp_history_append(char *inp);
+void inp_write(char *line, int offset);
#endif
diff --git a/src/ui/keyhandlers.c b/src/ui/keyhandlers.c
index d7c3c616..0836737b 100644
--- a/src/ui/keyhandlers.c
+++ b/src/ui/keyhandlers.c
@@ -42,7 +42,7 @@
#include "common.h"
void
-key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int wcols)
+key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int maxx)
{
int utf8_len = g_utf8_strlen(line, -1);
@@ -65,7 +65,7 @@ key_printable(char * const line, int * const line_utf8_pos, int * const col, int
free(new_line);
gunichar uni = g_utf8_get_char(bytes);
- if (*col == (*pad_start + wcols)) {
+ if (*col == (*pad_start + maxx)) {
(*pad_start)++;
if (g_unichar_iswide(uni)) {
(*pad_start)++;
@@ -101,7 +101,7 @@ key_printable(char * const line, int * const line_utf8_pos, int * const col, int
(*col)++;
}
- if (*col - *pad_start > wcols-1) {
+ if (*col - *pad_start > maxx-1) {
(*pad_start)++;
if (g_unichar_iswide(uni)) {
(*pad_start)++;
@@ -112,7 +112,7 @@ key_printable(char * const line, int * const line_utf8_pos, int * const col, int
}
void
-key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int wcols)
+key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int maxx)
{
if (*line_utf8_pos == 0) {
return;
@@ -120,6 +120,7 @@ key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const co
gchar *curr_ch = g_utf8_offset_to_pointer(line, *line_utf8_pos);
gunichar curr_uni = g_utf8_get_char(curr_ch);
+
(*line_utf8_pos)--;
(*col)--;
if (g_unichar_iswide(curr_uni)) {
@@ -145,7 +146,7 @@ key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const co
prev_uni = g_utf8_get_char(prev_ch);
(*line_utf8_pos)--;
(*col)--;
- if (g_unichar_iswide(prev_uni)) {
+ if (g_unichar_iswide(curr_uni)) {
(*col)--;
}
if (g_unichar_isspace(prev_uni)) {
@@ -169,3 +170,47 @@ key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const co
*pad_start = *col;
}
}
+
+void
+key_ctrl_right(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int maxx)
+{
+ int utf8_len = g_utf8_strlen(line, -1);
+ if (*line_utf8_pos >= utf8_len) {
+ return;
+ }
+
+ gchar *curr_ch = g_utf8_offset_to_pointer(line, *line_utf8_pos);
+ gunichar curr_uni = g_utf8_get_char(curr_ch);
+
+ // find next word if in whitespace
+ while (g_unichar_isspace(curr_uni)) {
+ (*col)++;
+ (*line_utf8_pos)++;
+ curr_ch = g_utf8_find_next_char(curr_ch, NULL);
+ if (!curr_ch) {
+ break;
+ }
+ curr_uni = g_utf8_get_char(curr_ch);
+ }
+
+ if (curr_ch) {
+ while (!g_unichar_isspace(curr_uni)) {
+ (*line_utf8_pos)++;
+ (*col)++;
+ if (g_unichar_iswide(curr_uni)) {
+ (*col)++;
+ }
+ curr_ch = g_utf8_find_next_char(curr_ch, NULL);
+ if (!curr_ch || *line_utf8_pos >= utf8_len) {
+ break;
+ }
+ curr_uni = g_utf8_get_char(curr_ch);
+ }
+ }
+
+ // if gone off screen to right, jump right (half a screen worth)
+// if (col > pad_start + wcols) {
+// pad_start = pad_start + (wcols / 2);
+// _inp_win_update_virtual();
+// }
+}
diff --git a/src/ui/keyhandlers.h b/src/ui/keyhandlers.h
index d8153356..62a2c0d6 100644
--- a/src/ui/keyhandlers.h
+++ b/src/ui/keyhandlers.h
@@ -37,8 +37,9 @@
#include
-void key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int wcols);
+void key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int maxx);
-void key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int wcols);
+void key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int maxx);
+void key_ctrl_right(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int maxx);
#endif
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 99e73b4a..23315af9 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -230,6 +230,7 @@ void ui_statusbar_new(const int win);
char * ui_readline(void);
void ui_input_clear(void);
void ui_input_nonblocking(gboolean);
+void ui_write(char *line, int offset);
void ui_invalid_command_usage(const char * const usage, void (*setting_func)(void));
diff --git a/tests/helpers.c b/tests/helpers.c
index 10310886..564b2716 100644
--- a/tests/helpers.c
+++ b/tests/helpers.c
@@ -85,6 +85,24 @@ void close_chat_sessions(void **state)
close_preferences(NULL);
}
+int
+utf8_pos_to_col(char *str, int utf8_pos)
+{
+ int col = 0;
+
+ int i = 0;
+ for (i = 0; i
#include
#include
@@ -9,26 +7,15 @@
#include
+#include "ui/keyhandlers.h"
+#include "ui/inputwin.h"
+#include "tests/helpers.h"
+
static char line[INP_WIN_MAX];
-static int utf8_pos_to_col(char *str, int utf8_pos)
-{
- int col = 0;
+// append
- int i = 0;
- for (i = 0; i
Date: Wed, 28 Jan 2015 19:50:16 +0000
Subject: [PATCH 010/252] Strip only trailing newline from eval_password
---
src/command/commands.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/command/commands.c b/src/command/commands.c
index 60ef3780..25314c2e 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -154,7 +154,10 @@ cmd_connect(gchar **args, struct cmd_help_t help)
cons_show("Error evaluating password, see logs for details.");
return TRUE;
}
- g_strstrip(account->password);
+ // strip trailing newline
+ if (g_str_has_suffix(account->password, "\n")) {
+ account->password[strlen(account->password)-1] = '\0';
+ }
} else {
log_error("popen failed when running eval_password.");
cons_show("Error evaluating password, see logs for details.");
From 351ff752a7b11408e62f00cb8b5778a58e8fdda7 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 28 Jan 2015 20:35:00 +0000
Subject: [PATCH 011/252] Renamed command group presence->presences to avoid
clash
---
src/command/command.c | 2 +-
src/command/commands.c | 2 +-
src/config/theme.c | 2 +-
src/ui/console.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index 8e16276b..f1926dbb 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1141,7 +1141,7 @@ cmd_init(void)
autocomplete_add(help_ac, "basic");
autocomplete_add(help_ac, "chatting");
autocomplete_add(help_ac, "groupchat");
- autocomplete_add(help_ac, "presence");
+ autocomplete_add(help_ac, "presences");
autocomplete_add(help_ac, "contacts");
autocomplete_add(help_ac, "service");
autocomplete_add(help_ac, "settings");
diff --git a/src/command/commands.c b/src/command/commands.c
index 25314c2e..2059c982 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -714,7 +714,7 @@ cmd_help(gchar **args, struct cmd_help_t help)
"/rooms", "/tiny", "/who", "/nick", "/privileges", "/info", "/occupants" };
_cmd_show_filtered_help("Groupchat commands", filter, ARRAY_SIZE(filter));
- } else if (strcmp(args[0], "presence") == 0) {
+ } else if (strcmp(args[0], "presences") == 0) {
gchar *filter[] = { "/autoaway", "/away", "/chat", "/dnd",
"/online", "/priority", "/account", "/status", "/statuses", "/who",
"/xa" };
diff --git a/src/config/theme.c b/src/config/theme.c
index 6d3c5938..a5dbd0dd 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -592,7 +592,7 @@ theme_attrs(theme_item_t attrs)
case THEME_BLACK_BOLD: result = COLOR_PAIR(52); break;
case THEME_MAGENTA: result = COLOR_PAIR(53); break;
case THEME_MAGENTA_BOLD: result = COLOR_PAIR(53); break;
- default: break;
+ default: break;
}
if (g_hash_table_lookup(bold_items, GINT_TO_POINTER(attrs))) {
diff --git a/src/ui/console.c b/src/ui/console.c
index dd50d6d3..cdf5d1b8 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1402,7 +1402,7 @@ cons_help(void)
cons_show("/help basic - List basic commands for getting started.");
cons_show("/help chatting - List chat commands.");
cons_show("/help groupchat - List groupchat commands.");
- cons_show("/help presence - List commands to change presence.");
+ cons_show("/help presences - List commands to change presence.");
cons_show("/help contacts - List commands for manipulating your roster.");
cons_show("/help service - List service discovery commands.");
cons_show("/help settings - List commands for changing settings.");
From 5b26879e3137c833baf393878d955420360b8edb Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 28 Jan 2015 20:59:25 +0000
Subject: [PATCH 012/252] Updated /wrap help
---
src/command/command.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/command/command.c b/src/command/command.c
index f1926dbb..7be6603d 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -615,7 +615,7 @@ static struct cmd_t command_defs[] =
{ "/wrap on|off", "Word wrapping.",
{ "/wrap on|off",
"------------",
- "Enable or disable word wrapping.",
+ "Enable or disable word wrapping in the main window.",
NULL } } },
{ "/time",
From 83bd207316037a8086f15f37c0e187a2ffba2e14 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 30 Jan 2015 23:28:02 +0000
Subject: [PATCH 013/252] Moved readline code to inputwin.c
---
src/profanity.c | 45 ++-----------------
src/ui/core.c | 105 ++++++++++++++++++++++-----------------------
src/ui/inputwin.c | 56 +++++++++++++++++++++++-
src/ui/inputwin.h | 2 +
src/ui/ui.h | 2 +-
tests/ui/stub_ui.c | 4 +-
6 files changed, 113 insertions(+), 101 deletions(-)
diff --git a/src/profanity.c b/src/profanity.c
index c105d33f..f3c53003 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -43,8 +43,6 @@
#include
#include
-#include
-#include
#include "profanity.h"
#include "chat_session.h"
@@ -73,20 +71,7 @@ static void _create_directories(void);
static void _connect_default(const char * const account);
static gboolean idle = FALSE;
-static void cb_linehandler(char *);
-static gboolean cmd_result = TRUE;
-
-static void
-cb_linehandler(char *line)
-{
- /* Can use ^D (stty eof) or `exit' to exit. */
- if (*line) {
- add_history(line);
- }
- rl_redisplay();
- cmd_result = cmd_process_input(line);
- free(line);
-}
+static gboolean cont = TRUE;
void
prof_run(const int disable_tls, char *log_level, char *account_name)
@@ -95,35 +80,13 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
_connect_default(account_name);
ui_update();
- fd_set fds;
- int r;
- rl_callback_handler_install(NULL, cb_linehandler);
-
log_info("Starting main event loop");
- struct timeval t;
- t.tv_sec = 0;
- t.tv_usec = 10000;
-
- while(cmd_result) {
+ while(cont) {
_check_autoaway();
- FD_ZERO(&fds);
- FD_SET(fileno (rl_instream), &fds);
- r = select(FD_SETSIZE, &fds, NULL, NULL, &t);
- if (r < 0) {
- perror ("rltest: select");
- rl_callback_handler_remove();
- break;
- }
+ cont = ui_readline();
- if (FD_ISSET (fileno (rl_instream), &fds)) {
- rl_callback_read_char();
- ui_write(rl_line_buffer, rl_point);
- }
-
-
-// line = ui_readline();
#ifdef HAVE_LIBOTR
otr_poll();
#endif
@@ -131,8 +94,6 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
jabber_process_events();
ui_update();
}
-
- rl_callback_handler_remove();
}
void
diff --git a/src/ui/core.c b/src/ui/core.c
index efebdb5e..3520f81d 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -82,7 +82,7 @@ static Display *display;
static GTimer *ui_idle_time;
-static void _win_handle_switch(const wint_t ch);
+//static void _win_handle_switch(const wint_t ch);
static void _win_show_history(int win_index, const char * const contact);
static void _ui_draw_term_title(void);
@@ -174,39 +174,36 @@ ui_close(void)
{
notifier_uninit();
wins_destroy();
+ inp_close();
endwin();
}
-void
-ui_write(char *line, int offset)
-{
- inp_write(line, offset);
-}
-
-char*
+gboolean
ui_readline(void)
{
- int key_type;
- wint_t ch;
+ return inp_readline();
- char *line = inp_read(&key_type, &ch);
- _win_handle_switch(ch);
-
- ProfWin *current = wins_get_current();
- win_handle_page(current, ch, key_type);
-
- if (ch == KEY_RESIZE) {
- ui_resize();
- }
-
- if (ch != ERR && key_type != ERR) {
- ui_reset_idle_time();
- ui_input_nonblocking(TRUE);
- } else {
- ui_input_nonblocking(FALSE);
- }
-
- return line;
+// int key_type;
+// wint_t ch;
+//
+// char *line = inp_read(&key_type, &ch);
+// _win_handle_switch(ch);
+//
+// ProfWin *current = wins_get_current();
+// win_handle_page(current, ch, key_type);
+//
+// if (ch == KEY_RESIZE) {
+// ui_resize();
+// }
+//
+// if (ch != ERR && key_type != ERR) {
+// ui_reset_idle_time();
+// ui_input_nonblocking(TRUE);
+// } else {
+// ui_input_nonblocking(FALSE);
+// }
+//
+// return line;
}
void
@@ -2945,32 +2942,32 @@ ui_hide_roster(void)
}
}
-static void
-_win_handle_switch(const wint_t ch)
-{
- if (ch == KEY_F(1)) {
- ui_switch_win(1);
- } else if (ch == KEY_F(2)) {
- ui_switch_win(2);
- } else if (ch == KEY_F(3)) {
- ui_switch_win(3);
- } else if (ch == KEY_F(4)) {
- ui_switch_win(4);
- } else if (ch == KEY_F(5)) {
- ui_switch_win(5);
- } else if (ch == KEY_F(6)) {
- ui_switch_win(6);
- } else if (ch == KEY_F(7)) {
- ui_switch_win(7);
- } else if (ch == KEY_F(8)) {
- ui_switch_win(8);
- } else if (ch == KEY_F(9)) {
- ui_switch_win(9);
- } else if (ch == KEY_F(10)) {
- ui_switch_win(0);
- }
-}
-
+//static void
+//_win_handle_switch(const wint_t ch)
+//{
+// if (ch == KEY_F(1)) {
+// ui_switch_win(1);
+// } else if (ch == KEY_F(2)) {
+// ui_switch_win(2);
+// } else if (ch == KEY_F(3)) {
+// ui_switch_win(3);
+// } else if (ch == KEY_F(4)) {
+// ui_switch_win(4);
+// } else if (ch == KEY_F(5)) {
+// ui_switch_win(5);
+// } else if (ch == KEY_F(6)) {
+// ui_switch_win(6);
+// } else if (ch == KEY_F(7)) {
+// ui_switch_win(7);
+// } else if (ch == KEY_F(8)) {
+// ui_switch_win(8);
+// } else if (ch == KEY_F(9)) {
+// ui_switch_win(9);
+// } else if (ch == KEY_F(10)) {
+// ui_switch_win(0);
+// }
+//}
+//
static void
_win_show_history(int win_index, const char * const contact)
{
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 64c65a96..4b3ec296 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -39,6 +39,9 @@
#include
#include
+#include
+#include
+
#ifdef HAVE_NCURSESW_NCURSES_H
#include
#elif HAVE_NCURSES_H
@@ -77,6 +80,11 @@
static WINDOW *inp_win;
static History history;
+static struct timeval p_rl_timeout;
+static fd_set fds;
+static int r;
+static gboolean cmd_result = TRUE;
+
// input line
static char line[INP_WIN_MAX];
// current position in the utf8 string
@@ -95,6 +103,17 @@ static gboolean _is_ctrl_right(int key_type, const wint_t ch);
static void _inp_win_update_virtual(void);
+static void
+cb_linehandler(char *line)
+{
+ if (*line) {
+ add_history(line);
+ }
+ rl_redisplay();
+ cmd_result = cmd_process_input(line);
+ free(line);
+}
+
void
create_input_window(void)
{
@@ -103,6 +122,10 @@ create_input_window(void)
#else
ESCDELAY = 25;
#endif
+ p_rl_timeout.tv_sec = 0;
+ p_rl_timeout.tv_usec = 500000;
+ rl_callback_handler_install(NULL, cb_linehandler);
+
inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
keypad(inp_win, TRUE);
@@ -169,9 +192,9 @@ inp_write(char *line, int offset)
}
void
-inp_non_block(gint timeout)
+inp_non_block(gint block_timeout)
{
- wtimeout(inp_win, timeout);
+ wtimeout(inp_win, block_timeout);
}
void
@@ -180,6 +203,35 @@ inp_block(void)
wtimeout(inp_win, -1);
}
+gboolean
+inp_readline(void)
+{
+ FD_ZERO(&fds);
+ FD_SET(fileno (rl_instream), &fds);
+ r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
+ if (r < 0) {
+ log_error("Readline failed.");
+ rl_callback_handler_remove();
+ return false;
+ }
+
+ if (FD_ISSET (fileno (rl_instream), &fds)) {
+ rl_callback_read_char();
+ inp_write(rl_line_buffer, rl_point);
+ }
+
+ p_rl_timeout.tv_sec = 0;
+ p_rl_timeout.tv_usec = 500000;
+
+ return cmd_result;
+}
+
+void
+inp_close(void)
+{
+ rl_callback_handler_remove();
+}
+
char *
inp_read(int *key_type, wint_t *ch)
{
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index d27bfef7..7193e049 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -40,6 +40,8 @@
#define INP_WIN_MAX 1000
void create_input_window(void);
+gboolean inp_readline(void);
+void inp_close(void);
char* inp_read(int *key_type, wint_t *ch);
void inp_win_clear(void);
void inp_win_resize(void);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 23315af9..2cfb6e6e 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -227,7 +227,7 @@ void ui_update_presence(const resource_presence_t resource_presence,
void ui_about(void);
void ui_statusbar_new(const int win);
-char * ui_readline(void);
+gboolean ui_readline(void);
void ui_input_clear(void);
void ui_input_nonblocking(gboolean);
void ui_write(char *line, int offset);
diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c
index 6b9050c3..6127e4f0 100644
--- a/tests/ui/stub_ui.c
+++ b/tests/ui/stub_ui.c
@@ -323,9 +323,9 @@ void ui_update_presence(const resource_presence_t resource_presence,
void ui_about(void) {}
void ui_statusbar_new(const int win) {}
-char * ui_readline(void)
+gboolean ui_readline(void)
{
- return NULL;
+ return TRUE;
}
void ui_inp_history_append(char *inp) {}
From a9ed64911d29819f20fe8cafae87af61b6f53e14 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 30 Jan 2015 23:42:51 +0000
Subject: [PATCH 014/252] Removed history and various key handlers
---
Makefile.am | 6 -
src/command/command.c | 5 -
src/tools/history.c | 283 --------------
src/tools/history.h | 45 ---
src/ui/core.c | 6 -
src/ui/inputwin.c | 844 ++++++++++--------------------------------
src/ui/keyhandlers.c | 216 -----------
src/ui/keyhandlers.h | 45 ---
tests/test_history.c | 219 -----------
tests/test_history.h | 13 -
tests/testsuite.c | 66 ----
11 files changed, 205 insertions(+), 1543 deletions(-)
delete mode 100644 src/tools/history.c
delete mode 100644 src/tools/history.h
delete mode 100644 src/ui/keyhandlers.c
delete mode 100644 src/ui/keyhandlers.h
delete mode 100644 tests/test_history.c
delete mode 100644 tests/test_history.h
diff --git a/Makefile.am b/Makefile.am
index abd1a1ff..300116b1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,6 @@ core_sources = \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
src/ui/console.c src/ui/notifier.c \
src/ui/windows.c src/ui/windows.h \
- src/ui/keyhandlers.c src/ui/keyhandlers.h \
src/ui/rosterwin.c src/ui/occupantswin.c \
src/ui/buffer.c src/ui/buffer.h \
src/command/command.h src/command/command.c \
@@ -28,7 +27,6 @@ core_sources = \
src/tools/parser.h \
src/tools/p_sha1.h src/tools/p_sha1.c \
src/tools/autocomplete.c src/tools/autocomplete.h \
- src/tools/history.c src/tools/history.h \
src/tools/tinyurl.c src/tools/tinyurl.h \
src/config/accounts.c src/config/accounts.h \
src/config/account.c src/config/account.h \
@@ -51,7 +49,6 @@ tests_sources = \
src/tools/parser.h \
src/tools/p_sha1.h src/tools/p_sha1.c \
src/tools/autocomplete.c src/tools/autocomplete.h \
- src/tools/history.c src/tools/history.h \
src/tools/tinyurl.c src/tools/tinyurl.h \
src/config/accounts.h \
src/config/account.c src/config/account.h \
@@ -59,7 +56,6 @@ tests_sources = \
src/config/theme.c src/config/theme.h \
src/ui/windows.c src/ui/windows.h \
src/ui/window.c src/ui/window.h \
- src/ui/keyhandlers.c src/ui/keyhandlers.h \
src/ui/buffer.c \
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
@@ -85,7 +81,6 @@ tests_sources = \
tests/test_common.c tests/test_common.h \
tests/test_contact.c tests/test_contact.h \
tests/test_form.c tests/test_form.h \
- tests/test_history.c tests/test_history.h \
tests/test_jid.c tests/test_jid.h \
tests/test_muc.c tests/test_muc.h \
tests/test_parser.c tests/test_parser.h \
@@ -94,7 +89,6 @@ tests_sources = \
tests/test_server_events.c tests/test_server_events.h \
tests/test_autocomplete.c tests/test_autocomplete.h \
tests/test_chat_session.c tests/test_chat_session.h \
- tests/test_keyhandlers.c tests/test_keyhandlers.h \
tests/testsuite.c
main_source = src/main.c
diff --git a/src/command/command.c b/src/command/command.c
index 8e16276b..909c954c 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1736,11 +1736,6 @@ cmd_process_input(char *inp)
gboolean result = FALSE;
g_strstrip(inp);
- // add line to history if something typed
- if (strlen(inp) > 0) {
- ui_inp_history_append(inp);
- }
-
// just carry on if no input
if (strlen(inp) == 0) {
result = TRUE;
diff --git a/src/tools/history.c b/src/tools/history.c
deleted file mode 100644
index def10feb..00000000
--- a/src/tools/history.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * history.c
- *
- * Copyright (C) 2012 - 2014 James Booth
- *
- * This file is part of Profanity.
- *
- * Profanity is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Profanity is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Profanity. If not, see .
- *
- * In addition, as a special exception, the copyright holders give permission to
- * link the code of portions of this program with the OpenSSL library under
- * certain conditions as described in each individual source file, and
- * distribute linked combinations including the two.
- *
- * You must obey the GNU General Public License in all respects for all of the
- * code used other than OpenSSL. If you modify file(s) with this exception, you
- * may extend this exception to your version of the file(s), but you are not
- * obligated to do so. If you do not wish to do so, delete this exception
- * statement from your version. If you delete this exception statement from all
- * source files in the program, then also delete it here.
- *
- */
-
-#include
-#include
-
-#include
-
-#include "history.h"
-
-struct history_session_t {
- GList *items;
- GList *sess_curr;
- GList *sess_new;
- GList *orig_curr;
-};
-
-struct history_t {
- GList *items;
- guint max_size;
- struct history_session_t session;
-};
-
-static void _replace_history_with_session(History history);
-static gboolean _adding_new(History history);
-static void _reset_session(History history);
-static gboolean _has_session(History history);
-static void _remove_first(History history);
-static void _update_current_session_item(History history, char *item);
-static void _add_to_history(History history, char *item);
-static void _remove_last_session_item(History history);
-static void _replace_current_with_original(History history);
-static void _create_session(History history);
-static void _session_previous(History history);
-static void _session_next(History history);
-
-History
-history_new(unsigned int size)
-{
- History new_history = malloc(sizeof(struct history_t));
- new_history->items = NULL;
- new_history->max_size = size;
-
- _reset_session(new_history);
-
- return new_history;
-}
-
-void
-history_append(History history, char *item)
-{
- char *copied = "";
- if (item != NULL) {
- copied = strdup(item);
- }
-
- if (history->items == NULL) {
- _add_to_history(history, copied);
- return;
- }
-
- if (!_has_session(history)) {
- if (g_list_length(history->items) == history->max_size) {
- _remove_first(history);
- }
-
- _add_to_history(history, copied);
-
- } else {
- _update_current_session_item(history, copied);
-
- if (_adding_new(history)) {
- if (strcmp(history->session.sess_curr->data, "") == 0) {
- _remove_last_session_item(history);
- }
-
- _replace_history_with_session(history);
-
- } else {
- _remove_last_session_item(history);
-
- char *new = strdup(history->session.sess_curr->data);
- history->session.items = g_list_append(history->session.items, new);
-
- _replace_current_with_original(history);
- _replace_history_with_session(history);
- }
- }
-}
-
-char *
-history_previous(History history, char *item)
-{
- // no history
- if (history->items == NULL) {
- return NULL;
- }
-
- char *copied = "";
- if (item != NULL) {
- copied = strdup(item);
- }
-
- if (!_has_session(history)) {
- _create_session(history);
-
- // add the new item
- history->session.items = g_list_append(history->session.items, copied);
- history->session.sess_new = g_list_last(history->session.items);
-
- char *result = strdup(history->session.sess_curr->data);
- return result;
- } else {
- _update_current_session_item(history, copied);
- _session_previous(history);
- }
-
- char *result = strdup(history->session.sess_curr->data);
- return result;
-}
-
-char *
-history_next(History history, char *item)
-{
- // no history, or no session, return NULL
- if ((history->items == NULL) || (history->session.items == NULL)) {
- return NULL;
- }
-
- if (g_list_next(history->session.sess_curr) == NULL) {
- return NULL;
- }
-
- char *copied = "";
- if (item != NULL) {
- copied = strdup(item);
- }
-
- _update_current_session_item(history, copied);
- _session_next(history);
-
- char *result = strdup(history->session.sess_curr->data);
- return result;
-}
-
-static void
-_replace_history_with_session(History history)
-{
- g_list_free(history->items);
- history->items = g_list_copy(history->session.items);
-
- if (g_list_length(history->items) > history->max_size) {
- _remove_first(history);
- }
-
- _reset_session(history);
-}
-
-static gboolean
-_adding_new(History history)
-{
- return (history->session.sess_curr ==
- g_list_last(history->session.items));
-}
-
-static void
-_reset_session(History history)
-{
- history->session.items = NULL;
- history->session.sess_curr = NULL;
- history->session.sess_new = NULL;
- history->session.orig_curr = NULL;
-}
-
-static gboolean
-_has_session(History history)
-{
- return (history->session.items != NULL);
-}
-
-static void
-_remove_first(History history)
-{
- GList *first = g_list_first(history->items);
- char *first_item = first->data;
- history->items = g_list_remove(history->items, first_item);
-}
-
-static void
-_update_current_session_item(History history, char *item)
-{
- history->session.sess_curr->data = item;
-}
-
-static void
-_add_to_history(History history, char *item)
-{
- history->items = g_list_append(history->items, item);
-}
-
-static void
-_remove_last_session_item(History history)
-{
- history->session.items = g_list_reverse(history->session.items);
- GList *first = g_list_first(history->session.items);
- history->session.items =
- g_list_remove(history->session.items, first->data);
- history->session.items = g_list_reverse(history->session.items);
-}
-
-static void
-_replace_current_with_original(History history)
-{
- history->session.sess_curr->data = strdup(history->session.orig_curr->data);
-}
-
-static void
-_create_session(History history)
-{
- history->session.items = g_list_copy(history->items);
- history->session.sess_curr = g_list_last(history->session.items);
- history->session.orig_curr = g_list_last(history->items);
-}
-
-static void
-_session_previous(History history)
-{
- history->session.sess_curr =
- g_list_previous(history->session.sess_curr);
- if (history->session.orig_curr == NULL)
- history->session.orig_curr = g_list_last(history->items);
- else
- history->session.orig_curr =
- g_list_previous(history->session.orig_curr);
-
- if (history->session.sess_curr == NULL) {
- history->session.sess_curr = g_list_first(history->session.items);
- history->session.orig_curr = g_list_first(history->items);
- }
-}
-
-static void
-_session_next(History history)
-{
- history->session.sess_curr = g_list_next(history->session.sess_curr);
- history->session.orig_curr = g_list_next(history->session.orig_curr);
-
- if (history->session.sess_curr == NULL) {
- history->session.sess_curr = g_list_last(history->session.items);
- history->session.orig_curr = NULL;
- }
-}
diff --git a/src/tools/history.h b/src/tools/history.h
deleted file mode 100644
index 7b334718..00000000
--- a/src/tools/history.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * history.h
- *
- * Copyright (C) 2012 - 2014 James Booth
- *
- * This file is part of Profanity.
- *
- * Profanity is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Profanity is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Profanity. If not, see .
- *
- * In addition, as a special exception, the copyright holders give permission to
- * link the code of portions of this program with the OpenSSL library under
- * certain conditions as described in each individual source file, and
- * distribute linked combinations including the two.
- *
- * You must obey the GNU General Public License in all respects for all of the
- * code used other than OpenSSL. If you modify file(s) with this exception, you
- * may extend this exception to your version of the file(s), but you are not
- * obligated to do so. If you do not wish to do so, delete this exception
- * statement from your version. If you delete this exception statement from all
- * source files in the program, then also delete it here.
- *
- */
-
-#ifndef HISTORY_H
-#define HISTORY_H
-
-typedef struct history_t *History;
-
-History history_new(unsigned int size);
-char * history_previous(History history, char *item);
-char * history_next(History history, char *item);
-void history_append(History history, char *item);
-
-#endif
diff --git a/src/ui/core.c b/src/ui/core.c
index 3520f81d..84a442f2 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -206,12 +206,6 @@ ui_readline(void)
// return line;
}
-void
-ui_inp_history_append(char *inp)
-{
- inp_history_append(inp);
-}
-
void
ui_input_clear(void)
{
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 4b3ec296..d669f67b 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -53,7 +53,6 @@
#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"
@@ -63,7 +62,6 @@
#include "ui/inputwin.h"
#include "ui/windows.h"
#include "xmpp/xmpp.h"
-#include "ui/keyhandlers.h"
#define KEY_CTRL_A 0001
#define KEY_CTRL_B 0002
@@ -78,7 +76,6 @@
#define MAX_HISTORY 100
static WINDOW *inp_win;
-static History history;
static struct timeval p_rl_timeout;
static fd_set fds;
@@ -92,15 +89,6 @@ static int line_utf8_pos;
static int pad_start = 0;
-static int _handle_edit(int key_type, const wint_t ch);
-static int _handle_alt_key(int key);
-
-static void _handle_delete_previous_word(void);
-static void _handle_backspace(void);
-
-static gboolean _is_ctrl_left(int key_type, const wint_t ch);
-static gboolean _is_ctrl_right(int key_type, const wint_t ch);
-
static void _inp_win_update_virtual(void);
static void
@@ -131,7 +119,6 @@ create_input_window(void)
keypad(inp_win, TRUE);
wmove(inp_win, 0, 0);
_inp_win_update_virtual();
- history = history_new(MAX_HISTORY);
line_utf8_pos = 0;
line[0] = '\0';
}
@@ -207,15 +194,14 @@ gboolean
inp_readline(void)
{
FD_ZERO(&fds);
- FD_SET(fileno (rl_instream), &fds);
+ FD_SET(fileno(rl_instream), &fds);
r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
if (r < 0) {
log_error("Readline failed.");
- rl_callback_handler_remove();
return false;
}
- if (FD_ISSET (fileno (rl_instream), &fds)) {
+ if (FD_ISSET(fileno(rl_instream), &fds)) {
rl_callback_read_char();
inp_write(rl_line_buffer, rl_point);
}
@@ -232,68 +218,68 @@ inp_close(void)
rl_callback_handler_remove();
}
-char *
-inp_read(int *key_type, wint_t *ch)
-{
- // echo off, and get some more input
- noecho();
- *key_type = wget_wch(inp_win, ch);
-
- int bytes_len = strlen(line);
-
- gboolean in_command = FALSE;
- if ((bytes_len > 0 && line[0] == '/') ||
- (bytes_len == 0 && *ch == '/')) {
- in_command = TRUE;
- }
-
- if (*key_type == ERR) {
- prof_handle_idle();
- }
- if ((*key_type != ERR) && (*key_type != KEY_CODE_YES) && !in_command && utf8_is_printable(*ch)) {
- prof_handle_activity();
- }
-
- // if it wasn't an arrow key etc
- if (!_handle_edit(*key_type, *ch)) {
- if (utf8_is_printable(*ch) && *key_type != KEY_CODE_YES) {
- if (bytes_len >= INP_WIN_MAX) {
- *ch = ERR;
- return NULL;
- }
-
- int col = getcurx(inp_win);
- int maxx = getmaxx(stdscr);
- key_printable(line, &line_utf8_pos, &col, &pad_start, *ch, maxx);
-
- werase(inp_win);
- waddstr(inp_win, line);
- wmove(inp_win, 0, col);
- _inp_win_update_virtual();
-
- cmd_reset_autocomplete();
- }
- }
-
- echo();
-
- char *result = NULL;
- if (*ch == '\n') {
- result = strdup(line);
- line[0] = '\0';
- line_utf8_pos = 0;
- }
-
- if (*ch != ERR && *key_type != ERR) {
- cons_debug("BYTE LEN = %d", strlen(line));
- cons_debug("UTF8 LEN = %d", utf8_display_len(line));
- cons_debug("CURR COL = %d", getcurx(inp_win));
- cons_debug("CURR UNI = %d", line_utf8_pos);
- cons_debug("");
- }
-
- return result;
-}
+//char *
+//inp_read(int *key_type, wint_t *ch)
+//{
+// // echo off, and get some more input
+// noecho();
+// *key_type = wget_wch(inp_win, ch);
+//
+// int bytes_len = strlen(line);
+//
+// gboolean in_command = FALSE;
+// if ((bytes_len > 0 && line[0] == '/') ||
+// (bytes_len == 0 && *ch == '/')) {
+// in_command = TRUE;
+// }
+//
+// if (*key_type == ERR) {
+// prof_handle_idle();
+// }
+// if ((*key_type != ERR) && (*key_type != KEY_CODE_YES) && !in_command && utf8_is_printable(*ch)) {
+// prof_handle_activity();
+// }
+//
+// // if it wasn't an arrow key etc
+// if (!_handle_edit(*key_type, *ch)) {
+// if (utf8_is_printable(*ch) && *key_type != KEY_CODE_YES) {
+// if (bytes_len >= INP_WIN_MAX) {
+// *ch = ERR;
+// return NULL;
+// }
+//
+// int col = getcurx(inp_win);
+// int maxx = getmaxx(stdscr);
+// key_printable(line, &line_utf8_pos, &col, &pad_start, *ch, maxx);
+//
+// werase(inp_win);
+// waddstr(inp_win, line);
+// wmove(inp_win, 0, col);
+// _inp_win_update_virtual();
+//
+// cmd_reset_autocomplete();
+// }
+// }
+//
+// echo();
+//
+// char *result = NULL;
+// if (*ch == '\n') {
+// result = strdup(line);
+// line[0] = '\0';
+// line_utf8_pos = 0;
+// }
+//
+// if (*ch != ERR && *key_type != ERR) {
+// cons_debug("BYTE LEN = %d", strlen(line));
+// cons_debug("UTF8 LEN = %d", utf8_display_len(line));
+// cons_debug("CURR COL = %d", getcurx(inp_win));
+// cons_debug("CURR UNI = %d", line_utf8_pos);
+// cons_debug("");
+// }
+//
+// return result;
+//}
void
inp_get_password(char *passwd)
@@ -329,572 +315,152 @@ inp_win_clear(void)
_inp_win_update_virtual();
}
-void
-inp_history_append(char *inp)
-{
- history_append(history, inp);
-}
-
/*
* Deal with command editing, return 1 if ch was an edit
* key press: up, down, left, right or backspace
* return 0 if it wasn't
*/
-static int
-_handle_edit(int key_type, const wint_t ch)
-{
- int col = getcurx(inp_win);
- int utf8_len = g_utf8_strlen(line, -1);
- int wcols = getmaxx(stdscr);
-
- // CTRL-LEFT
- if (_is_ctrl_left(key_type, ch)) {
- key_ctrl_left(line, &line_utf8_pos, &col, &pad_start, wcols);
- wmove(inp_win, 0, col);
- return 1;
-
- // CTRL-RIGHT
- } else if (_is_ctrl_right(key_type, ch)) {
- key_ctrl_right(line, &line_utf8_pos, &col, &pad_start, wcols);
- wmove(inp_win, 0, col);
- return 1;
-
- // ALT-LEFT
- } else if ((key_type == KEY_CODE_YES) && (ch == 537 || ch == 542)) {
- ui_previous_win();
- return 1;
-
- // ALT-RIGHT
- } else if ((key_type == KEY_CODE_YES) && (ch == 552 || ch == 557)) {
- ui_next_win();
- return 1;
-
- // other editing keys
- } else {
- int display_len;
- int bytes_len = strlen(line);
- int next_ch;
-
- switch(ch) {
-
- case 27: // ESC
- // check for ALT-key
- next_ch = wgetch(inp_win);
- if (next_ch != ERR) {
- return _handle_alt_key(next_ch);
- } else {
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- _inp_win_update_virtual();
- return 1;
- }
-
- case 127:
- _handle_backspace();
- return 1;
- case KEY_BACKSPACE:
- if (key_type != KEY_CODE_YES) {
- return 0;
- }
- _handle_backspace();
- return 1;
-
- case KEY_DC: // DEL
- if (key_type != KEY_CODE_YES) {
- return 0;
- }
- case KEY_CTRL_D:
- if (line_utf8_pos == utf8_len) {
- return 1;
- } else if (line_utf8_pos == utf8_len-1) {
- gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
- int bytes_len_ch = strlen(curr_ch);
- bytes_len -= bytes_len_ch;
- line[bytes_len] = '\0';
- line_utf8_pos--;
- wdelch(inp_win);
-
- return 1;
- } else if (line_utf8_pos < utf8_len-1) {
- gchar *start = g_utf8_substring(line, 0, col);
- gchar *end = g_utf8_substring(line, col+1, bytes_len);
- GString *new = g_string_new(start);
- g_string_append(new, end);
-
- for (bytes_len = 0; bytes_len < strlen(new->str); bytes_len++) {
- line[bytes_len] = new->str[bytes_len];
- }
- line[bytes_len] = '\0';
-
- g_free(start);
- g_free(end);
- g_string_free(new, FALSE);
-
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- waddstr(inp_win, line);
- wmove(inp_win, 0, col);
- }
- return 1;
-
- case KEY_LEFT:
- if (key_type != KEY_CODE_YES) {
- return 0;
- }
- case KEY_CTRL_B:
- if (line_utf8_pos > 0) {
- col--;
- gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
- gchar *prev_ch = g_utf8_find_prev_char(line, curr_ch);
- if (prev_ch) {
- gunichar uni = g_utf8_get_char(prev_ch);
- if (g_unichar_iswide(uni)) {
- col--;
- }
- }
- wmove(inp_win, 0, col);
- line_utf8_pos--;
-
- // current position off screen to left
- if (col < pad_start) {
- pad_start--;
- _inp_win_update_virtual();
- }
- }
- return 1;
-
- case KEY_RIGHT:
- if (key_type != KEY_CODE_YES) {
- return 0;
- }
- case KEY_CTRL_F:
- if (line_utf8_pos < utf8_len) {
- col++;
- gchar *curr_ch = g_utf8_offset_to_pointer(line, line_utf8_pos);
- if (curr_ch) {
- gunichar uni = g_utf8_get_char(curr_ch);
- if (g_unichar_iswide(uni)) {
- col++;
- }
- }
- wmove(inp_win, 0, col);
- line_utf8_pos++;
-
- // current position off screen to right
- int wcols = getmaxx(stdscr);
- if ((col - pad_start) >= wcols) {
- pad_start++;
- _inp_win_update_virtual();
- }
- }
- return 1;
-
- case KEY_UP:
- if (key_type != KEY_CODE_YES) {
- return 0;
- }
- case KEY_CTRL_P:
- line[bytes_len] = '\0';
- char *prev = history_previous(history, line);
- if (prev) {
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- strncpy(line, prev, INP_WIN_MAX);
- waddstr(inp_win, line);
-
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- int wcols = getmaxx(stdscr);
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
- }
- return 1;
-
- case KEY_DOWN:
- if (key_type != KEY_CODE_YES) {
- return 0;
- }
- case KEY_CTRL_N:
- line[bytes_len] = '\0';
- char *next = history_next(history, line);
- if (next) {
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- strncpy(line, next, INP_WIN_MAX);
- waddstr(inp_win, line);
-
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- int wcols = getmaxx(stdscr);
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
- } else if (bytes_len != 0) {
- line[bytes_len] = '\0';
- history_append(history, line);
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- strncpy(line, "", INP_WIN_MAX);
- waddstr(inp_win, line);
-
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- int wcols = getmaxx(stdscr);
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
- }
- return 1;
-
- case KEY_HOME:
- if (key_type != KEY_CODE_YES) {
- return 0;
- }
- case KEY_CTRL_A:
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line_utf8_pos = 0;
- _inp_win_update_virtual();
- return 1;
-
- case KEY_END:
- if (key_type != KEY_CODE_YES) {
- return 0;
- }
- case KEY_CTRL_E:
- display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- int wcols = getmaxx(stdscr);
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
- return 1;
-
- case 9: // tab
- if (bytes_len != 0) {
- line[bytes_len] = '\0';
- if ((strncmp(line, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
- char *result = muc_autocomplete(line);
- if (result) {
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- strncpy(line, result, INP_WIN_MAX);
- waddstr(inp_win, line);
-
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- int wcols = getmaxx(stdscr);
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
-
- free(result);
- }
- } else if (strncmp(line, "/", 1) == 0) {
- char *result = cmd_autocomplete(line);
- if (result) {
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- strncpy(line, result, INP_WIN_MAX);
- waddstr(inp_win, line);
-
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- int wcols = getmaxx(stdscr);
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
-
- free(result);
- }
- }
- }
- return 1;
-
- case KEY_CTRL_W:
- _handle_delete_previous_word();
- return 1;
- break;
-
- case KEY_CTRL_U:
- while (getcurx(inp_win) > 0) {
- _handle_delete_previous_word();
- }
- return 1;
- break;
-
- default:
- return 0;
- }
- }
-}
-
-static void
-_handle_backspace(void)
-{
- int col = getcurx(inp_win);
- int utf8_len = g_utf8_strlen(line, -1);
- roster_reset_search_attempts();
-
- if (utf8_len > 0) {
- // if at end, delete last char
- if (line_utf8_pos >= utf8_len) {
- gchar *new_line = g_utf8_substring(line, 0, utf8_len-1);
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- strncpy(line, new_line, INP_WIN_MAX);
- waddstr(inp_win, line);
-
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- int wcols = getmaxx(stdscr);
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
-
- // if in middle, delete and shift chars left
- } else if (line_utf8_pos > 0 && line_utf8_pos < utf8_len) {
- gchar *del_char = g_utf8_offset_to_pointer(line, line_utf8_pos-1);
- gunichar uni = g_utf8_get_char(del_char);
-
- gchar *start = g_utf8_substring(line, 0, line_utf8_pos-1);
- gchar *end = g_utf8_substring(line, line_utf8_pos, utf8_len);
- GString *new_line = g_string_new(start);
- g_string_append(new_line, end);
-
- int old_pos = line_utf8_pos;
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
- strncpy(line, new_line->str, INP_WIN_MAX);
- waddstr(inp_win, line);
-
- int display_len = utf8_display_len(line);
- wmove(inp_win, 0, display_len);
- line_utf8_pos = g_utf8_strlen(line, -1);
-
- int wcols = getmaxx(stdscr);
- if (display_len > wcols-2) {
- pad_start = display_len - wcols + 1;
- _inp_win_update_virtual();
- }
-
- line_utf8_pos = old_pos-1;
-
- g_free(start);
- g_free(end);
- g_string_free(new_line, TRUE);
-
- col--;
- if (g_unichar_iswide(uni)) {
- col--;
- }
-
- wmove(inp_win, 0, col);
- }
-
- // if gone off screen to left, jump left (half a screen worth)
- if (col <= pad_start) {
- int wcols = getmaxx(stdscr);
- pad_start = pad_start - (wcols / 2);
- if (pad_start < 0) {
- pad_start = 0;
- }
-
- _inp_win_update_virtual();
- }
- }
-
-}
-
-static int
-_handle_alt_key(int key)
-{
- switch (key)
- {
- case '1':
- ui_switch_win(1);
- break;
- case '2':
- ui_switch_win(2);
- break;
- case '3':
- ui_switch_win(3);
- break;
- case '4':
- ui_switch_win(4);
- break;
- case '5':
- ui_switch_win(5);
- break;
- case '6':
- ui_switch_win(6);
- break;
- case '7':
- ui_switch_win(7);
- break;
- case '8':
- ui_switch_win(8);
- break;
- case '9':
- ui_switch_win(9);
- break;
- case '0':
- ui_switch_win(0);
- break;
- case KEY_LEFT:
- ui_previous_win();
- break;
- case KEY_RIGHT:
- ui_next_win();
- break;
- case 263:
- case 127:
- _handle_delete_previous_word();
- break;
- default:
- break;
- }
- return 1;
-}
-
-static void
-_handle_delete_previous_word(void)
-{
- int end_del = getcurx(inp_win);
- int start_del = end_del;
-
- gchar *curr_ch = g_utf8_offset_to_pointer(line, end_del);
- curr_ch = g_utf8_find_prev_char(line, curr_ch);
- gchar *prev_ch;
- gunichar curr_uni;
- gunichar prev_uni;
-
- while (curr_ch != NULL) {
- curr_uni = g_utf8_get_char(curr_ch);
-
- if (g_unichar_isspace(curr_uni)) {
- curr_ch = g_utf8_find_prev_char(line, curr_ch);
- } else {
- prev_ch = g_utf8_find_prev_char(line, curr_ch);
- if (prev_ch == NULL) {
- curr_ch = NULL;
- break;
- } else {
- prev_uni = g_utf8_get_char(prev_ch);
- if (g_unichar_isspace(prev_uni)) {
- break;
- } else {
- curr_ch = prev_ch;
- }
- }
- }
- }
-
- if (curr_ch == NULL) {
- start_del = 0;
- } else {
- start_del = g_utf8_pointer_to_offset(line, curr_ch);
- }
-
- gint len = g_utf8_strlen(line, -1);
- gchar *start_string = g_utf8_substring(line, 0, start_del);
- gchar *end_string = g_utf8_substring(line, end_del, len);
-
- int i;
- for (i = 0; i < strlen(start_string); i++) {
- line[i] = start_string[i];
- }
- for (i = 0; i < strlen(end_string); i++) {
- line[strlen(start_string)+i] = end_string[i];
- }
-
- int bytes_len = strlen(start_string)+i;
- line[bytes_len] = '\0';
-
- werase(inp_win);
- wmove(inp_win, 0, 0);
- pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
-
- waddstr(inp_win, line);
- wmove(inp_win, 0, start_del);
-
- // if gone off screen to left, jump left (half a screen worth)
- if (start_del <= pad_start) {
- int wcols = getmaxx(stdscr);
- pad_start = pad_start - (wcols / 2);
- if (pad_start < 0) {
- pad_start = 0;
- }
-
- _inp_win_update_virtual();
- }
-}
-
-static gboolean
-_is_ctrl_left(int key_type, const wint_t ch)
-{
- return ((key_type == KEY_CODE_YES)
- && (ch == 547 || ch == 545 || ch == 544 || ch == 540 || ch == 539));
-}
-
-static gboolean
-_is_ctrl_right(int key_type, const wint_t ch)
-{
- return ((key_type == KEY_CODE_YES)
- && (ch == 562 || ch == 560 || ch == 555 || ch == 559 || ch == 554));
-}
-
+//static int
+//_handle_edit(int key_type, const wint_t ch)
+//{
+// // ALT-LEFT
+// if ((key_type == KEY_CODE_YES) && (ch == 537 || ch == 542)) {
+// ui_previous_win();
+// return 1;
+//
+// // ALT-RIGHT
+// } else if ((key_type == KEY_CODE_YES) && (ch == 552 || ch == 557)) {
+// ui_next_win();
+// return 1;
+//
+// // other editing keys
+// } else {
+// int bytes_len = strlen(line);
+// int next_ch;
+//
+// switch(ch) {
+//
+// case 27: // ESC
+// // check for ALT-key
+// next_ch = wgetch(inp_win);
+// if (next_ch != ERR) {
+// return _handle_alt_key(next_ch);
+// } else {
+// werase(inp_win);
+// wmove(inp_win, 0, 0);
+// pad_start = 0;
+// line[0] = '\0';
+// line_utf8_pos = 0;
+// _inp_win_update_virtual();
+// return 1;
+// }
+//
+// case 9: // tab
+// if (bytes_len != 0) {
+// line[bytes_len] = '\0';
+// if ((strncmp(line, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
+// char *result = muc_autocomplete(line);
+// if (result) {
+// werase(inp_win);
+// wmove(inp_win, 0, 0);
+// pad_start = 0;
+// line[0] = '\0';
+// line_utf8_pos = 0;
+// strncpy(line, result, INP_WIN_MAX);
+// waddstr(inp_win, line);
+//
+// int display_len = utf8_display_len(line);
+// wmove(inp_win, 0, display_len);
+// line_utf8_pos = g_utf8_strlen(line, -1);
+//
+// int wcols = getmaxx(stdscr);
+// if (display_len > wcols-2) {
+// pad_start = display_len - wcols + 1;
+// _inp_win_update_virtual();
+// }
+//
+// free(result);
+// }
+// } else if (strncmp(line, "/", 1) == 0) {
+// char *result = cmd_autocomplete(line);
+// if (result) {
+// werase(inp_win);
+// wmove(inp_win, 0, 0);
+// pad_start = 0;
+// line[0] = '\0';
+// line_utf8_pos = 0;
+// strncpy(line, result, INP_WIN_MAX);
+// waddstr(inp_win, line);
+//
+// int display_len = utf8_display_len(line);
+// wmove(inp_win, 0, display_len);
+// line_utf8_pos = g_utf8_strlen(line, -1);
+//
+// int wcols = getmaxx(stdscr);
+// if (display_len > wcols-2) {
+// pad_start = display_len - wcols + 1;
+// _inp_win_update_virtual();
+// }
+//
+// free(result);
+// }
+// }
+// }
+// return 1;
+//
+// default:
+// return 0;
+// }
+// }
+//}
+
+//static int
+//_handle_alt_key(int key)
+//{
+// switch (key)
+// {
+// case '1':
+// ui_switch_win(1);
+// break;
+// case '2':
+// ui_switch_win(2);
+// break;
+// case '3':
+// ui_switch_win(3);
+// break;
+// case '4':
+// ui_switch_win(4);
+// break;
+// case '5':
+// ui_switch_win(5);
+// break;
+// case '6':
+// ui_switch_win(6);
+// break;
+// case '7':
+// ui_switch_win(7);
+// break;
+// case '8':
+// ui_switch_win(8);
+// break;
+// case '9':
+// ui_switch_win(9);
+// break;
+// case '0':
+// ui_switch_win(0);
+// break;
+// case KEY_LEFT:
+// ui_previous_win();
+// break;
+// case KEY_RIGHT:
+// ui_next_win();
+// break;
+// default:
+// break;
+// }
+// return 1;
+//}
+//
static void
_inp_win_update_virtual(void)
{
diff --git a/src/ui/keyhandlers.c b/src/ui/keyhandlers.c
deleted file mode 100644
index 0836737b..00000000
--- a/src/ui/keyhandlers.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * keyhandlers.c
- *
- * Copyright (C) 2012 - 2014 James Booth
- *
- * This file is part of Profanity.
- *
- * Profanity is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Profanity is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Profanity. If not, see .
- *
- * In addition, as a special exception, the copyright holders give permission to
- * link the code of portions of this program with the OpenSSL library under
- * certain conditions as described in each individual source file, and
- * distribute linked combinations including the two.
- *
- * You must obey the GNU General Public License in all respects for all of the
- * code used other than OpenSSL. If you modify file(s) with this exception, you
- * may extend this exception to your version of the file(s), but you are not
- * obligated to do so. If you do not wish to do so, delete this exception
- * statement from your version. If you delete this exception statement from all
- * source files in the program, then also delete it here.
- *
- */
-
-#include
-#include
-#include
-
-#include
-
-#include "ui/inputwin.h"
-#include "common.h"
-
-void
-key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int maxx)
-{
- int utf8_len = g_utf8_strlen(line, -1);
-
- // handle insert if not at end of input
- if (*line_utf8_pos < utf8_len) {
- char bytes[MB_CUR_MAX];
- size_t utf8_ch_len = wcrtomb(bytes, ch, NULL);
- bytes[utf8_ch_len] = '\0';
- gchar *start = g_utf8_substring(line, 0, *line_utf8_pos);
- gchar *end = g_utf8_substring(line, *line_utf8_pos, utf8_len);
- GString *new_line_str = g_string_new(start);
- g_string_append(new_line_str, bytes);
- g_string_append(new_line_str, end);
- char *new_line = new_line_str->str;
- g_free(start);
- g_free(end);
- g_string_free(new_line_str, FALSE);
-
- strncpy(line, new_line, INP_WIN_MAX);
- free(new_line);
-
- gunichar uni = g_utf8_get_char(bytes);
- if (*col == (*pad_start + maxx)) {
- (*pad_start)++;
- if (g_unichar_iswide(uni)) {
- (*pad_start)++;
- }
- }
-
- (*line_utf8_pos)++;
-
- (*col)++;
- if (g_unichar_iswide(uni)) {
- (*col)++;
- }
-
- // otherwise just append
- } else {
- char bytes[MB_CUR_MAX+1];
- size_t utf8_ch_len = wcrtomb(bytes, ch, NULL);
- if (utf8_ch_len < MB_CUR_MAX) {
- int i;
- int bytes_len = strlen(line);
-
- for (i = 0 ; i < utf8_ch_len; i++) {
- line[bytes_len++] = bytes[i];
- }
- line[bytes_len] = '\0';
-
- (*line_utf8_pos)++;
-
- (*col)++;
- bytes[utf8_ch_len] = '\0';
- gunichar uni = g_utf8_get_char(bytes);
- if (g_unichar_iswide(uni)) {
- (*col)++;
- }
-
- if (*col - *pad_start > maxx-1) {
- (*pad_start)++;
- if (g_unichar_iswide(uni)) {
- (*pad_start)++;
- }
- }
- }
- }
-}
-
-void
-key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int maxx)
-{
- if (*line_utf8_pos == 0) {
- return;
- }
-
- gchar *curr_ch = g_utf8_offset_to_pointer(line, *line_utf8_pos);
- gunichar curr_uni = g_utf8_get_char(curr_ch);
-
- (*line_utf8_pos)--;
- (*col)--;
- if (g_unichar_iswide(curr_uni)) {
- (*col)--;
- }
-
- curr_ch = g_utf8_find_prev_char(line, curr_ch);
-
- gchar *prev_ch;
- gunichar prev_uni;
- while (curr_ch != NULL) {
- curr_uni = g_utf8_get_char(curr_ch);
- if (g_unichar_isspace(curr_uni)) {
- curr_ch = g_utf8_find_prev_char(line, curr_ch);
- (*line_utf8_pos)--;
- (*col)--;
- } else {
- prev_ch = g_utf8_find_prev_char(line, curr_ch);
- if (prev_ch == NULL) {
- curr_ch = NULL;
- break;
- } else {
- prev_uni = g_utf8_get_char(prev_ch);
- (*line_utf8_pos)--;
- (*col)--;
- if (g_unichar_iswide(curr_uni)) {
- (*col)--;
- }
- if (g_unichar_isspace(prev_uni)) {
- break;
- } else {
- curr_ch = prev_ch;
- }
- }
- }
- }
-
- if (curr_ch == NULL) {
- (*col) = 0;
- (*line_utf8_pos) = 0;
- } else {
- (*col)++;
- (*line_utf8_pos)++;
- }
-
- if (*col < *pad_start) {
- *pad_start = *col;
- }
-}
-
-void
-key_ctrl_right(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int maxx)
-{
- int utf8_len = g_utf8_strlen(line, -1);
- if (*line_utf8_pos >= utf8_len) {
- return;
- }
-
- gchar *curr_ch = g_utf8_offset_to_pointer(line, *line_utf8_pos);
- gunichar curr_uni = g_utf8_get_char(curr_ch);
-
- // find next word if in whitespace
- while (g_unichar_isspace(curr_uni)) {
- (*col)++;
- (*line_utf8_pos)++;
- curr_ch = g_utf8_find_next_char(curr_ch, NULL);
- if (!curr_ch) {
- break;
- }
- curr_uni = g_utf8_get_char(curr_ch);
- }
-
- if (curr_ch) {
- while (!g_unichar_isspace(curr_uni)) {
- (*line_utf8_pos)++;
- (*col)++;
- if (g_unichar_iswide(curr_uni)) {
- (*col)++;
- }
- curr_ch = g_utf8_find_next_char(curr_ch, NULL);
- if (!curr_ch || *line_utf8_pos >= utf8_len) {
- break;
- }
- curr_uni = g_utf8_get_char(curr_ch);
- }
- }
-
- // if gone off screen to right, jump right (half a screen worth)
-// if (col > pad_start + wcols) {
-// pad_start = pad_start + (wcols / 2);
-// _inp_win_update_virtual();
-// }
-}
diff --git a/src/ui/keyhandlers.h b/src/ui/keyhandlers.h
deleted file mode 100644
index 62a2c0d6..00000000
--- a/src/ui/keyhandlers.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * keyhandlers.c
- *
- * Copyright (C) 2012 - 2014 James Booth
- *
- * This file is part of Profanity.
- *
- * Profanity is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Profanity is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Profanity. If not, see .
- *
- * In addition, as a special exception, the copyright holders give permission to
- * link the code of portions of this program with the OpenSSL library under
- * certain conditions as described in each individual source file, and
- * distribute linked combinations including the two.
- *
- * You must obey the GNU General Public License in all respects for all of the
- * code used other than OpenSSL. If you modify file(s) with this exception, you
- * may extend this exception to your version of the file(s), but you are not
- * obligated to do so. If you do not wish to do so, delete this exception
- * statement from your version. If you delete this exception statement from all
- * source files in the program, then also delete it here.
- *
- */
-
-#ifndef UI_KEYHANDLERS_H
-#define UI_KEYHANDLERS_H
-
-#include
-
-void key_printable(char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const wint_t ch, const int maxx);
-
-void key_ctrl_left(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int maxx);
-void key_ctrl_right(const char * const line, int * const line_utf8_pos, int * const col, int * const pad_start, const int maxx);
-
-#endif
diff --git a/tests/test_history.c b/tests/test_history.c
deleted file mode 100644
index 1584b390..00000000
--- a/tests/test_history.c
+++ /dev/null
@@ -1,219 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-#include "tools/history.h"
-
-void previous_on_empty_returns_null(void **state)
-{
- History history = history_new(10);
- char *item = history_previous(history, "inp");
-
- assert_null(item);
-}
-
-void next_on_empty_returns_null(void **state)
-{
- History history = history_new(10);
- char *item = history_next(history, "inp");
-
- assert_null(item);
-}
-
-void previous_once_returns_last(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
-
- char *item = history_previous(history, "inp");
-
- assert_string_equal("Hello", item);
-}
-
-void previous_twice_when_one_returns_first(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
-
- char *item1 = history_previous(history, NULL);
- char *item2 = history_previous(history, item1);
-
- assert_string_equal("Hello", item2);
-}
-
-void previous_always_stops_at_first(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
-
- char *item1 = history_previous(history, NULL);
- char *item2 = history_previous(history, item1);
- char *item3 = history_previous(history, item2);
- char *item4 = history_previous(history, item3);
- char *item5 = history_previous(history, item4);
- char *item6 = history_previous(history, item5);
-
- assert_string_equal("Hello", item6);
-}
-
-void previous_goes_to_correct_element(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
- history_append(history, "world");
- history_append(history, "whats");
- history_append(history, "going");
- history_append(history, "on");
- history_append(history, "here");
-
- char *item1 = history_previous(history, NULL);
- char *item2 = history_previous(history, item1);
- char *item3 = history_previous(history, item2);
-
- assert_string_equal("going", item3);
-}
-
-void prev_then_next_returns_empty(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
-
- char *item1 = history_previous(history, NULL);
- char *item2 = history_next(history, item1);
-
- assert_string_equal("", item2);
-}
-
-void prev_with_val_then_next_returns_val(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
-
- char *item1 = history_previous(history, "Oioi");
- char *item2 = history_next(history, item1);
-
- assert_string_equal("Oioi", item2);
-}
-
-void prev_with_val_then_next_twice_returns_null(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
-
- char *item1 = history_previous(history, "Oioi");
- char *item2 = history_next(history, item1);
- char *item3 = history_next(history, item2);
-
- assert_null(item3);
-}
-
-void navigate_then_append_new(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
- history_append(history, "again");
- history_append(history, "testing");
- history_append(history, "history");
- history_append(history, "append");
-
- char *item1 = history_previous(history, "new text");
- assert_string_equal("append", item1);
-
- char *item2 = history_previous(history, item1);
- assert_string_equal("history", item2);
-
- char *item3 = history_previous(history, item2);
- assert_string_equal("testing", item3);
-
- char *item4 = history_next(history, item3);
- assert_string_equal("history", item4);
-
- char *item5 = history_next(history, item4);
- assert_string_equal("append", item5);
-
- char *item6 = history_next(history, item5);
- assert_string_equal("new text", item6);
-}
-
-void edit_item_mid_history(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
- history_append(history, "again");
- history_append(history, "testing");
- history_append(history, "history");
- history_append(history, "append");
-
- char *item1 = history_previous(history, "new item");
- assert_string_equal("append", item1);
-
- char *item2 = history_previous(history, item1);
- assert_string_equal("history", item2);
-
- char *item3 = history_previous(history, item2);
- assert_string_equal("testing", item3);
-
- char *item4 = history_previous(history, "EDITED");
- assert_string_equal("again", item4);
-
- char *item5 = history_previous(history, item4);
- assert_string_equal("Hello", item5);
-
- char *item6 = history_next(history, item5);
- assert_string_equal("again", item6);
-
- char *item7 = history_next(history, item6);
- assert_string_equal("EDITED", item7);
-
- char *item8 = history_next(history, item7);
- assert_string_equal("history", item8);
-
- char *item9 = history_next(history, item8);
- assert_string_equal("append", item9);
-
- char *item10 = history_next(history, item9);
- assert_string_equal("new item", item10);
-}
-
-void edit_previous_and_append(void **state)
-{
- History history = history_new(10);
- history_append(history, "Hello");
- history_append(history, "again");
- history_append(history, "testing");
- history_append(history, "history");
- history_append(history, "append");
-
- char *item1 = history_previous(history, "new item");
- assert_string_equal("append", item1);
-
- char *item2 = history_previous(history, item1);
- assert_string_equal("history", item2);
-
- char *item3 = history_previous(history, item2);
- assert_string_equal("testing", item3);
-
- history_append(history, "EDITED");
-
- char *item4 = history_previous(history, NULL);
- assert_string_equal("EDITED", item4);
-}
-
-void start_session_add_new_submit_previous(void **state)
-{
- History history = history_new(10);
- history_append(history, "hello");
-
- char *item1 = history_previous(history, NULL);
- assert_string_equal("hello", item1);
-
- char *item2 = history_next(history, item1);
- assert_string_equal("", item2);
-
- char *item3 = history_previous(history, "new text");
- assert_string_equal("hello", item3);
-
- history_append(history, item3);
-}
diff --git a/tests/test_history.h b/tests/test_history.h
deleted file mode 100644
index e6e8ec3f..00000000
--- a/tests/test_history.h
+++ /dev/null
@@ -1,13 +0,0 @@
-void previous_on_empty_returns_null(void **state);
-void next_on_empty_returns_null(void **state);
-void previous_once_returns_last(void **state);
-void previous_twice_when_one_returns_first(void **state);
-void previous_always_stops_at_first(void **state);
-void previous_goes_to_correct_element(void **state);
-void prev_then_next_returns_empty(void **state);
-void prev_with_val_then_next_returns_val(void **state);
-void prev_with_val_then_next_twice_returns_null(void **state);
-void navigate_then_append_new(void **state);
-void edit_item_mid_history(void **state);
-void edit_previous_and_append(void **state);
-void start_session_add_new_submit_previous(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index ca53961f..92abee4b 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -21,7 +21,6 @@
#include "test_cmd_sub.h"
#include "test_cmd_statuses.h"
#include "test_cmd_otr.h"
-#include "test_history.h"
#include "test_jid.h"
#include "test_parser.h"
#include "test_roster_list.h"
@@ -35,7 +34,6 @@
#include "test_cmd_win.h"
#include "test_cmd_disconnect.h"
#include "test_form.h"
-#include "test_keyhandlers.h"
int main(int argc, char* argv[]) {
const UnitTest all_tests[] = {
@@ -104,20 +102,6 @@ int main(int argc, char* argv[]) {
unit_test(add_two_same_adds_one),
unit_test(add_two_same_updates),
- unit_test(previous_on_empty_returns_null),
- unit_test(next_on_empty_returns_null),
- unit_test(previous_once_returns_last),
- unit_test(previous_twice_when_one_returns_first),
- unit_test(previous_always_stops_at_first),
- unit_test(previous_goes_to_correct_element),
- unit_test(prev_then_next_returns_empty),
- unit_test(prev_with_val_then_next_returns_val),
- unit_test(prev_with_val_then_next_twice_returns_null),
- unit_test(navigate_then_append_new),
- unit_test(edit_item_mid_history),
- unit_test(edit_previous_and_append),
- unit_test(start_session_add_new_submit_previous),
-
unit_test(create_jid_from_null_returns_null),
unit_test(create_jid_from_empty_string_returns_null),
unit_test(create_jid_from_full_returns_full),
@@ -623,56 +607,6 @@ int main(int argc, char* argv[]) {
unit_test(remove_text_multi_value_removes_when_many),
unit_test(clears_chat_sessions),
-
- unit_test(append_to_empty),
- unit_test(append_wide_to_empty),
-
- unit_test(append_to_single),
- unit_test(append_wide_to_single_non_wide),
- unit_test(append_non_wide_to_single_wide),
- unit_test(append_wide_to_single_wide),
-
- unit_test(append_non_wide_when_overrun),
-
- unit_test(insert_non_wide_to_non_wide),
- unit_test(insert_single_non_wide_when_pad_scrolled),
- unit_test(insert_many_non_wide_when_pad_scrolled),
- unit_test(insert_single_non_wide_last_column),
- unit_test(insert_many_non_wide_last_column),
-
- unit_test(ctrl_left_when_no_input),
- unit_test(ctrl_left_when_at_start),
- unit_test(ctrl_left_when_in_first_word),
- unit_test(ctrl_left_when_in_first_space),
- unit_test(ctrl_left_when_at_start_of_second_word),
- unit_test(ctrl_left_when_in_second_word),
- unit_test(ctrl_left_when_at_end_of_second_word),
- unit_test(ctrl_left_when_in_second_space),
- unit_test(ctrl_left_when_at_start_of_third_word),
- unit_test(ctrl_left_when_in_third_word),
- unit_test(ctrl_left_when_at_end_of_third_word),
- unit_test(ctrl_left_when_in_third_space),
- unit_test(ctrl_left_when_at_end),
- unit_test(ctrl_left_when_in_only_whitespace),
- unit_test(ctrl_left_when_start_whitespace_start_of_word),
- unit_test(ctrl_left_when_start_whitespace_middle_of_word),
- unit_test(ctrl_left_in_whitespace_between_words),
- unit_test(ctrl_left_in_whitespace_between_words_start_of_word),
- unit_test(ctrl_left_in_whitespace_between_words_middle_of_word),
- unit_test(ctrl_left_when_word_overrun_to_left),
-
- unit_test(ctrl_right_when_no_input),
- unit_test(ctrl_right_when_at_end),
- unit_test(ctrl_right_one_word_at_start),
- unit_test(ctrl_right_one_word_in_middle),
- unit_test(ctrl_right_one_word_at_end),
- unit_test(ctrl_right_two_words_from_middle_first),
- unit_test(ctrl_right_two_words_from_end_first),
- unit_test(ctrl_right_two_words_from_space),
- unit_test(ctrl_right_two_words_from_start_second),
- unit_test(ctrl_right_one_word_leading_whitespace),
- unit_test(ctrl_right_two_words_in_whitespace),
- unit_test(ctrl_right_trailing_whitespace_from_middle),
};
return run_tests(all_tests);
From 784a2ea862fb824a6f76191591590689fc704ac8 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 30 Jan 2015 23:44:17 +0000
Subject: [PATCH 015/252] Removed commented code
---
src/ui/inputwin.c | 216 ----------------------------------------------
1 file changed, 216 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index d669f67b..501ae95f 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -165,13 +165,6 @@ void
inp_write(char *line, int offset)
{
int col = offset_to_col(line, offset);
-
- cons_debug("LEN BYTES: %d", strlen(line));
- cons_debug("LEN UTF8 : %d", g_utf8_strlen(line, -1));
- cons_debug("OFFSET : %d", offset);
- cons_debug("COL : %d", col);
- cons_debug("");
-
werase(inp_win);
waddstr(inp_win, line);
wmove(inp_win, 0, col);
@@ -218,69 +211,6 @@ inp_close(void)
rl_callback_handler_remove();
}
-//char *
-//inp_read(int *key_type, wint_t *ch)
-//{
-// // echo off, and get some more input
-// noecho();
-// *key_type = wget_wch(inp_win, ch);
-//
-// int bytes_len = strlen(line);
-//
-// gboolean in_command = FALSE;
-// if ((bytes_len > 0 && line[0] == '/') ||
-// (bytes_len == 0 && *ch == '/')) {
-// in_command = TRUE;
-// }
-//
-// if (*key_type == ERR) {
-// prof_handle_idle();
-// }
-// if ((*key_type != ERR) && (*key_type != KEY_CODE_YES) && !in_command && utf8_is_printable(*ch)) {
-// prof_handle_activity();
-// }
-//
-// // if it wasn't an arrow key etc
-// if (!_handle_edit(*key_type, *ch)) {
-// if (utf8_is_printable(*ch) && *key_type != KEY_CODE_YES) {
-// if (bytes_len >= INP_WIN_MAX) {
-// *ch = ERR;
-// return NULL;
-// }
-//
-// int col = getcurx(inp_win);
-// int maxx = getmaxx(stdscr);
-// key_printable(line, &line_utf8_pos, &col, &pad_start, *ch, maxx);
-//
-// werase(inp_win);
-// waddstr(inp_win, line);
-// wmove(inp_win, 0, col);
-// _inp_win_update_virtual();
-//
-// cmd_reset_autocomplete();
-// }
-// }
-//
-// echo();
-//
-// char *result = NULL;
-// if (*ch == '\n') {
-// result = strdup(line);
-// line[0] = '\0';
-// line_utf8_pos = 0;
-// }
-//
-// if (*ch != ERR && *key_type != ERR) {
-// cons_debug("BYTE LEN = %d", strlen(line));
-// cons_debug("UTF8 LEN = %d", utf8_display_len(line));
-// cons_debug("CURR COL = %d", getcurx(inp_win));
-// cons_debug("CURR UNI = %d", line_utf8_pos);
-// cons_debug("");
-// }
-//
-// return result;
-//}
-
void
inp_get_password(char *passwd)
{
@@ -315,152 +245,6 @@ inp_win_clear(void)
_inp_win_update_virtual();
}
-/*
- * Deal with command editing, return 1 if ch was an edit
- * key press: up, down, left, right or backspace
- * return 0 if it wasn't
- */
-//static int
-//_handle_edit(int key_type, const wint_t ch)
-//{
-// // ALT-LEFT
-// if ((key_type == KEY_CODE_YES) && (ch == 537 || ch == 542)) {
-// ui_previous_win();
-// return 1;
-//
-// // ALT-RIGHT
-// } else if ((key_type == KEY_CODE_YES) && (ch == 552 || ch == 557)) {
-// ui_next_win();
-// return 1;
-//
-// // other editing keys
-// } else {
-// int bytes_len = strlen(line);
-// int next_ch;
-//
-// switch(ch) {
-//
-// case 27: // ESC
-// // check for ALT-key
-// next_ch = wgetch(inp_win);
-// if (next_ch != ERR) {
-// return _handle_alt_key(next_ch);
-// } else {
-// werase(inp_win);
-// wmove(inp_win, 0, 0);
-// pad_start = 0;
-// line[0] = '\0';
-// line_utf8_pos = 0;
-// _inp_win_update_virtual();
-// return 1;
-// }
-//
-// case 9: // tab
-// if (bytes_len != 0) {
-// line[bytes_len] = '\0';
-// if ((strncmp(line, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
-// char *result = muc_autocomplete(line);
-// if (result) {
-// werase(inp_win);
-// wmove(inp_win, 0, 0);
-// pad_start = 0;
-// line[0] = '\0';
-// line_utf8_pos = 0;
-// strncpy(line, result, INP_WIN_MAX);
-// waddstr(inp_win, line);
-//
-// int display_len = utf8_display_len(line);
-// wmove(inp_win, 0, display_len);
-// line_utf8_pos = g_utf8_strlen(line, -1);
-//
-// int wcols = getmaxx(stdscr);
-// if (display_len > wcols-2) {
-// pad_start = display_len - wcols + 1;
-// _inp_win_update_virtual();
-// }
-//
-// free(result);
-// }
-// } else if (strncmp(line, "/", 1) == 0) {
-// char *result = cmd_autocomplete(line);
-// if (result) {
-// werase(inp_win);
-// wmove(inp_win, 0, 0);
-// pad_start = 0;
-// line[0] = '\0';
-// line_utf8_pos = 0;
-// strncpy(line, result, INP_WIN_MAX);
-// waddstr(inp_win, line);
-//
-// int display_len = utf8_display_len(line);
-// wmove(inp_win, 0, display_len);
-// line_utf8_pos = g_utf8_strlen(line, -1);
-//
-// int wcols = getmaxx(stdscr);
-// if (display_len > wcols-2) {
-// pad_start = display_len - wcols + 1;
-// _inp_win_update_virtual();
-// }
-//
-// free(result);
-// }
-// }
-// }
-// return 1;
-//
-// default:
-// return 0;
-// }
-// }
-//}
-
-//static int
-//_handle_alt_key(int key)
-//{
-// switch (key)
-// {
-// case '1':
-// ui_switch_win(1);
-// break;
-// case '2':
-// ui_switch_win(2);
-// break;
-// case '3':
-// ui_switch_win(3);
-// break;
-// case '4':
-// ui_switch_win(4);
-// break;
-// case '5':
-// ui_switch_win(5);
-// break;
-// case '6':
-// ui_switch_win(6);
-// break;
-// case '7':
-// ui_switch_win(7);
-// break;
-// case '8':
-// ui_switch_win(8);
-// break;
-// case '9':
-// ui_switch_win(9);
-// break;
-// case '0':
-// ui_switch_win(0);
-// break;
-// case KEY_LEFT:
-// ui_previous_win();
-// break;
-// case KEY_RIGHT:
-// ui_next_win();
-// break;
-// default:
-// break;
-// }
-// return 1;
-//}
-//
static void
_inp_win_update_virtual(void)
{
From 1cf5592b1fd59b4a9277a5c969403f717d50a7cc Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 30 Jan 2015 23:46:34 +0000
Subject: [PATCH 016/252] Removed unused variables
---
src/ui/inputwin.c | 23 -----------------------
1 file changed, 23 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 501ae95f..55bf8912 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -63,18 +63,6 @@
#include "ui/windows.h"
#include "xmpp/xmpp.h"
-#define KEY_CTRL_A 0001
-#define KEY_CTRL_B 0002
-#define KEY_CTRL_D 0004
-#define KEY_CTRL_E 0005
-#define KEY_CTRL_F 0006
-#define KEY_CTRL_N 0016
-#define KEY_CTRL_P 0020
-#define KEY_CTRL_U 0025
-#define KEY_CTRL_W 0027
-
-#define MAX_HISTORY 100
-
static WINDOW *inp_win;
static struct timeval p_rl_timeout;
@@ -82,11 +70,6 @@ static fd_set fds;
static int r;
static gboolean cmd_result = TRUE;
-// input line
-static char line[INP_WIN_MAX];
-// current position in the utf8 string
-static int line_utf8_pos;
-
static int pad_start = 0;
static void _inp_win_update_virtual(void);
@@ -119,8 +102,6 @@ create_input_window(void)
keypad(inp_win, TRUE);
wmove(inp_win, 0, 0);
_inp_win_update_virtual();
- line_utf8_pos = 0;
- line[0] = '\0';
}
void
@@ -217,8 +198,6 @@ inp_get_password(char *passwd)
werase(inp_win);
wmove(inp_win, 0, 0);
pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
_inp_win_update_virtual();
doupdate();
noecho();
@@ -240,8 +219,6 @@ inp_win_clear(void)
werase(inp_win);
wmove(inp_win, 0, 0);
pad_start = 0;
- line[0] = '\0';
- line_utf8_pos = 0;
_inp_win_update_virtual();
}
From f94b6ef0a213df2834ceece34036cf4c4990ba9a Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 00:20:25 +0000
Subject: [PATCH 017/252] Added idle and activity handlers
---
src/profanity.c | 2 ++
src/ui/inputwin.c | 25 +++++++++++++++----------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/profanity.c b/src/profanity.c
index f3c53003..cb3ce4eb 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -99,6 +99,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
void
prof_handle_idle(void)
{
+ cons_debug("IDLE");
jabber_conn_status_t status = jabber_get_connection_status();
if (status == JABBER_CONNECTED) {
GSList *recipients = ui_get_chat_recipients();
@@ -120,6 +121,7 @@ prof_handle_idle(void)
void
prof_handle_activity(void)
{
+ cons_debug("ACTIVITY");
win_type_t win_type = ui_current_win_type();
jabber_conn_status_t status = jabber_get_connection_status();
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 55bf8912..b736fca3 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -142,16 +142,6 @@ offset_to_col(char *str, int offset)
return col;
}
-void
-inp_write(char *line, int offset)
-{
- int col = offset_to_col(line, offset);
- werase(inp_win);
- waddstr(inp_win, line);
- wmove(inp_win, 0, col);
- _inp_win_update_virtual();
-}
-
void
inp_non_block(gint block_timeout)
{
@@ -164,6 +154,16 @@ inp_block(void)
wtimeout(inp_win, -1);
}
+void
+inp_write(char *line, int offset)
+{
+ int col = offset_to_col(line, offset);
+ werase(inp_win);
+ waddstr(inp_win, line);
+ wmove(inp_win, 0, col);
+ _inp_win_update_virtual();
+}
+
gboolean
inp_readline(void)
{
@@ -177,7 +177,12 @@ inp_readline(void)
if (FD_ISSET(fileno(rl_instream), &fds)) {
rl_callback_read_char();
+ if (rl_line_buffer && rl_line_buffer[0] != '/') {
+ prof_handle_activity();
+ }
inp_write(rl_line_buffer, rl_point);
+ } else {
+ prof_handle_idle();
}
p_rl_timeout.tv_sec = 0;
From e161337b7f41be415f9e66ae8596268593f5c319 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 00:31:08 +0000
Subject: [PATCH 018/252] Debug input block
---
src/ui/core.c | 1 +
src/ui/inputwin.c | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/ui/core.c b/src/ui/core.c
index 84a442f2..e7477e57 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -240,6 +240,7 @@ ui_input_nonblocking(gboolean reset)
}
}
+ log_info("TIMEOUT: %d", timeout);
inp_non_block(timeout);
}
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index b736fca3..929f85fb 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -66,6 +66,7 @@
static WINDOW *inp_win;
static struct timeval p_rl_timeout;
+static int timeout_millis = 0;
static fd_set fds;
static int r;
static gboolean cmd_result = TRUE;
@@ -94,7 +95,7 @@ create_input_window(void)
ESCDELAY = 25;
#endif
p_rl_timeout.tv_sec = 0;
- p_rl_timeout.tv_usec = 500000;
+ p_rl_timeout.tv_usec = timeout_millis * 1000;
rl_callback_handler_install(NULL, cb_linehandler);
inp_win = newpad(1, INP_WIN_MAX);
@@ -145,7 +146,7 @@ offset_to_col(char *str, int offset)
void
inp_non_block(gint block_timeout)
{
- wtimeout(inp_win, block_timeout);
+ timeout_millis = block_timeout;
}
void
@@ -186,7 +187,7 @@ inp_readline(void)
}
p_rl_timeout.tv_sec = 0;
- p_rl_timeout.tv_usec = 500000;
+ p_rl_timeout.tv_usec = timeout_millis * 1000;
return cmd_result;
}
From b3448eb265c7b656c07d3a72ea498dc6b5c5b888 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 01:11:41 +0000
Subject: [PATCH 019/252] Moved input blocking code to inputwin.c
---
src/profanity.c | 2 --
src/ui/core.c | 31 +++----------------------------
src/ui/inputwin.c | 35 ++++++++++++++++++++++++++++++-----
src/ui/inputwin.h | 1 +
4 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/src/profanity.c b/src/profanity.c
index cb3ce4eb..f3c53003 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -99,7 +99,6 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
void
prof_handle_idle(void)
{
- cons_debug("IDLE");
jabber_conn_status_t status = jabber_get_connection_status();
if (status == JABBER_CONNECTED) {
GSList *recipients = ui_get_chat_recipients();
@@ -121,7 +120,6 @@ prof_handle_idle(void)
void
prof_handle_activity(void)
{
- cons_debug("ACTIVITY");
win_type_t win_type = ui_current_win_type();
jabber_conn_status_t status = jabber_get_connection_status();
diff --git a/src/ui/core.c b/src/ui/core.c
index e7477e57..ed21b233 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -215,33 +215,7 @@ ui_input_clear(void)
void
ui_input_nonblocking(gboolean reset)
{
- static gint timeout = 0;
- static gint no_input_count = 0;
-
- if (! prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) {
- inp_non_block(prefs_get_inpblock());
- return;
- }
-
- if (reset) {
- timeout = 0;
- no_input_count = 0;
- }
-
- if (timeout < prefs_get_inpblock()) {
- no_input_count++;
-
- if (no_input_count % 10 == 0) {
- timeout += no_input_count;
-
- if (timeout > prefs_get_inpblock()) {
- timeout = prefs_get_inpblock();
- }
- }
- }
-
- log_info("TIMEOUT: %d", timeout);
- inp_non_block(timeout);
+ inp_nonblocking(reset);
}
void
@@ -2250,7 +2224,8 @@ ui_ask_password(void)
status_bar_update_virtual();
inp_block();
inp_get_password(passwd);
- inp_non_block(prefs_get_inpblock());
+// inp_non_block(prefs_get_inpblock());
+ inp_nonblocking(TRUE);
return passwd;
}
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 929f85fb..fe75bc61 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -66,7 +66,9 @@
static WINDOW *inp_win;
static struct timeval p_rl_timeout;
-static int timeout_millis = 0;
+static gint inp_timeout = 0;
+static gint no_input_count = 0;
+
static fd_set fds;
static int r;
static gboolean cmd_result = TRUE;
@@ -95,7 +97,7 @@ create_input_window(void)
ESCDELAY = 25;
#endif
p_rl_timeout.tv_sec = 0;
- p_rl_timeout.tv_usec = timeout_millis * 1000;
+ p_rl_timeout.tv_usec = inp_timeout * 1000;
rl_callback_handler_install(NULL, cb_linehandler);
inp_win = newpad(1, INP_WIN_MAX);
@@ -144,9 +146,29 @@ offset_to_col(char *str, int offset)
}
void
-inp_non_block(gint block_timeout)
+inp_nonblocking(gboolean reset)
{
- timeout_millis = block_timeout;
+ if (! prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) {
+ inp_timeout = prefs_get_inpblock();
+ return;
+ }
+
+ if (reset) {
+ inp_timeout = 0;
+ no_input_count = 0;
+ }
+
+ if (inp_timeout < prefs_get_inpblock()) {
+ no_input_count++;
+
+ if (no_input_count % 10 == 0) {
+ inp_timeout += no_input_count;
+
+ if (inp_timeout > prefs_get_inpblock()) {
+ inp_timeout = prefs_get_inpblock();
+ }
+ }
+ }
}
void
@@ -181,13 +203,16 @@ inp_readline(void)
if (rl_line_buffer && rl_line_buffer[0] != '/') {
prof_handle_activity();
}
+ ui_reset_idle_time();
+ inp_nonblocking(TRUE);
inp_write(rl_line_buffer, rl_point);
} else {
+ inp_nonblocking(FALSE);
prof_handle_idle();
}
p_rl_timeout.tv_sec = 0;
- p_rl_timeout.tv_usec = timeout_millis * 1000;
+ p_rl_timeout.tv_usec = inp_timeout * 1000;
return cmd_result;
}
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index 7193e049..081fc56b 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -41,6 +41,7 @@
void create_input_window(void);
gboolean inp_readline(void);
+void inp_nonblocking(gboolean reset);
void inp_close(void);
char* inp_read(int *key_type, wint_t *ch);
void inp_win_clear(void);
From 2b11baa564e9b558cfc050b5f28505f37900f2c1 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 01:58:15 +0000
Subject: [PATCH 020/252] Added readline tab handler
---
src/ui/inputwin.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index fe75bc61..649590bc 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -88,6 +88,32 @@ cb_linehandler(char *line)
free(line);
}
+int
+tab_handler(int count, int key)
+{
+ if (rl_point != rl_end) {
+ return 0;
+ }
+
+ if ((strncmp(rl_line_buffer, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
+ char *result = muc_autocomplete(rl_line_buffer);
+ if (result) {
+ rl_replace_line(result, 0);
+ rl_point = rl_end;
+ inp_write(result, rl_point);
+ }
+ } else if (strncmp(rl_line_buffer, "/", 1) == 0) {
+ char *result = cmd_autocomplete(rl_line_buffer);
+ if (result) {
+ rl_replace_line(result, 0);
+ rl_point = rl_end;
+ inp_write(result, rl_point);
+ }
+ }
+
+ return 0;
+}
+
void
create_input_window(void)
{
@@ -99,7 +125,7 @@ create_input_window(void)
p_rl_timeout.tv_sec = 0;
p_rl_timeout.tv_usec = inp_timeout * 1000;
rl_callback_handler_install(NULL, cb_linehandler);
-
+ rl_bind_key('\t', tab_handler);
inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
keypad(inp_win, TRUE);
@@ -205,6 +231,7 @@ inp_readline(void)
}
ui_reset_idle_time();
inp_nonblocking(TRUE);
+ rl_redisplay();
inp_write(rl_line_buffer, rl_point);
} else {
inp_nonblocking(FALSE);
From fe10f2b2e38818cdc77b226ee498d0956d3bba40 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 16:51:09 +0000
Subject: [PATCH 021/252] Clear autocompleters on printable chars
---
src/ui/inputwin.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 649590bc..372048a2 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -91,7 +91,7 @@ cb_linehandler(char *line)
int
tab_handler(int count, int key)
{
- if (rl_point != rl_end) {
+ if (rl_point != rl_end || !rl_line_buffer) {
return 0;
}
@@ -126,6 +126,7 @@ create_input_window(void)
p_rl_timeout.tv_usec = inp_timeout * 1000;
rl_callback_handler_install(NULL, cb_linehandler);
rl_bind_key('\t', tab_handler);
+
inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
keypad(inp_win, TRUE);
@@ -213,6 +214,17 @@ inp_write(char *line, int offset)
_inp_win_update_virtual();
}
+static int
+_printable(const wint_t ch)
+{
+ char bytes[MB_CUR_MAX+1];
+ size_t utf_len = wcrtomb(bytes, ch, NULL);
+ bytes[utf_len] = '\0';
+ gunichar unichar = g_utf8_get_char(bytes);
+
+ return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
+}
+
gboolean
inp_readline(void)
{
@@ -225,13 +237,18 @@ inp_readline(void)
}
if (FD_ISSET(fileno(rl_instream), &fds)) {
+ if (_printable(rl_executing_key)) {
+ cmd_reset_autocomplete();
+ }
+
rl_callback_read_char();
+
if (rl_line_buffer && rl_line_buffer[0] != '/') {
prof_handle_activity();
}
+
ui_reset_idle_time();
inp_nonblocking(TRUE);
- rl_redisplay();
inp_write(rl_line_buffer, rl_point);
} else {
inp_nonblocking(FALSE);
From e6f27de55221f0f41362b81ca927d5d55682d14f Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 18:02:42 +0000
Subject: [PATCH 022/252] Added SIGWINCH handler
---
src/ui/core.c | 10 ++++++++--
src/ui/inputwin.c | 11 ++++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/ui/core.c b/src/ui/core.c
index ed21b233..254dd554 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -41,6 +41,9 @@
#include
#include
#include
+#include
+#include
+
#ifdef HAVE_LIBXSS
#include
#endif
@@ -91,7 +94,6 @@ ui_init(void)
{
log_info("Initialising UI");
initscr();
- raw();
keypad(stdscr, TRUE);
if (prefs_get_boolean(PREF_MOUSE)) {
mousemask(ALL_MOUSE_EVENTS, NULL);
@@ -221,9 +223,13 @@ ui_input_nonblocking(gboolean reset)
void
ui_resize(void)
{
- log_info("Resizing UI");
+ struct winsize w;
+ ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
erase();
+ resizeterm(w.ws_row, w.ws_col);
refresh();
+
+ log_info("Resizing UI");
title_bar_resize();
wins_resize_all();
status_bar_resize();
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 372048a2..627f9da7 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -114,6 +114,12 @@ tab_handler(int count, int key)
return 0;
}
+void
+resize_signal_handler(int signal)
+{
+ ui_resize();
+}
+
void
create_input_window(void)
{
@@ -127,10 +133,13 @@ create_input_window(void)
rl_callback_handler_install(NULL, cb_linehandler);
rl_bind_key('\t', tab_handler);
+ signal(SIGWINCH, resize_signal_handler);
+
inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
keypad(inp_win, TRUE);
wmove(inp_win, 0, 0);
+
_inp_win_update_virtual();
}
@@ -233,7 +242,7 @@ inp_readline(void)
r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
if (r < 0) {
log_error("Readline failed.");
- return false;
+ return TRUE;
}
if (FD_ISSET(fileno(rl_instream), &fds)) {
From 28dd5458777a7655a558c14e17d79464c8ab4324 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 22:00:22 +0000
Subject: [PATCH 023/252] Added paging handlers
---
src/ui/core.c | 28 ++++++++
src/ui/inputwin.c | 149 +++++++++++++++++++++++++++++++++++++++++--
src/ui/ui.h | 5 ++
src/ui/window.c | 159 +++++++++++++++++++++++++++-------------------
src/ui/window.h | 7 +-
5 files changed, 279 insertions(+), 69 deletions(-)
diff --git a/src/ui/core.c b/src/ui/core.c
index 254dd554..5b9970fc 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -208,6 +208,34 @@ ui_readline(void)
// return line;
}
+void
+ui_page_up(void)
+{
+ ProfWin *current = wins_get_current();
+ win_page_up(current);
+}
+
+void
+ui_page_down(void)
+{
+ ProfWin *current = wins_get_current();
+ win_page_down(current);
+}
+
+void
+ui_subwin_page_up(void)
+{
+ ProfWin *current = wins_get_current();
+ win_sub_page_up(current);
+}
+
+void
+ui_subwin_page_down(void)
+{
+ ProfWin *current = wins_get_current();
+ win_sub_page_down(current);
+}
+
void
ui_input_clear(void)
{
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 627f9da7..c6d15dce 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -88,6 +88,12 @@ cb_linehandler(char *line)
free(line);
}
+void
+resize_signal_handler(int signal)
+{
+ ui_resize();
+}
+
int
tab_handler(int count, int key)
{
@@ -114,10 +120,144 @@ tab_handler(int count, int key)
return 0;
}
-void
-resize_signal_handler(int signal)
+int
+alt1_handler(int count, int key)
{
- ui_resize();
+ ui_switch_win(1);
+ return 0;
+}
+
+int
+alt2_handler(int count, int key)
+{
+ ui_switch_win(2);
+ return 0;
+}
+
+int
+alt3_handler(int count, int key)
+{
+ ui_switch_win(3);
+ return 0;
+}
+
+int
+alt4_handler(int count, int key)
+{
+ ui_switch_win(4);
+ return 0;
+}
+
+int
+alt5_handler(int count, int key)
+{
+ ui_switch_win(5);
+ return 0;
+}
+
+int
+alt6_handler(int count, int key)
+{
+ ui_switch_win(6);
+ return 0;
+}
+
+int
+alt7_handler(int count, int key)
+{
+ ui_switch_win(7);
+ return 0;
+}
+
+int
+alt8_handler(int count, int key)
+{
+ ui_switch_win(8);
+ return 0;
+}
+
+int
+alt9_handler(int count, int key)
+{
+ ui_switch_win(9);
+ return 0;
+}
+
+int
+alt0_handler(int count, int key)
+{
+ ui_switch_win(0);
+ return 0;
+}
+
+int
+altleft_handler(int count, int key)
+{
+ ui_previous_win();
+ return 0;
+}
+
+int
+altright_handler(int count, int key)
+{
+ ui_next_win();
+ return 0;
+}
+
+int
+pageup_handler(int count, int key)
+{
+ ui_page_up();
+ return 0;
+}
+
+int
+pagedown_handler(int count, int key)
+{
+ ui_page_down();
+ return 0;
+}
+
+int
+altpageup_handler(int count, int key)
+{
+ ui_subwin_page_up();
+ return 0;
+}
+
+int
+altpagedown_handler(int count, int key)
+{
+ ui_subwin_page_down();
+ return 0;
+}
+
+int
+startup_hook(void)
+{
+ rl_bind_keyseq("\\e1", alt1_handler);
+ rl_bind_keyseq("\\e2", alt2_handler);
+ rl_bind_keyseq("\\e3", alt3_handler);
+ rl_bind_keyseq("\\e4", alt4_handler);
+ rl_bind_keyseq("\\e5", alt5_handler);
+ rl_bind_keyseq("\\e6", alt6_handler);
+ rl_bind_keyseq("\\e7", alt7_handler);
+ rl_bind_keyseq("\\e8", alt8_handler);
+ rl_bind_keyseq("\\e9", alt9_handler);
+ rl_bind_keyseq("\\e0", alt0_handler);
+
+ rl_bind_keyseq("\\e[1;3D", altleft_handler);
+ rl_bind_keyseq("\\e[1;3C", altright_handler);
+
+ rl_bind_keyseq("\\e[5~", pageup_handler);
+ rl_bind_keyseq("\\e[6~", pagedown_handler);
+
+ rl_bind_keyseq("\\e[5;3~", altpageup_handler);
+ rl_bind_keyseq("\\e[6;3~", altpagedown_handler);
+
+ rl_bind_key('\t', tab_handler);
+
+ return 0;
}
void
@@ -130,8 +270,8 @@ create_input_window(void)
#endif
p_rl_timeout.tv_sec = 0;
p_rl_timeout.tv_usec = inp_timeout * 1000;
+ rl_startup_hook = startup_hook;
rl_callback_handler_install(NULL, cb_linehandler);
- rl_bind_key('\t', tab_handler);
signal(SIGWINCH, resize_signal_handler);
@@ -140,6 +280,7 @@ create_input_window(void)
keypad(inp_win, TRUE);
wmove(inp_win, 0, 0);
+
_inp_win_update_virtual();
}
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 2cfb6e6e..5008593f 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -218,6 +218,11 @@ void ui_tidy_wins(void);
void ui_prune_wins(void);
gboolean ui_swap_wins(int source_win, int target_win);
+void ui_page_up(void);
+void ui_page_down(void);
+void ui_subwin_page_up(void);
+void ui_subwin_page_down(void);
+
void ui_auto_away(void);
void ui_end_auto_away(void);
void ui_titlebar_presence(contact_presence_t presence);
diff --git a/src/ui/window.c b/src/ui/window.c
index dfec5aab..915acb3c 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -358,7 +358,101 @@ win_free(ProfWin* window)
}
void
-win_handle_page(ProfWin *window, const wint_t ch, const int result)
+win_page_up(ProfWin *window)
+{
+ int rows = getmaxy(stdscr);
+ int y = getcury(window->layout->win);
+ int page_space = rows - 4;
+ int *page_start = &(window->layout->y_pos);
+
+ *page_start -= page_space;
+
+ // went past beginning, show first page
+ if (*page_start < 0)
+ *page_start = 0;
+
+ window->layout->paged = 1;
+ win_update_virtual(window);
+
+ // switch off page if last line and space line visible
+ if ((y) - *page_start == page_space) {
+ window->layout->paged = 0;
+ }
+}
+
+void
+win_page_down(ProfWin *window)
+{
+ int rows = getmaxy(stdscr);
+ int y = getcury(window->layout->win);
+ int page_space = rows - 4;
+ int *page_start = &(window->layout->y_pos);
+
+ *page_start += page_space;
+
+ // only got half a screen, show full screen
+ if ((y - (*page_start)) < page_space)
+ *page_start = y - page_space;
+
+ // went past end, show full screen
+ else if (*page_start >= y)
+ *page_start = y - page_space - 1;
+
+ window->layout->paged = 1;
+ win_update_virtual(window);
+
+ // switch off page if last line and space line visible
+ if ((y) - *page_start == page_space) {
+ window->layout->paged = 0;
+ }
+}
+
+void
+win_sub_page_down(ProfWin *window)
+{
+
+ if (window->layout->type == LAYOUT_SPLIT) {
+ int rows = getmaxy(stdscr);
+ int page_space = rows - 4;
+ ProfLayoutSplit *split_layout = (ProfLayoutSplit*)window->layout;
+ int sub_y = getcury(split_layout->subwin);
+ int *sub_y_pos = &(split_layout->sub_y_pos);
+
+ *sub_y_pos += page_space;
+
+ // only got half a screen, show full screen
+ if ((sub_y- (*sub_y_pos)) < page_space)
+ *sub_y_pos = sub_y - page_space;
+
+ // went past end, show full screen
+ else if (*sub_y_pos >= sub_y)
+ *sub_y_pos = sub_y - page_space - 1;
+
+ win_update_virtual(window);
+ }
+}
+
+void
+win_sub_page_up(ProfWin *window)
+{
+ if (window->layout->type == LAYOUT_SPLIT) {
+ int rows = getmaxy(stdscr);
+ int page_space = rows - 4;
+ ProfLayoutSplit *split_layout = (ProfLayoutSplit*)window->layout;
+ int *sub_y_pos = &(split_layout->sub_y_pos);
+
+ *sub_y_pos -= page_space;
+
+ // went past beginning, show first page
+ if (*sub_y_pos < 0)
+ *sub_y_pos = 0;
+
+ win_update_virtual(window);
+ }
+}
+
+void
+win_mouse(ProfWin *window, const wint_t ch, const int result)
{
int rows = getmaxy(stdscr);
int y = getcury(window->layout->win);
@@ -402,69 +496,6 @@ win_handle_page(ProfWin *window, const wint_t ch, const int result)
}
}
}
-
- // page up
- if (ch == KEY_PPAGE) {
- *page_start -= page_space;
-
- // went past beginning, show first page
- if (*page_start < 0)
- *page_start = 0;
-
- window->layout->paged = 1;
- win_update_virtual(window);
-
- // page down
- } else if (ch == KEY_NPAGE) {
- *page_start += page_space;
-
- // only got half a screen, show full screen
- if ((y - (*page_start)) < page_space)
- *page_start = y - page_space;
-
- // went past end, show full screen
- else if (*page_start >= y)
- *page_start = y - page_space - 1;
-
- window->layout->paged = 1;
- win_update_virtual(window);
- }
-
- // switch off page if last line and space line visible
- if ((y) - *page_start == page_space) {
- window->layout->paged = 0;
- }
-
- if (window->layout->type == LAYOUT_SPLIT) {
- ProfLayoutSplit *split_layout = (ProfLayoutSplit*)window->layout;
- int sub_y = getcury(split_layout->subwin);
- int *sub_y_pos = &(split_layout->sub_y_pos);
-
- // alt up arrow
- if ((result == KEY_CODE_YES) && ((ch == 565) || (ch == 337))) {
- *sub_y_pos -= page_space;
-
- // went past beginning, show first page
- if (*sub_y_pos < 0)
- *sub_y_pos = 0;
-
- win_update_virtual(window);
-
- // alt down arrow
- } else if ((result == KEY_CODE_YES) && ((ch == 524) || (ch == 336))) {
- *sub_y_pos += page_space;
-
- // only got half a screen, show full screen
- if ((sub_y- (*sub_y_pos)) < page_space)
- *sub_y_pos = sub_y - page_space;
-
- // went past end, show full screen
- else if (*sub_y_pos >= sub_y)
- *sub_y_pos = sub_y - page_space - 1;
-
- win_update_virtual(window);
- }
- }
}
void
diff --git a/src/ui/window.h b/src/ui/window.h
index fd10a1d7..66e4a5f2 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -178,9 +178,14 @@ void win_show_subwin(ProfWin *window);
int win_roster_cols(void);
int win_occpuants_cols(void);
void win_printline_nowrap(WINDOW *win, char *msg);
-void win_handle_page(ProfWin *current, const wint_t ch, const int result);
+void win_mouse(ProfWin *current, const wint_t ch, const int result);
int win_unread(ProfWin *window);
gboolean win_has_active_subwin(ProfWin *window);
+void win_page_up(ProfWin *window);
+void win_page_down(ProfWin *window);
+void win_sub_page_down(ProfWin *window);
+void win_sub_page_up(ProfWin *window);
+
#endif
From baa122e7dcd2cf9a996868e9f51f187a9b626f47 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 22:08:00 +0000
Subject: [PATCH 024/252] Added function key bindings
---
src/ui/inputwin.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index c6d15dce..2737101b 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -246,6 +246,17 @@ startup_hook(void)
rl_bind_keyseq("\\e9", alt9_handler);
rl_bind_keyseq("\\e0", alt0_handler);
+ rl_bind_keyseq("\\eOP", alt1_handler);
+ rl_bind_keyseq("\\eOQ", alt2_handler);
+ rl_bind_keyseq("\\eOR", alt3_handler);
+ rl_bind_keyseq("\\eOS", alt4_handler);
+ rl_bind_keyseq("\\e[15~", alt5_handler);
+ rl_bind_keyseq("\\e[17~", alt6_handler);
+ rl_bind_keyseq("\\e[18~", alt7_handler);
+ rl_bind_keyseq("\\e[19~", alt8_handler);
+ rl_bind_keyseq("\\e[20~", alt9_handler);
+ rl_bind_keyseq("\\e[21~", alt0_handler);
+
rl_bind_keyseq("\\e[1;3D", altleft_handler);
rl_bind_keyseq("\\e[1;3C", altright_handler);
From 84688c063e1b1684cebf7251f39a32e07f77c6b7 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 22:12:27 +0000
Subject: [PATCH 025/252] Removed commented code, renamed win switch handlers
---
src/ui/core.c | 22 -----------------
src/ui/inputwin.c | 60 +++++++++++++++++++++++------------------------
2 files changed, 30 insertions(+), 52 deletions(-)
diff --git a/src/ui/core.c b/src/ui/core.c
index 5b9970fc..7131b005 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -184,28 +184,6 @@ gboolean
ui_readline(void)
{
return inp_readline();
-
-// int key_type;
-// wint_t ch;
-//
-// char *line = inp_read(&key_type, &ch);
-// _win_handle_switch(ch);
-//
-// ProfWin *current = wins_get_current();
-// win_handle_page(current, ch, key_type);
-//
-// if (ch == KEY_RESIZE) {
-// ui_resize();
-// }
-//
-// if (ch != ERR && key_type != ERR) {
-// ui_reset_idle_time();
-// ui_input_nonblocking(TRUE);
-// } else {
-// ui_input_nonblocking(FALSE);
-// }
-//
-// return line;
}
void
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 2737101b..083b6c4e 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -121,70 +121,70 @@ tab_handler(int count, int key)
}
int
-alt1_handler(int count, int key)
+win1_handler(int count, int key)
{
ui_switch_win(1);
return 0;
}
int
-alt2_handler(int count, int key)
+win2_handler(int count, int key)
{
ui_switch_win(2);
return 0;
}
int
-alt3_handler(int count, int key)
+win3_handler(int count, int key)
{
ui_switch_win(3);
return 0;
}
int
-alt4_handler(int count, int key)
+win4_handler(int count, int key)
{
ui_switch_win(4);
return 0;
}
int
-alt5_handler(int count, int key)
+win5_handler(int count, int key)
{
ui_switch_win(5);
return 0;
}
int
-alt6_handler(int count, int key)
+win6_handler(int count, int key)
{
ui_switch_win(6);
return 0;
}
int
-alt7_handler(int count, int key)
+win7_handler(int count, int key)
{
ui_switch_win(7);
return 0;
}
int
-alt8_handler(int count, int key)
+win8_handler(int count, int key)
{
ui_switch_win(8);
return 0;
}
int
-alt9_handler(int count, int key)
+win9_handler(int count, int key)
{
ui_switch_win(9);
return 0;
}
int
-alt0_handler(int count, int key)
+win0_handler(int count, int key)
{
ui_switch_win(0);
return 0;
@@ -235,27 +235,27 @@ altpagedown_handler(int count, int key)
int
startup_hook(void)
{
- rl_bind_keyseq("\\e1", alt1_handler);
- rl_bind_keyseq("\\e2", alt2_handler);
- rl_bind_keyseq("\\e3", alt3_handler);
- rl_bind_keyseq("\\e4", alt4_handler);
- rl_bind_keyseq("\\e5", alt5_handler);
- rl_bind_keyseq("\\e6", alt6_handler);
- rl_bind_keyseq("\\e7", alt7_handler);
- rl_bind_keyseq("\\e8", alt8_handler);
- rl_bind_keyseq("\\e9", alt9_handler);
- rl_bind_keyseq("\\e0", alt0_handler);
+ rl_bind_keyseq("\\e1", win1_handler);
+ rl_bind_keyseq("\\e2", win2_handler);
+ rl_bind_keyseq("\\e3", win3_handler);
+ rl_bind_keyseq("\\e4", win4_handler);
+ rl_bind_keyseq("\\e5", win5_handler);
+ rl_bind_keyseq("\\e6", win6_handler);
+ rl_bind_keyseq("\\e7", win7_handler);
+ rl_bind_keyseq("\\e8", win8_handler);
+ rl_bind_keyseq("\\e9", win9_handler);
+ rl_bind_keyseq("\\e0", win0_handler);
- rl_bind_keyseq("\\eOP", alt1_handler);
- rl_bind_keyseq("\\eOQ", alt2_handler);
- rl_bind_keyseq("\\eOR", alt3_handler);
- rl_bind_keyseq("\\eOS", alt4_handler);
- rl_bind_keyseq("\\e[15~", alt5_handler);
- rl_bind_keyseq("\\e[17~", alt6_handler);
- rl_bind_keyseq("\\e[18~", alt7_handler);
- rl_bind_keyseq("\\e[19~", alt8_handler);
- rl_bind_keyseq("\\e[20~", alt9_handler);
- rl_bind_keyseq("\\e[21~", alt0_handler);
+ rl_bind_keyseq("\\eOP", win1_handler);
+ rl_bind_keyseq("\\eOQ", win2_handler);
+ rl_bind_keyseq("\\eOR", win3_handler);
+ rl_bind_keyseq("\\eOS", win4_handler);
+ rl_bind_keyseq("\\e[15~", win5_handler);
+ rl_bind_keyseq("\\e[17~", win6_handler);
+ rl_bind_keyseq("\\e[18~", win7_handler);
+ rl_bind_keyseq("\\e[19~", win8_handler);
+ rl_bind_keyseq("\\e[20~", win9_handler);
+ rl_bind_keyseq("\\e[21~", win0_handler);
rl_bind_keyseq("\\e[1;3D", altleft_handler);
rl_bind_keyseq("\\e[1;3C", altright_handler);
From 3b3ffcfb3770a781a38a93d930df38f9d4a37c28 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 22:14:41 +0000
Subject: [PATCH 026/252] Added mock ui functions to tests
---
tests/ui/stub_ui.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c
index 6127e4f0..d681ec15 100644
--- a/tests/ui/stub_ui.c
+++ b/tests/ui/stub_ui.c
@@ -178,6 +178,11 @@ int ui_win_unread(int index)
return 0;
}
+void ui_page_up(void) {}
+void ui_page_down(void) {}
+void ui_subwin_page_up(void) {}
+void ui_subwin_page_down(void) {}
+
char * ui_ask_password(void)
{
return mock_ptr_type(char *);
From a19c0a5989c45ced8460284fe6591bebe08d22ac Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 31 Jan 2015 22:29:44 +0000
Subject: [PATCH 027/252] Added scroll handler
---
src/ui/inputwin.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 083b6c4e..ee800e56 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -365,6 +365,26 @@ inp_block(void)
wtimeout(inp_win, -1);
}
+void
+inp_win_handle_scroll(void)
+{
+ int col = getcurx(inp_win);
+ int wcols = getmaxx(stdscr);
+
+ // if lost cursor off screen, move contents to show it
+ if (col >= pad_start + (wcols -2)) {
+ pad_start = col - (wcols / 2);
+ if (pad_start < 0) {
+ pad_start = 0;
+ }
+ } else if (col <= pad_start) {
+ pad_start = pad_start - (wcols / 2);
+ if (pad_start < 0) {
+ pad_start = 0;
+ }
+ }
+}
+
void
inp_write(char *line, int offset)
{
@@ -372,6 +392,8 @@ inp_write(char *line, int offset)
werase(inp_win);
waddstr(inp_win, line);
wmove(inp_win, 0, col);
+ inp_win_handle_scroll();
+
_inp_win_update_virtual();
}
From e8b6c505cb825422ee467c9210ba0b87097aa85d Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 1 Feb 2015 00:14:11 +0000
Subject: [PATCH 028/252] Handle word wrapping wide chars
---
src/ui/inputwin.c | 2 +-
src/ui/window.c | 45 ++++++++++++++++++++++++++++++++-------------
2 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index ee800e56..165a0b32 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -485,5 +485,5 @@ _inp_win_update_virtual(void)
{
int wrows, wcols;
getmaxyx(stdscr, wrows, wcols);
- pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-1);
+ pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-2);
}
\ No newline at end of file
diff --git a/src/ui/window.c b/src/ui/window.c
index 915acb3c..37da8e9d 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -37,6 +37,7 @@
#include
#include
#include
+#include
#include
#ifdef HAVE_NCURSESW_NCURSES_H
@@ -985,7 +986,6 @@ _win_indent(WINDOW *win, int size)
static void
_win_print_wrapped(WINDOW *win, const char * const message)
{
- int linei = 0;
int wordi = 0;
char *word = malloc(strlen(message) + 1);
@@ -998,18 +998,27 @@ _win_print_wrapped(WINDOW *win, const char * const message)
}
free(time_pref);
- while (message[linei] != '\0') {
- if (message[linei] == ' ') {
+ gchar *curr_ch = g_utf8_offset_to_pointer(message, 0);
+
+ while (*curr_ch != '\0') {
+ if (*curr_ch == ' ') {
waddch(win, ' ');
- linei++;
- } else if (message[linei] == '\n') {
+ curr_ch = g_utf8_next_char(curr_ch);
+ } else if (*curr_ch == '\n') {
waddch(win, '\n');
_win_indent(win, indent);
- linei++;
+ curr_ch = g_utf8_next_char(curr_ch);
} else {
+ // get word
wordi = 0;
- while (message[linei] != ' ' && message[linei] != '\n' && message[linei] != '\0') {
- word[wordi++] = message[linei++];
+ mbstate_t internal;
+ while (*curr_ch != ' ' && *curr_ch != '\n' && *curr_ch != '\0') {
+ size_t ch_len = mbrlen(curr_ch, 4, &internal);
+ int offset = 0;
+ while (offset < ch_len) {
+ word[wordi++] = curr_ch[offset++];
+ }
+ curr_ch = g_utf8_next_char(curr_ch);
}
word[wordi] = '\0';
@@ -1017,17 +1026,27 @@ _win_print_wrapped(WINDOW *win, const char * const message)
int maxx = getmaxx(win);
// word larger than line
- if (strlen(word) > (maxx - indent)) {
- int i;
- for (i = 0; i < wordi; i++) {
+ if (utf8_display_len(word) > (maxx - indent)) {
+ gchar *word_ch = g_utf8_offset_to_pointer(word, 0);
+ while(*word_ch != '\0') {
curx = getcurx(win);
if (curx < indent) {
_win_indent(win, indent);
}
- waddch(win, word[i]);
+
+ gchar copy[wordi++];
+ g_utf8_strncpy(copy, word_ch, 1);
+
+ if (curx + utf8_display_len(copy) > maxx) {
+ waddch(win, '\n');
+ _win_indent(win, indent);
+ }
+ waddstr(win, copy);
+
+ word_ch = g_utf8_next_char(word_ch);
}
} else {
- if (curx + strlen(word) > maxx) {
+ if (curx + utf8_display_len(word) > maxx) {
waddch(win, '\n');
_win_indent(win, indent);
}
From a9af8785a7b96af0288f3bb2cbc7128293a29917 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 1 Feb 2015 00:35:42 +0000
Subject: [PATCH 029/252] Added more ignore characters to handle activity
---
src/ui/inputwin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 165a0b32..e6782206 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -426,7 +426,7 @@ inp_readline(void)
rl_callback_read_char();
- if (rl_line_buffer && rl_line_buffer[0] != '/') {
+ if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
prof_handle_activity();
}
From 702ea0b5f38970d7a3e135ca39c2b255767de4f6 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 1 Feb 2015 20:14:07 +0000
Subject: [PATCH 030/252] Use getc wrapper for autocomplete reset check
---
src/ui/inputwin.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index e6782206..5a152620 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -77,6 +77,17 @@ static int pad_start = 0;
static void _inp_win_update_virtual(void);
+static int
+_printable(const wint_t ch)
+{
+ char bytes[MB_CUR_MAX+1];
+ size_t utf_len = wcrtomb(bytes, ch, NULL);
+ bytes[utf_len] = '\0';
+ gunichar unichar = g_utf8_get_char(bytes);
+
+ return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
+}
+
static void
cb_linehandler(char *line)
{
@@ -88,6 +99,16 @@ cb_linehandler(char *line)
free(line);
}
+int
+prof_rl_getc(FILE *filein)
+{
+ int ch = rl_getc(filein);
+ if (_printable(ch)) {
+ cmd_reset_autocomplete();
+ }
+ return ch;
+}
+
void
resize_signal_handler(int signal)
{
@@ -282,6 +303,7 @@ create_input_window(void)
p_rl_timeout.tv_sec = 0;
p_rl_timeout.tv_usec = inp_timeout * 1000;
rl_startup_hook = startup_hook;
+ rl_getc_function = prof_rl_getc;
rl_callback_handler_install(NULL, cb_linehandler);
signal(SIGWINCH, resize_signal_handler);
@@ -397,17 +419,6 @@ inp_write(char *line, int offset)
_inp_win_update_virtual();
}
-static int
-_printable(const wint_t ch)
-{
- char bytes[MB_CUR_MAX+1];
- size_t utf_len = wcrtomb(bytes, ch, NULL);
- bytes[utf_len] = '\0';
- gunichar unichar = g_utf8_get_char(bytes);
-
- return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
-}
-
gboolean
inp_readline(void)
{
@@ -420,10 +431,6 @@ inp_readline(void)
}
if (FD_ISSET(fileno(rl_instream), &fds)) {
- if (_printable(rl_executing_key)) {
- cmd_reset_autocomplete();
- }
-
rl_callback_read_char();
if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
From 51a54260064db3fc5d43456b15d821f192e9d12f Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 1 Feb 2015 21:01:00 +0000
Subject: [PATCH 031/252] Added include for timeval struct
---
src/ui/inputwin.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 5a152620..4ac34c97 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -38,6 +38,7 @@
#include
#include
#include
+#include
#include
#include
From e3feacddd6667fd8e111d0ee54846c6aeabe3a7d Mon Sep 17 00:00:00 2001
From: Olivier LE MOAL
Date: Mon, 2 Feb 2015 11:10:05 +0100
Subject: [PATCH 032/252] Add XEP-0280 support
---
src/server_events.c | 5 +++++
src/server_events.h | 1 +
src/xmpp/connection.c | 1 +
src/xmpp/iq.c | 10 ++++++++++
src/xmpp/message.c | 38 ++++++++++++++++++++++++++++++++++++++
src/xmpp/stanza.c | 18 ++++++++++++++++++
src/xmpp/stanza.h | 5 +++++
src/xmpp/xmpp.h | 1 +
8 files changed, 79 insertions(+)
diff --git a/src/server_events.c b/src/server_events.c
index fbf534ac..bf880a9d 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -296,6 +296,11 @@ handle_incoming_private_message(char *fulljid, char *message)
ui_incoming_private_msg(fulljid, message, NULL);
}
+void
+handle_carbon(char *barejid, char *message){
+ ui_outgoing_chat_msg("me", barejid, message);
+}
+
void
handle_incoming_message(char *barejid, char *resource, char *message)
{
diff --git a/src/server_events.h b/src/server_events.h
index 6a12dc6e..3ec6a332 100644
--- a/src/server_events.h
+++ b/src/server_events.h
@@ -101,6 +101,7 @@ void handle_group_remove(const char * const contact,
void handle_roster_remove(const char * const barejid);
void handle_roster_add(const char * const barejid, const char * const name);
void handle_autoping_cancel(void);
+void handle_carbon(char *barejid, char *message);
void handle_message_error(const char * const from, const char * const type,
const char * const err_msg);
void handle_presence_error(const char *from, const char * const type,
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 915525e4..8bb7c74c 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -463,6 +463,7 @@ _connection_handler(xmpp_conn_t * const conn,
message_add_handlers();
presence_add_handlers();
iq_add_handlers();
+ iq_enable_carbons();
roster_request();
bookmark_request();
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 7fedf0ed..071b07c5 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -152,6 +152,16 @@ iq_room_list_request(gchar *conferencejid)
xmpp_stanza_release(iq);
}
+void
+iq_enable_carbons()
+{
+ xmpp_conn_t * const conn = connection_get_conn();
+ xmpp_ctx_t * const ctx = connection_get_ctx();
+ xmpp_stanza_t *iq = stanza_enable_carbons(ctx);
+ xmpp_send(conn, iq);
+ xmpp_stanza_release(iq);
+}
+
void
iq_disco_info_request(gchar *jid)
{
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index e96c1a74..4f341f6a 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -423,6 +423,44 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
return 1;
}
+ // check if carbon message
+ xmpp_stanza_t *received = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);
+ if(received != NULL){
+ xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(received, STANZA_NS_FORWARD);
+ xmpp_stanza_t *message = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);
+
+ xmpp_ctx_t *ctx = connection_get_ctx();
+
+ gchar *to = xmpp_stanza_get_attribute(message, STANZA_ATTR_TO);
+ gchar *from = xmpp_stanza_get_attribute(message, STANZA_ATTR_FROM);
+
+ Jid *jid_from = jid_create(from);
+ Jid *jid_to = jid_create(to);
+ Jid *my_jid = jid_create(jabber_get_fulljid());
+
+ // check for and deal with message
+ xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY);
+ if (body != NULL) {
+ char *message = xmpp_stanza_get_text(body);
+ if (message != NULL) {
+ // if we are the recipient, treat as standard incoming message
+ if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){
+ handle_incoming_message(jid_from->barejid, jid_from->resourcepart, message);
+ }
+ // else treat as a sent message
+ else{
+ handle_carbon(jid_to->barejid, message);
+ }
+ xmpp_free(ctx, message);
+ }
+ }
+
+ jid_destroy(jid_from);
+ jid_destroy(jid_to);
+ jid_destroy(my_jid);
+ return 1;
+ }
+
// ignore handled namespaces
xmpp_stanza_t *conf = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);
xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 4f1d412d..06177800 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -198,6 +198,24 @@ stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char * const jid,
}
#endif
+xmpp_stanza_t *
+stanza_enable_carbons(xmpp_ctx_t *ctx){
+ xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
+ char *id = create_unique_id(NULL);
+
+ xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
+ xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
+ xmpp_stanza_set_id(iq, id);
+
+ xmpp_stanza_t *carbon_enable = xmpp_stanza_new(ctx);
+ xmpp_stanza_set_name(carbon_enable, STANZA_NAME_ENABLE);
+ xmpp_stanza_set_ns(carbon_enable, STANZA_NS_CARBONS);
+
+ xmpp_stanza_add_child(iq, carbon_enable);
+
+ return iq;
+}
+
xmpp_stanza_t *
stanza_create_chat_state(xmpp_ctx_t *ctx, const char * const fulljid, const char * const state)
{
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 84282401..0c5a2b01 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -77,6 +77,7 @@
#define STANZA_NAME_VALUE "value"
#define STANZA_NAME_DESTROY "destroy"
#define STANZA_NAME_ACTOR "actor"
+#define STANZA_NAME_ENABLE "enable"
// error conditions
#define STANZA_NAME_BAD_REQUEST "bad-request"
@@ -154,6 +155,8 @@
#define STANZA_NS_CONFERENCE "jabber:x:conference"
#define STANZA_NS_CAPTCHA "urn:xmpp:captcha"
#define STANZA_NS_PUBSUB "http://jabber.org/protocol/pubsub"
+#define STANZA_NS_CARBONS "urn:xmpp:carbons:2"
+#define STANZA_NS_FORWARD "urn:xmpp:forward:0"
#define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
@@ -178,6 +181,8 @@ typedef enum {
xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx);
+xmpp_stanza_t * stanza_enable_carbons(xmpp_ctx_t *ctx);
+
xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx,
const char * const fulljid, const char * const state);
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index a004a4bf..41355e30 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -172,6 +172,7 @@ void presence_update(resource_presence_t status, const char * const msg,
gboolean presence_sub_request_exists(const char * const bare_jid);
// iq functions
+void iq_enable_carbons();
void iq_send_software_version(const char * const fulljid);
void iq_room_list_request(gchar *conferencejid);
void iq_disco_info_request(gchar *jid);
From 5954c0d2fe398213b29a8b4aa60340d49bf9946e Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 2 Feb 2015 21:27:58 +0000
Subject: [PATCH 033/252] Readline osx compatibility
---
configure.ac | 9 +++++++--
src/ui/core.c | 4 ++++
src/ui/inputwin.c | 18 ++++++++++--------
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2794ad43..59d7f82a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,8 +133,8 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [],
[AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
PKG_CHECK_MODULES([curl], [libcurl], [],
[AC_MSG_ERROR([libcurl is required for profanity])])
-AC_CHECK_LIB([readline], [main], [],
- [AC_MSG_ERROR([libreadline is required for profanity])])
+###AC_CHECK_LIB([readline], [main], [],
+### [AC_MSG_ERROR([libreadline is required for profanity])])
AS_IF([test "x$PLATFORM" = xosx], [LIBS="-lcurl $LIBS"])
@@ -234,6 +234,11 @@ AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS"
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
LIBS="$glib_LIBS $curl_LIBS $libnotify_LIBS $LIBS"
+LIBS="-lreadline $LIBS"
+AM_CPPFLAGS="-I/usr/local/opt/readline/include $AM_CPPFLAGS"
+AM_LDFLAGS="-L/usr/local/opt/readline/lib $AM_LDFLAGS"
+AC_SUBST(AM_LDFLAGS)
+
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CPPFLAGS)
diff --git a/src/ui/core.c b/src/ui/core.c
index 47aa9d10..d6b45bde 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -94,6 +94,10 @@ ui_init(void)
{
log_info("Initialising UI");
initscr();
+ nonl();
+ cbreak();
+ noecho();
+ leaveok(stdscr, FALSE);
keypad(stdscr, TRUE);
if (prefs_get_boolean(PREF_MOUSE)) {
mousemask(ALL_MOUSE_EVENTS, NULL);
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 4ac34c97..0c1c617e 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -92,10 +92,9 @@ _printable(const wint_t ch)
static void
cb_linehandler(char *line)
{
- if (*line) {
+ if (line && *line) {
add_history(line);
}
- rl_redisplay();
cmd_result = cmd_process_input(line);
free(line);
}
@@ -103,7 +102,7 @@ cb_linehandler(char *line)
int
prof_rl_getc(FILE *filein)
{
- int ch = rl_getc(filein);
+ int ch = getc(stdin);
if (_printable(ch)) {
cmd_reset_autocomplete();
}
@@ -128,14 +127,12 @@ tab_handler(int count, int key)
if (result) {
rl_replace_line(result, 0);
rl_point = rl_end;
- inp_write(result, rl_point);
}
} else if (strncmp(rl_line_buffer, "/", 1) == 0) {
char *result = cmd_autocomplete(rl_line_buffer);
if (result) {
rl_replace_line(result, 0);
rl_point = rl_end;
- inp_write(result, rl_point);
}
}
@@ -296,15 +293,19 @@ startup_hook(void)
void
create_input_window(void)
{
+/*
#ifdef NCURSES_REENTRANT
set_escdelay(25);
#else
ESCDELAY = 25;
#endif
+*/
p_rl_timeout.tv_sec = 0;
p_rl_timeout.tv_usec = inp_timeout * 1000;
- rl_startup_hook = startup_hook;
+
+ rl_readline_name = "profanity";
rl_getc_function = prof_rl_getc;
+ rl_startup_hook = startup_hook;
rl_callback_handler_install(NULL, cb_linehandler);
signal(SIGWINCH, resize_signal_handler);
@@ -314,7 +315,6 @@ create_input_window(void)
keypad(inp_win, TRUE);
wmove(inp_win, 0, 0);
-
_inp_win_update_virtual();
}
@@ -433,6 +433,8 @@ inp_readline(void)
if (FD_ISSET(fileno(rl_instream), &fds)) {
rl_callback_read_char();
+ cons_debug("LINE: %s", rl_line_buffer);
+ cons_debug("POS : %d", rl_point);
if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
prof_handle_activity();
@@ -494,4 +496,4 @@ _inp_win_update_virtual(void)
int wrows, wcols;
getmaxyx(stdscr, wrows, wcols);
pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-2);
-}
\ No newline at end of file
+}
From 1c157b04df75a71672d97ba970fc1a24a2f10a3c Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 2 Feb 2015 23:17:47 +0000
Subject: [PATCH 034/252] Fixed arrow keys with debug
---
src/ui/core.c | 1 -
src/ui/inputwin.c | 9 +++------
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/ui/core.c b/src/ui/core.c
index d6b45bde..de3bafd2 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -97,7 +97,6 @@ ui_init(void)
nonl();
cbreak();
noecho();
- leaveok(stdscr, FALSE);
keypad(stdscr, TRUE);
if (prefs_get_boolean(PREF_MOUSE)) {
mousemask(ALL_MOUSE_EVENTS, NULL);
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 0c1c617e..02278adf 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -102,7 +102,7 @@ cb_linehandler(char *line)
int
prof_rl_getc(FILE *filein)
{
- int ch = getc(stdin);
+ int ch = rl_getc(filein);
if (_printable(ch)) {
cmd_reset_autocomplete();
}
@@ -293,13 +293,11 @@ startup_hook(void)
void
create_input_window(void)
{
-/*
#ifdef NCURSES_REENTRANT
set_escdelay(25);
#else
ESCDELAY = 25;
#endif
-*/
p_rl_timeout.tv_sec = 0;
p_rl_timeout.tv_usec = inp_timeout * 1000;
@@ -433,16 +431,15 @@ inp_readline(void)
if (FD_ISSET(fileno(rl_instream), &fds)) {
rl_callback_read_char();
- cons_debug("LINE: %s", rl_line_buffer);
- cons_debug("POS : %d", rl_point);
if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
prof_handle_activity();
}
ui_reset_idle_time();
- inp_nonblocking(TRUE);
+ cons_show("");
inp_write(rl_line_buffer, rl_point);
+ inp_nonblocking(TRUE);
} else {
inp_nonblocking(FALSE);
prof_handle_idle();
From 2a12a4d93bcb898225003a8d38e7f28662075b70 Mon Sep 17 00:00:00 2001
From: Olivier LE MOAL
Date: Tue, 3 Feb 2015 15:27:56 +0100
Subject: [PATCH 035/252] Add preference/commands for carbons message
---
src/command/command.c | 10 ++++++++++
src/command/commands.c | 16 ++++++++++++++++
src/command/commands.h | 1 +
src/config/preferences.c | 5 ++++-
src/config/preferences.h | 1 +
src/ui/console.c | 9 +++++++++
src/ui/ui.h | 1 +
src/xmpp/connection.c | 6 +++++-
src/xmpp/iq.c | 10 ++++++++++
src/xmpp/stanza.c | 28 ++++++++++++++++++++++++----
src/xmpp/stanza.h | 3 +++
src/xmpp/xmpp.h | 1 +
12 files changed, 85 insertions(+), 6 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index 7be6603d..f44a21f5 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -858,6 +858,16 @@ static struct cmd_t command_defs[] =
"shared : Share logs between all instances, accepts 'on' or 'off', defaults to 'on'.",
NULL } } },
+ { "/carbons",
+ cmd_carbons, parse_args, 1, 1, &cons_carbons_setting,
+ { "/carbons on|off", "Message carbons.",
+ { "/carbons on|off",
+ "---------------",
+ "Enable or disable message carbons.",
+ "",
+ "Example : /carbons on",
+ NULL } } },
+
{ "/reconnect",
cmd_reconnect, parse_args, 1, 1, &cons_reconnect_setting,
{ "/reconnect seconds", "Set reconnect interval.",
diff --git a/src/command/commands.c b/src/command/commands.c
index 2059c982..477471d5 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -3882,6 +3882,22 @@ cmd_history(gchar **args, struct cmd_help_t help)
return result;
}
+gboolean
+cmd_carbons(gchar **args, struct cmd_help_t help)
+{
+ gboolean result = _cmd_set_boolean_preference(args[0], help,
+ "Carbons message", PREF_CARBONS);
+
+ // enable carbons
+ if (strcmp(args[0], "on") == 0) {
+ iq_enable_carbons();
+ }
+ else if (strcmp(args[0], "off") == 0){
+ iq_disable_carbons();
+ }
+ return result;
+}
+
gboolean
cmd_away(gchar **args, struct cmd_help_t help)
{
diff --git a/src/command/commands.h b/src/command/commands.h
index f4e040a9..1c16d635 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -85,6 +85,7 @@ gboolean cmd_grlog(gchar **args, struct cmd_help_t help);
gboolean cmd_group(gchar **args, struct cmd_help_t help);
gboolean cmd_help(gchar **args, struct cmd_help_t help);
gboolean cmd_history(gchar **args, struct cmd_help_t help);
+gboolean cmd_carbons(gchar **args, struct cmd_help_t help);
gboolean cmd_info(gchar **args, struct cmd_help_t help);
gboolean cmd_intype(gchar **args, struct cmd_help_t help);
gboolean cmd_invite(gchar **args, struct cmd_help_t help);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 67f12b18..47ef9391 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -558,6 +558,7 @@ _get_group(preference_t pref)
return PREF_GROUP_PRESENCE;
case PREF_CONNECT_ACCOUNT:
case PREF_DEFAULT_ACCOUNT:
+ case PREF_CARBONS:
return PREF_GROUP_CONNECTION;
case PREF_OTR_WARN:
case PREF_OTR_LOG:
@@ -593,6 +594,8 @@ _get_key(preference_t pref)
return "intype";
case PREF_HISTORY:
return "history";
+ case PREF_CARBONS:
+ return "carbons";
case PREF_MOUSE:
return "mouse";
case PREF_OCCUPANTS:
@@ -698,7 +701,7 @@ _get_default_boolean(preference_t pref)
case PREF_OCCUPANTS:
case PREF_MUC_PRIVILEGES:
case PREF_PRESENCE:
- case PREF_WRAP:
+ case PREF_WRAP:
case PREF_INPBLOCK_DYNAMIC:
return TRUE;
default:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 68286f09..aa23e48a 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -59,6 +59,7 @@ typedef enum {
PREF_FLASH,
PREF_INTYPE,
PREF_HISTORY,
+ PREF_CARBONS,
PREF_MOUSE,
PREF_OCCUPANTS,
PREF_OCCUPANTS_SIZE,
diff --git a/src/ui/console.c b/src/ui/console.c
index cdf5d1b8..82bac1e0 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1167,6 +1167,15 @@ cons_history_setting(void)
cons_show("Chat history (/history) : OFF");
}
+void
+cons_carbons_setting(void)
+{
+ if (prefs_get_boolean(PREF_CARBONS))
+ cons_show("Message carbons (/carbons) : ON");
+ else
+ cons_show("Message carbons (/carbons) : OFF");
+}
+
void
cons_show_chat_prefs(void)
{
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 99e73b4a..44ff42f4 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -308,6 +308,7 @@ void cons_outtype_setting(void);
void cons_intype_setting(void);
void cons_gone_setting(void);
void cons_history_setting(void);
+void cons_carbons_setting(void);
void cons_log_setting(void);
void cons_chlog_setting(void);
void cons_grlog_setting(void);
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 8bb7c74c..34fba22d 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -463,10 +463,14 @@ _connection_handler(xmpp_conn_t * const conn,
message_add_handlers();
presence_add_handlers();
iq_add_handlers();
- iq_enable_carbons();
roster_request();
bookmark_request();
+
+ if (prefs_get_boolean(PREF_CARBONS)){
+ iq_enable_carbons();
+ }
+
jabber_conn.conn_status = JABBER_CONNECTED;
if (prefs_get_reconnect() != 0) {
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 071b07c5..be22b01f 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -162,6 +162,16 @@ iq_enable_carbons()
xmpp_stanza_release(iq);
}
+void
+iq_disable_carbons()
+{
+ xmpp_conn_t * const conn = connection_get_conn();
+ xmpp_ctx_t * const ctx = connection_get_ctx();
+ xmpp_stanza_t *iq = stanza_disable_carbons(ctx);
+ xmpp_send(conn, iq);
+ xmpp_stanza_release(iq);
+}
+
void
iq_disco_info_request(gchar *jid)
{
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 06177800..b0d7de86 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -206,12 +206,32 @@ stanza_enable_carbons(xmpp_ctx_t *ctx){
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
xmpp_stanza_set_id(iq, id);
+ free(id);
- xmpp_stanza_t *carbon_enable = xmpp_stanza_new(ctx);
- xmpp_stanza_set_name(carbon_enable, STANZA_NAME_ENABLE);
- xmpp_stanza_set_ns(carbon_enable, STANZA_NS_CARBONS);
+ xmpp_stanza_t *carbons_enable = xmpp_stanza_new(ctx);
+ xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE);
+ xmpp_stanza_set_ns(carbons_enable, STANZA_NS_CARBONS);
- xmpp_stanza_add_child(iq, carbon_enable);
+ xmpp_stanza_add_child(iq, carbons_enable);
+
+ return iq;
+}
+
+xmpp_stanza_t *
+stanza_disable_carbons(xmpp_ctx_t *ctx){
+ xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
+ char *id = create_unique_id(NULL);
+
+ xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
+ xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
+ xmpp_stanza_set_id(iq, id);
+ free(id);
+
+ xmpp_stanza_t *carbons_disable = xmpp_stanza_new(ctx);
+ xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE);
+ xmpp_stanza_set_ns(carbons_disable, STANZA_NS_CARBONS);
+
+ xmpp_stanza_add_child(iq, carbons_disable);
return iq;
}
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 0c5a2b01..e4f3ce57 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -78,6 +78,7 @@
#define STANZA_NAME_DESTROY "destroy"
#define STANZA_NAME_ACTOR "actor"
#define STANZA_NAME_ENABLE "enable"
+#define STANZA_NAME_DISABLE "disable"
// error conditions
#define STANZA_NAME_BAD_REQUEST "bad-request"
@@ -183,6 +184,8 @@ xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx);
xmpp_stanza_t * stanza_enable_carbons(xmpp_ctx_t *ctx);
+xmpp_stanza_t * stanza_disable_carbons(xmpp_ctx_t *ctx);
+
xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx,
const char * const fulljid, const char * const state);
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 41355e30..1fc32665 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -173,6 +173,7 @@ gboolean presence_sub_request_exists(const char * const bare_jid);
// iq functions
void iq_enable_carbons();
+void iq_disable_carbons();
void iq_send_software_version(const char * const fulljid);
void iq_room_list_request(gchar *conferencejid);
void iq_disco_info_request(gchar *jid);
From a89e04b9d5ef8b65181ddcd1bc3c3ad261406e1a Mon Sep 17 00:00:00 2001
From: Olivier LE MOAL
Date: Tue, 3 Feb 2015 15:48:19 +0100
Subject: [PATCH 036/252] Fix help for message carbons
---
src/command/command.c | 3 +--
src/config/preferences.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index f44a21f5..d22786af 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -864,8 +864,7 @@ static struct cmd_t command_defs[] =
{ "/carbons on|off",
"---------------",
"Enable or disable message carbons.",
- "",
- "Example : /carbons on",
+ "The message carbons feature ensures that both sides of all conversations are shared with all the user's clients that implement this protocol.",
NULL } } },
{ "/reconnect",
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 47ef9391..7753ad71 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -701,7 +701,7 @@ _get_default_boolean(preference_t pref)
case PREF_OCCUPANTS:
case PREF_MUC_PRIVILEGES:
case PREF_PRESENCE:
- case PREF_WRAP:
+ case PREF_WRAP:
case PREF_INPBLOCK_DYNAMIC:
return TRUE;
default:
From 62c1a59f388a55d6a4002e29b03d477262cbbb2d Mon Sep 17 00:00:00 2001
From: Olivier LE MOAL
Date: Tue, 3 Feb 2015 18:19:04 +0100
Subject: [PATCH 037/252] Add /carbons in /help settings
---
src/command/commands.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/command/commands.c b/src/command/commands.c
index 477471d5..29615913 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -730,7 +730,7 @@ cmd_help(gchar **args, struct cmd_help_t help)
} else if (strcmp(args[0], "settings") == 0) {
gchar *filter[] = { "/account", "/autoaway", "/autoping", "/autoconnect", "/beep",
- "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype",
+ "/carbons", "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype",
"/log", "/mouse", "/notify", "/outtype", "/prefs", "/priority",
"/reconnect", "/roster", "/splash", "/states", "/statuses", "/theme",
"/titlebar", "/vercheck", "/privileges", "/occupants", "/presence", "/wrap" };
From ecfc2a3904c6e2bb4053df42203a359bab1d51be Mon Sep 17 00:00:00 2001
From: Olivier LE MOAL
Date: Tue, 3 Feb 2015 18:52:31 +0100
Subject: [PATCH 038/252] Add declarations to tests headers
---
tests/ui/stub_ui.c | 1 +
tests/xmpp/stub_xmpp.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c
index 51b82d42..fe650921 100644
--- a/tests/ui/stub_ui.c
+++ b/tests/ui/stub_ui.c
@@ -457,6 +457,7 @@ void cons_outtype_setting(void) {}
void cons_intype_setting(void) {}
void cons_gone_setting(void) {}
void cons_history_setting(void) {}
+void cons_carbons_setting(void) {}
void cons_log_setting(void) {}
void cons_chlog_setting(void) {}
void cons_grlog_setting(void) {}
diff --git a/tests/xmpp/stub_xmpp.c b/tests/xmpp/stub_xmpp.c
index 281857f0..02c0acf8 100644
--- a/tests/xmpp/stub_xmpp.c
+++ b/tests/xmpp/stub_xmpp.c
@@ -119,6 +119,8 @@ gboolean presence_sub_request_exists(const char * const bare_jid)
}
// iq functions
+void iq_disable_carbons();
+void iq_enable_carbons();
void iq_send_software_version(const char * const fulljid) {}
void iq_room_list_request(gchar *conferencejid)
From 89f472512f3ea88337bcfbee51431f1f7a1934b9 Mon Sep 17 00:00:00 2001
From: Olivier LE MOAL
Date: Tue, 3 Feb 2015 19:09:37 +0100
Subject: [PATCH 039/252] Fix stub
---
tests/xmpp/stub_xmpp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/xmpp/stub_xmpp.c b/tests/xmpp/stub_xmpp.c
index 02c0acf8..dc9a258e 100644
--- a/tests/xmpp/stub_xmpp.c
+++ b/tests/xmpp/stub_xmpp.c
@@ -119,8 +119,8 @@ gboolean presence_sub_request_exists(const char * const bare_jid)
}
// iq functions
-void iq_disable_carbons();
-void iq_enable_carbons();
+void iq_disable_carbons() {};
+void iq_enable_carbons() {};
void iq_send_software_version(const char * const fulljid) {}
void iq_room_list_request(gchar *conferencejid)
From 836fdd2eb1fdba1dab6bd2b93ad65deb64185dd5 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Feb 2015 21:04:51 +0000
Subject: [PATCH 040/252] Remove state passed to wide char len check
---
src/ui/inputwin.c | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 02278adf..9321706a 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -334,26 +334,6 @@ inp_win_resize(void)
_inp_win_update_virtual();
}
-static int
-offset_to_col(char *str, int offset)
-{
- int i = 0;
- int col = 0;
- mbstate_t internal;
-
- while (i != offset && str[i] != '\n') {
- gunichar uni = g_utf8_get_char(&str[i]);
- size_t ch_len = mbrlen(&str[i], 4, &internal);
- i += ch_len;
- col++;
- if (g_unichar_iswide(uni)) {
- col++;
- }
- }
-
- return col;
-}
-
void
inp_nonblocking(gboolean reset)
{
@@ -406,6 +386,25 @@ inp_win_handle_scroll(void)
}
}
+int
+offset_to_col(char *str, int offset)
+{
+ int i = 0;
+ int col = 0;
+
+ while (i < offset && str[i] != '\0') {
+ gunichar uni = g_utf8_get_char(&str[i]);
+ size_t ch_len = mbrlen(&str[i], 4, NULL);
+ i += ch_len;
+ col++;
+ if (g_unichar_iswide(uni)) {
+ col++;
+ }
+ }
+
+ return col;
+}
+
void
inp_write(char *line, int offset)
{
@@ -437,7 +436,6 @@ inp_readline(void)
}
ui_reset_idle_time();
- cons_show("");
inp_write(rl_line_buffer, rl_point);
inp_nonblocking(TRUE);
} else {
From b76501f0bc908cbbb7850adf1e9e49eed95b0d31 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Feb 2015 21:08:34 +0000
Subject: [PATCH 041/252] Removed mbstate_t use
---
src/ui/window.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/ui/window.c b/src/ui/window.c
index 37da8e9d..46d2e85c 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1011,9 +1011,8 @@ _win_print_wrapped(WINDOW *win, const char * const message)
} else {
// get word
wordi = 0;
- mbstate_t internal;
while (*curr_ch != ' ' && *curr_ch != '\n' && *curr_ch != '\0') {
- size_t ch_len = mbrlen(curr_ch, 4, &internal);
+ size_t ch_len = mbrlen(curr_ch, 4, NULL);
int offset = 0;
while (offset < ch_len) {
word[wordi++] = curr_ch[offset++];
From 82ddbf332d65ce56f4152915060ff7241bfbe7b9 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Feb 2015 21:38:48 +0000
Subject: [PATCH 042/252] Added OSX readline keyseq bindings
---
configure.ac | 2 ++
src/ui/inputwin.c | 13 +++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 59d7f82a..77d2a7a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,8 @@ AC_DEFINE_UNQUOTED([PACKAGE_STATUS], ["$PACKAGE_STATUS"], [Status of this build]
AS_IF([test "x$PLATFORM" = xcygwin],
[AC_DEFINE([PLATFORM_CYGWIN], [1], [Cygwin])])
+AS_IF([test "x$PLATFORM" = xosx],
+ [AC_DEFINE([PLATFORM_OSX], [1], [OSx])])
### Options
AC_ARG_ENABLE([notifications],
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 9321706a..d0d0dfe6 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -276,14 +276,19 @@ startup_hook(void)
rl_bind_keyseq("\\e[20~", win9_handler);
rl_bind_keyseq("\\e[21~", win0_handler);
+#ifdef PLATFORM_OSX
+ rl_bind_keyseq("\\e[1;9D", altleft_handler);
+ rl_bind_keyseq("\\e[1;9C", altright_handler);
+ rl_bind_keyseq("\\e\\e[5~", altpageup_handler);
+ rl_bind_keyseq("\\e\\e[6~", altpagedown_handler);
+#else
rl_bind_keyseq("\\e[1;3D", altleft_handler);
rl_bind_keyseq("\\e[1;3C", altright_handler);
-
- rl_bind_keyseq("\\e[5~", pageup_handler);
- rl_bind_keyseq("\\e[6~", pagedown_handler);
-
rl_bind_keyseq("\\e[5;3~", altpageup_handler);
rl_bind_keyseq("\\e[6;3~", altpagedown_handler);
+#endif
+ rl_bind_keyseq("\\e[5~", pageup_handler);
+ rl_bind_keyseq("\\e[6~", pagedown_handler);
rl_bind_key('\t', tab_handler);
From f80f79e0b54ec24bd0491a97733b159b5f9113cf Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Feb 2015 22:04:30 +0000
Subject: [PATCH 043/252] Added configure conditions for OSX brew installed
readline
---
configure.ac | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index 77d2a7a0..19c9b984 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,8 +135,8 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [],
[AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
PKG_CHECK_MODULES([curl], [libcurl], [],
[AC_MSG_ERROR([libcurl is required for profanity])])
-###AC_CHECK_LIB([readline], [main], [],
-### [AC_MSG_ERROR([libreadline is required for profanity])])
+AC_CHECK_LIB([readline], [main], [],
+ [AC_MSG_ERROR([libreadline is required for profanity])])
AS_IF([test "x$PLATFORM" = xosx], [LIBS="-lcurl $LIBS"])
@@ -236,10 +236,12 @@ AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS"
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
LIBS="$glib_LIBS $curl_LIBS $libnotify_LIBS $LIBS"
-LIBS="-lreadline $LIBS"
-AM_CPPFLAGS="-I/usr/local/opt/readline/include $AM_CPPFLAGS"
-AM_LDFLAGS="-L/usr/local/opt/readline/lib $AM_LDFLAGS"
-AC_SUBST(AM_LDFLAGS)
+### Use brew installed gnu readline
+AS_IF([test "x$PLATFORM" = xosx], [
+ LIBS="-lreadline $LIBS"
+ AM_CPPFLAGS="-I/usr/local/opt/readline/include $AM_CPPFLAGS"
+ AM_LDFLAGS="-L/usr/local/opt/readline/lib $AM_LDFLAGS"
+ AC_SUBST(AM_LDFLAGS)])
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CPPFLAGS)
From af345b6700f37ae190985c4e27f5ba01931da63e Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Feb 2015 22:24:47 +0000
Subject: [PATCH 044/252] Updated navigation help
---
src/ui/console.c | 23 +++--------------------
1 file changed, 3 insertions(+), 20 deletions(-)
diff --git a/src/ui/console.c b/src/ui/console.c
index cdf5d1b8..579d9c49 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1419,27 +1419,10 @@ cons_navigation_help(void)
cons_show("");
cons_show("Navigation:");
cons_show("");
- cons_show("Alt-1 : This console window.");
- cons_show("F1 : This console window.");
- cons_show("Alt-2..Alt-0 : Chat windows.");
- cons_show("F2..F10 : Chat windows.");
+ cons_show("Alt-1..Alt-0, F1..F10 : Choose window.");
cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window");
- cons_show("UP, DOWN : Navigate input history.");
- cons_show("Ctrl-n, Ctrl-p : Navigate input history.");
- cons_show("LEFT, RIGHT, HOME, END : Move cursor.");
- cons_show("Ctrl-b, Ctrl-f, Ctrl-a, Ctrl-e : Move cursor.");
- cons_show("Ctrl-LEFT, Ctrl-RIGHT : Jump word.");
- cons_show("Ctrl-w : Delete previous word.");
- cons_show("Alt-Backspace : Delete previous word.");
- cons_show("Backspace : Delete previous character.");
- cons_show("DEL : Delete next character.");
- cons_show("Ctrl-d : Delete next character.");
- cons_show("ESC : Clear current input.");
- cons_show("Ctrl-u : Delete all previous characters.");
- cons_show("TAB : Autocomplete.");
- cons_show("PAGE UP, PAGE DOWN : Page the main window.");
- cons_show("Shift-UP, Shift-DOWN : Page occupants/roster panel.");
- cons_show("Ctrl-UP, Ctrl-DOWN : Page occupants/roster panel.");
+ cons_show("PAGEUP, PAGEDOWN : Page the main window.");
+ cons_show("Alt-PAGEUP, Alt-PAGEDOWN : Page occupants/roster panel.");
cons_show("");
cons_alert();
From 8b58eb68d302b6b7c2c6e6319daf8cb064c38d54 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Feb 2015 23:07:15 +0000
Subject: [PATCH 045/252] Tidied inputwin.c
---
src/ui/inputwin.c | 636 ++++++++++++++++++++++++----------------------
1 file changed, 332 insertions(+), 304 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index d0d0dfe6..f9e123c5 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -65,6 +65,7 @@
#include "xmpp/xmpp.h"
static WINDOW *inp_win;
+static int pad_start = 0;
static struct timeval p_rl_timeout;
static gint inp_timeout = 0;
@@ -74,226 +75,33 @@ static fd_set fds;
static int r;
static gboolean cmd_result = TRUE;
-static int pad_start = 0;
-
static void _inp_win_update_virtual(void);
+static int _inp_printable(const wint_t ch);
+static void _inp_win_handle_scroll(void);
+static void _inp_resize_signal_handler(int signal);
+static int _inp_offset_to_col(char *str, int offset);
+static void _inp_write(char *line, int offset);
-static int
-_printable(const wint_t ch)
-{
- char bytes[MB_CUR_MAX+1];
- size_t utf_len = wcrtomb(bytes, ch, NULL);
- bytes[utf_len] = '\0';
- gunichar unichar = g_utf8_get_char(bytes);
-
- return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
-}
-
-static void
-cb_linehandler(char *line)
-{
- if (line && *line) {
- add_history(line);
- }
- cmd_result = cmd_process_input(line);
- free(line);
-}
-
-int
-prof_rl_getc(FILE *filein)
-{
- int ch = rl_getc(filein);
- if (_printable(ch)) {
- cmd_reset_autocomplete();
- }
- return ch;
-}
-
-void
-resize_signal_handler(int signal)
-{
- ui_resize();
-}
-
-int
-tab_handler(int count, int key)
-{
- if (rl_point != rl_end || !rl_line_buffer) {
- return 0;
- }
-
- if ((strncmp(rl_line_buffer, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
- char *result = muc_autocomplete(rl_line_buffer);
- if (result) {
- rl_replace_line(result, 0);
- rl_point = rl_end;
- }
- } else if (strncmp(rl_line_buffer, "/", 1) == 0) {
- char *result = cmd_autocomplete(rl_line_buffer);
- if (result) {
- rl_replace_line(result, 0);
- rl_point = rl_end;
- }
- }
-
- return 0;
-}
-
-int
-win1_handler(int count, int key)
-{
- ui_switch_win(1);
- return 0;
-}
-
-int
-win2_handler(int count, int key)
-{
- ui_switch_win(2);
- return 0;
-}
-
-int
-win3_handler(int count, int key)
-{
- ui_switch_win(3);
- return 0;
-}
-
-int
-win4_handler(int count, int key)
-{
- ui_switch_win(4);
- return 0;
-}
-
-int
-win5_handler(int count, int key)
-{
- ui_switch_win(5);
- return 0;
-}
-
-int
-win6_handler(int count, int key)
-{
- ui_switch_win(6);
- return 0;
-}
-
-int
-win7_handler(int count, int key)
-{
- ui_switch_win(7);
- return 0;
-}
-
-int
-win8_handler(int count, int key)
-{
- ui_switch_win(8);
- return 0;
-}
-
-int
-win9_handler(int count, int key)
-{
- ui_switch_win(9);
- return 0;
-}
-
-int
-win0_handler(int count, int key)
-{
- ui_switch_win(0);
- return 0;
-}
-
-int
-altleft_handler(int count, int key)
-{
- ui_previous_win();
- return 0;
-}
-
-int
-altright_handler(int count, int key)
-{
- ui_next_win();
- return 0;
-}
-
-int
-pageup_handler(int count, int key)
-{
- ui_page_up();
- return 0;
-}
-
-int
-pagedown_handler(int count, int key)
-{
- ui_page_down();
- return 0;
-}
-
-int
-altpageup_handler(int count, int key)
-{
- ui_subwin_page_up();
- return 0;
-}
-
-int
-altpagedown_handler(int count, int key)
-{
- ui_subwin_page_down();
- return 0;
-}
-
-int
-startup_hook(void)
-{
- rl_bind_keyseq("\\e1", win1_handler);
- rl_bind_keyseq("\\e2", win2_handler);
- rl_bind_keyseq("\\e3", win3_handler);
- rl_bind_keyseq("\\e4", win4_handler);
- rl_bind_keyseq("\\e5", win5_handler);
- rl_bind_keyseq("\\e6", win6_handler);
- rl_bind_keyseq("\\e7", win7_handler);
- rl_bind_keyseq("\\e8", win8_handler);
- rl_bind_keyseq("\\e9", win9_handler);
- rl_bind_keyseq("\\e0", win0_handler);
-
- rl_bind_keyseq("\\eOP", win1_handler);
- rl_bind_keyseq("\\eOQ", win2_handler);
- rl_bind_keyseq("\\eOR", win3_handler);
- rl_bind_keyseq("\\eOS", win4_handler);
- rl_bind_keyseq("\\e[15~", win5_handler);
- rl_bind_keyseq("\\e[17~", win6_handler);
- rl_bind_keyseq("\\e[18~", win7_handler);
- rl_bind_keyseq("\\e[19~", win8_handler);
- rl_bind_keyseq("\\e[20~", win9_handler);
- rl_bind_keyseq("\\e[21~", win0_handler);
-
-#ifdef PLATFORM_OSX
- rl_bind_keyseq("\\e[1;9D", altleft_handler);
- rl_bind_keyseq("\\e[1;9C", altright_handler);
- rl_bind_keyseq("\\e\\e[5~", altpageup_handler);
- rl_bind_keyseq("\\e\\e[6~", altpagedown_handler);
-#else
- rl_bind_keyseq("\\e[1;3D", altleft_handler);
- rl_bind_keyseq("\\e[1;3C", altright_handler);
- rl_bind_keyseq("\\e[5;3~", altpageup_handler);
- rl_bind_keyseq("\\e[6;3~", altpagedown_handler);
-#endif
- rl_bind_keyseq("\\e[5~", pageup_handler);
- rl_bind_keyseq("\\e[6~", pagedown_handler);
-
- rl_bind_key('\t', tab_handler);
-
- return 0;
-}
+static int _inp_rl_getc(FILE *stream);
+static void _inp_rl_linehandler(char *line);
+static int _inp_rl_tab_handler(int count, int key);
+static int _inp_rl_win1_handler(int count, int key);
+static int _inp_rl_win2_handler(int count, int key);
+static int _inp_rl_win3_handler(int count, int key);
+static int _inp_rl_win4_handler(int count, int key);
+static int _inp_rl_win5_handler(int count, int key);
+static int _inp_rl_win6_handler(int count, int key);
+static int _inp_rl_win7_handler(int count, int key);
+static int _inp_rl_win8_handler(int count, int key);
+static int _inp_rl_win9_handler(int count, int key);
+static int _inp_rl_win0_handler(int count, int key);
+static int _inp_rl_altleft_handler(int count, int key);
+static int _inp_rl_altright_handler(int count, int key);
+static int _inp_rl_pageup_handler(int count, int key);
+static int _inp_rl_pagedown_handler(int count, int key);
+static int _inp_rl_altpageup_handler(int count, int key);
+static int _inp_rl_altpagedown_handler(int count, int key);
+static int _inp_rl_startup_hook(void);
void
create_input_window(void)
@@ -307,11 +115,11 @@ create_input_window(void)
p_rl_timeout.tv_usec = inp_timeout * 1000;
rl_readline_name = "profanity";
- rl_getc_function = prof_rl_getc;
- rl_startup_hook = startup_hook;
- rl_callback_handler_install(NULL, cb_linehandler);
+ rl_getc_function = _inp_rl_getc;
+ rl_startup_hook = _inp_rl_startup_hook;
+ rl_callback_handler_install(NULL, _inp_rl_linehandler);
- signal(SIGWINCH, resize_signal_handler);
+ signal(SIGWINCH, _inp_resize_signal_handler);
inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
@@ -321,6 +129,38 @@ create_input_window(void)
_inp_win_update_virtual();
}
+gboolean
+inp_readline(void)
+{
+ FD_ZERO(&fds);
+ FD_SET(fileno(rl_instream), &fds);
+ r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
+ if (r < 0) {
+ log_error("Readline failed.");
+ return TRUE;
+ }
+
+ if (FD_ISSET(fileno(rl_instream), &fds)) {
+ rl_callback_read_char();
+
+ if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
+ prof_handle_activity();
+ }
+
+ ui_reset_idle_time();
+ _inp_write(rl_line_buffer, rl_point);
+ inp_nonblocking(TRUE);
+ } else {
+ inp_nonblocking(FALSE);
+ prof_handle_idle();
+ }
+
+ p_rl_timeout.tv_sec = 0;
+ p_rl_timeout.tv_usec = inp_timeout * 1000;
+
+ return cmd_result;
+}
+
void
inp_win_resize(void)
{
@@ -371,88 +211,6 @@ inp_block(void)
wtimeout(inp_win, -1);
}
-void
-inp_win_handle_scroll(void)
-{
- int col = getcurx(inp_win);
- int wcols = getmaxx(stdscr);
-
- // if lost cursor off screen, move contents to show it
- if (col >= pad_start + (wcols -2)) {
- pad_start = col - (wcols / 2);
- if (pad_start < 0) {
- pad_start = 0;
- }
- } else if (col <= pad_start) {
- pad_start = pad_start - (wcols / 2);
- if (pad_start < 0) {
- pad_start = 0;
- }
- }
-}
-
-int
-offset_to_col(char *str, int offset)
-{
- int i = 0;
- int col = 0;
-
- while (i < offset && str[i] != '\0') {
- gunichar uni = g_utf8_get_char(&str[i]);
- size_t ch_len = mbrlen(&str[i], 4, NULL);
- i += ch_len;
- col++;
- if (g_unichar_iswide(uni)) {
- col++;
- }
- }
-
- return col;
-}
-
-void
-inp_write(char *line, int offset)
-{
- int col = offset_to_col(line, offset);
- werase(inp_win);
- waddstr(inp_win, line);
- wmove(inp_win, 0, col);
- inp_win_handle_scroll();
-
- _inp_win_update_virtual();
-}
-
-gboolean
-inp_readline(void)
-{
- FD_ZERO(&fds);
- FD_SET(fileno(rl_instream), &fds);
- r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
- if (r < 0) {
- log_error("Readline failed.");
- return TRUE;
- }
-
- if (FD_ISSET(fileno(rl_instream), &fds)) {
- rl_callback_read_char();
-
- if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
- prof_handle_activity();
- }
-
- ui_reset_idle_time();
- inp_write(rl_line_buffer, rl_point);
- inp_nonblocking(TRUE);
- } else {
- inp_nonblocking(FALSE);
- prof_handle_idle();
- }
-
- p_rl_timeout.tv_sec = 0;
- p_rl_timeout.tv_usec = inp_timeout * 1000;
-
- return cmd_result;
-}
void
inp_close(void)
@@ -497,3 +255,273 @@ _inp_win_update_virtual(void)
getmaxyx(stdscr, wrows, wcols);
pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-2);
}
+
+static void
+_inp_write(char *line, int offset)
+{
+ int col = _inp_offset_to_col(line, offset);
+ werase(inp_win);
+ waddstr(inp_win, line);
+ wmove(inp_win, 0, col);
+ _inp_win_handle_scroll();
+
+ _inp_win_update_virtual();
+}
+
+static int
+_inp_printable(const wint_t ch)
+{
+ char bytes[MB_CUR_MAX+1];
+ size_t utf_len = wcrtomb(bytes, ch, NULL);
+ bytes[utf_len] = '\0';
+ gunichar unichar = g_utf8_get_char(bytes);
+
+ return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
+}
+
+static int
+_inp_offset_to_col(char *str, int offset)
+{
+ int i = 0;
+ int col = 0;
+
+ while (i < offset && str[i] != '\0') {
+ gunichar uni = g_utf8_get_char(&str[i]);
+ size_t ch_len = mbrlen(&str[i], 4, NULL);
+ i += ch_len;
+ col++;
+ if (g_unichar_iswide(uni)) {
+ col++;
+ }
+ }
+
+ return col;
+}
+
+static void
+_inp_resize_signal_handler(int signal)
+{
+ ui_resize();
+}
+
+static void
+_inp_win_handle_scroll(void)
+{
+ int col = getcurx(inp_win);
+ int wcols = getmaxx(stdscr);
+
+ // if lost cursor off screen, move contents to show it
+ if (col >= pad_start + (wcols -2)) {
+ pad_start = col - (wcols / 2);
+ if (pad_start < 0) {
+ pad_start = 0;
+ }
+ } else if (col <= pad_start) {
+ pad_start = pad_start - (wcols / 2);
+ if (pad_start < 0) {
+ pad_start = 0;
+ }
+ }
+}
+
+// Readline callbacks
+
+static void
+_inp_rl_linehandler(char *line)
+{
+ if (line && *line) {
+ add_history(line);
+ }
+ cmd_result = cmd_process_input(line);
+ free(line);
+}
+
+static int
+_inp_rl_getc(FILE *stream)
+{
+ int ch = rl_getc(stream);
+ if (_inp_printable(ch)) {
+ cmd_reset_autocomplete();
+ }
+ return ch;
+}
+
+static int
+_inp_rl_tab_handler(int count, int key)
+{
+ if (rl_point != rl_end || !rl_line_buffer) {
+ return 0;
+ }
+
+ if ((strncmp(rl_line_buffer, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
+ char *result = muc_autocomplete(rl_line_buffer);
+ if (result) {
+ rl_replace_line(result, 0);
+ rl_point = rl_end;
+ }
+ } else if (strncmp(rl_line_buffer, "/", 1) == 0) {
+ char *result = cmd_autocomplete(rl_line_buffer);
+ if (result) {
+ rl_replace_line(result, 0);
+ rl_point = rl_end;
+ }
+ }
+
+ return 0;
+}
+
+static int
+_inp_rl_win1_handler(int count, int key)
+{
+ ui_switch_win(1);
+ return 0;
+}
+
+static int
+_inp_rl_win2_handler(int count, int key)
+{
+ ui_switch_win(2);
+ return 0;
+}
+
+static int
+_inp_rl_win3_handler(int count, int key)
+{
+ ui_switch_win(3);
+ return 0;
+}
+
+static int
+_inp_rl_win4_handler(int count, int key)
+{
+ ui_switch_win(4);
+ return 0;
+}
+
+static int
+_inp_rl_win5_handler(int count, int key)
+{
+ ui_switch_win(5);
+ return 0;
+}
+
+static int
+_inp_rl_win6_handler(int count, int key)
+{
+ ui_switch_win(6);
+ return 0;
+}
+
+static int
+_inp_rl_win7_handler(int count, int key)
+{
+ ui_switch_win(7);
+ return 0;
+}
+
+static int
+_inp_rl_win8_handler(int count, int key)
+{
+ ui_switch_win(8);
+ return 0;
+}
+
+static int
+_inp_rl_win9_handler(int count, int key)
+{
+ ui_switch_win(9);
+ return 0;
+}
+
+static int
+_inp_rl_win0_handler(int count, int key)
+{
+ ui_switch_win(0);
+ return 0;
+}
+
+static int
+_inp_rl_altleft_handler(int count, int key)
+{
+ ui_previous_win();
+ return 0;
+}
+
+static int
+_inp_rl_altright_handler(int count, int key)
+{
+ ui_next_win();
+ return 0;
+}
+
+static int
+_inp_rl_pageup_handler(int count, int key)
+{
+ ui_page_up();
+ return 0;
+}
+
+static int
+_inp_rl_pagedown_handler(int count, int key)
+{
+ ui_page_down();
+ return 0;
+}
+
+static int
+_inp_rl_altpageup_handler(int count, int key)
+{
+ ui_subwin_page_up();
+ return 0;
+}
+
+static int
+_inp_rl_altpagedown_handler(int count, int key)
+{
+ ui_subwin_page_down();
+ return 0;
+}
+
+static int
+_inp_rl_startup_hook(void)
+{
+ rl_bind_keyseq("\\e1", _inp_rl_win1_handler);
+ rl_bind_keyseq("\\e2", _inp_rl_win2_handler);
+ rl_bind_keyseq("\\e3", _inp_rl_win3_handler);
+ rl_bind_keyseq("\\e4", _inp_rl_win4_handler);
+ rl_bind_keyseq("\\e5", _inp_rl_win5_handler);
+ rl_bind_keyseq("\\e6", _inp_rl_win6_handler);
+ rl_bind_keyseq("\\e7", _inp_rl_win7_handler);
+ rl_bind_keyseq("\\e8", _inp_rl_win8_handler);
+ rl_bind_keyseq("\\e9", _inp_rl_win9_handler);
+ rl_bind_keyseq("\\e0", _inp_rl_win0_handler);
+
+ rl_bind_keyseq("\\eOP", _inp_rl_win1_handler);
+ rl_bind_keyseq("\\eOQ", _inp_rl_win2_handler);
+ rl_bind_keyseq("\\eOR", _inp_rl_win3_handler);
+ rl_bind_keyseq("\\eOS", _inp_rl_win4_handler);
+ rl_bind_keyseq("\\e[15~", _inp_rl_win5_handler);
+ rl_bind_keyseq("\\e[17~", _inp_rl_win6_handler);
+ rl_bind_keyseq("\\e[18~", _inp_rl_win7_handler);
+ rl_bind_keyseq("\\e[19~", _inp_rl_win8_handler);
+ rl_bind_keyseq("\\e[20~", _inp_rl_win9_handler);
+ rl_bind_keyseq("\\e[21~", _inp_rl_win0_handler);
+
+#ifdef PLATFORM_OSX
+ rl_bind_keyseq("\\e[1;9D", _inp_rl_altleft_handler);
+ rl_bind_keyseq("\\e[1;9C", _inp_rl_altright_handler);
+ rl_bind_keyseq("\\e\\e[5~", _inp_rl_altpageup_handler);
+ rl_bind_keyseq("\\e\\e[6~", _inp_rl_altpagedown_handler);
+#else
+ rl_bind_keyseq("\\e[1;3D", _inp_rl_altleft_handler);
+ rl_bind_keyseq("\\e[1;3C", _inp_rl_altright_handler);
+ rl_bind_keyseq("\\e[5;3~", _inp_rl_altpageup_handler);
+ rl_bind_keyseq("\\e[6;3~", _inp_rl_altpagedown_handler);
+#endif
+ rl_bind_keyseq("\\e[5~", _inp_rl_pageup_handler);
+ rl_bind_keyseq("\\e[6~", _inp_rl_pagedown_handler);
+
+ rl_bind_key('\t', _inp_rl_tab_handler);
+
+ return 0;
+}
\ No newline at end of file
From 7ab301869f919ef815c7dbb024a7b19ceaec671f Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Feb 2015 23:27:06 +0000
Subject: [PATCH 046/252] Moved readline startup hook
---
src/ui/inputwin.c | 88 +++++++++++++++++++++++------------------------
1 file changed, 44 insertions(+), 44 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index f9e123c5..0ee1d721 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -326,6 +326,50 @@ _inp_win_handle_scroll(void)
// Readline callbacks
+static int
+_inp_rl_startup_hook(void)
+{
+ rl_bind_keyseq("\\e1", _inp_rl_win1_handler);
+ rl_bind_keyseq("\\e2", _inp_rl_win2_handler);
+ rl_bind_keyseq("\\e3", _inp_rl_win3_handler);
+ rl_bind_keyseq("\\e4", _inp_rl_win4_handler);
+ rl_bind_keyseq("\\e5", _inp_rl_win5_handler);
+ rl_bind_keyseq("\\e6", _inp_rl_win6_handler);
+ rl_bind_keyseq("\\e7", _inp_rl_win7_handler);
+ rl_bind_keyseq("\\e8", _inp_rl_win8_handler);
+ rl_bind_keyseq("\\e9", _inp_rl_win9_handler);
+ rl_bind_keyseq("\\e0", _inp_rl_win0_handler);
+
+ rl_bind_keyseq("\\eOP", _inp_rl_win1_handler);
+ rl_bind_keyseq("\\eOQ", _inp_rl_win2_handler);
+ rl_bind_keyseq("\\eOR", _inp_rl_win3_handler);
+ rl_bind_keyseq("\\eOS", _inp_rl_win4_handler);
+ rl_bind_keyseq("\\e[15~", _inp_rl_win5_handler);
+ rl_bind_keyseq("\\e[17~", _inp_rl_win6_handler);
+ rl_bind_keyseq("\\e[18~", _inp_rl_win7_handler);
+ rl_bind_keyseq("\\e[19~", _inp_rl_win8_handler);
+ rl_bind_keyseq("\\e[20~", _inp_rl_win9_handler);
+ rl_bind_keyseq("\\e[21~", _inp_rl_win0_handler);
+
+#ifdef PLATFORM_OSX
+ rl_bind_keyseq("\\e[1;9D", _inp_rl_altleft_handler);
+ rl_bind_keyseq("\\e[1;9C", _inp_rl_altright_handler);
+ rl_bind_keyseq("\\e\\e[5~", _inp_rl_altpageup_handler);
+ rl_bind_keyseq("\\e\\e[6~", _inp_rl_altpagedown_handler);
+#else
+ rl_bind_keyseq("\\e[1;3D", _inp_rl_altleft_handler);
+ rl_bind_keyseq("\\e[1;3C", _inp_rl_altright_handler);
+ rl_bind_keyseq("\\e[5;3~", _inp_rl_altpageup_handler);
+ rl_bind_keyseq("\\e[6;3~", _inp_rl_altpagedown_handler);
+#endif
+ rl_bind_keyseq("\\e[5~", _inp_rl_pageup_handler);
+ rl_bind_keyseq("\\e[6~", _inp_rl_pagedown_handler);
+
+ rl_bind_key('\t', _inp_rl_tab_handler);
+
+ return 0;
+}
+
static void
_inp_rl_linehandler(char *line)
{
@@ -481,47 +525,3 @@ _inp_rl_altpagedown_handler(int count, int key)
ui_subwin_page_down();
return 0;
}
-
-static int
-_inp_rl_startup_hook(void)
-{
- rl_bind_keyseq("\\e1", _inp_rl_win1_handler);
- rl_bind_keyseq("\\e2", _inp_rl_win2_handler);
- rl_bind_keyseq("\\e3", _inp_rl_win3_handler);
- rl_bind_keyseq("\\e4", _inp_rl_win4_handler);
- rl_bind_keyseq("\\e5", _inp_rl_win5_handler);
- rl_bind_keyseq("\\e6", _inp_rl_win6_handler);
- rl_bind_keyseq("\\e7", _inp_rl_win7_handler);
- rl_bind_keyseq("\\e8", _inp_rl_win8_handler);
- rl_bind_keyseq("\\e9", _inp_rl_win9_handler);
- rl_bind_keyseq("\\e0", _inp_rl_win0_handler);
-
- rl_bind_keyseq("\\eOP", _inp_rl_win1_handler);
- rl_bind_keyseq("\\eOQ", _inp_rl_win2_handler);
- rl_bind_keyseq("\\eOR", _inp_rl_win3_handler);
- rl_bind_keyseq("\\eOS", _inp_rl_win4_handler);
- rl_bind_keyseq("\\e[15~", _inp_rl_win5_handler);
- rl_bind_keyseq("\\e[17~", _inp_rl_win6_handler);
- rl_bind_keyseq("\\e[18~", _inp_rl_win7_handler);
- rl_bind_keyseq("\\e[19~", _inp_rl_win8_handler);
- rl_bind_keyseq("\\e[20~", _inp_rl_win9_handler);
- rl_bind_keyseq("\\e[21~", _inp_rl_win0_handler);
-
-#ifdef PLATFORM_OSX
- rl_bind_keyseq("\\e[1;9D", _inp_rl_altleft_handler);
- rl_bind_keyseq("\\e[1;9C", _inp_rl_altright_handler);
- rl_bind_keyseq("\\e\\e[5~", _inp_rl_altpageup_handler);
- rl_bind_keyseq("\\e\\e[6~", _inp_rl_altpagedown_handler);
-#else
- rl_bind_keyseq("\\e[1;3D", _inp_rl_altleft_handler);
- rl_bind_keyseq("\\e[1;3C", _inp_rl_altright_handler);
- rl_bind_keyseq("\\e[5;3~", _inp_rl_altpageup_handler);
- rl_bind_keyseq("\\e[6;3~", _inp_rl_altpagedown_handler);
-#endif
- rl_bind_keyseq("\\e[5~", _inp_rl_pageup_handler);
- rl_bind_keyseq("\\e[6~", _inp_rl_pagedown_handler);
-
- rl_bind_key('\t', _inp_rl_tab_handler);
-
- return 0;
-}
\ No newline at end of file
From b2536e91c0a9eac16aee999aa6550b2fc3de6b87 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 4 Feb 2015 01:04:56 +0000
Subject: [PATCH 047/252] Fixed input timout returning EINVAL on OSX
---
src/ui/inputwin.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 0ee1d721..f29b5318 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -39,6 +39,7 @@
#include
#include
#include
+#include
#include
#include
@@ -111,8 +112,13 @@ create_input_window(void)
#else
ESCDELAY = 25;
#endif
- p_rl_timeout.tv_sec = 0;
- p_rl_timeout.tv_usec = inp_timeout * 1000;
+ if (inp_timeout == 1000) {
+ p_rl_timeout.tv_sec = 1;
+ p_rl_timeout.tv_usec = 0;
+ } else {
+ p_rl_timeout.tv_sec = 0;
+ p_rl_timeout.tv_usec = inp_timeout * 1000;
+ }
rl_readline_name = "profanity";
rl_getc_function = _inp_rl_getc;
@@ -134,9 +140,11 @@ inp_readline(void)
{
FD_ZERO(&fds);
FD_SET(fileno(rl_instream), &fds);
+ errno = 0;
r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
if (r < 0) {
- log_error("Readline failed.");
+ char *err_msg = strerror(errno);
+ log_error("Readline failed: %s", err_msg);
return TRUE;
}
@@ -155,8 +163,13 @@ inp_readline(void)
prof_handle_idle();
}
- p_rl_timeout.tv_sec = 0;
- p_rl_timeout.tv_usec = inp_timeout * 1000;
+ if (inp_timeout == 1000) {
+ p_rl_timeout.tv_sec = 1;
+ p_rl_timeout.tv_usec = 0;
+ } else {
+ p_rl_timeout.tv_sec = 0;
+ p_rl_timeout.tv_usec = inp_timeout * 1000;
+ }
return cmd_result;
}
From d64c4a69d76aa982f1631449169e35e6eb77bc89 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 4 Feb 2015 22:22:18 +0000
Subject: [PATCH 048/252] Removed unused functions from inputwin.c
---
src/ui/inputwin.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index 081fc56b..a88211c4 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -43,14 +43,10 @@ void create_input_window(void);
gboolean inp_readline(void);
void inp_nonblocking(gboolean reset);
void inp_close(void);
-char* inp_read(int *key_type, wint_t *ch);
void inp_win_clear(void);
void inp_win_resize(void);
void inp_put_back(void);
-void inp_non_block(gint);
void inp_block(void);
void inp_get_password(char *passwd);
-void inp_history_append(char *inp);
-void inp_write(char *line, int offset);
#endif
From 30180ac8bb125e4cae03c415201f796863d4c80b Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 4 Feb 2015 23:35:28 +0000
Subject: [PATCH 049/252] Move SIGWINCH handling to ui/core.c, ignore signal
whilst resizing
---
src/profanity.c | 1 +
src/ui/core.c | 15 +++++++++++++++
src/ui/inputwin.c | 9 ---------
src/ui/ui.h | 1 +
tests/ui/stub_ui.c | 1 +
5 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/profanity.c b/src/profanity.c
index f3c53003..f863a323 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -204,6 +204,7 @@ _init(const int disable_tls, char *log_level)
signal(SIGPIPE, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
+ signal(SIGWINCH, ui_sigwinch_handler);
_create_directories();
log_level_t prof_log_level = log_level_from_string(log_level);
prefs_load();
diff --git a/src/ui/core.c b/src/ui/core.c
index de3bafd2..add80dff 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -79,6 +79,8 @@ static char *win_title;
static int inp_size;
+static gboolean perform_resize = FALSE;
+
#ifdef HAVE_LIBXSS
static Display *display;
#endif
@@ -120,6 +122,12 @@ ui_init(void)
win_update_virtual(window);
}
+void
+ui_sigwinch_handler(int sig)
+{
+ perform_resize = TRUE;
+}
+
void
ui_update(void)
{
@@ -137,6 +145,13 @@ ui_update(void)
status_bar_update_virtual();
inp_put_back();
doupdate();
+
+ if (perform_resize) {
+ signal(SIGWINCH, SIG_IGN);
+ ui_resize();
+ perform_resize = FALSE;
+ signal(SIGWINCH, ui_sigwinch_handler);
+ }
}
void
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index f29b5318..1e78bbcc 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -79,7 +79,6 @@ static gboolean cmd_result = TRUE;
static void _inp_win_update_virtual(void);
static int _inp_printable(const wint_t ch);
static void _inp_win_handle_scroll(void);
-static void _inp_resize_signal_handler(int signal);
static int _inp_offset_to_col(char *str, int offset);
static void _inp_write(char *line, int offset);
@@ -125,8 +124,6 @@ create_input_window(void)
rl_startup_hook = _inp_rl_startup_hook;
rl_callback_handler_install(NULL, _inp_rl_linehandler);
- signal(SIGWINCH, _inp_resize_signal_handler);
-
inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
keypad(inp_win, TRUE);
@@ -311,12 +308,6 @@ _inp_offset_to_col(char *str, int offset)
return col;
}
-static void
-_inp_resize_signal_handler(int signal)
-{
- ui_resize();
-}
-
static void
_inp_win_handle_scroll(void)
{
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 5008593f..92f570d5 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -62,6 +62,7 @@ GSList* ui_get_chat_recipients(void);
gboolean ui_switch_win(const int i);
void ui_next_win(void);
void ui_previous_win(void);
+void ui_sigwinch_handler(int sig);
void ui_gone_secure(const char * const barejid, gboolean trusted);
void ui_gone_insecure(const char * const barejid);
diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c
index d681ec15..e0556ac8 100644
--- a/tests/ui/stub_ui.c
+++ b/tests/ui/stub_ui.c
@@ -91,6 +91,7 @@ void ui_smp_answer_failure(const char * const barejid) {}
void ui_otr_authenticating(const char * const barejid) {}
void ui_otr_authetication_waiting(const char * const recipient) {}
+void ui_sigwinch_handler(int sig) {}
unsigned long ui_get_idle_time(void)
{
From a70aa0255fc438894e563f80dfb4ab88278a1118 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Thu, 5 Feb 2015 00:58:23 +0000
Subject: [PATCH 050/252] Moved command processing to main loop, allow resize
during password prompt
---
src/profanity.c | 10 ++++++++-
src/ui/core.c | 10 ++-------
src/ui/inputwin.c | 51 +++++++++++++++++++++++++++++++++-------------
src/ui/inputwin.h | 4 ++--
src/ui/ui.h | 2 +-
tests/ui/stub_ui.c | 4 ++--
6 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/src/profanity.c b/src/profanity.c
index f863a323..86730649 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -82,10 +82,18 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
log_info("Starting main event loop");
+ char *line = NULL;
while(cont) {
_check_autoaway();
- cont = ui_readline();
+ line = ui_readline();
+ if (line) {
+ cont = cmd_process_input(line);
+ free(line);
+ line = NULL;
+ } else {
+ cont = TRUE;
+ }
#ifdef HAVE_LIBOTR
otr_poll();
diff --git a/src/ui/core.c b/src/ui/core.c
index add80dff..0fde3387 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -198,7 +198,7 @@ ui_close(void)
endwin();
}
-gboolean
+char *
ui_readline(void)
{
return inp_readline();
@@ -2249,15 +2249,9 @@ ui_win_unread(int index)
char *
ui_ask_password(void)
{
- char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1));
status_bar_get_password();
status_bar_update_virtual();
- inp_block();
- inp_get_password(passwd);
-// inp_non_block(prefs_get_inpblock());
- inp_nonblocking(TRUE);
-
- return passwd;
+ return inp_get_password();
}
void
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 1e78bbcc..5f13377a 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -74,7 +74,8 @@ static gint no_input_count = 0;
static fd_set fds;
static int r;
-static gboolean cmd_result = TRUE;
+static char *inp_line = NULL;
+static gboolean get_password = FALSE;
static void _inp_win_update_virtual(void);
static int _inp_printable(const wint_t ch);
@@ -132,9 +133,11 @@ create_input_window(void)
_inp_win_update_virtual();
}
-gboolean
+char *
inp_readline(void)
{
+ free(inp_line);
+ inp_line = NULL;
FD_ZERO(&fds);
FD_SET(fileno(rl_instream), &fds);
errno = 0;
@@ -142,13 +145,16 @@ inp_readline(void)
if (r < 0) {
char *err_msg = strerror(errno);
log_error("Readline failed: %s", err_msg);
- return TRUE;
+ return NULL;
}
if (FD_ISSET(fileno(rl_instream), &fds)) {
rl_callback_read_char();
- if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
+ if (rl_line_buffer &&
+ rl_line_buffer[0] != '/' &&
+ rl_line_buffer[0] != '\0' &&
+ rl_line_buffer[0] != '\n') {
prof_handle_activity();
}
@@ -168,7 +174,11 @@ inp_readline(void)
p_rl_timeout.tv_usec = inp_timeout * 1000;
}
- return cmd_result;
+ if (inp_line) {
+ return strdup(inp_line);
+ } else {
+ return NULL;
+ }
}
void
@@ -213,6 +223,8 @@ inp_nonblocking(gboolean reset)
}
}
}
+
+ log_info("Timeout: %d", inp_timeout);
}
void
@@ -228,19 +240,29 @@ inp_close(void)
rl_callback_handler_remove();
}
-void
-inp_get_password(char *passwd)
+char*
+inp_get_password(void)
{
werase(inp_win);
wmove(inp_win, 0, 0);
pad_start = 0;
_inp_win_update_virtual();
doupdate();
- noecho();
- mvwgetnstr(inp_win, 0, 1, passwd, MAX_PASSWORD_SIZE);
- wmove(inp_win, 0, 0);
- echo();
+ char *password = NULL;
+ get_password = TRUE;
+ while (!password) {
+ password = inp_readline();
+ ui_update();
+ werase(inp_win);
+ wmove(inp_win, 0, 0);
+ pad_start = 0;
+ _inp_win_update_virtual();
+ doupdate();
+ }
+ get_password = FALSE;
+
status_bar_clear();
+ return password;
}
void
@@ -378,10 +400,11 @@ static void
_inp_rl_linehandler(char *line)
{
if (line && *line) {
- add_history(line);
+ if (!get_password) {
+ add_history(line);
+ }
}
- cmd_result = cmd_process_input(line);
- free(line);
+ inp_line = line;
}
static int
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index a88211c4..b9026863 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -40,13 +40,13 @@
#define INP_WIN_MAX 1000
void create_input_window(void);
-gboolean inp_readline(void);
+char* inp_readline(void);
void inp_nonblocking(gboolean reset);
void inp_close(void);
void inp_win_clear(void);
void inp_win_resize(void);
void inp_put_back(void);
void inp_block(void);
-void inp_get_password(char *passwd);
+char* inp_get_password(void);
#endif
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 92f570d5..1062eac1 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -233,7 +233,7 @@ void ui_update_presence(const resource_presence_t resource_presence,
void ui_about(void);
void ui_statusbar_new(const int win);
-gboolean ui_readline(void);
+char* ui_readline(void);
void ui_input_clear(void);
void ui_input_nonblocking(gboolean);
void ui_write(char *line, int offset);
diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c
index e0556ac8..2d67a543 100644
--- a/tests/ui/stub_ui.c
+++ b/tests/ui/stub_ui.c
@@ -329,9 +329,9 @@ void ui_update_presence(const resource_presence_t resource_presence,
void ui_about(void) {}
void ui_statusbar_new(const int win) {}
-gboolean ui_readline(void)
+char* ui_readline(void)
{
- return TRUE;
+ return NULL;
}
void ui_inp_history_append(char *inp) {}
From 113cb6cf9a26fd8518ccfcf07207ddb69f2f2f84 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Thu, 5 Feb 2015 01:00:06 +0000
Subject: [PATCH 051/252] Removed debug logging
---
src/ui/inputwin.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 5f13377a..b3216a16 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -223,8 +223,6 @@ inp_nonblocking(gboolean reset)
}
}
}
-
- log_info("Timeout: %d", inp_timeout);
}
void
From 2e83d23873983303665b2ce25587bdb771f770b5 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 6 Feb 2015 00:20:06 +0000
Subject: [PATCH 052/252] Removed unused function
---
src/ui/inputwin.c | 7 -------
src/ui/inputwin.h | 1 -
2 files changed, 8 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index b3216a16..5ae6656e 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -225,13 +225,6 @@ inp_nonblocking(gboolean reset)
}
}
-void
-inp_block(void)
-{
- wtimeout(inp_win, -1);
-}
-
-
void
inp_close(void)
{
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index b9026863..91cbb0b2 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -46,7 +46,6 @@ void inp_close(void);
void inp_win_clear(void);
void inp_win_resize(void);
void inp_put_back(void);
-void inp_block(void);
char* inp_get_password(void);
#endif
From f08657fa9afee6ea74dfdb9660dd4d23f20ee43f Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 6 Feb 2015 14:11:21 +0000
Subject: [PATCH 053/252] Handle home scroll
---
src/ui/inputwin.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 5ae6656e..6f043b31 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -327,8 +327,9 @@ _inp_win_handle_scroll(void)
int col = getcurx(inp_win);
int wcols = getmaxx(stdscr);
- // if lost cursor off screen, move contents to show it
- if (col >= pad_start + (wcols -2)) {
+ if (col == 0) {
+ pad_start = 0;
+ } else if (col >= pad_start + (wcols -2)) {
pad_start = col - (wcols / 2);
if (pad_start < 0) {
pad_start = 0;
From f447ac418983b94a71afecbd1d9057344adddee1 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 6 Feb 2015 21:39:53 +0000
Subject: [PATCH 054/252] Free win layout
---
src/ui/window.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/ui/window.c b/src/ui/window.c
index dfec5aab..54f1b99f 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -330,6 +330,7 @@ win_free(ProfWin* window)
buffer_free(window->layout->buffer);
delwin(window->layout->win);
}
+ free(window->layout);
if (window->type == WIN_CHAT) {
ProfChatWin *chatwin = (ProfChatWin*)window;
From 8977c9c721f0d8cf6f25f908f93ec6f6f8196bac Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 6 Feb 2015 21:40:35 +0000
Subject: [PATCH 055/252] Removed duplicate time_ac
---
src/command/command.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index 7be6603d..9698f0bd 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1466,10 +1466,6 @@ cmd_init(void)
autocomplete_add(time_ac, "seconds");
autocomplete_add(time_ac, "off");
- time_ac = autocomplete_new();
- autocomplete_add(time_ac, "minutes");
- autocomplete_add(time_ac, "seconds");
-
resource_ac = autocomplete_new();
autocomplete_add(resource_ac, "set");
autocomplete_add(resource_ac, "off");
From 1e35b76bf9767667c0a2dafb7d016a34ae6cac33 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 6 Feb 2015 21:41:24 +0000
Subject: [PATCH 056/252] Added callgrind.out files to gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index be11f141..09d5c04d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,3 +64,4 @@ profanity.workspace
m4/
test.sh
clean-test.sh
+callgrind.out.*
From bec95afc8b4ba3d86b0a74d68285042c7c40948e Mon Sep 17 00:00:00 2001
From: James Booth
Date: Fri, 6 Feb 2015 22:03:40 +0000
Subject: [PATCH 057/252] Removed strdup passed to autocompleter
---
src/contact.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/contact.c b/src/contact.c
index f16f1679..943be374 100644
--- a/src/contact.c
+++ b/src/contact.c
@@ -381,7 +381,7 @@ void
p_contact_set_presence(const PContact contact, Resource *resource)
{
g_hash_table_replace(contact->available_resources, strdup(resource->name), resource);
- autocomplete_add(contact->resource_ac, strdup(resource->name));
+ autocomplete_add(contact->resource_ac, resource->name);
}
void
From e0dfe4832be53987ea5beb5c39e9985d5bc1aa15 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 8 Feb 2015 00:42:21 +0000
Subject: [PATCH 058/252] Added code to generate HTML command reference for
website
---
.gitignore | 3 +++
src/command/command.c | 53 +++++++++++++++++++++++++++++++++++++++++++
src/command/command.h | 2 ++
src/main.c | 13 +++++------
4 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
index 09d5c04d..7f15f3c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,3 +65,6 @@ m4/
test.sh
clean-test.sh
callgrind.out.*
+gen_docs.sh
+main_fragment.html
+toc_fragment.html
diff --git a/src/command/command.c b/src/command/command.c
index 9698f0bd..1a673568 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
#include
#include
@@ -2990,3 +2991,55 @@ _account_autocomplete(const char * const input)
found = autocomplete_param_with_ac(input, "/account", account_ac, TRUE);
return found;
}
+
+static int
+_cmp_command(Command *cmd1, Command *cmd2)
+{
+ return g_strcmp0(cmd1->cmd, cmd2->cmd);
+}
+
+void
+command_docgen(void)
+{
+ GList *cmds = NULL;
+ unsigned int i;
+ for (i = 0; i < ARRAY_SIZE(command_defs); i++) {
+ Command *pcmd = command_defs+i;
+ cmds = g_list_insert_sorted(cmds, pcmd, (GCompareFunc)_cmp_command);
+ }
+
+ FILE *toc_fragment = fopen("toc_fragment.html", "w");
+ FILE *main_fragment = fopen("main_fragment.html", "w");
+
+ fputs("- \n", toc_fragment);
+ fputs("
\n", main_fragment);
+
+ GList *curr = cmds;
+ while (curr) {
+ Command *pcmd = curr->data;
+
+ fprintf(toc_fragment, "%s,\n", &pcmd->cmd[1], pcmd->cmd);
+
+ fprintf(main_fragment, "\n", &pcmd->cmd[1]);
+ fprintf(main_fragment, "%s
\n", pcmd->cmd);
+ fputs("Usage:
\n", main_fragment);
+ fprintf(main_fragment, "%s
\n", pcmd->help.usage);
+
+ fputs("Details:
\n", main_fragment);
+ fputs("", main_fragment);
+ int i = 2;
+ while (pcmd->help.long_help[i] != NULL) {
+ fprintf(main_fragment, "%s\n", pcmd->help.long_help[i++]);
+ }
+ fputs("
\nback to top
\n", main_fragment);
+ fputs("\n", main_fragment);
+
+ curr = g_list_next(curr);
+ }
+
+ fputs("\n", toc_fragment);
+
+ fclose(toc_fragment);
+ fclose(main_fragment);
+ g_list_free(cmds);
+}
\ No newline at end of file
diff --git a/src/command/command.h b/src/command/command.h
index ffbccfa4..8be1143f 100644
--- a/src/command/command.h
+++ b/src/command/command.h
@@ -66,4 +66,6 @@ void cmd_history_append(char *inp);
char *cmd_history_previous(char *inp);
char *cmd_history_next(char *inp);
+void command_docgen(void);
+
#endif
diff --git a/src/main.c b/src/main.c
index f3b6a17f..7ee5affe 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,13 +40,7 @@
#endif
#include "profanity.h"
-
-#ifdef HAVE_LIBOTR
-#include "otr/otr.h"
-#endif
-#include "xmpp/xmpp.h"
-
-#include "ui/ui.h"
+#include "command/command.h"
static gboolean disable_tls = FALSE;
static gboolean version = FALSE;
@@ -56,6 +50,11 @@ static char *account_name = NULL;
int
main(int argc, char **argv)
{
+ if (argc == 2 && g_strcmp0(argv[1], "docgen") == 0 && g_strcmp0(PACKAGE_STATUS, "development") == 0) {
+ command_docgen();
+ return 0;
+ }
+
static GOptionEntry entries[] =
{
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL },
From 916a3d94517bd227aa48936dc19e7a44fc17dfea Mon Sep 17 00:00:00 2001
From: Christian Storm
Date: Sun, 8 Feb 2015 12:15:01 +0100
Subject: [PATCH 059/252] Bind ^L to own clear method to retain ui elements
When using readline's standard ^L binding, the screen
is completely cleared, including status and title bar.
By binding ^L to profanity's clear method, status and
title bar are retained.
---
src/ui/inputwin.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 6f043b31..328b92d6 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -86,6 +86,7 @@ static void _inp_write(char *line, int offset);
static int _inp_rl_getc(FILE *stream);
static void _inp_rl_linehandler(char *line);
static int _inp_rl_tab_handler(int count, int key);
+static int _inp_rl_clear_handler(int count, int key);
static int _inp_rl_win1_handler(int count, int key);
static int _inp_rl_win2_handler(int count, int key);
static int _inp_rl_win3_handler(int count, int key);
@@ -384,6 +385,7 @@ _inp_rl_startup_hook(void)
rl_bind_keyseq("\\e[6~", _inp_rl_pagedown_handler);
rl_bind_key('\t', _inp_rl_tab_handler);
+ rl_bind_key(CTRL('L'), _inp_rl_clear_handler);
return 0;
}
@@ -409,6 +411,13 @@ _inp_rl_getc(FILE *stream)
return ch;
}
+static int
+_inp_rl_clear_handler(int count, int key)
+{
+ ui_clear_current();
+ return 0;
+}
+
static int
_inp_rl_tab_handler(int count, int key)
{
From 44c5b34a710f7c90b455ec92146530f95e25ab90 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 8 Feb 2015 20:59:51 +0000
Subject: [PATCH 060/252] Moved quote stripper to common, added tests
---
src/command/command.c | 29 +++-------------------------
src/common.c | 22 ++++++++++++++++++++++
src/common.h | 1 +
tests/test_common.c | 44 +++++++++++++++++++++++++++++++++++++++++++
tests/test_common.h | 6 +++++-
tests/testsuite.c | 4 ++++
6 files changed, 79 insertions(+), 27 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index 4a8c73e9..9f17596b 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -76,8 +76,6 @@ static gboolean _cmd_execute_alias(const char * const inp, gboolean *ran);
static char * _cmd_complete_parameters(const char * const input);
-static char * _strip_quotes_from_names(const char * const input);
-
static char * _sub_autocomplete(const char * const input);
static char * _notify_autocomplete(const char * const input);
static char * _theme_autocomplete(const char * const input);
@@ -1970,7 +1968,7 @@ _cmd_complete_parameters(const char * const input)
gchar *nick_choices[] = { "/msg", "/info", "/caps", "/status", "/software" } ;
// Remove quote character before and after names when doing autocomplete
- char *unquoted = _strip_quotes_from_names(input);
+ char *unquoted = strip_arg_quotes(input);
for (i = 0; i < ARRAY_SIZE(nick_choices); i++) {
result = autocomplete_param_with_ac(unquoted, nick_choices[i], nick_ac, TRUE);
if (result) {
@@ -1985,7 +1983,7 @@ _cmd_complete_parameters(const char * const input)
} else {
gchar *contact_choices[] = { "/msg", "/info", "/status" };
// Remove quote character before and after names when doing autocomplete
- char *unquoted = _strip_quotes_from_names(input);
+ char *unquoted = strip_arg_quotes(input);
for (i = 0; i < ARRAY_SIZE(contact_choices); i++) {
result = autocomplete_param_with_func(unquoted, contact_choices[i], roster_contact_autocomplete);
if (result) {
@@ -3052,25 +3050,4 @@ command_docgen(void)
fclose(toc_fragment);
fclose(main_fragment);
g_list_free(cmds);
-}
-
-static char *
-_strip_quotes_from_names(const char * const input) {
- char *unquoted = strdup(input);
-
- // Remove starting quote if it exists
- if(strchr(unquoted, '"') != NULL) {
- if(strchr(unquoted, ' ') + 1 == strchr(unquoted, '"')) {
- memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
- }
- }
-
- // Remove ending quote if it exists
- if(strchr(unquoted, '"') != NULL) {
- if(strchr(unquoted, '\0') - 1 == strchr(unquoted, '"')) {
- memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
- }
- }
-
- return unquoted;
-}
+}
\ No newline at end of file
diff --git a/src/common.c b/src/common.c
index 7638da31..95deecbb 100644
--- a/src/common.c
+++ b/src/common.c
@@ -566,3 +566,25 @@ get_file_or_linked(char *loc, char *basedir)
return true_loc;
}
+
+char *
+strip_arg_quotes(const char * const input)
+{
+ char *unquoted = strdup(input);
+
+ // Remove starting quote if it exists
+ if(strchr(unquoted, '"') != NULL) {
+ if(strchr(unquoted, ' ') + 1 == strchr(unquoted, '"')) {
+ memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
+ }
+ }
+
+ // Remove ending quote if it exists
+ if(strchr(unquoted, '"') != NULL) {
+ if(strchr(unquoted, '\0') - 1 == strchr(unquoted, '"')) {
+ memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
+ }
+ }
+
+ return unquoted;
+}
\ No newline at end of file
diff --git a/src/common.h b/src/common.h
index 26d4a99a..c22706ec 100644
--- a/src/common.h
+++ b/src/common.h
@@ -123,5 +123,6 @@ int cmp_win_num(gconstpointer a, gconstpointer b);
int get_next_available_win_num(GList *used);
char* get_file_or_linked(char *loc, char *basedir);
+char * strip_arg_quotes(const char * const input);
#endif
diff --git a/tests/test_common.c b/tests/test_common.c
index 0c4530a0..980f2198 100644
--- a/tests/test_common.c
+++ b/tests/test_common.c
@@ -587,3 +587,47 @@ void utf8_display_len_all_wide(void **state)
assert_int_equal(8, result);
}
+void strip_quotes_does_nothing_when_no_quoted(void **state)
+{
+ char *input = "/cmd test string";
+
+ char *result = strip_arg_quotes(input);
+
+ assert_string_equal("/cmd test string", result);
+
+ free(result);
+}
+
+void strip_quotes_strips_first(void **state)
+{
+ char *input = "/cmd \"test string";
+
+ char *result = strip_arg_quotes(input);
+
+ assert_string_equal("/cmd test string", result);
+
+ free(result);
+}
+
+void strip_quotes_strips_last(void **state)
+{
+ char *input = "/cmd test string\"";
+
+ char *result = strip_arg_quotes(input);
+
+ assert_string_equal("/cmd test string", result);
+
+ free(result);
+}
+
+void strip_quotes_strips_both(void **state)
+{
+ char *input = "/cmd \"test string\"";
+
+ char *result = strip_arg_quotes(input);
+
+ assert_string_equal("/cmd test string", result);
+
+ free(result);
+}
+
diff --git a/tests/test_common.h b/tests/test_common.h
index 1866e73d..b4b98e5a 100644
--- a/tests/test_common.h
+++ b/tests/test_common.h
@@ -51,4 +51,8 @@ void utf8_display_len_1_non_wide(void **state);
void utf8_display_len_1_wide(void **state);
void utf8_display_len_non_wide(void **state);
void utf8_display_len_wide(void **state);
-void utf8_display_len_all_wide(void **state);
\ No newline at end of file
+void utf8_display_len_all_wide(void **state);
+void strip_quotes_does_nothing_when_no_quoted(void **state);
+void strip_quotes_strips_first(void **state);
+void strip_quotes_strips_last(void **state);
+void strip_quotes_strips_both(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index cf511c59..ddfb45cd 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -91,6 +91,10 @@ int main(int argc, char* argv[]) {
unit_test(utf8_display_len_non_wide),
unit_test(utf8_display_len_wide),
unit_test(utf8_display_len_all_wide),
+ unit_test(strip_quotes_does_nothing_when_no_quoted),
+ unit_test(strip_quotes_strips_first),
+ unit_test(strip_quotes_strips_last),
+ unit_test(strip_quotes_strips_both),
unit_test(clear_empty),
unit_test(reset_after_create),
From 268c33e1c6e7ee5a4a26299311289933c66460e2 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 19:50:41 +0000
Subject: [PATCH 061/252] Free resource lists on /account command
---
.gitignore | 2 +-
src/ui/console.c | 19 ++++++++++++-------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 7f15f3c9..37449348 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,7 +25,7 @@ configure.scan
stamp-h1
*~
*dirstamp
-valgrind.out
+valgrind*.out*
core
bugs/
TODO
diff --git a/src/ui/console.c b/src/ui/console.c
index cdf5d1b8..2c37c40c 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -717,20 +717,24 @@ cons_show_account(ProfAccount *account)
GList *resources = jabber_get_available_resources();
GList *ordered_resources = NULL;
- if (resources != NULL) {
+ GList *curr = resources;
+ if (curr != NULL) {
win_save_println(console, "Resources:");
// sort in order of availabiltiy
- while (resources != NULL) {
- Resource *resource = resources->data;
+ while (curr != NULL) {
+ Resource *resource = curr->data;
ordered_resources = g_list_insert_sorted(ordered_resources,
resource, (GCompareFunc)resource_compare_availability);
- resources = g_list_next(resources);
+ curr = g_list_next(curr);
}
}
- while (ordered_resources != NULL) {
- Resource *resource = ordered_resources->data;
+ g_list_free(resources);
+
+ curr = ordered_resources;
+ while (curr != NULL) {
+ Resource *resource = curr->data;
const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
@@ -785,8 +789,9 @@ cons_show_account(ProfAccount *account)
caps_destroy(caps);
}
- ordered_resources = g_list_next(ordered_resources);
+ curr = g_list_next(curr);
}
+ g_list_free(ordered_resources);
}
cons_alert();
From 23aaa51a2af836d705a49bde561d9b8431695499 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 19:59:04 +0000
Subject: [PATCH 062/252] Free utf8 substrings for delete word (ctrl-w)
---
src/ui/inputwin.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 85ddc79a..b2d5e420 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -747,6 +747,9 @@ _delete_previous_word(void)
input_len_bytes = strlen(start_string)+i;
input[input_len_bytes] = '\0';
+ g_free(start_string);
+ g_free(end_string);
+
_clear_input();
waddstr(inp_win, input);
wmove(inp_win, 0, start_del);
From 893b58bf4e0f6329ac36caac4408aa1200912e30 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 20:11:51 +0000
Subject: [PATCH 063/252] Use chat_state_free to free chat states
---
src/ui/window.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ui/window.c b/src/ui/window.c
index 54f1b99f..1cdf2f26 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -336,7 +336,7 @@ win_free(ProfWin* window)
ProfChatWin *chatwin = (ProfChatWin*)window;
free(chatwin->barejid);
free(chatwin->resource_override);
- free(chatwin->state);
+ chat_state_free(chatwin->state);
}
if (window->type == WIN_MUC) {
From aad7b3ed8ac245252e8d400ee79205a196989a11 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 20:15:24 +0000
Subject: [PATCH 064/252] Free GTimer on switch to console
---
src/ui/titlebar.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index 326dbf8b..a3299946 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -109,8 +109,11 @@ void
title_bar_console(void)
{
werase(win);
- typing = FALSE;
+ if (typing_elapsed) {
+ g_timer_destroy(typing_elapsed);
+ }
typing_elapsed = NULL;
+ typing = FALSE;
_title_bar_draw();
}
From 6682f243ce2cbb46a1323bcd5fdf3a672b5a5d00 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 21:21:22 +0000
Subject: [PATCH 065/252] Free theme list after use
---
src/command/command.c | 11 ++++++-----
src/config/theme.c | 4 +++-
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index 9f17596b..f05d2a79 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1659,7 +1659,7 @@ cmd_reset_autocomplete()
autocomplete_reset(autoconnect_ac);
autocomplete_reset(theme_ac);
if (theme_load_ac != NULL) {
- autocomplete_reset(theme_load_ac);
+ autocomplete_free(theme_load_ac);
theme_load_ac = NULL;
}
autocomplete_reset(account_ac);
@@ -2473,11 +2473,12 @@ _theme_autocomplete(const char * const input)
if (theme_load_ac == NULL) {
theme_load_ac = autocomplete_new();
GSList *themes = theme_list();
- while (themes != NULL) {
- autocomplete_add(theme_load_ac, themes->data);
- themes = g_slist_next(themes);
+ GSList *curr = themes;
+ while (curr != NULL) {
+ autocomplete_add(theme_load_ac, curr->data);
+ curr = g_slist_next(curr);
}
- g_slist_free(themes);
+ g_slist_free_full(themes, g_free);
autocomplete_add(theme_load_ac, "default");
}
result = autocomplete_param_with_ac(input, "/theme set", theme_load_ac, TRUE);
diff --git a/src/config/theme.c b/src/config/theme.c
index a5dbd0dd..26d48091 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -192,7 +192,9 @@ GSList *
theme_list(void)
{
GSList *result = NULL;
- _theme_list_dir(_get_themes_dir(), &result);
+ char *themes_dir = _get_themes_dir();
+ _theme_list_dir(themes_dir, &result);
+ free(themes_dir);
#ifdef THEMES_PATH
_theme_list_dir(THEMES_PATH, &result);
#endif
From 50601d4db30431a4da18694f065e922593d9599c Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 21:36:04 +0000
Subject: [PATCH 066/252] Removed strdup calls when creating capabilities
---
src/xmpp/capabilities.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index 164313e1..1a9eed74 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -154,49 +154,49 @@ _caps_by_ver(const char * const ver)
char *category = g_key_file_get_string(cache, ver, "category", NULL);
if (category) {
- new_caps->category = strdup(category);
+ new_caps->category = category;
} else {
new_caps->category = NULL;
}
char *type = g_key_file_get_string(cache, ver, "type", NULL);
if (type) {
- new_caps->type = strdup(type);
+ new_caps->type = type;
} else {
new_caps->type = NULL;
}
char *name = g_key_file_get_string(cache, ver, "name", NULL);
if (name) {
- new_caps->name = strdup(name);
+ new_caps->name = name;
} else {
new_caps->name = NULL;
}
char *software = g_key_file_get_string(cache, ver, "software", NULL);
if (software) {
- new_caps->software = strdup(software);
+ new_caps->software = software;
} else {
new_caps->software = NULL;
}
char *software_version = g_key_file_get_string(cache, ver, "software_version", NULL);
if (software_version) {
- new_caps->software_version = strdup(software_version);
+ new_caps->software_version = software_version;
} else {
new_caps->software_version = NULL;
}
char *os = g_key_file_get_string(cache, ver, "os", NULL);
if (os) {
- new_caps->os = strdup(os);
+ new_caps->os = os;
} else {
new_caps->os = NULL;
}
char *os_version = g_key_file_get_string(cache, ver, "os_version", NULL);
if (os_version) {
- new_caps->os_version = strdup(os_version);
+ new_caps->os_version = os_version;
} else {
new_caps->os_version = NULL;
}
From 1a98f1404bd44579954358aa95dbb3c45c84f3f3 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 21:46:54 +0000
Subject: [PATCH 067/252] Free resource lists
---
src/ui/window.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/ui/window.c b/src/ui/window.c
index 1cdf2f26..aba2f40a 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -650,8 +650,6 @@ win_show_info(ProfWin *window, PContact contact)
const char *name = p_contact_name(contact);
const char *presence = p_contact_presence(contact);
const char *sub = p_contact_subscription(contact);
- GList *resources = p_contact_get_available_resources(contact);
- GList *ordered_resources = NULL;
GDateTime *last_activity = p_contact_last_activity(contact);
theme_item_t presence_colour = theme_main_presence_attrs(presence);
@@ -687,20 +685,25 @@ win_show_info(ProfWin *window, PContact contact)
g_date_time_unref(now);
}
+ GList *resources = p_contact_get_available_resources(contact);
+ GList *ordered_resources = NULL;
if (resources != NULL) {
win_save_print(window, '-', NULL, 0, 0, "", "Resources:");
// sort in order of availabiltiy
- while (resources != NULL) {
- Resource *resource = resources->data;
+ GList *curr = resources;
+ while (curr != NULL) {
+ Resource *resource = curr->data;
ordered_resources = g_list_insert_sorted(ordered_resources,
resource, (GCompareFunc)resource_compare_availability);
- resources = g_list_next(resources);
+ curr = g_list_next(curr);
}
}
+ g_list_free(resources);
- while (ordered_resources != NULL) {
- Resource *resource = ordered_resources->data;
+ GList *curr = ordered_resources;
+ while (curr != NULL) {
+ Resource *resource = curr->data;
const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_save_vprint(window, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
@@ -755,8 +758,9 @@ win_show_info(ProfWin *window, PContact contact)
caps_destroy(caps);
}
- ordered_resources = g_list_next(ordered_resources);
+ curr = g_list_next(curr);
}
+ g_list_free(ordered_resources);
}
void
From 75f791da8f28f575f9772180f3a31841814fe817 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 21:53:55 +0000
Subject: [PATCH 068/252] Free hash table keys before modifying hash table
---
src/ui/windows.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 5ecada12..5993df19 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -408,9 +408,9 @@ wins_new_xmlconsole(void)
{
GList *keys = g_hash_table_get_keys(windows);
int result = get_next_available_win_num(keys);
+ g_list_free(keys);
ProfWin *newwin = win_create_xmlconsole();
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
- g_list_free(keys);
return newwin;
}
@@ -419,9 +419,9 @@ wins_new_chat(const char * const barejid)
{
GList *keys = g_hash_table_get_keys(windows);
int result = get_next_available_win_num(keys);
+ g_list_free(keys);
ProfWin *newwin = win_create_chat(barejid);
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
- g_list_free(keys);
return newwin;
}
@@ -430,9 +430,9 @@ wins_new_muc(const char * const roomjid)
{
GList *keys = g_hash_table_get_keys(windows);
int result = get_next_available_win_num(keys);
+ g_list_free(keys);
ProfWin *newwin = win_create_muc(roomjid);
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
- g_list_free(keys);
return newwin;
}
@@ -441,9 +441,9 @@ wins_new_muc_config(const char * const roomjid, DataForm *form)
{
GList *keys = g_hash_table_get_keys(windows);
int result = get_next_available_win_num(keys);
+ g_list_free(keys);
ProfWin *newwin = win_create_muc_config(roomjid, form);
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
- g_list_free(keys);
return newwin;
}
@@ -452,9 +452,9 @@ wins_new_private(const char * const fulljid)
{
GList *keys = g_hash_table_get_keys(windows);
int result = get_next_available_win_num(keys);
+ g_list_free(keys);
ProfWin *newwin = win_create_private(fulljid);
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
- g_list_free(keys);
return newwin;
}
From 38e6dc0e852b0aac3704827f50719c42869c134d Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 21:59:17 +0000
Subject: [PATCH 069/252] Free expected_node for legacy caps
---
src/xmpp/iq.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 7fedf0ed..bc12b780 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -631,6 +631,8 @@ _caps_response_handler_for_jid(xmpp_conn_t *const conn, xmpp_stanza_t * const st
Capabilities *capabilities = caps_create(query);
caps_add_by_jid(jid, capabilities);
+ free(jid);
+
return 0;
}
@@ -640,10 +642,12 @@ _caps_response_handler_legacy(xmpp_conn_t *const conn, xmpp_stanza_t * const sta
{
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+ char *expected_node = (char *)userdata;
char *type = xmpp_stanza_get_type(stanza);
// ignore non result
if ((g_strcmp0(type, "get") == 0) || (g_strcmp0(type, "set") == 0)) {
+ free(expected_node);
return 1;
}
@@ -656,6 +660,7 @@ _caps_response_handler_legacy(xmpp_conn_t *const conn, xmpp_stanza_t * const sta
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
if (!from) {
log_info("No from attribute");
+ free(expected_node);
return 0;
}
@@ -664,22 +669,23 @@ _caps_response_handler_legacy(xmpp_conn_t *const conn, xmpp_stanza_t * const sta
char *error_message = stanza_get_error_message(stanza);
log_warning("Error received for capabilities response from %s: ", from, error_message);
free(error_message);
+ free(expected_node);
return 0;
}
if (query == NULL) {
log_warning("No query element found.");
+ free(expected_node);
return 0;
}
char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
if (node == NULL) {
log_warning("No node attribute found");
+ free(expected_node);
return 0;
}
- char *expected_node = (char *)userdata;
-
// nodes match
if (g_strcmp0(expected_node, node) == 0) {
log_info("Legacy capabilities, nodes match %s", node);
From a9c69670fa246fefb2095aac1b8cf9581e2cd67c Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 22:03:17 +0000
Subject: [PATCH 070/252] Free filtered lists for who command
---
src/command/commands.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/command/commands.c b/src/command/commands.c
index 2059c982..6eca1bd1 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1069,6 +1069,7 @@ _who_roster(gchar **args, struct cmd_help_t help)
cons_show_contacts(filtered);
}
}
+ g_slist_free(filtered);
// unavailable
} else if (strcmp("unavailable", presence) == 0) {
@@ -1097,6 +1098,7 @@ _who_roster(gchar **args, struct cmd_help_t help)
cons_show_contacts(filtered);
}
}
+ g_slist_free(filtered);
// online, available resources
} else if (strcmp("online", presence) == 0) {
@@ -1125,6 +1127,7 @@ _who_roster(gchar **args, struct cmd_help_t help)
cons_show_contacts(filtered);
}
}
+ g_slist_free(filtered);
// offline, no available resources
} else if (strcmp("offline", presence) == 0) {
@@ -1153,6 +1156,7 @@ _who_roster(gchar **args, struct cmd_help_t help)
cons_show_contacts(filtered);
}
}
+ g_slist_free(filtered);
// show specific status
} else {
@@ -1181,6 +1185,7 @@ _who_roster(gchar **args, struct cmd_help_t help)
cons_show_contacts(filtered);
}
}
+ g_slist_free(filtered);
}
g_slist_free(list);
From 5c9dd2802a6aefcaa67cbf03a65128b595b587c9 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 9 Feb 2015 22:08:47 +0000
Subject: [PATCH 071/252] Free lists on get muc and private windows
---
src/ui/windows.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 5993df19..3132902f 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -132,6 +132,7 @@ wins_get_muc(const char * const roomjid)
if (window->type == WIN_MUC) {
ProfMucWin *mucwin = (ProfMucWin*)window;
if (g_strcmp0(mucwin->roomjid, roomjid) == 0) {
+ g_list_free(values);
return mucwin;
}
}
@@ -153,6 +154,7 @@ wins_get_private(const char * const fulljid)
if (window->type == WIN_PRIVATE) {
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
if (g_strcmp0(privatewin->fulljid, fulljid) == 0) {
+ g_list_free(values);
return privatewin;
}
}
From 48f9f3b3b0d4e12f55ba5ea2c34695e899916c3d Mon Sep 17 00:00:00 2001
From: Olivier LE MOAL
Date: Mon, 2 Feb 2015 11:10:05 +0100
Subject: [PATCH 072/252] Add XEP-0280 support
---
src/command/command.c | 9 +++++++++
src/command/commands.c | 18 +++++++++++++++++-
src/command/commands.h | 1 +
src/config/preferences.c | 3 +++
src/config/preferences.h | 1 +
src/server_events.c | 5 +++++
src/server_events.h | 1 +
src/ui/console.c | 9 +++++++++
src/ui/ui.h | 1 +
src/xmpp/connection.c | 5 +++++
src/xmpp/iq.c | 20 ++++++++++++++++++++
src/xmpp/message.c | 38 ++++++++++++++++++++++++++++++++++++++
src/xmpp/stanza.c | 38 ++++++++++++++++++++++++++++++++++++++
src/xmpp/stanza.h | 8 ++++++++
src/xmpp/xmpp.h | 2 ++
tests/ui/stub_ui.c | 1 +
tests/xmpp/stub_xmpp.c | 2 ++
17 files changed, 161 insertions(+), 1 deletion(-)
diff --git a/src/command/command.c b/src/command/command.c
index f05d2a79..b4daadcc 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -859,6 +859,15 @@ static struct cmd_t command_defs[] =
"shared : Share logs between all instances, accepts 'on' or 'off', defaults to 'on'.",
NULL } } },
+ { "/carbons",
+ cmd_carbons, parse_args, 1, 1, &cons_carbons_setting,
+ { "/carbons on|off", "Message carbons.",
+ { "/carbons on|off",
+ "---------------",
+ "Enable or disable message carbons.",
+ "The message carbons feature ensures that both sides of all conversations are shared with all the user's clients that implement this protocol.",
+ NULL } } },
+
{ "/reconnect",
cmd_reconnect, parse_args, 1, 1, &cons_reconnect_setting,
{ "/reconnect seconds", "Set reconnect interval.",
diff --git a/src/command/commands.c b/src/command/commands.c
index 6eca1bd1..f6784fb5 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -730,7 +730,7 @@ cmd_help(gchar **args, struct cmd_help_t help)
} else if (strcmp(args[0], "settings") == 0) {
gchar *filter[] = { "/account", "/autoaway", "/autoping", "/autoconnect", "/beep",
- "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype",
+ "/carbons", "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype",
"/log", "/mouse", "/notify", "/outtype", "/prefs", "/priority",
"/reconnect", "/roster", "/splash", "/states", "/statuses", "/theme",
"/titlebar", "/vercheck", "/privileges", "/occupants", "/presence", "/wrap" };
@@ -3887,6 +3887,22 @@ cmd_history(gchar **args, struct cmd_help_t help)
return result;
}
+gboolean
+cmd_carbons(gchar **args, struct cmd_help_t help)
+{
+ gboolean result = _cmd_set_boolean_preference(args[0], help,
+ "Carbons message", PREF_CARBONS);
+
+ // enable carbons
+ if (strcmp(args[0], "on") == 0) {
+ iq_enable_carbons();
+ }
+ else if (strcmp(args[0], "off") == 0){
+ iq_disable_carbons();
+ }
+ return result;
+}
+
gboolean
cmd_away(gchar **args, struct cmd_help_t help)
{
diff --git a/src/command/commands.h b/src/command/commands.h
index f4e040a9..1c16d635 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -85,6 +85,7 @@ gboolean cmd_grlog(gchar **args, struct cmd_help_t help);
gboolean cmd_group(gchar **args, struct cmd_help_t help);
gboolean cmd_help(gchar **args, struct cmd_help_t help);
gboolean cmd_history(gchar **args, struct cmd_help_t help);
+gboolean cmd_carbons(gchar **args, struct cmd_help_t help);
gboolean cmd_info(gchar **args, struct cmd_help_t help);
gboolean cmd_intype(gchar **args, struct cmd_help_t help);
gboolean cmd_invite(gchar **args, struct cmd_help_t help);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 67f12b18..7753ad71 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -558,6 +558,7 @@ _get_group(preference_t pref)
return PREF_GROUP_PRESENCE;
case PREF_CONNECT_ACCOUNT:
case PREF_DEFAULT_ACCOUNT:
+ case PREF_CARBONS:
return PREF_GROUP_CONNECTION;
case PREF_OTR_WARN:
case PREF_OTR_LOG:
@@ -593,6 +594,8 @@ _get_key(preference_t pref)
return "intype";
case PREF_HISTORY:
return "history";
+ case PREF_CARBONS:
+ return "carbons";
case PREF_MOUSE:
return "mouse";
case PREF_OCCUPANTS:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 68286f09..aa23e48a 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -59,6 +59,7 @@ typedef enum {
PREF_FLASH,
PREF_INTYPE,
PREF_HISTORY,
+ PREF_CARBONS,
PREF_MOUSE,
PREF_OCCUPANTS,
PREF_OCCUPANTS_SIZE,
diff --git a/src/server_events.c b/src/server_events.c
index fbf534ac..bf880a9d 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -296,6 +296,11 @@ handle_incoming_private_message(char *fulljid, char *message)
ui_incoming_private_msg(fulljid, message, NULL);
}
+void
+handle_carbon(char *barejid, char *message){
+ ui_outgoing_chat_msg("me", barejid, message);
+}
+
void
handle_incoming_message(char *barejid, char *resource, char *message)
{
diff --git a/src/server_events.h b/src/server_events.h
index 6a12dc6e..3ec6a332 100644
--- a/src/server_events.h
+++ b/src/server_events.h
@@ -101,6 +101,7 @@ void handle_group_remove(const char * const contact,
void handle_roster_remove(const char * const barejid);
void handle_roster_add(const char * const barejid, const char * const name);
void handle_autoping_cancel(void);
+void handle_carbon(char *barejid, char *message);
void handle_message_error(const char * const from, const char * const type,
const char * const err_msg);
void handle_presence_error(const char *from, const char * const type,
diff --git a/src/ui/console.c b/src/ui/console.c
index 2c37c40c..e5383f06 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1172,6 +1172,15 @@ cons_history_setting(void)
cons_show("Chat history (/history) : OFF");
}
+void
+cons_carbons_setting(void)
+{
+ if (prefs_get_boolean(PREF_CARBONS))
+ cons_show("Message carbons (/carbons) : ON");
+ else
+ cons_show("Message carbons (/carbons) : OFF");
+}
+
void
cons_show_chat_prefs(void)
{
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 99e73b4a..44ff42f4 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -308,6 +308,7 @@ void cons_outtype_setting(void);
void cons_intype_setting(void);
void cons_gone_setting(void);
void cons_history_setting(void);
+void cons_carbons_setting(void);
void cons_log_setting(void);
void cons_chlog_setting(void);
void cons_grlog_setting(void);
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 915525e4..34fba22d 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -466,6 +466,11 @@ _connection_handler(xmpp_conn_t * const conn,
roster_request();
bookmark_request();
+
+ if (prefs_get_boolean(PREF_CARBONS)){
+ iq_enable_carbons();
+ }
+
jabber_conn.conn_status = JABBER_CONNECTED;
if (prefs_get_reconnect() != 0) {
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index bc12b780..90b87676 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -152,6 +152,26 @@ iq_room_list_request(gchar *conferencejid)
xmpp_stanza_release(iq);
}
+void
+iq_enable_carbons()
+{
+ xmpp_conn_t * const conn = connection_get_conn();
+ xmpp_ctx_t * const ctx = connection_get_ctx();
+ xmpp_stanza_t *iq = stanza_enable_carbons(ctx);
+ xmpp_send(conn, iq);
+ xmpp_stanza_release(iq);
+}
+
+void
+iq_disable_carbons()
+{
+ xmpp_conn_t * const conn = connection_get_conn();
+ xmpp_ctx_t * const ctx = connection_get_ctx();
+ xmpp_stanza_t *iq = stanza_disable_carbons(ctx);
+ xmpp_send(conn, iq);
+ xmpp_stanza_release(iq);
+}
+
void
iq_disco_info_request(gchar *jid)
{
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index e96c1a74..4f341f6a 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -423,6 +423,44 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
return 1;
}
+ // check if carbon message
+ xmpp_stanza_t *received = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);
+ if(received != NULL){
+ xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(received, STANZA_NS_FORWARD);
+ xmpp_stanza_t *message = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);
+
+ xmpp_ctx_t *ctx = connection_get_ctx();
+
+ gchar *to = xmpp_stanza_get_attribute(message, STANZA_ATTR_TO);
+ gchar *from = xmpp_stanza_get_attribute(message, STANZA_ATTR_FROM);
+
+ Jid *jid_from = jid_create(from);
+ Jid *jid_to = jid_create(to);
+ Jid *my_jid = jid_create(jabber_get_fulljid());
+
+ // check for and deal with message
+ xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY);
+ if (body != NULL) {
+ char *message = xmpp_stanza_get_text(body);
+ if (message != NULL) {
+ // if we are the recipient, treat as standard incoming message
+ if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){
+ handle_incoming_message(jid_from->barejid, jid_from->resourcepart, message);
+ }
+ // else treat as a sent message
+ else{
+ handle_carbon(jid_to->barejid, message);
+ }
+ xmpp_free(ctx, message);
+ }
+ }
+
+ jid_destroy(jid_from);
+ jid_destroy(jid_to);
+ jid_destroy(my_jid);
+ return 1;
+ }
+
// ignore handled namespaces
xmpp_stanza_t *conf = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);
xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 4f1d412d..b0d7de86 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -198,6 +198,44 @@ stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char * const jid,
}
#endif
+xmpp_stanza_t *
+stanza_enable_carbons(xmpp_ctx_t *ctx){
+ xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
+ char *id = create_unique_id(NULL);
+
+ xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
+ xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
+ xmpp_stanza_set_id(iq, id);
+ free(id);
+
+ xmpp_stanza_t *carbons_enable = xmpp_stanza_new(ctx);
+ xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE);
+ xmpp_stanza_set_ns(carbons_enable, STANZA_NS_CARBONS);
+
+ xmpp_stanza_add_child(iq, carbons_enable);
+
+ return iq;
+}
+
+xmpp_stanza_t *
+stanza_disable_carbons(xmpp_ctx_t *ctx){
+ xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
+ char *id = create_unique_id(NULL);
+
+ xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
+ xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
+ xmpp_stanza_set_id(iq, id);
+ free(id);
+
+ xmpp_stanza_t *carbons_disable = xmpp_stanza_new(ctx);
+ xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE);
+ xmpp_stanza_set_ns(carbons_disable, STANZA_NS_CARBONS);
+
+ xmpp_stanza_add_child(iq, carbons_disable);
+
+ return iq;
+}
+
xmpp_stanza_t *
stanza_create_chat_state(xmpp_ctx_t *ctx, const char * const fulljid, const char * const state)
{
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 84282401..e4f3ce57 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -77,6 +77,8 @@
#define STANZA_NAME_VALUE "value"
#define STANZA_NAME_DESTROY "destroy"
#define STANZA_NAME_ACTOR "actor"
+#define STANZA_NAME_ENABLE "enable"
+#define STANZA_NAME_DISABLE "disable"
// error conditions
#define STANZA_NAME_BAD_REQUEST "bad-request"
@@ -154,6 +156,8 @@
#define STANZA_NS_CONFERENCE "jabber:x:conference"
#define STANZA_NS_CAPTCHA "urn:xmpp:captcha"
#define STANZA_NS_PUBSUB "http://jabber.org/protocol/pubsub"
+#define STANZA_NS_CARBONS "urn:xmpp:carbons:2"
+#define STANZA_NS_FORWARD "urn:xmpp:forward:0"
#define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
@@ -178,6 +182,10 @@ typedef enum {
xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx);
+xmpp_stanza_t * stanza_enable_carbons(xmpp_ctx_t *ctx);
+
+xmpp_stanza_t * stanza_disable_carbons(xmpp_ctx_t *ctx);
+
xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx,
const char * const fulljid, const char * const state);
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index a004a4bf..1fc32665 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -172,6 +172,8 @@ void presence_update(resource_presence_t status, const char * const msg,
gboolean presence_sub_request_exists(const char * const bare_jid);
// iq functions
+void iq_enable_carbons();
+void iq_disable_carbons();
void iq_send_software_version(const char * const fulljid);
void iq_room_list_request(gchar *conferencejid);
void iq_disco_info_request(gchar *jid);
diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c
index 51b82d42..fe650921 100644
--- a/tests/ui/stub_ui.c
+++ b/tests/ui/stub_ui.c
@@ -457,6 +457,7 @@ void cons_outtype_setting(void) {}
void cons_intype_setting(void) {}
void cons_gone_setting(void) {}
void cons_history_setting(void) {}
+void cons_carbons_setting(void) {}
void cons_log_setting(void) {}
void cons_chlog_setting(void) {}
void cons_grlog_setting(void) {}
diff --git a/tests/xmpp/stub_xmpp.c b/tests/xmpp/stub_xmpp.c
index 281857f0..dc9a258e 100644
--- a/tests/xmpp/stub_xmpp.c
+++ b/tests/xmpp/stub_xmpp.c
@@ -119,6 +119,8 @@ gboolean presence_sub_request_exists(const char * const bare_jid)
}
// iq functions
+void iq_disable_carbons() {};
+void iq_enable_carbons() {};
void iq_send_software_version(const char * const fulljid) {}
void iq_room_list_request(gchar *conferencejid)
From 6bee6cb0fbc7215091cbcbe9d146835a1a5405cb Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 19:30:18 +0000
Subject: [PATCH 073/252] Free string on backspace
---
src/ui/inputwin.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index b2d5e420..269d6fa7 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -611,17 +611,17 @@ _handle_backspace(void)
} else if (inp_x > 0 && inp_x < display_size) {
gchar *start = g_utf8_substring(input, 0, inp_x - 1);
gchar *end = g_utf8_substring(input, inp_x, input_len_bytes);
- GString *new = g_string_new(start);
- g_string_append(new, end);
+ GString *new_str = g_string_new(start);
+ g_string_append(new_str, end);
- for (input_len_bytes = 0; input_len_bytes < strlen(new->str); input_len_bytes++) {
- input[input_len_bytes] = new->str[input_len_bytes];
+ for (input_len_bytes = 0; input_len_bytes < strlen(new_str->str); input_len_bytes++) {
+ input[input_len_bytes] = new_str->str[input_len_bytes];
}
input[input_len_bytes] = '\0';
g_free(start);
g_free(end);
- g_string_free(new, FALSE);
+ g_string_free(new_str, TRUE);
_clear_input();
waddstr(inp_win, input);
From 30739ed157efcacd38dee69e35872f8ca9215b2f Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 19:39:18 +0000
Subject: [PATCH 074/252] Free contact list
---
src/command/commands.c | 1 +
src/ui/console.c | 9 +++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/command/commands.c b/src/command/commands.c
index 6eca1bd1..af5c8cc8 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1188,6 +1188,7 @@ _who_roster(gchar **args, struct cmd_help_t help)
g_slist_free(filtered);
}
+ list = g_slist_nth(list, 0);
g_slist_free(list);
}
diff --git a/src/ui/console.c b/src/ui/console.c
index 2c37c40c..8d6f88b4 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -402,17 +402,18 @@ cons_show_sent_subs(void)
GSList *contacts = roster_get_contacts();
PContact contact = NULL;
cons_show("Awaiting subscription responses from:");
- while (contacts != NULL) {
- contact = (PContact) contacts->data;
+ GSList *curr = contacts;
+ while (curr != NULL) {
+ contact = (PContact) curr->data;
if (p_contact_pending_out(contact)) {
cons_show(" %s", p_contact_barejid(contact));
}
- contacts = g_slist_next(contacts);
+ curr = g_slist_next(curr);
}
+ g_slist_free(contacts);
} else {
cons_show("No pending requests sent.");
}
-
cons_alert();
}
From 75d766387677c783694df9ccfda9dffbb3bf4ef7 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 19:42:13 +0000
Subject: [PATCH 075/252] Free wins summary list
---
src/ui/console.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/ui/console.c b/src/ui/console.c
index 8d6f88b4..c1bfe450 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -251,6 +251,7 @@ cons_show_wins(void)
win_save_println(console, curr->data);
curr = g_slist_next(curr);
}
+ g_slist_free_full(window_strings, free);
cons_show("");
cons_alert();
From 22b92c751445b14e35b9b0e94479f79d2434c0a5 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 19:53:34 +0000
Subject: [PATCH 076/252] Used g_hash_table_destroy to free logs
---
src/log.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/log.c b/src/log.c
index c525c3d9..4270a54f 100644
--- a/src/log.c
+++ b/src/log.c
@@ -236,7 +236,7 @@ chat_log_init(void)
{
session_started = g_date_time_new_now_local();
log_info("Initialising chat logs");
- logs = g_hash_table_new_full(g_str_hash, (GEqualFunc) _key_equals, g_free,
+ logs = g_hash_table_new_full(g_str_hash, (GEqualFunc) _key_equals, free,
(GDestroyNotify)_free_chat_log);
}
@@ -244,7 +244,7 @@ void
groupchat_log_init(void)
{
log_info("Initialising groupchat logs");
- groupchat_logs = g_hash_table_new_full(g_str_hash, (GEqualFunc) _key_equals, g_free,
+ groupchat_logs = g_hash_table_new_full(g_str_hash, (GEqualFunc) _key_equals, free,
(GDestroyNotify)_free_chat_log);
}
@@ -396,8 +396,8 @@ chat_log_get_previous(const gchar * const login, const gchar * const recipient)
void
chat_log_close(void)
{
- g_hash_table_remove_all(logs);
- g_hash_table_remove_all(groupchat_logs);
+ g_hash_table_destroy(logs);
+ g_hash_table_destroy(groupchat_logs);
g_date_time_unref(session_started);
}
From e565812d09cc3b257792cbafbb7ee1aa37d238c3 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 20:30:50 +0000
Subject: [PATCH 077/252] Free roster list
---
src/command/commands.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/src/command/commands.c b/src/command/commands.c
index af5c8cc8..3c1a0980 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1046,12 +1046,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
} else if (strcmp("available", presence) == 0) {
GSList *filtered = NULL;
- while (list != NULL) {
- PContact contact = list->data;
+ GSList *curr = list;
+ while (curr != NULL) {
+ PContact contact = curr->data;
if (p_contact_is_available(contact)) {
filtered = g_slist_append(filtered, contact);
}
- list = g_slist_next(list);
+ curr = g_slist_next(curr);
}
if (group != NULL) {
@@ -1075,12 +1076,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
} else if (strcmp("unavailable", presence) == 0) {
GSList *filtered = NULL;
- while (list != NULL) {
- PContact contact = list->data;
+ GSList *curr = list;
+ while (curr != NULL) {
+ PContact contact = curr->data;
if (!p_contact_is_available(contact)) {
filtered = g_slist_append(filtered, contact);
}
- list = g_slist_next(list);
+ curr = g_slist_next(curr);
}
if (group != NULL) {
@@ -1104,12 +1106,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
} else if (strcmp("online", presence) == 0) {
GSList *filtered = NULL;
- while (list != NULL) {
- PContact contact = list->data;
+ GSList *curr = list;
+ while (curr != NULL) {
+ PContact contact = curr->data;
if (p_contact_has_available_resource(contact)) {
filtered = g_slist_append(filtered, contact);
}
- list = g_slist_next(list);
+ curr = g_slist_next(curr);
}
if (group != NULL) {
@@ -1133,12 +1136,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
} else if (strcmp("offline", presence) == 0) {
GSList *filtered = NULL;
- while (list != NULL) {
- PContact contact = list->data;
+ GSList *curr = list;
+ while (curr != NULL) {
+ PContact contact = curr->data;
if (!p_contact_has_available_resource(contact)) {
filtered = g_slist_append(filtered, contact);
}
- list = g_slist_next(list);
+ curr = g_slist_next(curr);
}
if (group != NULL) {
@@ -1162,12 +1166,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
} else {
GSList *filtered = NULL;
- while (list != NULL) {
- PContact contact = list->data;
+ GSList *curr = list;
+ while (curr != NULL) {
+ PContact contact = curr->data;
if (strcmp(p_contact_presence(contact), presence) == 0) {
filtered = g_slist_append(filtered, contact);
}
- list = g_slist_next(list);
+ curr = g_slist_next(curr);
}
if (group != NULL) {
@@ -1188,7 +1193,6 @@ _who_roster(gchar **args, struct cmd_help_t help)
g_slist_free(filtered);
}
- list = g_slist_nth(list, 0);
g_slist_free(list);
}
From 6ab937c3e37b71315ab8661c6188ded49dfa182b Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 20:39:57 +0000
Subject: [PATCH 078/252] Copy list when sorting windows for /wins
---
src/common.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/common.c b/src/common.c
index 95deecbb..3af4f550 100644
--- a/src/common.c
+++ b/src/common.c
@@ -488,25 +488,34 @@ cmp_win_num(gconstpointer a, gconstpointer b)
int
get_next_available_win_num(GList *used)
{
- used = g_list_sort(used, cmp_win_num);
// only console used
if (g_list_length(used) == 1) {
return 2;
} else {
+ GList *sorted = NULL;
+ GList *curr = used;
+ while (curr) {
+ sorted = g_list_insert_sorted(sorted, curr->data, cmp_win_num);
+ curr = g_list_next(curr);
+ }
+
int result = 0;
int last_num = 1;
- GList *curr = used;
+ curr = sorted;
// skip console
curr = g_list_next(curr);
while (curr != NULL) {
int curr_num = GPOINTER_TO_INT(curr->data);
+
if (((last_num != 9) && ((last_num + 1) != curr_num)) ||
((last_num == 9) && (curr_num != 0))) {
result = last_num + 1;
if (result == 10) {
result = 0;
}
+ g_list_free(sorted);
return (result);
+
} else {
last_num = curr_num;
if (last_num == 0) {
@@ -520,6 +529,7 @@ get_next_available_win_num(GList *used)
result = 0;
}
+ g_list_free(sorted);
return result;
}
}
From 1e2ef973348a58b0ba58eb020cc91e4f41a1d10e Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 21:26:59 +0000
Subject: [PATCH 079/252] Fixed parameter order for /tiny in private and group
chat
fixes #502
---
src/command/commands.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/command/commands.c b/src/command/commands.c
index 3c1a0980..9e9191d4 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -3116,11 +3116,11 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
#endif
} else if (win_type == WIN_PRIVATE) {
ProfPrivateWin *privatewin = wins_get_current_private();
- message_send_private(tiny, privatewin->fulljid);
+ message_send_private(privatewin->fulljid, tiny);
ui_outgoing_private_msg("me", privatewin->fulljid, tiny);
} else if (win_type == WIN_MUC) {
ProfMucWin *mucwin = wins_get_current_muc();
- message_send_groupchat(tiny, mucwin->roomjid);
+ message_send_groupchat(mucwin->roomjid, tiny);
}
free(tiny);
} else {
From b3be26a21406b549426f6c94c91e8b2a6bf32701 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 23:16:09 +0000
Subject: [PATCH 080/252] Updated copyright
---
LICENSE.txt | 2 +-
docs/profanity.1 | 4 ++--
src/chat_session.c | 2 +-
src/chat_session.h | 2 +-
src/chat_state.c | 2 +-
src/chat_state.h | 2 +-
src/command/command.c | 2 +-
src/command/command.h | 2 +-
src/command/commands.c | 2 +-
src/command/commands.h | 2 +-
src/common.c | 2 +-
src/common.h | 2 +-
src/config/account.c | 2 +-
src/config/account.h | 2 +-
src/config/accounts.c | 2 +-
src/config/accounts.h | 2 +-
src/config/preferences.c | 2 +-
src/config/preferences.h | 2 +-
src/config/theme.c | 2 +-
src/config/theme.h | 2 +-
src/contact.c | 2 +-
src/contact.h | 2 +-
src/jid.c | 2 +-
src/jid.h | 2 +-
src/log.c | 2 +-
src/log.h | 2 +-
src/main.c | 4 ++--
src/muc.c | 2 +-
src/muc.h | 2 +-
src/otr/otr.c | 2 +-
src/otr/otr.h | 2 +-
src/otr/otrlib.h | 2 +-
src/otr/otrlibv3.c | 2 +-
src/otr/otrlibv4.c | 2 +-
src/profanity.c | 2 +-
src/profanity.h | 2 +-
src/resource.c | 2 +-
src/resource.h | 2 +-
src/roster_list.c | 2 +-
src/roster_list.h | 2 +-
src/server_events.c | 2 +-
src/server_events.h | 2 +-
src/tools/autocomplete.c | 2 +-
src/tools/autocomplete.h | 2 +-
src/tools/history.c | 2 +-
src/tools/history.h | 2 +-
src/tools/parser.c | 2 +-
src/tools/parser.h | 2 +-
src/tools/tinyurl.c | 2 +-
src/tools/tinyurl.h | 2 +-
src/ui/buffer.c | 2 +-
src/ui/buffer.h | 2 +-
src/ui/console.c | 4 ++--
src/ui/core.c | 2 +-
src/ui/inputwin.c | 2 +-
src/ui/inputwin.h | 2 +-
src/ui/notifier.c | 2 +-
src/ui/occupantswin.c | 2 +-
src/ui/rosterwin.c | 2 +-
src/ui/statusbar.c | 2 +-
src/ui/statusbar.h | 2 +-
src/ui/titlebar.c | 2 +-
src/ui/titlebar.h | 2 +-
src/ui/ui.h | 2 +-
src/ui/window.c | 2 +-
src/ui/window.h | 2 +-
src/ui/windows.c | 2 +-
src/ui/windows.h | 2 +-
src/xmpp/bookmark.c | 2 +-
src/xmpp/bookmark.h | 2 +-
src/xmpp/capabilities.c | 2 +-
src/xmpp/capabilities.h | 2 +-
src/xmpp/connection.c | 2 +-
src/xmpp/connection.h | 2 +-
src/xmpp/form.c | 2 +-
src/xmpp/form.h | 2 +-
src/xmpp/iq.c | 2 +-
src/xmpp/iq.h | 2 +-
src/xmpp/message.c | 2 +-
src/xmpp/message.h | 2 +-
src/xmpp/presence.c | 2 +-
src/xmpp/presence.h | 2 +-
src/xmpp/roster.c | 2 +-
src/xmpp/roster.h | 2 +-
src/xmpp/stanza.c | 2 +-
src/xmpp/stanza.h | 2 +-
src/xmpp/xmpp.h | 2 +-
87 files changed, 90 insertions(+), 90 deletions(-)
diff --git a/LICENSE.txt b/LICENSE.txt
index 609ce80c..e1990985 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,5 +1,5 @@
Profanity
-Copyright (C) 2012 - 2014 James Booth
+Copyright (C) 2012 - 2015 James Booth
Profanity is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/docs/profanity.1 b/docs/profanity.1
index a65281fb..5b87d381 100644
--- a/docs/profanity.1
+++ b/docs/profanity.1
@@ -1,4 +1,4 @@
-.TH Profanity 1 "March 2014" "Profanity XMPP client"
+.TH Profanity 1 "February 2015" "Profanity XMPP client"
.SH NAME
Profanity \- a simple console based XMPP chat client.
.SH SYNOPSIS
@@ -62,7 +62,7 @@ or with a Github account by logging issues on the issue tracker at:
.PP
.SH LICENSE
-Copyright (C) 2012 \- 2014 James Booth .
+Copyright (C) 2012 \- 2015 James Booth .
License GPLv3+: GNU GPL version 3 or later
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
diff --git a/src/chat_session.c b/src/chat_session.c
index fbe06f76..555452cb 100644
--- a/src/chat_session.c
+++ b/src/chat_session.c
@@ -1,7 +1,7 @@
/*
* chat_session.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/chat_session.h b/src/chat_session.h
index 585a523b..f51a8341 100644
--- a/src/chat_session.h
+++ b/src/chat_session.h
@@ -1,7 +1,7 @@
/*
* chat_session.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/chat_state.c b/src/chat_state.c
index 99a83f43..8ddb6f1e 100644
--- a/src/chat_state.c
+++ b/src/chat_state.c
@@ -1,7 +1,7 @@
/*
* chat_state.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/chat_state.h b/src/chat_state.h
index ba394a56..7f0d8832 100644
--- a/src/chat_state.h
+++ b/src/chat_state.h
@@ -1,7 +1,7 @@
/*
* chat_state.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/command/command.c b/src/command/command.c
index f05d2a79..e810f8af 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1,7 +1,7 @@
/*
* command.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/command/command.h b/src/command/command.h
index 8be1143f..b500404b 100644
--- a/src/command/command.h
+++ b/src/command/command.h
@@ -1,7 +1,7 @@
/*
* command.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/command/commands.c b/src/command/commands.c
index 9e9191d4..63cdedf7 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1,7 +1,7 @@
/*
* commands.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/command/commands.h b/src/command/commands.h
index f4e040a9..aeb34661 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -1,7 +1,7 @@
/*
* commands.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/common.c b/src/common.c
index 3af4f550..17c74b94 100644
--- a/src/common.c
+++ b/src/common.c
@@ -1,7 +1,7 @@
/*
* common.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/common.h b/src/common.h
index c22706ec..ea6eeaa2 100644
--- a/src/common.h
+++ b/src/common.h
@@ -1,7 +1,7 @@
/*
* common.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/config/account.c b/src/config/account.c
index 6df00382..3896286b 100644
--- a/src/config/account.c
+++ b/src/config/account.c
@@ -1,7 +1,7 @@
/*
* account.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/config/account.h b/src/config/account.h
index ab43234d..c237a19e 100644
--- a/src/config/account.h
+++ b/src/config/account.h
@@ -1,7 +1,7 @@
/*
* account.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 4d4d47d0..dd0d6eb4 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -1,7 +1,7 @@
/*
* accounts.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/config/accounts.h b/src/config/accounts.h
index cbbe88e6..50307b5b 100644
--- a/src/config/accounts.h
+++ b/src/config/accounts.h
@@ -1,7 +1,7 @@
/*
* accounts.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 67f12b18..11a0b217 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1,7 +1,7 @@
/*
* preferences.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 68286f09..2a23261f 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -1,7 +1,7 @@
/*
* preferences.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/config/theme.c b/src/config/theme.c
index 26d48091..e9389417 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -1,7 +1,7 @@
/*
* theme.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/config/theme.h b/src/config/theme.h
index a6a580f8..f2e38404 100644
--- a/src/config/theme.h
+++ b/src/config/theme.h
@@ -1,7 +1,7 @@
/*
* theme.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/contact.c b/src/contact.c
index 943be374..cd7d5d9d 100644
--- a/src/contact.c
+++ b/src/contact.c
@@ -1,7 +1,7 @@
/*
* contact.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/contact.h b/src/contact.h
index 17a3b210..a08aef43 100644
--- a/src/contact.h
+++ b/src/contact.h
@@ -1,7 +1,7 @@
/*
* contact.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/jid.c b/src/jid.c
index 690f36ca..d1c25ddb 100644
--- a/src/jid.c
+++ b/src/jid.c
@@ -1,7 +1,7 @@
/*
* jid.c
*
- * Copyright (C) 2012 -2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/jid.h b/src/jid.h
index 64c147f9..6d530c5a 100644
--- a/src/jid.h
+++ b/src/jid.h
@@ -1,7 +1,7 @@
/*
* jid.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/log.c b/src/log.c
index 4270a54f..004d4dcf 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,7 +1,7 @@
/*
* log.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/log.h b/src/log.h
index 8ffc6f22..fdfd6caa 100644
--- a/src/log.h
+++ b/src/log.h
@@ -1,7 +1,7 @@
/*
* log.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/main.c b/src/main.c
index 7ee5affe..3bb7eeb6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,7 @@
/*
* main.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
@@ -89,7 +89,7 @@ main(int argc, char **argv)
g_print("Profanity, version %s\n", PACKAGE_VERSION);
}
- g_print("Copyright (C) 2012 - 2014 James Booth <%s>.\n", PACKAGE_BUGREPORT);
+ g_print("Copyright (C) 2012 - 2015 James Booth <%s>.\n", PACKAGE_BUGREPORT);
g_print("License GPLv3+: GNU GPL version 3 or later \n");
g_print("\n");
g_print("This is free software; you are free to change and redistribute it.\n");
diff --git a/src/muc.c b/src/muc.c
index f50f3879..0d606873 100644
--- a/src/muc.c
+++ b/src/muc.c
@@ -1,7 +1,7 @@
/*
* muc.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/muc.h b/src/muc.h
index 01f8b44b..16f217d0 100644
--- a/src/muc.h
+++ b/src/muc.h
@@ -1,7 +1,7 @@
/*
* muc.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/otr/otr.c b/src/otr/otr.c
index bd1c2ce3..7c500e71 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -1,7 +1,7 @@
/*
* otr.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/otr/otr.h b/src/otr/otr.h
index 155e287b..58d5c04b 100644
--- a/src/otr/otr.h
+++ b/src/otr/otr.h
@@ -1,7 +1,7 @@
/*
* otr.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/otr/otrlib.h b/src/otr/otrlib.h
index da1c8547..0310c9e6 100644
--- a/src/otr/otrlib.h
+++ b/src/otr/otrlib.h
@@ -1,7 +1,7 @@
/*
* otrlib.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c
index 77b00660..77b0ee77 100644
--- a/src/otr/otrlibv3.c
+++ b/src/otr/otrlibv3.c
@@ -1,7 +1,7 @@
/*
* otrlibv3.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c
index 62379d0f..e090ead4 100644
--- a/src/otr/otrlibv4.c
+++ b/src/otr/otrlibv4.c
@@ -1,7 +1,7 @@
/*
* otrlibv4.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/profanity.c b/src/profanity.c
index 13297124..f694ea68 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -1,7 +1,7 @@
/*
* profanity.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/profanity.h b/src/profanity.h
index f01169f8..269c616a 100644
--- a/src/profanity.h
+++ b/src/profanity.h
@@ -1,7 +1,7 @@
/*
* profanity.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/resource.c b/src/resource.c
index 844cb1d3..620dd38d 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -1,7 +1,7 @@
/*
* resource.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/resource.h b/src/resource.h
index 5c39d969..43bb6d18 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -1,7 +1,7 @@
/*
* resource.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/roster_list.c b/src/roster_list.c
index 44d05ff0..4ec5ea4f 100644
--- a/src/roster_list.c
+++ b/src/roster_list.c
@@ -1,7 +1,7 @@
/*
* roster_list.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/roster_list.h b/src/roster_list.h
index e193085b..6c66d142 100644
--- a/src/roster_list.h
+++ b/src/roster_list.h
@@ -1,7 +1,7 @@
/*
* roster_list.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/server_events.c b/src/server_events.c
index fbf534ac..206146e9 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -1,7 +1,7 @@
/*
* server_events.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/server_events.h b/src/server_events.h
index 6a12dc6e..4e04f507 100644
--- a/src/server_events.h
+++ b/src/server_events.h
@@ -1,7 +1,7 @@
/*
* server_events.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index 2623c828..7624f1df 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -1,7 +1,7 @@
/*
* autocomplete.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/tools/autocomplete.h b/src/tools/autocomplete.h
index 70cd8f30..c4b94b09 100644
--- a/src/tools/autocomplete.h
+++ b/src/tools/autocomplete.h
@@ -1,7 +1,7 @@
/*
* autocomplete.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/tools/history.c b/src/tools/history.c
index def10feb..826df693 100644
--- a/src/tools/history.c
+++ b/src/tools/history.c
@@ -1,7 +1,7 @@
/*
* history.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/tools/history.h b/src/tools/history.h
index 7b334718..4a903cbc 100644
--- a/src/tools/history.h
+++ b/src/tools/history.h
@@ -1,7 +1,7 @@
/*
* history.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/tools/parser.c b/src/tools/parser.c
index e91b227d..98fc21d4 100644
--- a/src/tools/parser.c
+++ b/src/tools/parser.c
@@ -1,7 +1,7 @@
/*
* parser.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/tools/parser.h b/src/tools/parser.h
index eeb97df3..34fa55a0 100644
--- a/src/tools/parser.h
+++ b/src/tools/parser.h
@@ -1,7 +1,7 @@
/*
* parser.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/tools/tinyurl.c b/src/tools/tinyurl.c
index 3addc646..34e8967a 100644
--- a/src/tools/tinyurl.c
+++ b/src/tools/tinyurl.c
@@ -1,7 +1,7 @@
/*
* tinyurl.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/tools/tinyurl.h b/src/tools/tinyurl.h
index 9557228f..f69570c3 100644
--- a/src/tools/tinyurl.h
+++ b/src/tools/tinyurl.h
@@ -1,7 +1,7 @@
/*
* tinyurl.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/buffer.c b/src/ui/buffer.c
index 52397b4b..da505867 100644
--- a/src/ui/buffer.c
+++ b/src/ui/buffer.c
@@ -1,7 +1,7 @@
/*
* buffer.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/buffer.h b/src/ui/buffer.h
index 34d6b04f..5258b8c1 100644
--- a/src/ui/buffer.h
+++ b/src/ui/buffer.h
@@ -1,7 +1,7 @@
/*
* buffer.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/console.c b/src/ui/console.c
index c1bfe450..01d1c73a 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1,7 +1,7 @@
/*
* console.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
@@ -176,7 +176,7 @@ cons_about(void)
}
}
- win_save_vprint(console, '-', NULL, 0, 0, "", "Copyright (C) 2012 - 2014 James Booth <%s>.", PACKAGE_BUGREPORT);
+ win_save_vprint(console, '-', NULL, 0, 0, "", "Copyright (C) 2012 - 2015 James Booth <%s>.", PACKAGE_BUGREPORT);
win_save_println(console, "License GPLv3+: GNU GPL version 3 or later ");
win_save_println(console, "");
win_save_println(console, "This is free software; you are free to change and redistribute it.");
diff --git a/src/ui/core.c b/src/ui/core.c
index 85d5748a..fc6c0ed4 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1,7 +1,7 @@
/*
* core.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 269d6fa7..bc042b3f 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -1,7 +1,7 @@
/*
* inputwin.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h
index 39fde720..4a2767c2 100644
--- a/src/ui/inputwin.h
+++ b/src/ui/inputwin.h
@@ -1,7 +1,7 @@
/*
* inputwin.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index 7ca8f705..693817d6 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -1,7 +1,7 @@
/*
* notifier.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/occupantswin.c b/src/ui/occupantswin.c
index 429c2fdf..d865eeed 100644
--- a/src/ui/occupantswin.c
+++ b/src/ui/occupantswin.c
@@ -1,7 +1,7 @@
/*
* occupantswin.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index 828ed429..763490c3 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -1,7 +1,7 @@
/*
* rosterwin.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index 2ef20913..58f3fc58 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -1,7 +1,7 @@
/*
* statusbar.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/statusbar.h b/src/ui/statusbar.h
index 5c37867b..7d2c5ea0 100644
--- a/src/ui/statusbar.h
+++ b/src/ui/statusbar.h
@@ -1,7 +1,7 @@
/*
* statusbar.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index a3299946..7b80c889 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -1,7 +1,7 @@
/*
* titlebar.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/titlebar.h b/src/ui/titlebar.h
index 08a56514..66237f86 100644
--- a/src/ui/titlebar.h
+++ b/src/ui/titlebar.h
@@ -1,7 +1,7 @@
/*
* titlebar.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 99e73b4a..65dabeb5 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -1,7 +1,7 @@
/*
* ui.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/window.c b/src/ui/window.c
index aba2f40a..85cc875c 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1,7 +1,7 @@
/*
* window.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/window.h b/src/ui/window.h
index fd10a1d7..87a4bb79 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -1,7 +1,7 @@
/*
* window.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 3132902f..dba5290c 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -1,7 +1,7 @@
/*
* windows.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/ui/windows.h b/src/ui/windows.h
index c144a5a2..97183d51 100644
--- a/src/ui/windows.h
+++ b/src/ui/windows.h
@@ -1,7 +1,7 @@
/*
* windows.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c
index 94adabea..1cf11f93 100644
--- a/src/xmpp/bookmark.c
+++ b/src/xmpp/bookmark.c
@@ -1,7 +1,7 @@
/*
* bookmark.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/bookmark.h b/src/xmpp/bookmark.h
index f9392182..c8de8147 100644
--- a/src/xmpp/bookmark.h
+++ b/src/xmpp/bookmark.h
@@ -1,7 +1,7 @@
/*
* bookmark.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index 1a9eed74..54144330 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -1,7 +1,7 @@
/*
* capabilities.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h
index 692ac49d..85f1d989 100644
--- a/src/xmpp/capabilities.h
+++ b/src/xmpp/capabilities.h
@@ -1,7 +1,7 @@
/*
* capabilities.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 915525e4..375dfcba 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -1,7 +1,7 @@
/*
* connection.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h
index f9e2cf22..63f7cde0 100644
--- a/src/xmpp/connection.h
+++ b/src/xmpp/connection.h
@@ -1,7 +1,7 @@
/*
* connection.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/form.c b/src/xmpp/form.c
index 1facc754..02d26ba0 100644
--- a/src/xmpp/form.c
+++ b/src/xmpp/form.c
@@ -1,7 +1,7 @@
/*
* form.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/form.h b/src/xmpp/form.h
index fa14e1c5..86cd4b7b 100644
--- a/src/xmpp/form.h
+++ b/src/xmpp/form.h
@@ -1,7 +1,7 @@
/*
* form.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index bc12b780..e1aa773a 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1,7 +1,7 @@
/*
* iq.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/iq.h b/src/xmpp/iq.h
index 8c803ab5..d3a22fe4 100644
--- a/src/xmpp/iq.h
+++ b/src/xmpp/iq.h
@@ -1,7 +1,7 @@
/*
* iq.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index e96c1a74..7d504e48 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -1,7 +1,7 @@
/*
* message.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/message.h b/src/xmpp/message.h
index b3410dc9..6fbc27bd 100644
--- a/src/xmpp/message.h
+++ b/src/xmpp/message.h
@@ -1,7 +1,7 @@
/*
* message.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 65384a0d..a0d9e0f1 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -1,7 +1,7 @@
/*
* presence.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/presence.h b/src/xmpp/presence.h
index e704aea0..90b83473 100644
--- a/src/xmpp/presence.h
+++ b/src/xmpp/presence.h
@@ -1,7 +1,7 @@
/*
* presence.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index 3449c8d5..e6f4c2ca 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -1,7 +1,7 @@
/*
* roster.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/roster.h b/src/xmpp/roster.h
index c29a674a..68811a5c 100644
--- a/src/xmpp/roster.h
+++ b/src/xmpp/roster.h
@@ -1,7 +1,7 @@
/*
* roster.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 4f1d412d..563aa982 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -1,7 +1,7 @@
/*
* stanza.c
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 84282401..b61e8ab8 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -1,7 +1,7 @@
/*
* stanza.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index a004a4bf..79bc0579 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -1,7 +1,7 @@
/*
* xmpp.h
*
- * Copyright (C) 2012 - 2014 James Booth
+ * Copyright (C) 2012 - 2015 James Booth
*
* This file is part of Profanity.
*
From f4459f7f67af388baa5bab9bbbdf89392dfd432f Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 23:30:21 +0000
Subject: [PATCH 081/252] Updated man page
---
docs/profanity.1 | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/docs/profanity.1 b/docs/profanity.1
index 5b87d381..63cd0677 100644
--- a/docs/profanity.1
+++ b/docs/profanity.1
@@ -3,7 +3,7 @@
Profanity \- a simple console based XMPP chat client.
.SH SYNOPSIS
.B profanity
-[\-vhd] [\-l level]
+[\-vhd] [\-l level] [\-a account]
.SH DESCRIPTION
.B Profanity
is a simple lightweight console based XMPP chat client. Its emphasis is
@@ -15,19 +15,21 @@ at:
.SH OPTIONS
.TP
.BI "\-v, \-\-version"
-Show version information.
+Show version and build information.
.TP
.BI "\-h, \-\-help"
Show help on command line arguments.
.TP
-.BI "\-a, \-\-account"
-Auto connect to an account on startup.
+.BI "\-a, \-\-account "ACCOUNT
+Auto connect to an account on startup,
+.I ACCOUNT
+must be an existing account.
.TP
.BI "\-d, \-\-disable\-tls"
Disable TLS for servers that either don't support it, or claim to but do not
complete the handshake.
.TP
-.BI "\-l, \-\-log="LEVEL
+.BI "\-l, \-\-log "LEVEL
Set the logging level,
.I LEVEL
may be set to DEBUG, INFO (the default), WARN or ERROR.
@@ -45,10 +47,10 @@ is stored in
, details on configuring Profanity can be found at .
.PP
.SH BUGS
-Bugs can either be reported by sending a mail directly to:
+Bugs can either be reported by raising an issue at the Github issue tracker:
.br
.PP
-
+
.br
.PP
or to the mailing list at:
@@ -57,10 +59,12 @@ or to the mailing list at:
.br
.PP
-or with a Github account by logging issues on the issue tracker at:
+or by sending a mail directly to:
+.br
+.PP
+
.br
.PP
-
.SH LICENSE
Copyright (C) 2012 \- 2015 James Booth .
License GPLv3+: GNU GPL version 3 or later
From 421ce2876a2b59b4ef3e04348be9c442a92997f5 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 10 Feb 2015 23:40:23 +0000
Subject: [PATCH 082/252] Changed default inpblock delay to 1 second
---
src/config/preferences.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 11a0b217..a1f82940 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -62,7 +62,7 @@
#define PREF_GROUP_ALIAS "alias"
#define PREF_GROUP_OTR "otr"
-#define INPBLOCK_DEFAULT 20
+#define INPBLOCK_DEFAULT 1000
static gchar *prefs_loc;
static GKeyFile *prefs;
From 0bf9d324ff6a1c4f2ce724f6c54d0b39e157a3c8 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 11 Feb 2015 00:01:17 +0000
Subject: [PATCH 083/252] Updated CHANGELOG
---
CHANGELOG | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 815f6e55..2d9970c7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,16 +1,17 @@
0.4.6
=====
-- 16 colour support
+- 16 colour support (/theme colours)
- UI preferences included in themes
-- Word wrapping (/wrap)
-- Show hide time (/time)
-- Show or hide and customise roster panel (/roster)
+- /wrap - Word wrapping
+- /time - Show/hide time in main window, and configure precision
+- /roster - Show/hide and customise roster panel
+- /roster and /occupants panel size settings (% of screen width)
+- /account default - Set default account for /connect
- /account remove
-- Added default account for /connect
-- Additional readline style shortcuts
-- Improved chat session handling
-- Override resource during chat and resource display settings (/resource)
-- Disable terminal title by default, additonal title on exit
-- Dynamic input blocking timeout to use less CPU
-- eval_password property on accounts for retrieving password from keyring/keychain
+- /presence - Show/hide contact presence in titlebar
+- /resource - Override resource during chat, resource display settings
+- Improved chat session handling
+- Lower CPU usage with dynamic input blocking timeout
+- Keychain/keyring integration using account eval_password property
+- Disable term window title by default
From 9951da0c8fbb0dd3fa26b74165b7cb64b25d7cf9 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 11 Feb 2015 00:17:07 +0000
Subject: [PATCH 084/252] Free jid on caps response handler
---
src/xmpp/iq.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index e1aa773a..c0a982fa 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -586,12 +586,14 @@ static int
_caps_response_handler_for_jid(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza,
void * const userdata)
{
+ char *jid = (char *)userdata;
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
char *type = xmpp_stanza_get_type(stanza);
// ignore non result
if ((g_strcmp0(type, "get") == 0) || (g_strcmp0(type, "set") == 0)) {
+ free(jid);
return 1;
}
@@ -604,6 +606,7 @@ _caps_response_handler_for_jid(xmpp_conn_t *const conn, xmpp_stanza_t * const st
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
if (!from) {
log_info("No from attribute");
+ free(jid);
return 0;
}
@@ -612,21 +615,23 @@ _caps_response_handler_for_jid(xmpp_conn_t *const conn, xmpp_stanza_t * const st
char *error_message = stanza_get_error_message(stanza);
log_warning("Error received for capabilities response from %s: ", from, error_message);
free(error_message);
+ free(jid);
return 0;
}
if (query == NULL) {
log_warning("No query element found.");
+ free(jid);
return 0;
}
char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
if (node == NULL) {
log_warning("No node attribute found");
+ free(jid);
return 0;
}
- char *jid = (char *)userdata;
log_info("Associating capabilities with: %s", jid);
Capabilities *capabilities = caps_create(query);
caps_add_by_jid(jid, capabilities);
From d02b364b3ca8728c9b2fdc181400906050e9fd45 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 11 Feb 2015 23:58:11 +0000
Subject: [PATCH 085/252] Tidy help
---
src/command/command.c | 206 ++++++++++++++++++------------------------
1 file changed, 87 insertions(+), 119 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index e810f8af..491bf5f2 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -112,18 +112,13 @@ static struct cmd_t command_defs[] =
{
{ "/help",
cmd_help, parse_args, 0, 1, NULL,
- { "/help [area|command]", "Get help on using Profanity.",
+ { "/help [area|command]", "Help on using Profanity.",
{ "/help [area|command]",
- "-------------------------",
- "Use with no arguments to get a help summary.",
- "Supply an area to see help for commands related to specific features.",
- "Supply a command (without the leading slash) to see help for that command.",
- "",
- "Example : /help commands",
- "Example : /help presence",
- "Example : /help who",
- "",
- "For more detailed help, see the user guide at http://www.profanity.im/userguide.html.",
+ "--------------------",
+ "Help on using Profanity.",
+ "area - Summary help for commands in a certain area of functionality.",
+ "command - Full help for a specific command, for example '/help connect'.",
+ "Use with no arguments to see a list of areas.",
NULL } } },
{ "/about",
@@ -136,21 +131,15 @@ static struct cmd_t command_defs[] =
{ "/connect",
cmd_connect, parse_args, 0, 5, NULL,
- { "/connect [account] [server value] [port value]", "Login to a chat service.",
+ { "/connect [account] [server value] [port value]", "Account login.",
{ "/connect [account] [server value] [port value]",
"----------------------------------------------",
- "Connect to an XMPP service using the specified account.",
- "Use the server property to specify a server if required.",
- "Change the default port (5222, or 5223 for SSL) with the port property.",
- "An account is automatically created if one does not exist.",
- "If no account is specified, then the default account is used."
- "See the /account command for more details.",
- "",
- "Example: /connect",
- "Example: /connect myuser@gmail.com",
- "Example: /connect myuser@mycompany.com server talk.google.com",
- "Example: /connect bob@someplace port 5678",
- "Example: /connect me@chatty server chatty.com port 5443",
+ "Login to a chat service.",
+ "account - The local account you wish to connect with, or a JID if connecting for the first time.",
+ "server value - Supply a server if it is different to the domain part of your JID.",
+ "port value - The port to use if different to the default (5222, or 5223 for SSL).",
+ "If no account is specified, the default is used if one is configured.",
+ "A local account is created with the JID as it's name if it doesn't already exist.",
NULL } } },
{ "/disconnect",
@@ -163,48 +152,40 @@ static struct cmd_t command_defs[] =
{ "/msg",
cmd_msg, parse_args_with_freetext, 1, 2, NULL,
- { "/msg contact|nick [message]", "Start chat with user.",
+ { "/msg contact|nick [message]", "Start chat with a user.",
{ "/msg contact|nick [message]",
"---------------------------",
- "Open a chat window for the contact and send the message if one is supplied.",
- "When in a chat room, supply a nickname to start private chat with a room member.",
+ "Send a one to one chat message, or a private message to a chat room occupant.",
+ "contact - The contact's JID, or nickname if one has been set in your roster.",
+ "nick - A chat room occupant, to whom you wish to send a private message.",
+ "message - The message to send",
+ "If the message is omitted, a new chat window will be opened without sending a message.",
"Use quotes if the nickname includes spaces.",
- "",
- "Example : /msg myfriend@server.com Hey, here's a message!",
- "Example : /msg otherfriend@server.com",
- "Example : /msg Bob Here is a private message",
- "Example : /msg \"My Friend\" Hi, how are you?",
NULL } } },
{ "/roster",
cmd_roster, parse_args_with_freetext, 0, 3, NULL,
- { "/roster [online|show|hide|by|size|add|remove|nick|clearnick] [offline|resource] [percent] [group|presence|none] [jid] [nickname]", "Manage your roster.",
- { "/roster [online|show|hide|by|size|add|remove|nick|clearnick] [offline|resource] [percent] [group|presence|none] [jid] [nickname]",
- "-------------------------------------------------------------------------------------------------------------------------",
- "View, add to, and remove from your roster.",
+ { "/roster [command] [args..]", "Manage your roster.",
+ { "/roster [command] [args..]",
+ "--------------------------",
+ "Manage your roster, and roster display settings.",
+ "command - online|show|hide|by|size|add|remove|nick|clearnick",
+ "online - Show all online contacts in your roster.",
+ "show - Show the roster panel.",
+ "show offline - Show offline contacts in the roster panel.",
+ "show resource - Show contact's connected resources in the roster panel.",
+ "hide - Hide the roster panel.",
+ "hide offline - Hide offline contacts in the roster panel.",
+ "hide resource - Hide contact's connected resources in the roster panel.",
+ "by group - Group contacts in the roster panel by roster group.",
+ "by presence - Group contacts in the roster panel by presence.",
+ "by none - No grouping in the roster panel.",
+ "size - Percentage of the screen taken up by the roster (1-99).",
+ "add jid [nick] - Add a new item to the roster.",
+ "remove jid - Removes an item from the roster.",
+ "nick jid nick - Change a contacts nickname.",
+ "clearnick jid - Removes the current nickname.",
"Passing no arguments lists all contacts in your roster.",
- "online - Show all online contacts in your roster.",
- "show - Show the roster panel in the console window.",
- "hide - Hide the roster panel.",
- "show offline - Show offline contacts in the roster panel.",
- "hide offline - Hide offline contacts in the roster panel.",
- "show resource - Show contact's connected resources in the roster panel.",
- "hide resource - Hide contact's connected resources in the roster panel.",
- "by group - Group contacts in the roster panel by roster group.",
- "by presence - Group contacts in the roster panel by presence.",
- "by none - No grouping in the roster panel.",
- "size - Percentage of the screen taken up by the roster (1-99).",
- "add - Add a new item, jid is required, nickname is optional.",
- "remove - Removes a contact, jid is required.",
- "nick - Changes a contacts nickname, both jid and nickname are required,",
- "clearnick - Removes the current nickname, jid is required.",
- "",
- "Example : /roster (show your roster)",
- "Example : /roster add someone@contacts.org (add the contact)",
- "Example : /roster add someone@contacts.org Buddy (add the contact with nickname 'Buddy')",
- "Example : /roster remove someone@contacts.org (remove the contact)",
- "Example : /roster nick myfriend@chat.org My Friend",
- "Example : /roster clearnick kai@server.com (clears nickname)",
NULL } } },
{ "/group",
@@ -213,31 +194,22 @@ static struct cmd_t command_defs[] =
{ "/group [show|add|remove] [group] [contact]",
"------------------------------------------",
"View, add to, and remove from roster groups.",
+ "show group - List all roster items a group.",
+ "add group contact - Added a contact to a group.",
+ "remove group contact - Remove a contact from a group.",
"Passing no argument will list all roster groups.",
- "The 'show' command takes 'group' as an argument, and lists all roster items in that group.",
- "The 'add' command takes 'group' and 'contact' arguments, and adds the contact to the group.",
- "The 'remove' command takes 'group' and 'contact' arguments and removes the contact from the group,",
- "",
- "Example : /group",
- "Example : /group show friends",
- "Example : /group add friends newfriend@server.org",
- "Example : /group add family Brother (using contacts nickname)",
- "Example : /group remove colleagues boss@work.com",
NULL } } },
{ "/info",
cmd_info, parse_args, 0, 1, NULL,
- { "/info [contact|nick]", "Show basic information about a contact, room, or room member.",
+ { "/info [contact|nick]", "Show information about a contact, room, or room member.",
{ "/info [contact|nick]",
"--------------------",
- "Show basic information about a contact, room, or room member.",
- "If in the console, a contact must be specified.",
- "If in a chat window the parameter is not required, the current recipient will be used.",
- "If in a chat room, providing no arguments will display information about the room.",
- "If in a chat room, supplying a nick will show information about the occupant.",
- "",
- "Example : /info mybuddy@chat.server.org",
- "Example : /info kai",
+ "Show information about a contact, room, or room member.",
+ "contact - The contact you wish to view information about.",
+ "nick - When in a chat room, the occupant you wish to view information about.",
+ "Passing no argument in a chat window will use the current recipient.",
+ "Passing no argument in a chat room will display information about the room.",
NULL } } },
{ "/caps",
@@ -245,14 +217,10 @@ static struct cmd_t command_defs[] =
{ "/caps [fulljid|nick]", "Find out a contacts client software capabilities.",
{ "/caps [fulljid|nick]",
"--------------------",
- "Find out a contact, or room members client software capabilities.",
- "If in the console window or a regular chat window, a full JID is required.",
- "If in a chat room, the nickname is required.",
- "If in private chat, no parameter is required.",
- "",
- "Example : /caps mybuddy@chat.server.org/laptop (contact's laptop resource)",
- "Example : /caps mybuddy@chat.server.org/phone (contact's phone resource)",
- "Example : /caps bruce (room member)",
+ "Find out a contacts, or room members client software capabilities.",
+ "fulljid - If in the console or a chat window, the full JID for which you wish to see capabilities.",
+ "nick - If in a chat room, nickname for which you wish to see capabilities.",
+ "If in private chat initiated from a chat room, no parameter is required.",
NULL } } },
{ "/software",
@@ -260,15 +228,11 @@ static struct cmd_t command_defs[] =
{ "/software [fulljid|nick]", "Find out software version information about a contacts resource.",
{ "/software [fulljid|nick]",
"------------------------",
- "Find out a contact, or room members software version information, if such requests are supported.",
- "If in the console window or a regular chat window, a full JID is required.",
- "If in a chat room, the nickname is required.",
- "If in private chat, no parameter is required.",
+ "Find out a contact, or room members software version information.",
+ "fulljid - If in the console or a chat window, the full JID for which you wish to see software information.",
+ "nick - If in a chat room, nickname for which you wish to see software information.",
+ "If in private chat initiated from a chat room, no parameter is required.",
"If the contact's software does not support software version requests, nothing will be displayed.",
- "",
- "Example : /software mybuddy@chat.server.org/laptop (contact's laptop resource)",
- "Example : /software mybuddy@chat.server.org/phone (contact's phone resource)",
- "Example : /software bruce (room member)",
NULL } } },
{ "/status",
@@ -277,22 +241,21 @@ static struct cmd_t command_defs[] =
{ "/status [contact|nick]",
"----------------------",
"Find out a contact, or room members presence information.",
+ "contact - The contact who's presence you which to see.",
+ "nick - If in a chat room, the occupant who's presence you wish to see.",
"If in a chat window the parameter is not required, the current recipient will be used.",
- "",
- "Example : /status buddy@server.com",
- "Example : /status jon",
NULL } } },
{ "/resource",
cmd_resource, parse_args, 1, 2, &cons_resource_setting,
- { "/resource set|off|title|message [resource]", "Set the contact's resource.",
+ { "/resource set|off|title|message [resource]", "Set the contact's resource, display settings.",
{ "/resource set|off|title|message [resource]",
"------------------------------------------",
- "Set the resource to use when chatting to a contact and manage resource display settings.",
- "set resource - Set the resource.",
+ "Override chat session resource, and manage resource display settings.",
+ "set resource - Set the resource to which messages will be sent.",
"off - Let the server choose which resource to route messages to.",
"title on|off - Show or hide the current resource in the titlebar.",
- "message on|off - Show or hide the resource from which a message was recieved.",
+ "message on|off - Show or hide the resource when showing an incoming message.",
NULL } } },
{ "/join",
@@ -301,15 +264,12 @@ static struct cmd_t command_defs[] =
{ "/join room[@server] [nick value] [password value]",
"-------------------------------------------------",
"Join a chat room at the conference server.",
- "If nick is specified you will join with this nickname.",
- "Otherwise the account preference 'muc.nick' will be used which by default is the localpart of your JID (before the @).",
- "If no server is supplied, the account preference 'muc.service' is used, which is 'conference.' by default.",
+ "room - Bare room JID, the chat server is determined by the 'muc.service' account property, 'conference.' by default.",
+ "room@server - Full room JID.",
+ "nick value - Nickname to use in the room",
+ "password value - Password if the room requires it.",
+ "If no nickname is specfied the account preference 'muc.nick' will be used which by default is the localpart of your JID.",
"If the room doesn't exist, and the server allows it, a new one will be created.",
- "",
- "Example : /join jdev@conference.jabber.org",
- "Example : /join jdev@conference.jabber.org nick mynick",
- "Example : /join private@conference.jabber.org nick mynick password mypassword",
- "Example : /join jdev (as user@jabber.org will join jdev@conference.jabber.org)",
NULL } } },
{ "/leave",
@@ -325,8 +285,9 @@ static struct cmd_t command_defs[] =
{ "/invite contact [message]", "Invite contact to chat room.",
{ "/invite contact [message]",
"-------------------------",
- "Send a direct invite to the specified contact to the current chat room.",
- "If a message is supplied it will be sent as the reason for the invite.",
+ "Send a direct invite to the current chat room.",
+ "contact - The contact you wish to invite",
+ "message - An optional message to send with the invite.",
NULL } } },
{ "/invites",
@@ -334,9 +295,7 @@ static struct cmd_t command_defs[] =
{ "/invites", "Show outstanding chat room invites.",
{ "/invites",
"--------",
- "Show all rooms that you have been invited to, and have not yet been accepted or declind.",
- "Use \"/join \" to accept a room invitation.",
- "Use \"/decline \" to decline a room invitation.",
+ "Show all rooms that you have been invited to, and not accepted or declind.",
NULL } } },
{ "/decline",
@@ -344,7 +303,8 @@ static struct cmd_t command_defs[] =
{ "/decline room", "Decline a chat room invite.",
{ "/decline room",
"-------------",
- "Decline invitation to a chat room, the room will no longer be in the list of outstanding invites.",
+ "Decline a chat room ivivation.",
+ "room - The room for the invite you wish to decline.",
NULL } } },
{ "/room",
@@ -352,6 +312,7 @@ static struct cmd_t command_defs[] =
{ "/room accept|destroy|config", "Room configuration.",
{ "/room accept|destroy|config",
"---------------------------",
+ "Chat room configuration.",
"accept - Accept default room configuration.",
"destroy - Reject default room configuration.",
"config - Edit room configuration.",
@@ -362,6 +323,7 @@ static struct cmd_t command_defs[] =
{ "/kick nick [reason]", "Kick occupants from chat rooms.",
{ "/kick nick [reason]",
"-------------------",
+ "Kick occupants from chat rooms.",
"nick - Nickname of the occupant to kick from the room.",
"reason - Optional reason for kicking the occupant.",
NULL } } },
@@ -371,6 +333,7 @@ static struct cmd_t command_defs[] =
{ "/ban jid [reason]", "Ban users from chat rooms.",
{ "/ban jid [reason]",
"-----------------",
+ "Ban users from chat rooms.",
"jid - Bare JID of the user to ban from the room.",
"reason - Optional reason for banning the user.",
NULL } } },
@@ -380,6 +343,7 @@ static struct cmd_t command_defs[] =
{ "/subject set|clear [subject]", "Set or clear room subject.",
{ "/subject set|clear [subject]",
"----------------------------",
+ "Set or clear room subject.",
"set subject - Set the room subject.",
"clear - Clear the room subject.",
NULL } } },
@@ -389,6 +353,7 @@ static struct cmd_t command_defs[] =
{ "/affiliation set|list [affiliation] [jid] [reason]", "Manage room affiliations.",
{ "/affiliation set|list [affiliation] [jid] [reason]",
"--------------------------------------------------",
+ "Manage room affiliations.",
"set affiliation jid [reason]- Set the affiliation of user with jid, with an optional reason.",
"list [affiliation] - List all users with the specified affiliation, or all if none specified.",
"The affiliation may be one of owner, admin, member, outcast or none.",
@@ -399,6 +364,7 @@ static struct cmd_t command_defs[] =
{ "/role set|list [role] [nick] [reason]", "Manage room roles.",
{ "/role set|list [role] [nick] [reason]",
"-------------------------------------",
+ "Manage room roles.",
"set role nick [reason] - Set the role of occupant with nick, with an optional reason.",
"list [role] - List all occupants with the specified role, or all if none specified.",
"The role may be one of moderator, participant, visitor or none.",
@@ -409,10 +375,11 @@ static struct cmd_t command_defs[] =
{ "/occupants show|hide|default|size [show|hide] [percent]", "Show or hide room occupants.",
{ "/occupants show|hide|default|size [show|hide] [percent]",
"-------------------------------------------------------",
- "show - Show the occupants panel in chat rooms.",
- "hide - Hide the occupants panel in chat rooms.",
- "default - Whether occupants are shown by default in new rooms, 'show' or 'hide'",
- "size - Percentage of the screen taken by the occupants list in rooms (1-99).",
+ "Show or hide room occupants, and occupants panel display settings.",
+ "show - Show the occupants panel in chat rooms.",
+ "hide - Hide the occupants panel in chat rooms.",
+ "default show|hide - Whether occupants are shown by default in new rooms, 'show' or 'hide'",
+ "size percent - Percentage of the screen taken by the occupants list in rooms (1-99).",
NULL } } },
{ "/form",
@@ -420,13 +387,14 @@ static struct cmd_t command_defs[] =
{ "/form show|submit|cancel|help [tag]", "Form handling.",
{ "/form show|submit|cancel|help [tag]",
"-----------------------------------",
+ "Form configuration."
"show - Show the current form.",
"submit - Submit the current form.",
"cancel - Cancel changes to the current form.",
"help [tag] - Display help for form, or a specific field.",
NULL } } },
- { "/rooms",
+ { "/rooms", // TODO help review
cmd_rooms, parse_args, 0, 1, NULL,
{ "/rooms [conference-service]", "List chat rooms.",
{ "/rooms [conference-service]",
@@ -3051,4 +3019,4 @@ command_docgen(void)
fclose(toc_fragment);
fclose(main_fragment);
g_list_free(cmds);
-}
\ No newline at end of file
+}
From c9a6e10c2621a5df3285c881fa98eb00707fc6ad Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sat, 14 Feb 2015 16:20:15 +0000
Subject: [PATCH 086/252] Use single quotes for terminal notifier notifications
to avoid variable expansion
---
src/ui/notifier.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index 693817d6..e8bc61e3 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -243,10 +243,9 @@ _notify(const char * const message, int timeout,
Shell_NotifyIcon(NIM_MODIFY, &nid);
#endif
#ifdef HAVE_OSXNOTIFY
- GString *notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message \"");
+ GString *notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message '");
- char *escaped_double = str_replace(message, "\"", "\\\"");
- char *escaped_single = str_replace(escaped_double, "`", "\\`");
+ char *escaped_single = str_replace(message, "'", "'\\''");
if (escaped_single[0] == '<') {
g_string_append(notify_command, "\\<");
@@ -264,8 +263,7 @@ _notify(const char * const message, int timeout,
g_string_append(notify_command, escaped_single);
}
- g_string_append(notify_command, "\"");
- free(escaped_double);
+ g_string_append(notify_command, "'");
free(escaped_single);
char *term_name = getenv("TERM_PROGRAM");
@@ -288,4 +286,4 @@ _notify(const char * const message, int timeout,
g_string_free(notify_command, TRUE);
#endif
-}
\ No newline at end of file
+}
From 2605b84a7043d98f105f18a0866776e021be81f2 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 16 Feb 2015 22:37:17 +0000
Subject: [PATCH 087/252] Tidy help
---
src/command/command.c | 186 ++++++++++++++++++++++++------------------
1 file changed, 107 insertions(+), 79 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index 491bf5f2..81633443 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -116,8 +116,10 @@ static struct cmd_t command_defs[] =
{ "/help [area|command]",
"--------------------",
"Help on using Profanity.",
+ "",
"area - Summary help for commands in a certain area of functionality.",
"command - Full help for a specific command, for example '/help connect'.",
+ "",
"Use with no arguments to see a list of areas.",
NULL } } },
@@ -135,9 +137,11 @@ static struct cmd_t command_defs[] =
{ "/connect [account] [server value] [port value]",
"----------------------------------------------",
"Login to a chat service.",
+ "",
"account - The local account you wish to connect with, or a JID if connecting for the first time.",
"server value - Supply a server if it is different to the domain part of your JID.",
"port value - The port to use if different to the default (5222, or 5223 for SSL).",
+ "",
"If no account is specified, the default is used if one is configured.",
"A local account is created with the JID as it's name if it doesn't already exist.",
NULL } } },
@@ -156,9 +160,11 @@ static struct cmd_t command_defs[] =
{ "/msg contact|nick [message]",
"---------------------------",
"Send a one to one chat message, or a private message to a chat room occupant.",
+ "",
"contact - The contact's JID, or nickname if one has been set in your roster.",
"nick - A chat room occupant, to whom you wish to send a private message.",
"message - The message to send",
+ "",
"If the message is omitted, a new chat window will be opened without sending a message.",
"Use quotes if the nickname includes spaces.",
NULL } } },
@@ -169,7 +175,9 @@ static struct cmd_t command_defs[] =
{ "/roster [command] [args..]",
"--------------------------",
"Manage your roster, and roster display settings.",
+ "",
"command - online|show|hide|by|size|add|remove|nick|clearnick",
+ "",
"online - Show all online contacts in your roster.",
"show - Show the roster panel.",
"show offline - Show offline contacts in the roster panel.",
@@ -185,6 +193,7 @@ static struct cmd_t command_defs[] =
"remove jid - Removes an item from the roster.",
"nick jid nick - Change a contacts nickname.",
"clearnick jid - Removes the current nickname.",
+ "",
"Passing no arguments lists all contacts in your roster.",
NULL } } },
@@ -194,9 +203,11 @@ static struct cmd_t command_defs[] =
{ "/group [show|add|remove] [group] [contact]",
"------------------------------------------",
"View, add to, and remove from roster groups.",
+ "",
"show group - List all roster items a group.",
"add group contact - Added a contact to a group.",
"remove group contact - Remove a contact from a group.",
+ "",
"Passing no argument will list all roster groups.",
NULL } } },
@@ -206,8 +217,10 @@ static struct cmd_t command_defs[] =
{ "/info [contact|nick]",
"--------------------",
"Show information about a contact, room, or room member.",
+ "",
"contact - The contact you wish to view information about.",
"nick - When in a chat room, the occupant you wish to view information about.",
+ "",
"Passing no argument in a chat window will use the current recipient.",
"Passing no argument in a chat room will display information about the room.",
NULL } } },
@@ -218,8 +231,10 @@ static struct cmd_t command_defs[] =
{ "/caps [fulljid|nick]",
"--------------------",
"Find out a contacts, or room members client software capabilities.",
+ "",
"fulljid - If in the console or a chat window, the full JID for which you wish to see capabilities.",
"nick - If in a chat room, nickname for which you wish to see capabilities.",
+ "",
"If in private chat initiated from a chat room, no parameter is required.",
NULL } } },
@@ -229,8 +244,10 @@ static struct cmd_t command_defs[] =
{ "/software [fulljid|nick]",
"------------------------",
"Find out a contact, or room members software version information.",
+ "",
"fulljid - If in the console or a chat window, the full JID for which you wish to see software information.",
"nick - If in a chat room, nickname for which you wish to see software information.",
+ "",
"If in private chat initiated from a chat room, no parameter is required.",
"If the contact's software does not support software version requests, nothing will be displayed.",
NULL } } },
@@ -241,8 +258,10 @@ static struct cmd_t command_defs[] =
{ "/status [contact|nick]",
"----------------------",
"Find out a contact, or room members presence information.",
+ "",
"contact - The contact who's presence you which to see.",
"nick - If in a chat room, the occupant who's presence you wish to see.",
+ "",
"If in a chat window the parameter is not required, the current recipient will be used.",
NULL } } },
@@ -252,6 +271,7 @@ static struct cmd_t command_defs[] =
{ "/resource set|off|title|message [resource]",
"------------------------------------------",
"Override chat session resource, and manage resource display settings.",
+ "",
"set resource - Set the resource to which messages will be sent.",
"off - Let the server choose which resource to route messages to.",
"title on|off - Show or hide the current resource in the titlebar.",
@@ -264,10 +284,12 @@ static struct cmd_t command_defs[] =
{ "/join room[@server] [nick value] [password value]",
"-------------------------------------------------",
"Join a chat room at the conference server.",
+ "",
"room - Bare room JID, the chat server is determined by the 'muc.service' account property, 'conference.' by default.",
"room@server - Full room JID.",
"nick value - Nickname to use in the room",
"password value - Password if the room requires it.",
+ "",
"If no nickname is specfied the account preference 'muc.nick' will be used which by default is the localpart of your JID.",
"If the room doesn't exist, and the server allows it, a new one will be created.",
NULL } } },
@@ -286,6 +308,7 @@ static struct cmd_t command_defs[] =
{ "/invite contact [message]",
"-------------------------",
"Send a direct invite to the current chat room.",
+ "",
"contact - The contact you wish to invite",
"message - An optional message to send with the invite.",
NULL } } },
@@ -304,6 +327,7 @@ static struct cmd_t command_defs[] =
{ "/decline room",
"-------------",
"Decline a chat room ivivation.",
+ "",
"room - The room for the invite you wish to decline.",
NULL } } },
@@ -313,6 +337,7 @@ static struct cmd_t command_defs[] =
{ "/room accept|destroy|config",
"---------------------------",
"Chat room configuration.",
+ "",
"accept - Accept default room configuration.",
"destroy - Reject default room configuration.",
"config - Edit room configuration.",
@@ -324,6 +349,7 @@ static struct cmd_t command_defs[] =
{ "/kick nick [reason]",
"-------------------",
"Kick occupants from chat rooms.",
+ "",
"nick - Nickname of the occupant to kick from the room.",
"reason - Optional reason for kicking the occupant.",
NULL } } },
@@ -334,6 +360,7 @@ static struct cmd_t command_defs[] =
{ "/ban jid [reason]",
"-----------------",
"Ban users from chat rooms.",
+ "",
"jid - Bare JID of the user to ban from the room.",
"reason - Optional reason for banning the user.",
NULL } } },
@@ -344,6 +371,7 @@ static struct cmd_t command_defs[] =
{ "/subject set|clear [subject]",
"----------------------------",
"Set or clear room subject.",
+ "",
"set subject - Set the room subject.",
"clear - Clear the room subject.",
NULL } } },
@@ -354,8 +382,10 @@ static struct cmd_t command_defs[] =
{ "/affiliation set|list [affiliation] [jid] [reason]",
"--------------------------------------------------",
"Manage room affiliations.",
+ "",
"set affiliation jid [reason]- Set the affiliation of user with jid, with an optional reason.",
"list [affiliation] - List all users with the specified affiliation, or all if none specified.",
+ "",
"The affiliation may be one of owner, admin, member, outcast or none.",
NULL } } },
@@ -365,8 +395,10 @@ static struct cmd_t command_defs[] =
{ "/role set|list [role] [nick] [reason]",
"-------------------------------------",
"Manage room roles.",
+ "",
"set role nick [reason] - Set the role of occupant with nick, with an optional reason.",
"list [role] - List all occupants with the specified role, or all if none specified.",
+ "",
"The role may be one of moderator, participant, visitor or none.",
NULL } } },
@@ -376,6 +408,7 @@ static struct cmd_t command_defs[] =
{ "/occupants show|hide|default|size [show|hide] [percent]",
"-------------------------------------------------------",
"Show or hide room occupants, and occupants panel display settings.",
+ "",
"show - Show the occupants panel in chat rooms.",
"hide - Hide the occupants panel in chat rooms.",
"default show|hide - Whether occupants are shown by default in new rooms, 'show' or 'hide'",
@@ -387,7 +420,8 @@ static struct cmd_t command_defs[] =
{ "/form show|submit|cancel|help [tag]", "Form handling.",
{ "/form show|submit|cancel|help [tag]",
"-----------------------------------",
- "Form configuration."
+ "Form configuration.",
+ "",
"show - Show the current form.",
"submit - Submit the current form.",
"cancel - Cancel changes to the current form.",
@@ -400,45 +434,43 @@ static struct cmd_t command_defs[] =
{ "/rooms [conference-service]",
"---------------------------",
"List the chat rooms available at the specified conference service",
- "If no argument is supplied, the account preference 'muc.service' is used, which is 'conference.' by default.",
"",
- "Example : /rooms conference.jabber.org",
- "Example : /rooms (if logged in as me@server.org, is equivalent to /rooms conference.server.org)",
+ "conference-service - The conference service to query.",
+ "",
+ "If no argument is supplied, the account preference 'muc.service' is used, 'conference.' by default.",
NULL } } },
{ "/bookmark",
cmd_bookmark, parse_args, 0, 8, NULL,
- { "/bookmark [list|add|update|remove|join] [room@server] [nick value] [password value] [autojoin on|off]", "Manage bookmarks.",
- { "/bookmark [list|add|update|remove|join] [room@server] [nick value] [password value] [autojoin on|off]",
- "---------------------------------------------------------------------------------------------------",
- "Manage bookmarks.",
- "list: List all bookmarks.",
- "add: Add a bookmark for room@server with the following optional properties:",
- " nick: Nickname used in the chat room",
- " password: Password for private rooms, note this may be stored in plaintext on your server",
- " autojoin: Whether to join the room automatically on login \"on\" or \"off\".",
- "update: Update any of the above properties associated with the bookmark.",
- "remove: Remove the bookmark for room@server.",
- "join: Join room@server using the properties associated with the bookmark.",
- "When in a chat room, the /bookmark command with no arguments will bookmark the current room with the current settings, and set autojoin to \"on\".",
+ { "/bookmark [command] [args..]", "Manage bookmarks.",
+ { "/bookmark [command] [args..]",
+ "----------------------------",
+ "Manage bookmarks and join bookmarked rooms.",
+ "",
+ "command - list|add|update|remove|join",
+ "",
+ "list - List all bookmarks.",
+ "add room@server [prop value..] - Add a bookmark for room@server with the following optional properties:",
+ " nick value - Nickname used in the chat room",
+ " password value - Password if required, may be stored in plaintext on your server",
+ " autojoin on|off - Whether to join the room automatically on login.",
+ "update room@server [prop value..] - Update any of the above properties associated with the bookmark.",
+ "remove room@server - Remove the bookmark for room@server.",
+ "join room@server - Join room using the properties associated with the bookmark.",
+ "",
+ "In a chat room, /bookmark with no arguments will bookmark the current room, setting autojoin to \"on\".",
NULL } } },
{ "/disco",
cmd_disco, parse_args, 1, 2, NULL,
- { "/disco command entity", "Service discovery.",
- { "/disco command entity",
+ { "/disco info|items entity", "Service discovery.",
+ { "/disco info|items entity",
"---------------------",
"Find out information about an entities supported services.",
- "Command may be one of:",
- "info: List protocols and features supported by an entity.",
- "items: List items associated with an entity.",
"",
- "The entity must be a Jabber ID.",
- "",
- "Example : /disco info myserver.org",
- "Example : /disco items myserver.org",
- "Example : /disco items conference.jabber.org",
- "Example : /disco info myfriend@server.com/laptop",
+ "info - List protocols and features supported by an entity.",
+ "items - List items associated with an entity.",
+ "entity - Jabber ID.",
NULL } } },
{ "/nick",
@@ -447,52 +479,49 @@ static struct cmd_t command_defs[] =
{ "/nick nickname",
"--------------",
"Change the name by which other members of a chat room see you.",
- "This command is only valid when called within a chat room window.",
"",
- "Example : /nick kai hansen",
- "Example : /nick bob",
+ "nickname - The new nickname.",
NULL } } },
{ "/win",
cmd_win, parse_args, 1, 1, NULL,
{ "/win num", "View a window.",
{ "/win num",
- "------------------",
+ "--------",
"Show the contents of a specific window in the main window area.",
+ "",
+ "num - Window number to display.",
NULL } } },
{ "/wins",
cmd_wins, parse_args, 0, 3, NULL,
- { "/wins [tidy|prune|swap] [source] [target]", "List or tidy active windows.",
- { "/wins [tidy|prune|swap] [source] [target]",
- "-----------------------------------------",
+ { "/wins [tidy|prune|swap] [source target]", "List or tidy active windows.",
+ { "/wins [tidy|prune|swap] [source target]",
+ "---------------------------------------",
+ "Show a list of windows, or tidy or swap.",
+ "",
+ "tidy - Move windows so there are no gaps.",
+ "prune - Close all windows with no unread messages, and then tidy as above.",
+ "swap source target - Swap windows, target may be an empty position.",
+ "",
"Passing no argument will list all currently active windows and information about their usage.",
- "tidy : Shuffle windows so there are no gaps.",
- "prune : Close all windows with no unread messages, and then tidy as above.",
- "swap source target : Swap windows, target may be an empty position.",
NULL } } },
{ "/sub",
cmd_sub, parse_args, 1, 2, NULL,
- { "/sub command [jid]", "Manage subscriptions.",
- { "/sub command [jid]",
- "------------------",
- "command : One of the following,",
- "request : Send a subscription request to the user to be informed of their",
- " : presence.",
- "allow : Approve a contact's subscription reqeust to see your presence.",
- "deny : Remove subscription for a contact, or deny a request",
- "show : Show subscriprion status for a contact.",
- "sent : Show all sent subscription requests pending a response.",
- "received : Show all received subscription requests awaiting your response.",
+ { "/sub request|allow|deny|show|sent|received [jid]", "Manage subscriptions.",
+ { "/sub request|allow|deny|show|sent|received [jid]",
+ "------------------------------------------------",
+ "Manage subscriptions to contact presence.",
"",
- "The optional 'jid' parameter only applys to 'request', 'allow', 'deny' and 'show'",
- "If it is omitted the contact of the current window is used.",
+ "request [jid] - Send a subscription request to the user.",
+ "allow [jid] - Approve a contact's subscription reqeust.",
+ "deny [jid] - Remove subscription for a contact, or deny a request",
+ "show [jid] - Show subscriprion status for a contact.",
+ "sent - Show all sent subscription requests pending a response.",
+ "received - Show all received subscription requests awaiting your response.",
"",
- "Example: /sub request myfriend@jabber.org",
- "Example: /sub allow myfriend@jabber.org",
- "Example: /sub request (whilst in chat with contact)",
- "Example: /sub sent",
+ "If jid is omitted, the contact of the current window is used.",
NULL } } },
{ "/tiny",
@@ -500,9 +529,9 @@ static struct cmd_t command_defs[] =
{ "/tiny url", "Send url as tinyurl in current chat.",
{ "/tiny url",
"---------",
- "Send the url as a tiny url.",
+ "Send url as tinyurl in current chat.",
"",
- "Example : /tiny http://www.profanity.im",
+ "url - The url to make tiny.",
NULL } } },
{ "/who",
@@ -510,31 +539,30 @@ static struct cmd_t command_defs[] =
{ "/who [status|role|affiliation] [group]", "Show contacts/room occupants with chosen status, role or affiliation",
{ "/who [status|role|affiliation] [group]",
"--------------------------------------",
- "Normal usage:",
- "Status may be one of - online, offline, away, dnd, xa, chat, available, unavailable, or any where:",
- "online : Contacts that are online, chat, away, xa, dnd",
- "available : Contacts that are available for chat - online, chat.",
- "unavailable : Contacts that are not available for chat - offline, away, xa, dnd.",
- "any : Contacts with any status (same as calling with no argument).",
+ "Show contacts/room occupants with chosen status, role or affiliation",
"",
- "The group argument filters the list by that group.",
- "",
- "In a chat room, a role or affiliation may also be supplied instead of status.",
- "Roles: moderator, participant, visitor",
- "Affiliations: owner, admin, member",
+ "status - online|offline|away|dnd|xa|chat|available|unavailable|any",
+ " online - Contacts that are online, chat, away, xa, dnd",
+ " available - Contacts that are available for chat - online, chat.",
+ " unavailable - Contacts that are not available for chat - offline, away, xa, dnd.",
+ " any - Contacts with any status (same as calling with no argument).",
+ "role - moderator|participant|visitor",
+ "affiliation - owner|admin|member",
+ "group - Filter the results by the specfied group.",
NULL } } },
{ "/close",
cmd_close, parse_args, 0, 1, NULL,
- { "/close [win|read|all]", "Close windows.",
- { "/close [win|read|all]",
+ { "/close [num|read|all]", "Close windows.",
+ { "/close [num|read|all]",
"---------------------",
+ "Close the current window, or a number of windows.",
+ "",
+ "num - Close the specified window.",
+ "all - Close all windows.",
+ "read - Close all windows that have no new messages.",
+ "",
"Passing no argument will close the current window.",
- "2,3,4,5,6,7,8,9 or 0 : Close the specified window.",
- "all : Close all currently open windows.",
- "read : Close all windows that have no new messages.",
- "The console window cannot be closed.",
- "If in a chat room, you will leave the room.",
NULL } } },
{ "/clear",
@@ -557,8 +585,8 @@ static struct cmd_t command_defs[] =
cmd_privileges, parse_args, 1, 1, &cons_privileges_setting,
{ "/privileges on|off", "Show occupant privileges in chat rooms.",
{ "/privileges on|off",
- "---------------------------",
- "If enabled the room roster will be broken down my role, and role information will be showin in the room.",
+ "------------------",
+ "If enabled the room occupants panel will be grouped by role, and role information will be shown in the room.",
NULL } } },
{ "/beep",
@@ -576,7 +604,7 @@ static struct cmd_t command_defs[] =
{ "/presence on|off", "Show the contacts presence in the titlebar.",
{ "/presence on|off",
"----------------",
- "Switch display of the contacts presence on or off.",
+ "Switch display of the contacts presence in the titlebar on or off.",
NULL } } },
{ "/wrap",
@@ -595,7 +623,7 @@ static struct cmd_t command_defs[] =
"Configure time precision for the main window.",
NULL } } },
- { "/inpblock",
+ { "/inpblock", // TODO review
cmd_inpblock, parse_args, 2, 2, &cons_inpblock_setting,
{ "/inpblock timeout|dynamic [millis|on|off]", "Input blocking delay (dynamic or static).",
{ "/inpblock timeout|dynamic [millis|on|off]",
From 0997bafeb99541fff67765506392209ef2ce1ef1 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 16 Feb 2015 22:52:18 +0000
Subject: [PATCH 088/252] Removed comment
---
src/command/command.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/command/command.c b/src/command/command.c
index 81633443..4411487d 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -428,7 +428,7 @@ static struct cmd_t command_defs[] =
"help [tag] - Display help for form, or a specific field.",
NULL } } },
- { "/rooms", // TODO help review
+ { "/rooms",
cmd_rooms, parse_args, 0, 1, NULL,
{ "/rooms [conference-service]", "List chat rooms.",
{ "/rooms [conference-service]",
From a1d14c4526a8d47adeef254cf0ae9142ae2b13b3 Mon Sep 17 00:00:00 2001
From: Christian Storm
Date: Tue, 17 Feb 2015 10:52:37 +0100
Subject: [PATCH 089/252] Fixed spelling.
---
src/chat_session.c | 2 +-
src/command/command.c | 32 ++++++++++++++++----------------
src/config/accounts.c | 2 +-
src/muc.c | 2 +-
src/roster_list.c | 10 +++++-----
src/tools/parser.c | 10 +++++-----
src/ui/console.c | 2 +-
src/ui/core.c | 8 ++++----
src/ui/statusbar.c | 4 ++--
src/ui/window.c | 2 +-
src/xmpp/presence.c | 2 +-
11 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/src/chat_session.c b/src/chat_session.c
index 555452cb..8ce2e437 100644
--- a/src/chat_session.c
+++ b/src/chat_session.c
@@ -141,7 +141,7 @@ chat_session_recipient_active(const char * const barejid, const char * const res
// session exists with resource, update chat_states
if (g_strcmp0(session->resource, resource) == 0) {
session->send_states = send_states;
- // session exists with differet resource and no override, replace
+ // session exists with different resource and no override, replace
} else if (!session->resource_override) {
_chat_session_new(barejid, resource, FALSE, send_states);
}
diff --git a/src/command/command.c b/src/command/command.c
index 4411487d..944a9b8d 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -290,7 +290,7 @@ static struct cmd_t command_defs[] =
"nick value - Nickname to use in the room",
"password value - Password if the room requires it.",
"",
- "If no nickname is specfied the account preference 'muc.nick' will be used which by default is the localpart of your JID.",
+ "If no nickname is specified the account preference 'muc.nick' will be used which by default is the localpart of your JID.",
"If the room doesn't exist, and the server allows it, a new one will be created.",
NULL } } },
@@ -318,7 +318,7 @@ static struct cmd_t command_defs[] =
{ "/invites", "Show outstanding chat room invites.",
{ "/invites",
"--------",
- "Show all rooms that you have been invited to, and not accepted or declind.",
+ "Show all rooms that you have been invited to, and not accepted or declined.",
NULL } } },
{ "/decline",
@@ -326,7 +326,7 @@ static struct cmd_t command_defs[] =
{ "/decline room", "Decline a chat room invite.",
{ "/decline room",
"-------------",
- "Decline a chat room ivivation.",
+ "Decline a chat room invitation.",
"",
"room - The room for the invite you wish to decline.",
NULL } } },
@@ -515,9 +515,9 @@ static struct cmd_t command_defs[] =
"Manage subscriptions to contact presence.",
"",
"request [jid] - Send a subscription request to the user.",
- "allow [jid] - Approve a contact's subscription reqeust.",
+ "allow [jid] - Approve a contact's subscription request.",
"deny [jid] - Remove subscription for a contact, or deny a request",
- "show [jid] - Show subscriprion status for a contact.",
+ "show [jid] - Show subscription status for a contact.",
"sent - Show all sent subscription requests pending a response.",
"received - Show all received subscription requests awaiting your response.",
"",
@@ -548,7 +548,7 @@ static struct cmd_t command_defs[] =
" any - Contacts with any status (same as calling with no argument).",
"role - moderator|participant|visitor",
"affiliation - owner|admin|member",
- "group - Filter the results by the specfied group.",
+ "group - Filter the results by the specified group.",
NULL } } },
{ "/close",
@@ -633,24 +633,24 @@ static struct cmd_t command_defs[] =
" : Valid values are 1-1000.",
"dynamic : Start with a 0 timeout and increase the value dynamically up to the specified 'timeout'.",
" : on|off",
- "A higher timeout will result in less CPU usage, but a noticable delay for response to input.",
+ "A higher timeout will result in less CPU usage, but a noticeable delay for response to input.",
"A lower timeout will result in higher CPU usage, but faster response to input.",
"Using the dynamic setting, higher CPU usage will occur during activity, but over time the CPU usage will decrease whilst there is no activity.",
NULL } } },
{ "/notify",
cmd_notify, parse_args, 2, 3, &cons_notify_setting,
- { "/notify [type value]|[type setting value]", "Control various desktop noficiations.",
+ { "/notify [type value]|[type setting value]", "Control various desktop notifications.",
{ "/notify [type value]|[type setting value]",
"-----------------------------------------",
"Settings for various desktop notifications where type is one of:",
- "message : Notificaitons for regular messages.",
+ "message : Notifications for regular messages.",
" : on|off",
"message current : Whether messages in the current window trigger notifications.",
" : on|off",
"message text : Show message text in message notifications.",
" : on|off",
- "room : Notificaitons for chat room messages.",
+ "room : Notifications for chat room messages.",
" : on|off|mention",
"room current : Whether chat room messages in the current window trigger notifications.",
" : on|off",
@@ -661,7 +661,7 @@ static struct cmd_t command_defs[] =
" : use 0 to disable.",
"typing : Notifications when contacts are typing.",
" : on|off",
- "typing current : Whether typing notifications are triggerd for the current window.",
+ "typing current : Whether typing notifications are triggered for the current window.",
" : on|off",
"invite : Notifications for chat room invites.",
" : on|off",
@@ -742,7 +742,7 @@ static struct cmd_t command_defs[] =
{ "/mouse on|off",
"-------------",
"If set to 'on', profanity will handle mouse actions, which enables scrolling the main window with the mouse wheel.",
- "To select text, use the shift key while selcting an area.",
+ "To select text, use the shift key while selecting an area.",
"If set to 'off', profanity leaves mouse handling to the terminal implementation.",
"This feature is experimental, certain mouse click events may occasionally freeze",
"Profanity until a key is pressed or another mouse event is received",
@@ -804,13 +804,13 @@ static struct cmd_t command_defs[] =
"start [contact] - Start an OTR session with the contact, or the current recipient if in a chat window and no argument supplied.",
"end - End the current OTR session,",
"trust - Indicate that you have verified the contact's fingerprint.",
- "untrust - Indicate the the contact's fingerprint is not verified,",
+ "untrust - Indicate the contact's fingerprint is not verified,",
"log - How to log OTR messages, options are 'on', 'off' and 'redact', with redaction being the default.",
"warn - Show when unencrypted messaging is being used in the title bar, options are 'on' and 'off' with 'on' being the default.",
"libver - Show which version of the libotr library is being used.",
"policy - manual, opportunistic or always.",
"secret [secret]- Verify a contacts identity using a shared secret.",
- "question [question] [answer] - Verify a contacts identity using a question and expected anwser, if the question has spaces, surround with double quotes.",
+ "question [question] [answer] - Verify a contacts identity using a question and expected answer, if the question has spaces, surround with double quotes.",
"answer [answer] - Respond to a question answer verification request with your answer.",
NULL } } },
@@ -876,9 +876,9 @@ static struct cmd_t command_defs[] =
{ "/ping",
cmd_ping, parse_args, 0, 1, NULL,
{ "/ping [target]", "Send ping IQ request.",
- { "/ping [rarget]",
+ { "/ping [target]",
"--------------",
- "Sends an IQ ping stanza to the specificed target.",
+ "Sends an IQ ping stanza to the specified target.",
"If no target is supplied, your chat server will be used.",
NULL } } },
diff --git a/src/config/accounts.c b/src/config/accounts.c
index dd0d6eb4..6c04549c 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -828,7 +828,7 @@ _fix_legacy_accounts(const char * const account_name)
_save_accounts();
}
- // acounts with no muc service or nick
+ // accounts with no muc service or nick
if (!g_key_file_has_key(accounts, account_name, "muc.service", NULL)) {
gchar *account_jid = g_key_file_get_string(accounts, account_name, "jid", NULL);
Jid *jidp = jid_create(account_jid);
diff --git a/src/muc.c b/src/muc.c
index 0d606873..ea4ae915 100644
--- a/src/muc.c
+++ b/src/muc.c
@@ -315,7 +315,7 @@ muc_nick_change_pending(const char * const room)
}
/*
- * Change the current nuck name for the room, call once
+ * Change the current nick name for the room, call once
* the service has responded
*/
void
diff --git a/src/roster_list.c b/src/roster_list.c
index 4ec5ea4f..b9a142cb 100644
--- a/src/roster_list.c
+++ b/src/roster_list.c
@@ -286,7 +286,7 @@ roster_get_contacts_by_presence(const char * const presence)
}
}
- // resturn all contact structs
+ // return all contact structs
return result;
}
@@ -303,7 +303,7 @@ roster_get_contacts(void)
result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_contacts);
}
- // resturn all contact structs
+ // return all contact structs
return result;
}
@@ -321,7 +321,7 @@ roster_get_contacts_online(void)
result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_contacts);
}
- // resturn all contact structs
+ // return all contact structs
return result;
}
@@ -371,7 +371,7 @@ roster_get_nogroup(void)
}
}
- // resturn all contact structs
+ // return all contact structs
return result;
}
@@ -395,7 +395,7 @@ roster_get_group(const char * const group)
}
}
- // resturn all contact structs
+ // return all contact structs
return result;
}
diff --git a/src/tools/parser.c b/src/tools/parser.c
index 98fc21d4..1f8a5220 100644
--- a/src/tools/parser.c
+++ b/src/tools/parser.c
@@ -47,9 +47,9 @@
*
* inp - The line of input
* min - The minimum allowed number of arguments
- * max - The maxmimum allowed number of arguments
+ * max - The maximum allowed number of arguments
*
- * Returns - An NULL terminated array of strings representing the aguments
+ * Returns - An NULL terminated array of strings representing the arguments
* of the command, or NULL if the validation fails.
*
* E.g. the following input line:
@@ -69,7 +69,7 @@ parse_args(const char * const inp, int min, int max, gboolean *result)
return NULL;
}
- // copy and strip input of leading/trailing whitepsace
+ // copy and strip input of leading/trailing whitespace
char *copy = strdup(inp);
g_strstrip(copy);
@@ -181,9 +181,9 @@ parse_args(const char * const inp, int min, int max, gboolean *result)
*
* inp - The line of input
* min - The minimum allowed number of arguments
- * max - The maxmimum allowed number of arguments
+ * max - The maximum allowed number of arguments
*
- * Returns - An NULL terminated array of strings representing the aguments
+ * Returns - An NULL terminated array of strings representing the arguments
* of the command, or NULL if the validation fails.
*
* E.g. the following input line:
diff --git a/src/ui/console.c b/src/ui/console.c
index 01d1c73a..ef7df667 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -723,7 +723,7 @@ cons_show_account(ProfAccount *account)
if (curr != NULL) {
win_save_println(console, "Resources:");
- // sort in order of availabiltiy
+ // sort in order of availability
while (curr != NULL) {
Resource *resource = curr->data;
ordered_resources = g_list_insert_sorted(ordered_resources,
diff --git a/src/ui/core.c b/src/ui/core.c
index fc6c0ed4..b5d32c73 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1871,7 +1871,7 @@ ui_room_message(const char * const roomjid, const char * const nick,
if (wins_is_current(window)) {
status_bar_active(num);
- // not currenlty on groupchat window
+ // not currently on groupchat window
} else {
status_bar_new(num);
cons_show_incoming_message(nick, num);
@@ -1955,7 +1955,7 @@ ui_room_requires_config(const char * const roomjid)
if (wins_is_current(window)) {
status_bar_active(num);
- // not currenlty on groupchat window
+ // not currently on groupchat window
} else {
status_bar_new(num);
}
@@ -2096,7 +2096,7 @@ ui_room_subject(const char * const roomjid, const char * const nick, const char
if (wins_is_current(window)) {
status_bar_active(num);
- // not currenlty on groupchat window
+ // not currently on groupchat window
} else {
status_bar_active(num);
}
@@ -2130,7 +2130,7 @@ ui_room_broadcast(const char * const roomjid, const char * const message)
if (wins_is_current(window)) {
status_bar_active(num);
- // not currenlty on groupchat window
+ // not currently on groupchat window
} else {
status_bar_new(num);
}
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index 58f3fc58..b9244fcd 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -192,7 +192,7 @@ status_bar_inactive(const int win)
is_new[11] = TRUE;
_mark_new(11);
- // still have active winsows
+ // still have active windows
} else if (g_hash_table_size(remaining_active) != 0) {
is_active[11] = TRUE;
is_new[11] = FALSE;
@@ -241,7 +241,7 @@ status_bar_active(const int win)
_mark_active(11);
}
- // visible winsow indicators
+ // visible window indicators
} else {
is_active[true_win] = TRUE;
is_new[true_win] = FALSE;
diff --git a/src/ui/window.c b/src/ui/window.c
index 85cc875c..d683312b 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -690,7 +690,7 @@ win_show_info(ProfWin *window, PContact contact)
if (resources != NULL) {
win_save_print(window, '-', NULL, 0, 0, "", "Resources:");
- // sort in order of availabiltiy
+ // sort in order of availability
GList *curr = resources;
while (curr != NULL) {
Resource *resource = curr->data;
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index a0d9e0f1..f4c45318 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -517,7 +517,7 @@ _handle_caps(char *jid, XMPPCaps *caps)
}
}
- // unsupported hash, xep-0115, assoiciate with JID, no cache
+ // unsupported hash, xep-0115, associate with JID, no cache
} else if (caps->hash) {
log_info("Hash %s not supported: %s, sending service discovery request", caps->hash, jid);
char *id = create_unique_id("caps");
From 3eeafa2277c6e3002d5f8cc1aa645701527942c8 Mon Sep 17 00:00:00 2001
From: Olivier Le Moal
Date: Sat, 21 Feb 2015 22:22:21 +0100
Subject: [PATCH 090/252] fix segfault on self sent message carbon
---
src/xmpp/message.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 4f341f6a..b264df54 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -434,6 +434,11 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
gchar *to = xmpp_stanza_get_attribute(message, STANZA_ATTR_TO);
gchar *from = xmpp_stanza_get_attribute(message, STANZA_ATTR_FROM);
+ // happens when receive a carbon of a self sent message
+ if(to == NULL) {
+ to = from;
+ }
+
Jid *jid_from = jid_create(from);
Jid *jid_to = jid_create(to);
Jid *my_jid = jid_create(jabber_get_fulljid());
From c249a60cba286ccf9eff1610c30d2e211d723ea4 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 23 Feb 2015 00:15:33 +0000
Subject: [PATCH 091/252] Finished help tidy
---
src/command/command.c | 602 +++++++++++++++++++++++-------------------
1 file changed, 327 insertions(+), 275 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index 4411487d..b6ac88e4 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -117,10 +117,14 @@ static struct cmd_t command_defs[] =
"--------------------",
"Help on using Profanity.",
"",
- "area - Summary help for commands in a certain area of functionality.",
- "command - Full help for a specific command, for example '/help connect'.",
+ "area : Summary help for commands in a certain area of functionality.",
+ "command : Full help for a specific command, for example '/help connect'.",
"",
"Use with no arguments to see a list of areas.",
+ "",
+ "Example: /help commands",
+ "Example: /help presence",
+ "Example: /help who",
NULL } } },
{ "/about",
@@ -138,12 +142,18 @@ static struct cmd_t command_defs[] =
"----------------------------------------------",
"Login to a chat service.",
"",
- "account - The local account you wish to connect with, or a JID if connecting for the first time.",
- "server value - Supply a server if it is different to the domain part of your JID.",
- "port value - The port to use if different to the default (5222, or 5223 for SSL).",
+ "account : The local account you wish to connect with, or a JID if connecting for the first time.",
+ "server value : Supply a server if it is different to the domain part of your JID.",
+ "port value : The port to use if different to the default (5222, or 5223 for SSL).",
"",
"If no account is specified, the default is used if one is configured.",
"A local account is created with the JID as it's name if it doesn't already exist.",
+ "",
+ "Example: /connect",
+ "Example: /connect myuser@gmail.com",
+ "Example: /connect myuser@mycompany.com server talk.google.com",
+ "Example: /connect bob@someplace port 5678",
+ "Example: /connect me@chatty server chatty.com port 5443",
NULL } } },
{ "/disconnect",
@@ -161,12 +171,17 @@ static struct cmd_t command_defs[] =
"---------------------------",
"Send a one to one chat message, or a private message to a chat room occupant.",
"",
- "contact - The contact's JID, or nickname if one has been set in your roster.",
- "nick - A chat room occupant, to whom you wish to send a private message.",
- "message - The message to send",
+ "contact : The contact's JID, or nickname if one has been set in your roster.",
+ "nick : A chat room occupant, to whom you wish to send a private message.",
+ "message : The message to send",
"",
"If the message is omitted, a new chat window will be opened without sending a message.",
"Use quotes if the nickname includes spaces.",
+ "",
+ "Example: /msg myfriend@server.com Hey, here's a message!",
+ "Example: /msg otherfriend@server.com",
+ "Example: /msg Bob Here is a private message",
+ "Example: /msg \"My Friend\" Hi, how are you?",
NULL } } },
{ "/roster",
@@ -178,23 +193,30 @@ static struct cmd_t command_defs[] =
"",
"command - online|show|hide|by|size|add|remove|nick|clearnick",
"",
- "online - Show all online contacts in your roster.",
- "show - Show the roster panel.",
- "show offline - Show offline contacts in the roster panel.",
- "show resource - Show contact's connected resources in the roster panel.",
- "hide - Hide the roster panel.",
- "hide offline - Hide offline contacts in the roster panel.",
- "hide resource - Hide contact's connected resources in the roster panel.",
- "by group - Group contacts in the roster panel by roster group.",
- "by presence - Group contacts in the roster panel by presence.",
- "by none - No grouping in the roster panel.",
- "size - Percentage of the screen taken up by the roster (1-99).",
- "add jid [nick] - Add a new item to the roster.",
- "remove jid - Removes an item from the roster.",
- "nick jid nick - Change a contacts nickname.",
- "clearnick jid - Removes the current nickname.",
+ "online : Show all online contacts in your roster.",
+ "show : Show the roster panel.",
+ "show offline : Show offline contacts in the roster panel.",
+ "show resource : Show contact's connected resources in the roster panel.",
+ "hide : Hide the roster panel.",
+ "hide offline : Hide offline contacts in the roster panel.",
+ "hide resource : Hide contact's connected resources in the roster panel.",
+ "by group : Group contacts in the roster panel by roster group.",
+ "by presence : Group contacts in the roster panel by presence.",
+ "by none : No grouping in the roster panel.",
+ "size : Percentage of the screen taken up by the roster (1-99).",
+ "add jid [nick] : Add a new item to the roster.",
+ "remove jid : Removes an item from the roster.",
+ "nick jid nick : Change a contacts nickname.",
+ "clearnick jid : Removes the current nickname.",
"",
"Passing no arguments lists all contacts in your roster.",
+ "",
+ "Example: /roster (show your roster)",
+ "Example: /roster add someone@contacts.org (add the contact)",
+ "Example: /roster add someone@contacts.org Buddy (add the contact with nickname 'Buddy')",
+ "Example: /roster remove someone@contacts.org (remove the contact)",
+ "Example: /roster nick myfriend@chat.org My Friend",
+ "Example: /roster clearnick kai@server.com (clears nickname)",
NULL } } },
{ "/group",
@@ -204,11 +226,17 @@ static struct cmd_t command_defs[] =
"------------------------------------------",
"View, add to, and remove from roster groups.",
"",
- "show group - List all roster items a group.",
- "add group contact - Added a contact to a group.",
- "remove group contact - Remove a contact from a group.",
+ "show group : List all roster items a group.",
+ "add group contact : Added a contact to a group.",
+ "remove group contact : Remove a contact from a group.",
"",
"Passing no argument will list all roster groups.",
+ "",
+ "Example: /group",
+ "Example: /group show friends",
+ "Example: /group add friends newfriend@server.org",
+ "Example: /group add family Brother (using contacts nickname)",
+ "Example: /group remove colleagues boss@work.com",
NULL } } },
{ "/info",
@@ -218,11 +246,14 @@ static struct cmd_t command_defs[] =
"--------------------",
"Show information about a contact, room, or room member.",
"",
- "contact - The contact you wish to view information about.",
- "nick - When in a chat room, the occupant you wish to view information about.",
+ "contact : The contact you wish to view information about.",
+ "nick : When in a chat room, the occupant you wish to view information about.",
"",
"Passing no argument in a chat window will use the current recipient.",
"Passing no argument in a chat room will display information about the room.",
+ "",
+ "Example: /info mybuddy@chat.server.org",
+ "Example: /info kai",
NULL } } },
{ "/caps",
@@ -232,10 +263,14 @@ static struct cmd_t command_defs[] =
"--------------------",
"Find out a contacts, or room members client software capabilities.",
"",
- "fulljid - If in the console or a chat window, the full JID for which you wish to see capabilities.",
- "nick - If in a chat room, nickname for which you wish to see capabilities.",
+ "fulljid : If in the console or a chat window, the full JID for which you wish to see capabilities.",
+ "nick : If in a chat room, nickname for which you wish to see capabilities.",
"",
"If in private chat initiated from a chat room, no parameter is required.",
+ "",
+ "Example: /caps mybuddy@chat.server.org/laptop (contact's laptop resource)",
+ "Example: /caps mybuddy@chat.server.org/phone (contact's phone resource)",
+ "Example: /caps bruce (room member)",
NULL } } },
{ "/software",
@@ -245,11 +280,15 @@ static struct cmd_t command_defs[] =
"------------------------",
"Find out a contact, or room members software version information.",
"",
- "fulljid - If in the console or a chat window, the full JID for which you wish to see software information.",
- "nick - If in a chat room, nickname for which you wish to see software information.",
+ "fulljid : If in the console or a chat window, the full JID for which you wish to see software information.",
+ "nick : If in a chat room, nickname for which you wish to see software information.",
"",
"If in private chat initiated from a chat room, no parameter is required.",
"If the contact's software does not support software version requests, nothing will be displayed.",
+ "",
+ "Example: /software mybuddy@chat.server.org/laptop (contact's laptop resource)",
+ "Example: /software mybuddy@chat.server.org/phone (contact's phone resource)",
+ "Example: /software bruce (room member)",
NULL } } },
{ "/status",
@@ -259,10 +298,13 @@ static struct cmd_t command_defs[] =
"----------------------",
"Find out a contact, or room members presence information.",
"",
- "contact - The contact who's presence you which to see.",
- "nick - If in a chat room, the occupant who's presence you wish to see.",
+ "contact : The contact who's presence you which to see.",
+ "nick : If in a chat room, the occupant who's presence you wish to see.",
"",
"If in a chat window the parameter is not required, the current recipient will be used.",
+ "",
+ "Example: /status buddy@server.com",
+ "Example: /status jon",
NULL } } },
{ "/resource",
@@ -272,10 +314,10 @@ static struct cmd_t command_defs[] =
"------------------------------------------",
"Override chat session resource, and manage resource display settings.",
"",
- "set resource - Set the resource to which messages will be sent.",
- "off - Let the server choose which resource to route messages to.",
- "title on|off - Show or hide the current resource in the titlebar.",
- "message on|off - Show or hide the resource when showing an incoming message.",
+ "set resource : Set the resource to which messages will be sent.",
+ "off : Let the server choose which resource to route messages to.",
+ "title on|off : Show or hide the current resource in the titlebar.",
+ "message on|off : Show or hide the resource when showing an incoming message.",
NULL } } },
{ "/join",
@@ -285,13 +327,18 @@ static struct cmd_t command_defs[] =
"-------------------------------------------------",
"Join a chat room at the conference server.",
"",
- "room - Bare room JID, the chat server is determined by the 'muc.service' account property, 'conference.' by default.",
- "room@server - Full room JID.",
- "nick value - Nickname to use in the room",
- "password value - Password if the room requires it.",
+ "room : Bare room JID, the chat server is determined by the 'muc.service' account property, 'conference.' by default.",
+ "room@server : Full room JID.",
+ "nick value : Nickname to use in the room",
+ "password value : Password if the room requires it.",
"",
"If no nickname is specfied the account preference 'muc.nick' will be used which by default is the localpart of your JID.",
"If the room doesn't exist, and the server allows it, a new one will be created.",
+ "",
+ "Example: /join jdev@conference.jabber.org",
+ "Example: /join jdev@conference.jabber.org nick mynick",
+ "Example: /join private@conference.jabber.org nick mynick password mypassword",
+ "Example: /join jdev (as user@jabber.org will join jdev@conference.jabber.org)",
NULL } } },
{ "/leave",
@@ -309,8 +356,8 @@ static struct cmd_t command_defs[] =
"-------------------------",
"Send a direct invite to the current chat room.",
"",
- "contact - The contact you wish to invite",
- "message - An optional message to send with the invite.",
+ "contact : The contact you wish to invite",
+ "message : An optional message to send with the invite.",
NULL } } },
{ "/invites",
@@ -328,7 +375,7 @@ static struct cmd_t command_defs[] =
"-------------",
"Decline a chat room ivivation.",
"",
- "room - The room for the invite you wish to decline.",
+ "room : The room for the invite you wish to decline.",
NULL } } },
{ "/room",
@@ -338,9 +385,9 @@ static struct cmd_t command_defs[] =
"---------------------------",
"Chat room configuration.",
"",
- "accept - Accept default room configuration.",
- "destroy - Reject default room configuration.",
- "config - Edit room configuration.",
+ "accept : Accept default room configuration.",
+ "destroy : Reject default room configuration.",
+ "config : Edit room configuration.",
NULL } } },
{ "/kick",
@@ -350,8 +397,8 @@ static struct cmd_t command_defs[] =
"-------------------",
"Kick occupants from chat rooms.",
"",
- "nick - Nickname of the occupant to kick from the room.",
- "reason - Optional reason for kicking the occupant.",
+ "nick : Nickname of the occupant to kick from the room.",
+ "reason : Optional reason for kicking the occupant.",
NULL } } },
{ "/ban",
@@ -361,8 +408,8 @@ static struct cmd_t command_defs[] =
"-----------------",
"Ban users from chat rooms.",
"",
- "jid - Bare JID of the user to ban from the room.",
- "reason - Optional reason for banning the user.",
+ "jid : Bare JID of the user to ban from the room.",
+ "reason : Optional reason for banning the user.",
NULL } } },
{ "/subject",
@@ -372,8 +419,8 @@ static struct cmd_t command_defs[] =
"----------------------------",
"Set or clear room subject.",
"",
- "set subject - Set the room subject.",
- "clear - Clear the room subject.",
+ "set subject : Set the room subject.",
+ "clear : Clear the room subject.",
NULL } } },
{ "/affiliation",
@@ -383,8 +430,8 @@ static struct cmd_t command_defs[] =
"--------------------------------------------------",
"Manage room affiliations.",
"",
- "set affiliation jid [reason]- Set the affiliation of user with jid, with an optional reason.",
- "list [affiliation] - List all users with the specified affiliation, or all if none specified.",
+ "set affiliation jid [reason]: Set the affiliation of user with jid, with an optional reason.",
+ "list [affiliation] : List all users with the specified affiliation, or all if none specified.",
"",
"The affiliation may be one of owner, admin, member, outcast or none.",
NULL } } },
@@ -396,8 +443,8 @@ static struct cmd_t command_defs[] =
"-------------------------------------",
"Manage room roles.",
"",
- "set role nick [reason] - Set the role of occupant with nick, with an optional reason.",
- "list [role] - List all occupants with the specified role, or all if none specified.",
+ "set role nick [reason] : Set the role of occupant with nick, with an optional reason.",
+ "list [role] : List all occupants with the specified role, or all if none specified.",
"",
"The role may be one of moderator, participant, visitor or none.",
NULL } } },
@@ -409,10 +456,10 @@ static struct cmd_t command_defs[] =
"-------------------------------------------------------",
"Show or hide room occupants, and occupants panel display settings.",
"",
- "show - Show the occupants panel in chat rooms.",
- "hide - Hide the occupants panel in chat rooms.",
- "default show|hide - Whether occupants are shown by default in new rooms, 'show' or 'hide'",
- "size percent - Percentage of the screen taken by the occupants list in rooms (1-99).",
+ "show : Show the occupants panel in chat rooms.",
+ "hide : Hide the occupants panel in chat rooms.",
+ "default show|hide : Whether occupants are shown by default in new rooms, 'show' or 'hide'",
+ "size percent : Percentage of the screen taken by the occupants list in rooms (1-99).",
NULL } } },
{ "/form",
@@ -422,10 +469,10 @@ static struct cmd_t command_defs[] =
"-----------------------------------",
"Form configuration.",
"",
- "show - Show the current form.",
- "submit - Submit the current form.",
- "cancel - Cancel changes to the current form.",
- "help [tag] - Display help for form, or a specific field.",
+ "show : Show the current form.",
+ "submit : Submit the current form.",
+ "cancel : Cancel changes to the current form.",
+ "help [tag] : Display help for form, or a specific field.",
NULL } } },
{ "/rooms",
@@ -435,9 +482,12 @@ static struct cmd_t command_defs[] =
"---------------------------",
"List the chat rooms available at the specified conference service",
"",
- "conference-service - The conference service to query.",
+ "conference-service : The conference service to query.",
"",
"If no argument is supplied, the account preference 'muc.service' is used, 'conference.' by default.",
+ "",
+ "Example: /rooms conference.jabber.org",
+ "Example: /rooms (if logged in as me@server.org, is equivalent to /rooms conference.server.org)",
NULL } } },
{ "/bookmark",
@@ -447,16 +497,16 @@ static struct cmd_t command_defs[] =
"----------------------------",
"Manage bookmarks and join bookmarked rooms.",
"",
- "command - list|add|update|remove|join",
+ "command : list|add|update|remove|join",
"",
- "list - List all bookmarks.",
- "add room@server [prop value..] - Add a bookmark for room@server with the following optional properties:",
- " nick value - Nickname used in the chat room",
- " password value - Password if required, may be stored in plaintext on your server",
- " autojoin on|off - Whether to join the room automatically on login.",
- "update room@server [prop value..] - Update any of the above properties associated with the bookmark.",
- "remove room@server - Remove the bookmark for room@server.",
- "join room@server - Join room using the properties associated with the bookmark.",
+ "list : List all bookmarks.",
+ "add room@server [prop value..] : Add a bookmark for room@server with the following optional properties:",
+ " nick value : Nickname used in the chat room",
+ " password value : Password if required, may be stored in plaintext on your server",
+ " autojoin on|off : Whether to join the room automatically on login.",
+ "update room@server [prop value..] : Update any of the above properties associated with the bookmark.",
+ "remove room@server : Remove the bookmark for room@server.",
+ "join room@server : Join room using the properties associated with the bookmark.",
"",
"In a chat room, /bookmark with no arguments will bookmark the current room, setting autojoin to \"on\".",
NULL } } },
@@ -468,9 +518,14 @@ static struct cmd_t command_defs[] =
"---------------------",
"Find out information about an entities supported services.",
"",
- "info - List protocols and features supported by an entity.",
- "items - List items associated with an entity.",
- "entity - Jabber ID.",
+ "info : List protocols and features supported by an entity.",
+ "items : List items associated with an entity.",
+ "entity : Jabber ID.",
+ "",
+ "Example: /disco info myserver.org",
+ "Example: /disco items myserver.org",
+ "Example: /disco items conference.jabber.org",
+ "Example: /disco info myfriend@server.com/laptop",
NULL } } },
{ "/nick",
@@ -480,7 +535,10 @@ static struct cmd_t command_defs[] =
"--------------",
"Change the name by which other members of a chat room see you.",
"",
- "nickname - The new nickname.",
+ "nickname : The new nickname.",
+ "",
+ "Example: /nick kai hansen",
+ "Example: /nick bob",
NULL } } },
{ "/win",
@@ -500,9 +558,9 @@ static struct cmd_t command_defs[] =
"---------------------------------------",
"Show a list of windows, or tidy or swap.",
"",
- "tidy - Move windows so there are no gaps.",
- "prune - Close all windows with no unread messages, and then tidy as above.",
- "swap source target - Swap windows, target may be an empty position.",
+ "tidy : Move windows so there are no gaps.",
+ "prune : Close all windows with no unread messages, and then tidy as above.",
+ "swap source target : Swap windows, target may be an empty position.",
"",
"Passing no argument will list all currently active windows and information about their usage.",
NULL } } },
@@ -514,14 +572,19 @@ static struct cmd_t command_defs[] =
"------------------------------------------------",
"Manage subscriptions to contact presence.",
"",
- "request [jid] - Send a subscription request to the user.",
- "allow [jid] - Approve a contact's subscription reqeust.",
- "deny [jid] - Remove subscription for a contact, or deny a request",
- "show [jid] - Show subscriprion status for a contact.",
- "sent - Show all sent subscription requests pending a response.",
- "received - Show all received subscription requests awaiting your response.",
+ "request [jid] : Send a subscription request to the user.",
+ "allow [jid] : Approve a contact's subscription reqeust.",
+ "deny [jid] : Remove subscription for a contact, or deny a request",
+ "show [jid] : Show subscriprion status for a contact.",
+ "sent : Show all sent subscription requests pending a response.",
+ "received : Show all received subscription requests awaiting your response.",
"",
"If jid is omitted, the contact of the current window is used.",
+ "",
+ "Example: /sub request myfriend@jabber.org",
+ "Example: /sub allow myfriend@jabber.org",
+ "Example: /sub request (whilst in chat with contact)",
+ "Example: /sub sent",
NULL } } },
{ "/tiny",
@@ -531,7 +594,9 @@ static struct cmd_t command_defs[] =
"---------",
"Send url as tinyurl in current chat.",
"",
- "url - The url to make tiny.",
+ "url : The url to make tiny.",
+ "",
+ "Example: /tiny http://www.profanity.im",
NULL } } },
{ "/who",
@@ -541,14 +606,14 @@ static struct cmd_t command_defs[] =
"--------------------------------------",
"Show contacts/room occupants with chosen status, role or affiliation",
"",
- "status - online|offline|away|dnd|xa|chat|available|unavailable|any",
- " online - Contacts that are online, chat, away, xa, dnd",
- " available - Contacts that are available for chat - online, chat.",
- " unavailable - Contacts that are not available for chat - offline, away, xa, dnd.",
- " any - Contacts with any status (same as calling with no argument).",
- "role - moderator|participant|visitor",
- "affiliation - owner|admin|member",
- "group - Filter the results by the specfied group.",
+ "status : online|offline|away|dnd|xa|chat|available|unavailable|any",
+ " online : Contacts that are online, chat, away, xa, dnd",
+ " available : Contacts that are available for chat - online, chat.",
+ " unavailable : Contacts that are not available for chat - offline, away, xa, dnd.",
+ " any : Contacts with any status (same as calling with no argument).",
+ "role : moderator|participant|visitor",
+ "affiliation : owner|admin|member",
+ "group : Filter the results by the specfied group.",
NULL } } },
{ "/close",
@@ -558,9 +623,9 @@ static struct cmd_t command_defs[] =
"---------------------",
"Close the current window, or a number of windows.",
"",
- "num - Close the specified window.",
- "all - Close all windows.",
- "read - Close all windows that have no new messages.",
+ "num : Close the specified window.",
+ "all : Close all windows.",
+ "read : Close all windows that have no new messages.",
"",
"Passing no argument will close the current window.",
NULL } } },
@@ -623,19 +688,15 @@ static struct cmd_t command_defs[] =
"Configure time precision for the main window.",
NULL } } },
- { "/inpblock", // TODO review
+ { "/inpblock",
cmd_inpblock, parse_args, 2, 2, &cons_inpblock_setting,
- { "/inpblock timeout|dynamic [millis|on|off]", "Input blocking delay (dynamic or static).",
+ { "/inpblock timeout|dynamic [millis|on|off]", "Configure input blocking.",
{ "/inpblock timeout|dynamic [millis|on|off]",
"-----------------------------------------",
"How long to wait for input before checking for new messages or checking for state changes such as 'idle'.",
- "timeout : Time to wait in milliseconds before reading input from the terminal buffer, defaults to 500.",
- " : Valid values are 1-1000.",
- "dynamic : Start with a 0 timeout and increase the value dynamically up to the specified 'timeout'.",
- " : on|off",
- "A higher timeout will result in less CPU usage, but a noticable delay for response to input.",
- "A lower timeout will result in higher CPU usage, but faster response to input.",
- "Using the dynamic setting, higher CPU usage will occur during activity, but over time the CPU usage will decrease whilst there is no activity.",
+ "",
+ "timeout millis : Time to wait (1-1000) in milliseconds before reading input from the terminal buffer, default: 1000.",
+ "dynamic on|off : Start with 0 millis and dynamically increase up to timeout when no activity, default: on.",
NULL } } },
{ "/notify",
@@ -643,40 +704,29 @@ static struct cmd_t command_defs[] =
{ "/notify [type value]|[type setting value]", "Control various desktop noficiations.",
{ "/notify [type value]|[type setting value]",
"-----------------------------------------",
- "Settings for various desktop notifications where type is one of:",
- "message : Notificaitons for regular messages.",
- " : on|off",
- "message current : Whether messages in the current window trigger notifications.",
- " : on|off",
- "message text : Show message text in message notifications.",
- " : on|off",
- "room : Notificaitons for chat room messages.",
- " : on|off|mention",
- "room current : Whether chat room messages in the current window trigger notifications.",
- " : on|off",
- "room text : Show message test in chat room message notifications.",
- " : on|off",
- "remind : Notification reminders of unread messages.",
- " : where value is the reminder period in seconds,",
- " : use 0 to disable.",
- "typing : Notifications when contacts are typing.",
- " : on|off",
- "typing current : Whether typing notifications are triggerd for the current window.",
- " : on|off",
- "invite : Notifications for chat room invites.",
- " : on|off",
- "sub : Notifications for subscription requests.",
- " : on|off",
+ "Settings for various kinds of desktop notifications.",
"",
- "Example : /notify message on (enable message notifications)",
- "Example : /notify message text on (show message text in notifications)",
- "Example : /notify room mention (enable chat room notifications only on mention)",
- "Example : /notify room current off (disable room message notifications when window visible)",
- "Example : /notify room text off (do not show message text in chat room notifications)",
- "Example : /notify remind 10 (remind every 10 seconds)",
- "Example : /notify remind 0 (switch off reminders)",
- "Example : /notify typing on (enable typing notifications)",
- "Example : /notify invite on (enable chat room invite notifications)",
+ "message on|off : Notificaitons for regular messages.",
+ "message current on|off : Whether messages in the current window trigger notifications.",
+ "message text on|off : Show message text in message notifications.",
+ "room on|off|mention : Notificaitons for chat room messages.",
+ "room current on|off : Whether chat room messages in the current window trigger notifications.",
+ "room text on|off : Show message text in chat room message notifications.",
+ "remind seconds : Notification reminder period for unread messages, use 0 to disable.",
+ "typing on|off : Notifications when contacts are typing.",
+ "typing current of|off : Whether typing notifications are triggerd for the current window.",
+ "invite on|off : Notifications for chat room invites.",
+ "sub on|off : Notifications for subscription requests.",
+ "",
+ "Example: /notify message on (enable message notifications)",
+ "Example: /notify message text on (show message text in notifications)",
+ "Example: /notify room mention (enable chat room notifications only on mention)",
+ "Example: /notify room current off (disable room message notifications when window visible)",
+ "Example: /notify room text off (do not show message text in chat room notifications)",
+ "Example: /notify remind 10 (remind every 10 seconds)",
+ "Example: /notify remind 0 (switch off reminders)",
+ "Example: /notify typing on (enable typing notifications)",
+ "Example: /notify invite on (enable chat room invite notifications)",
NULL } } },
{ "/flash",
@@ -684,8 +734,7 @@ static struct cmd_t command_defs[] =
{ "/flash on|off", "Terminal flash on new messages.",
{ "/flash on|off",
"-------------",
- "Make the terminal flash when incoming messages are received.",
- "The flash will only occur if you are not in the chat window associated with the user sending the message.",
+ "Make the terminal flash when incoming messages are received in another window.",
"If the terminal doesn't support flashing, it may attempt to beep.",
NULL } } },
@@ -714,7 +763,7 @@ static struct cmd_t command_defs[] =
"The setting can be overridden by the -a (--account) command line option.",
"",
"Example: /autoconnect set jc@stuntteam.org (autoconnect with the specified account).",
- "Example: /autoconnect off (disable autoconnect).",
+ "Example: /autoconnect off (disable autoconnect).",
NULL } } },
{ "/vercheck",
@@ -722,18 +771,18 @@ static struct cmd_t command_defs[] =
{ "/vercheck [on|off]", "Check for a new release.",
{ "/vercheck [on|off]",
"------------------",
- "Without a parameter will check for a new release.",
- "Switching on or off will enable/disable a version check when Profanity starts, and each time the /about command is run.",
+ "Enable/disable a version check when Profanity starts, and each time the /about command is run.",
NULL } } },
{ "/titlebar",
cmd_titlebar, parse_args, 2, 2, &cons_titlebar_setting,
{ "/titlebar show|goodbye on|off", "Manage the terminal window title.",
{ "/titlebar show|goodbye on|off",
- "---------------------",
+ "-----------------------------",
"Show or hide a title and exit message in the terminal window title.",
- "show - Show current logged in user, and unread messages in the title.",
- "goodbye - Show a message in the title when exiting profanity.",
+ "",
+ "show : Show current logged in user, and unread messages in the title.",
+ "goodbye : Show a message in the title when exiting profanity.",
NULL } } },
{ "/mouse",
@@ -741,12 +790,7 @@ static struct cmd_t command_defs[] =
{ "/mouse on|off", "Use profanity mouse handling.",
{ "/mouse on|off",
"-------------",
- "If set to 'on', profanity will handle mouse actions, which enables scrolling the main window with the mouse wheel.",
- "To select text, use the shift key while selcting an area.",
- "If set to 'off', profanity leaves mouse handling to the terminal implementation.",
- "This feature is experimental, certain mouse click events may occasionally freeze",
- "Profanity until a key is pressed or another mouse event is received",
- "The default is 'off'.",
+ "This feature is experimental, default is 'off'.",
NULL } } },
{ "/alias",
@@ -755,12 +799,17 @@ static struct cmd_t command_defs[] =
{ "/alias add|remove|list [name value]",
"-----------------------------------",
"Add, remove or show command aliases.",
- "The alias will be available as a command, the leading '/' will be added if not supplied.",
- "Example : /alias add friends /who online friends",
- "Example : /alias add /q /quit",
- "Example : /alias a /away \"I'm in a meeting.\"",
- "Example : /alias remove q",
- "Example : /alias list",
+ "",
+ "add name value : Add a new command alias.",
+ "remove name : Remove a command alias.",
+ "list : List all aliases.",
+ "",
+ "Example: /alias add friends /who online friends",
+ "Example: /alias add /q /quit",
+ "Example: /alias a /away \"I'm in a meeting.\"",
+ "Example: /alias remove q",
+ "Example: /alias list",
+ "",
"The above aliases will be available as /friends and /a",
NULL } } },
@@ -789,29 +838,30 @@ static struct cmd_t command_defs[] =
{ "/states on|off", "Send chat states during a chat session.",
{ "/states on|off",
"--------------",
- "Sending of chat state notifications during chat sessions.",
- "Such as whether you have become inactive, or have closed the chat window.",
+ "Send chat state notifications during chat sessions.",
NULL } } },
{ "/otr",
cmd_otr, parse_args, 1, 3, NULL,
- { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn|libver|policy|secret|question|answer", "Off The Record encryption commands.",
- { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn|libver|policy|secret|question|answer",
- "-------------------------------------------------------------------------------------------",
- "gen - Generate your private key.",
- "myfp - Show your fingerprint.",
- "theirfp - Show contacts fingerprint.",
- "start [contact] - Start an OTR session with the contact, or the current recipient if in a chat window and no argument supplied.",
- "end - End the current OTR session,",
- "trust - Indicate that you have verified the contact's fingerprint.",
- "untrust - Indicate the the contact's fingerprint is not verified,",
- "log - How to log OTR messages, options are 'on', 'off' and 'redact', with redaction being the default.",
- "warn - Show when unencrypted messaging is being used in the title bar, options are 'on' and 'off' with 'on' being the default.",
- "libver - Show which version of the libotr library is being used.",
- "policy - manual, opportunistic or always.",
- "secret [secret]- Verify a contacts identity using a shared secret.",
- "question [question] [answer] - Verify a contacts identity using a question and expected anwser, if the question has spaces, surround with double quotes.",
- "answer [answer] - Respond to a question answer verification request with your answer.",
+ { "/otr command [args..]", "Off The Record encryption commands.",
+ { "/otr command [args..]",
+ "---------------------",
+ "Off The Record encryption commands.",
+ "",
+ "gen : Generate your private key.",
+ "myfp : Show your fingerprint.",
+ "theirfp : Show contacts fingerprint.",
+ "start [contact] : Start an OTR session with contact, or current recipient if omitted.",
+ "end : End the current OTR session,",
+ "trust : Indicate that you have verified the contact's fingerprint.",
+ "untrust : Indicate the the contact's fingerprint is not verified,",
+ "log on|off|redact : OTR message logging, default: redact.",
+ "warn on|off : Show in the titlebar when unencrypted messaging is being used.",
+ "libver : Show which version of the libotr library is being used.",
+ "policy manual|opportunistic|always : Set the global OTR policy.",
+ "secret [secret] : Verify a contacts identity using a shared secret.",
+ "question [question] [answer] : Verify a contacts identity using a question and expected anwser.",
+ "answer [answer] : Respond to a question answer verification request with your answer.",
NULL } } },
{ "/outtype",
@@ -819,8 +869,7 @@ static struct cmd_t command_defs[] =
{ "/outtype on|off", "Send typing notification to recipient.",
{ "/outtype on|off",
"---------------",
- "Send an indication that you are typing to the chat recipient.",
- "Chat states (/states) will be enabled if this setting is set.",
+ "Send typing notifications, chat states (/states) will be enabled if this setting is set.",
NULL } } },
{ "/gone",
@@ -828,8 +877,7 @@ static struct cmd_t command_defs[] =
{ "/gone minutes", "Send 'gone' state to recipient after a period.",
{ "/gone minutes",
"-------------",
- "Send a 'gone' state to the recipient after the specified number of minutes."
- "This indicates to the recipient's client that you have left the conversation.",
+ "Send a 'gone' state to the recipient after the specified number of minutes.",
"A value of 0 will disable sending this chat state.",
"Chat states (/states) will be enabled if this setting is set.",
NULL } } },
@@ -845,14 +893,15 @@ static struct cmd_t command_defs[] =
{ "/log",
cmd_log, parse_args, 1, 2, &cons_log_setting,
- { "/log [property] [value]", "Manage system logging settings.",
- { "/log [property] [value]",
- "-----------------------",
- "where : Show the current log file location.",
- "Property may be one of:",
- "rotate : Rotate log, accepts 'on' or 'off', defaults to 'on'.",
- "maxsize : With rotate enabled, specifies the max log size, defaults to 1048580 (1MB).",
- "shared : Share logs between all instances, accepts 'on' or 'off', defaults to 'on'.",
+ { "/log where|rotate|maxsize|shared [value]", "Manage system logging settings.",
+ { "/log where|rotate|maxsize|shared [value]",
+ "----------------------------------------",
+ "Manage profanity logging settings.",
+ "",
+ "where : Show the current log file location.",
+ "rotate on|off : Rotate log, default on.",
+ "maxsize bytes : With rotate enabled, specifies the max log size, defaults to 1048580 (1MB).",
+ "shared on|off : Share logs between all instances, default: on.",
NULL } } },
{ "/reconnect",
@@ -879,23 +928,22 @@ static struct cmd_t command_defs[] =
{ "/ping [rarget]",
"--------------",
"Sends an IQ ping stanza to the specificed target.",
- "If no target is supplied, your chat server will be used.",
+ "If no target is supplied, your chat server will be pinged.",
NULL } } },
{ "/autoaway",
cmd_autoaway, parse_args_with_freetext, 2, 2, &cons_autoaway_setting,
- { "/autoaway setting value", "Set auto idle/away properties.",
- { "/autoaway setting value",
- "-----------------------",
- "'setting' may be one of 'mode', 'time', 'message' or 'check', with the following values:",
+ { "/autoaway mode|time|message|check value", "Set auto idle/away properties.",
+ { "/autoaway mode|time|message|check value",
+ "---------------------------------------",
+ "Manage autoway properties.",
"",
- "mode : idle - Sends idle time, whilst your status remains online.",
- " away - Sends an away presence.",
- " off - Disabled (default).",
- "time : Number of minutes before the presence change is sent, the default is 15.",
- "message : Optional message to send with the presence change.",
- " : off - Disable message (default).",
- "check : on|off, when enabled, checks for activity and sends online presence, default is 'on'.",
+ "mode idle : Sends idle time, status remains online.",
+ "mode away : Sends an away presence.",
+ "mode off : Disabled (default).",
+ "time minutes : Number of minutes before the presence change is sent, default: 15.",
+ "message text|off : Optional message to send with the presence change, default: off (disabled).",
+ "check on|off : When enabled, checks for activity and sends online presence, default: on.",
"",
"Example: /autoaway mode idle",
"Example: /autoaway time 30",
@@ -908,9 +956,11 @@ static struct cmd_t command_defs[] =
{ "/priority value", "Set priority for the current account.",
{ "/priority value",
"---------------",
- "Set priority for the current account, presence will be sent when calling this command.",
- "See the /account command for more specific priority settings per presence status.",
- "value : Number between -128 and 127. Default value is 0.",
+ "Set priority for the current account.",
+ "",
+ "value : Number between -128 and 127, default: 0.",
+ "",
+ "See the /account command for specific priority settings per presence status.",
NULL } } },
{ "/account",
@@ -919,6 +969,7 @@ static struct cmd_t command_defs[] =
{ "/account [command] [account] [property] [value]",
"-----------------------------------------------",
"Commands for creating and managing accounts.",
+ "",
"list : List all accounts.",
"show account : Show information about an account.",
"enable account : Enable the account, it will be used for autocomplete.",
@@ -930,43 +981,38 @@ static struct cmd_t command_defs[] =
"set account property value : Set 'property' of 'account' to 'value'.",
"clear account property value : Clear 'property' of 'account'.",
"",
- "When connected, the /account command can be called with no arguments, to show current account settings.",
+ "Account properties.",
"",
- "The set command may use one of the following for 'property'.",
- "jid : The Jabber ID of the account, the account name will be used if this property is not set.",
- "server : The chat server, if different to the domainpart of the JID.",
- "port : The port used for connecting if not the default (5222, or 5223 for SSL).",
- "status : The presence status to use on login, use 'last' to use whatever your last status was.",
- "online|chat|away",
- "|xa|dnd : Priority for the specified presence.",
- "resource : The resource to be used.",
- "password : Password for the account, note this is currently stored in plaintext if set.",
- "eval_password : Shell command evaluated to retrieve password for the account. Can be used to retrieve password from keyring.",
- "muc : The default MUC chat service to use.",
- "nick : The default nickname to use when joining chat rooms.",
- "otr : Override global OTR policy for this account: manual, opportunistic or always.",
+ "jid : The Jabber ID of the account, account name will be used if not set.",
+ "server : The chat server, if different to the domainpart of the JID.",
+ "port : The port used for connecting if not the default (5222, or 5223 for SSL).",
+ "status : The presence status to use on login, use 'last' to use your last status before logging out.",
+ "online|chat|away|xa|dnd : Priority for the specified presence.",
+ "resource : The resource to be used.",
+ "password : Password for the account, note this is currently stored in plaintext if set.",
+ "eval_password : Shell command evaluated to retrieve password for the account. Can be used to retrieve password from keyring.",
+ "muc : The default MUC chat service to use.",
+ "nick : The default nickname to use when joining chat rooms.",
+ "otr : Override global OTR policy for this account: manual, opportunistic or always.",
"",
- "The clear command works for password, port and server",
- "",
- "Example : /account add work",
- " : /account set work jid me@chatty",
- " : /account set work server talk.chat.com",
- " : /account set work port 5111",
- " : /account set work resource desktop",
- " : /account set work muc chatservice.mycompany.com",
- " : /account set work nick dennis",
- " : /account set work status dnd",
- " : /account set work dnd -1",
- " : /account set work online 10",
- " : /account rename work gtalk",
+ "Example: /account add me",
+ "Example: /account set me jid me@chatty",
+ "Example: /account set me server talk.chat.com",
+ "Example: /account set me port 5111",
+ "Example: /account set me muc chatservice.mycompany.com",
+ "Example: /account set me nick dennis",
+ "Example: /account set me status dnd",
+ "Example: /account set me dnd -1",
+ "Example: /account rename me gtalk",
NULL } } },
{ "/prefs",
cmd_prefs, parse_args, 0, 1, NULL,
- { "/prefs [area]", "Show configuration.",
- { "/prefs [area]",
- "-------------",
- "Area is one of:",
+ { "/prefs [ui|desktop|chat|log|conn|presence]", "Show configuration.",
+ { "/prefs [ui|desktop|chat|log|conn|presence]",
+ "------------------------------------------",
+ "Show preferences for different areas of functionality.",
+ "",
"ui : User interface preferences.",
"desktop : Desktop notification preferences.",
"chat : Chat state preferences.",
@@ -974,7 +1020,7 @@ static struct cmd_t command_defs[] =
"conn : Connection handling preferences.",
"presence : Chat presence preferences.",
"",
- "No argument shows all categories.",
+ "No argument shows all preferences.",
NULL } } },
{ "/theme",
@@ -982,14 +1028,14 @@ static struct cmd_t command_defs[] =
{ "/theme list|set|colours [theme-name]", "Change colour theme.",
{ "/theme list|set|colours [theme-name]",
"------------------------------------",
- "Change the colour settings used.",
+ "Load a theme, includes colours and UI options.",
"",
"list : List all available themes.",
- "set theme-name : Load the named theme.\"default\" will reset to the default colours.",
+ "set theme-name : Load the named theme. 'default' will reset to the default theme.",
"colours : Show the colour values as rendered by the terminal.",
"",
- "Example : /theme list",
- "Example : /theme set mycooltheme",
+ "Example: /theme list",
+ "Example: /theme set mycooltheme",
NULL } } },
@@ -998,12 +1044,23 @@ static struct cmd_t command_defs[] =
{ "/statuses console|chat|muc setting", "Set preferences for presence change messages.",
{ "/statuses console|chat|muc setting",
"----------------------------------",
- "Configure how presence changes are displayed in various windows.",
- "Settings:",
- " all - Show all presence changes.",
- " online - Show only online/offline changes.",
- " none - Don't show any presence changes.",
+ "Configure which presence changes are displayed in various windows.",
+ "",
+ "console : Configure what is displayed in the console window.",
+ "chat : Configure what is displayed in chat windows.",
+ "muc : Configure what is displayed in chat room windows.",
+ "",
+ "Available options are:",
+ "",
+ "all : Show all presence changes.",
+ "online : Show only online/offline changes.",
+ "none : Don't show any presence changes.",
+ "",
"The default is 'all' for all windows.",
+ "",
+ "Example: /statuses console none",
+ "Example: /statuses chat online",
+ "Example: /statuses muc all",
NULL } } },
{ "/xmlconsole",
@@ -1016,57 +1073,52 @@ static struct cmd_t command_defs[] =
{ "/away",
cmd_away, parse_args_with_freetext, 0, 1, NULL,
- { "/away [msg]", "Set status to away.",
- { "/away [msg]",
- "-----------",
+ { "/away [message]", "Set status to away.",
+ { "/away [message]",
+ "---------------",
"Set your status to 'away' with the optional message.",
- "Your current status can be found in the top right of the screen.",
"",
- "Example : /away Gone for lunch",
+ "Example: /away Gone for lunch",
NULL } } },
{ "/chat",
cmd_chat, parse_args_with_freetext, 0, 1, NULL,
- { "/chat [msg]", "Set status to chat (available for chat).",
- { "/chat [msg]",
- "-----------",
+ { "/chat [message]", "Set status to chat (available for chat).",
+ { "/chat [message]",
+ "---------------",
"Set your status to 'chat', meaning 'available for chat', with the optional message.",
- "Your current status can be found in the top right of the screen.",
"",
- "Example : /chat Please talk to me!",
+ "Example: /chat Please talk to me!",
NULL } } },
{ "/dnd",
cmd_dnd, parse_args_with_freetext, 0, 1, NULL,
- { "/dnd [msg]", "Set status to dnd (do not disturb).",
- { "/dnd [msg]",
- "----------",
+ { "/dnd [message]", "Set status to dnd (do not disturb).",
+ { "/dnd [message]",
+ "--------------",
"Set your status to 'dnd', meaning 'do not disturb', with the optional message.",
- "Your current status can be found in the top right of the screen.",
"",
- "Example : /dnd I'm in the zone",
+ "Example: /dnd I'm in the zone",
NULL } } },
{ "/online",
cmd_online, parse_args_with_freetext, 0, 1, NULL,
- { "/online [msg]", "Set status to online.",
- { "/online [msg]",
- "-------------",
+ { "/online [message]", "Set status to online.",
+ { "/online [message]",
+ "-----------------",
"Set your status to 'online' with the optional message.",
- "Your current status can be found in the top right of the screen.",
"",
- "Example : /online Up the Irons!",
+ "Example: /online Up the Irons!",
NULL } } },
{ "/xa",
cmd_xa, parse_args_with_freetext, 0, 1, NULL,
- { "/xa [msg]", "Set status to xa (extended away).",
- { "/xa [msg]",
- "---------",
+ { "/xa [message]", "Set status to xa (extended away).",
+ { "/xa [message]",
+ "-------------",
"Set your status to 'xa', meaning 'extended away', with the optional message.",
- "Your current status can be found in the top right of the screen.",
"",
- "Example : /xa This meeting is going to be a long one",
+ "Example: /xa This meeting is going to be a long one",
NULL } } },
};
From ba22baba90358ce755644b4478e506a88314f81d Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 23 Feb 2015 00:24:24 +0000
Subject: [PATCH 092/252] Updated .travis.yml to use cmocka-1.0.0
---
.travis.yml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index c87d68b7..534440d0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,15 +11,15 @@ install:
- sudo make install
- cd ..
- rm -rf libstrophe
- - wget https://open.cryptomilk.org/attachments/download/42/cmocka-0.4.1.tar.xz
- - tar -xvf cmocka-0.4.1.tar.xz
- - cd cmocka-0.4.1
+ - wget https://cmocka.org/files/1.0/cmocka-1.0.0.tar.xz
+ - tar -xvf cmocka-1.0.0.tar.xz
+ - cd cmocka-1.0.0
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
- make
- sudo make install
- cd ../..
- - rm -rf cmocka-0.4.1
+ - rm -rf cmocka-1.0.0
- ./bootstrap.sh
script: ./configure && make && make check
From cd084c7e46d40deee566e4aa5758c233d9f56632 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 23 Feb 2015 00:37:46 +0000
Subject: [PATCH 093/252] Updated CHANGELOG
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index 2d9970c7..4add51cf 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,3 +15,4 @@
- Lower CPU usage with dynamic input blocking timeout
- Keychain/keyring integration using account eval_password property
- Disable term window title by default
+- Fixed remote code execution bug on OSX when desktop notifications configured to show message text
From a2a187892b7bb0a343b8bbe3c46dee051d534bde Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 23 Feb 2015 23:12:44 +0000
Subject: [PATCH 094/252] Lowercase barejid before adding to roster
---
src/xmpp/roster.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index e6f4c2ca..1e943fb6 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -241,6 +241,7 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
jid_destroy(my_jid);
const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+ gchar *barejid_lower = g_utf8_strdown(barejid, -1);
const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
@@ -254,12 +255,12 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
if (g_strcmp0(sub, "remove") == 0) {
// remove barejid and name
if (name == NULL) {
- name = barejid;
+ name = barejid_lower;
}
- roster_remove(name, barejid);
+ roster_remove(name, barejid_lower);
- handle_roster_remove(barejid);
+ handle_roster_remove(barejid_lower);
// otherwise update local roster
} else {
@@ -273,14 +274,14 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
GSList *groups = _get_groups_from_item(item);
// update the local roster
- PContact contact = roster_get_contact(barejid);
+ PContact contact = roster_get_contact(barejid_lower);
if (contact == NULL) {
- gboolean added = roster_add(barejid, name, groups, sub, pending_out);
+ gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
if (added) {
- handle_roster_add(barejid, name);
+ handle_roster_add(barejid_lower, name);
}
} else {
- handle_roster_update(barejid, name, groups, sub, pending_out);
+ handle_roster_update(barejid_lower, name, groups, sub, pending_out);
}
}
@@ -300,6 +301,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
while (item != NULL) {
const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+ gchar *barejid_lower = g_utf8_strdown(barejid, -1);
const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
@@ -316,10 +318,10 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
GSList *groups = _get_groups_from_item(item);
- gboolean added = roster_add(barejid, name, groups, sub, pending_out);
+ gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
if (!added) {
- log_warning("Attempt to add contact twice: %s", barejid);
+ log_warning("Attempt to add contact twice: %s", barejid_lower);
}
item = xmpp_stanza_get_next(item);
From b0176d050f9eb93101ac3e5775e43e881a0060fd Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 23 Feb 2015 23:30:13 +0000
Subject: [PATCH 095/252] Lowercase barejid before searching roster
---
src/roster_list.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/roster_list.c b/src/roster_list.c
index b9a142cb..ad1864f1 100644
--- a/src/roster_list.c
+++ b/src/roster_list.c
@@ -91,7 +91,7 @@ roster_update_presence(const char * const barejid, Resource *resource,
assert(barejid != NULL);
assert(resource != NULL);
- PContact contact = g_hash_table_lookup(contacts, barejid);
+ PContact contact = roster_get_contact(barejid);
if (contact == NULL) {
return FALSE;
}
@@ -109,14 +109,18 @@ roster_update_presence(const char * const barejid, Resource *resource,
PContact
roster_get_contact(const char * const barejid)
{
- return g_hash_table_lookup(contacts, barejid);
+ gchar *barejidlower = g_utf8_strdown(barejid, -1);
+ PContact contact = g_hash_table_lookup(contacts, barejidlower);
+ g_free(barejidlower);
+
+ return contact;
}
gboolean
roster_contact_offline(const char * const barejid,
const char * const resource, const char * const status)
{
- PContact contact = g_hash_table_lookup(contacts, barejid);
+ PContact contact = roster_get_contact(barejid);
if (contact == NULL) {
return FALSE;
@@ -212,7 +216,7 @@ void
roster_update(const char * const barejid, const char * const name,
GSList *groups, const char * const subscription, gboolean pending_out)
{
- PContact contact = g_hash_table_lookup(contacts, barejid);
+ PContact contact = roster_get_contact(barejid);
assert(contact != NULL);
p_contact_set_subscription(contact, subscription);
@@ -239,7 +243,7 @@ gboolean
roster_add(const char * const barejid, const char * const name, GSList *groups,
const char * const subscription, gboolean pending_out)
{
- PContact contact = g_hash_table_lookup(contacts, barejid);
+ PContact contact = roster_get_contact(barejid);
if (contact != NULL) {
return FALSE;
}
From 70b923a7fcc11011e536ffb741f6158798f2fb8e Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 23 Feb 2015 23:44:34 +0000
Subject: [PATCH 096/252] Lowercase barejid in Jid
---
src/jid.c | 7 +++++--
src/xmpp/roster.c | 3 +++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/jid.c b/src/jid.c
index d1c25ddb..e314b2cf 100644
--- a/src/jid.c
+++ b/src/jid.c
@@ -88,11 +88,12 @@ jid_create(const gchar * const str)
if (slashp != NULL) {
result->resourcepart = g_strdup(slashp + 1);
result->domainpart = g_utf8_substring(domain_start, 0, g_utf8_pointer_to_offset(domain_start, slashp));
- result->barejid = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp));
+ char *barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp));
+ result->barejid = g_utf8_strdown(barejidraw, -1);
result->fulljid = g_strdup(trimmed);
} else {
result->domainpart = g_strdup(domain_start);
- result->barejid = g_strdup(trimmed);
+ result->barejid = g_utf8_strdown(trimmed, -1);
}
if (result->domainpart == NULL) {
@@ -144,7 +145,9 @@ jid_is_valid_room_form(Jid *jid)
char *
create_fulljid(const char * const barejid, const char * const resource)
{
+ gchar *barejidlower = g_utf8_strdown(barejid, -1);
GString *full_jid = g_string_new(barejid);
+ g_free(barejidlower);
g_string_append(full_jid, "/");
g_string_append(full_jid, resource);
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index 1e943fb6..6de370aa 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -285,6 +285,8 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
}
}
+ g_free(barejid_lower);
+
return 1;
}
@@ -324,6 +326,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
log_warning("Attempt to add contact twice: %s", barejid_lower);
}
+ g_free(barejid_lower);
item = xmpp_stanza_get_next(item);
}
From f5686cab1e5fbfc6bcfb2385792e8738a38a1890 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Mon, 23 Feb 2015 23:52:53 +0000
Subject: [PATCH 097/252] Fixed create_fulljid
---
src/jid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/jid.c b/src/jid.c
index e314b2cf..0a722b1e 100644
--- a/src/jid.c
+++ b/src/jid.c
@@ -146,7 +146,7 @@ char *
create_fulljid(const char * const barejid, const char * const resource)
{
gchar *barejidlower = g_utf8_strdown(barejid, -1);
- GString *full_jid = g_string_new(barejid);
+ GString *full_jid = g_string_new(barejidlower);
g_free(barejidlower);
g_string_append(full_jid, "/");
g_string_append(full_jid, resource);
From 434fb1878bd3a387ef7b36c8e8dc124160d023ad Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 24 Feb 2015 21:42:43 +0000
Subject: [PATCH 098/252] Fixed /resource preference display
---
src/ui/console.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ui/console.c b/src/ui/console.c
index ef7df667..c5b743fa 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -857,9 +857,9 @@ cons_resource_setting(void)
else
cons_show("Resource title (/resource) : OFF");
if (prefs_get_boolean(PREF_RESOURCE_MESSAGE))
- cons_show("Message title (/resource) : ON");
+ cons_show("Resource message (/resource) : ON");
else
- cons_show("Message title (/resource) : OFF");
+ cons_show("Resource message (/resource) : OFF");
}
void
From 84c02ffb72c2adae8d3a8b5231004b184c213d3e Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 24 Feb 2015 22:24:20 +0000
Subject: [PATCH 099/252] Added /roster by preference to UI preferences summary
---
src/ui/console.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/ui/console.c b/src/ui/console.c
index c5b743fa..194d7698 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1003,6 +1003,9 @@ cons_roster_setting(void)
else
cons_show("Roster resource (/roster) : hide");
+ char *by = prefs_get_string(PREF_ROSTER_BY);
+ cons_show("Roster by (/roster : %s", by);
+
int size = prefs_get_roster_size();
cons_show("Roster size (/roster) : %d", size);
}
From 68a8ab3401046d4e8b62a8e0081db2b156f0c5b1 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 24 Feb 2015 22:53:57 +0000
Subject: [PATCH 100/252] Updated default preferences
---
src/config/preferences.c | 17 +++++++++++++----
src/ui/console.c | 2 +-
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/config/preferences.c b/src/config/preferences.c
index a1f82940..d5bd64d3 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -358,7 +358,7 @@ prefs_get_occupants_size(void)
gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "occupants.size", NULL);
if (result > 99 || result < 1) {
- return 20;
+ return 15;
} else {
return result;
}
@@ -377,7 +377,7 @@ prefs_get_roster_size(void)
gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "roster.size", NULL);
if (result > 99 || result < 1) {
- return 20;
+ return 25;
} else {
return result;
}
@@ -691,15 +691,24 @@ _get_default_boolean(preference_t pref)
case PREF_AUTOAWAY_CHECK:
case PREF_LOG_ROTATE:
case PREF_LOG_SHARED:
+ case PREF_NOTIFY_MESSAGE:
case PREF_NOTIFY_MESSAGE_CURRENT:
case PREF_NOTIFY_ROOM_CURRENT:
+ case PREF_NOTIFY_TYPING:
case PREF_NOTIFY_TYPING_CURRENT:
+ case PREF_NOTIFY_SUB:
+ case PREF_NOTIFY_INVITE:
case PREF_SPLASH:
case PREF_OCCUPANTS:
case PREF_MUC_PRIVILEGES:
case PREF_PRESENCE:
case PREF_WRAP:
case PREF_INPBLOCK_DYNAMIC:
+ case PREF_RESOURCE_TITLE:
+ case PREF_RESOURCE_MESSAGE:
+ case PREF_ROSTER:
+ case PREF_ROSTER_OFFLINE:
+ case PREF_ROSTER_RESOURCE:
return TRUE;
default:
return FALSE;
@@ -715,7 +724,7 @@ _get_default_string(preference_t pref)
{
case PREF_AUTOAWAY_MODE:
case PREF_NOTIFY_ROOM:
- return "off";
+ return "on";
case PREF_OTR_LOG:
return "redact";
case PREF_OTR_POLICY:
@@ -725,7 +734,7 @@ _get_default_string(preference_t pref)
case PREF_STATUSES_MUC:
return "all";
case PREF_ROSTER_BY:
- return "none";
+ return "presence";
case PREF_TIME:
return "seconds";
default:
diff --git a/src/ui/console.c b/src/ui/console.c
index 194d7698..8f1a1143 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1004,7 +1004,7 @@ cons_roster_setting(void)
cons_show("Roster resource (/roster) : hide");
char *by = prefs_get_string(PREF_ROSTER_BY);
- cons_show("Roster by (/roster : %s", by);
+ cons_show("Roster by (/roster) : %s", by);
int size = prefs_get_roster_size();
cons_show("Roster size (/roster) : %d", size);
From 22daac5fe9a0b2121deca57ea42e4094b288fb8c Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 25 Feb 2015 00:01:41 +0000
Subject: [PATCH 101/252] Upgrade otr warn preference, added UI theme settings
---
src/config/preferences.c | 30 ++++++------------------------
src/config/theme.c | 18 +++++++++++-------
2 files changed, 17 insertions(+), 31 deletions(-)
diff --git a/src/config/preferences.c b/src/config/preferences.c
index d5bd64d3..b29d7322 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -100,30 +100,12 @@ prefs_load(void)
g_error_free(err);
}
- // move pre 0.4.1 OTR preferences to [otr] group
+ // move pre 0.4.6 OTR warn preferences to [ui] group
err = NULL;
- gboolean ui_otr_warn = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "otr.warn", &err);
+ gboolean otr_warn = g_key_file_get_boolean(prefs, PREF_GROUP_OTR, "warn", &err);
if (err == NULL) {
- g_key_file_set_boolean(prefs, PREF_GROUP_OTR, _get_key(PREF_OTR_WARN), ui_otr_warn);
- g_key_file_remove_key(prefs, PREF_GROUP_UI, "otr.warn", NULL);
- } else {
- g_error_free(err);
- }
-
- err = NULL;
- gchar *ui_otr_log = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "otr", &err);
- if (err == NULL) {
- g_key_file_set_string(prefs, PREF_GROUP_OTR, _get_key(PREF_OTR_LOG), ui_otr_log);
- g_key_file_remove_key(prefs, PREF_GROUP_LOGGING, "otr", NULL);
- } else {
- g_error_free(err);
- }
-
- err = NULL;
- gchar *ui_otr_policy = g_key_file_get_string(prefs, "policy", "otr.policy", &err);
- if (err == NULL) {
- g_key_file_set_string(prefs, PREF_GROUP_OTR, _get_key(PREF_OTR_POLICY), ui_otr_policy);
- g_key_file_remove_group(prefs, "policy", NULL);
+ g_key_file_set_boolean(prefs, PREF_GROUP_UI, _get_key(PREF_OTR_WARN), otr_warn);
+ g_key_file_remove_key(prefs, PREF_GROUP_OTR, "warn", NULL);
} else {
g_error_free(err);
}
@@ -531,6 +513,7 @@ _get_group(preference_t pref)
case PREF_ROSTER_BY:
case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_MESSAGE:
+ case PREF_OTR_WARN:
case PREF_INPBLOCK_DYNAMIC:
return PREF_GROUP_UI;
case PREF_STATES:
@@ -559,7 +542,6 @@ _get_group(preference_t pref)
case PREF_CONNECT_ACCOUNT:
case PREF_DEFAULT_ACCOUNT:
return PREF_GROUP_CONNECTION;
- case PREF_OTR_WARN:
case PREF_OTR_LOG:
case PREF_OTR_POLICY:
return PREF_GROUP_OTR;
@@ -648,7 +630,7 @@ _get_key(preference_t pref)
case PREF_OTR_LOG:
return "log";
case PREF_OTR_WARN:
- return "warn";
+ return "otr.warn";
case PREF_OTR_POLICY:
return "policy";
case PREF_LOG_ROTATE:
diff --git a/src/config/theme.c b/src/config/theme.c
index e9389417..d2bf0a48 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -421,20 +421,20 @@ _set_boolean_preference(char *prefstr, preference_t pref)
static void
_load_preferences(void)
{
- _set_boolean_preference("intype", PREF_INTYPE);
_set_boolean_preference("beep", PREF_BEEP);
_set_boolean_preference("flash", PREF_FLASH);
- _set_boolean_preference("privileges", PREF_MUC_PRIVILEGES);
- _set_boolean_preference("presence", PREF_PRESENCE);
+ _set_boolean_preference("splash", PREF_SPLASH);
_set_boolean_preference("wrap", PREF_WRAP);
-
_set_string_preference("time", PREF_TIME);
- _set_string_preference("statuses.muc", PREF_STATUSES_MUC);
+
+ _set_boolean_preference("resource.title", PREF_RESOURCE_TITLE);
+ _set_boolean_preference("resource.message", PREF_RESOURCE_MESSAGE);
+
_set_string_preference("statuses.console", PREF_STATUSES_CONSOLE);
_set_string_preference("statuses.chat", PREF_STATUSES_CHAT);
+ _set_string_preference("statuses.muc", PREF_STATUSES_MUC);
_set_boolean_preference("occupants", PREF_OCCUPANTS);
-
if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) {
gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL);
prefs_set_occupants_size(occupants_size);
@@ -444,12 +444,16 @@ _load_preferences(void)
_set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE);
_set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE);
_set_string_preference("roster.by", PREF_ROSTER_BY);
-
if (g_key_file_has_key(theme, "ui", "roster.size", NULL)) {
gint roster_size = g_key_file_get_integer(theme, "ui", "roster.size", NULL);
prefs_set_roster_size(roster_size);
}
+ _set_boolean_preference("privileges", PREF_MUC_PRIVILEGES);
+
+ _set_boolean_preference("presence", PREF_PRESENCE);
+ _set_boolean_preference("intype", PREF_INTYPE);
+
_set_boolean_preference("otr.warn", PREF_OTR_WARN);
}
From d89112e13894d4d6a23846997ea7ef0c42674fe4 Mon Sep 17 00:00:00 2001
From: Olivier LE MOAL
Date: Wed, 25 Feb 2015 10:10:30 +0100
Subject: [PATCH 102/252] Upgrade CMocka to 1.0.0
---
.travis.yml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index c87d68b7..534440d0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,15 +11,15 @@ install:
- sudo make install
- cd ..
- rm -rf libstrophe
- - wget https://open.cryptomilk.org/attachments/download/42/cmocka-0.4.1.tar.xz
- - tar -xvf cmocka-0.4.1.tar.xz
- - cd cmocka-0.4.1
+ - wget https://cmocka.org/files/1.0/cmocka-1.0.0.tar.xz
+ - tar -xvf cmocka-1.0.0.tar.xz
+ - cd cmocka-1.0.0
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
- make
- sudo make install
- cd ../..
- - rm -rf cmocka-0.4.1
+ - rm -rf cmocka-1.0.0
- ./bootstrap.sh
script: ./configure && make && make check
From cbdfc09a84ba80dce2199447b2b59f0d5866e3a4 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Thu, 26 Feb 2015 00:49:21 +0000
Subject: [PATCH 103/252] Renamed /theme set -> /theme load
---
src/command/command.c | 20 ++++++++++----------
src/command/commands.c | 2 +-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/command/command.c b/src/command/command.c
index f37ea461..d596c489 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1025,17 +1025,17 @@ static struct cmd_t command_defs[] =
{ "/theme",
cmd_theme, parse_args, 1, 2, &cons_theme_setting,
- { "/theme list|set|colours [theme-name]", "Change colour theme.",
- { "/theme list|set|colours [theme-name]",
- "------------------------------------",
+ { "/theme list|load|colours [theme-name]", "Change colour theme.",
+ { "/theme list|load|colours [theme-name]",
+ "-------------------------------------",
"Load a theme, includes colours and UI options.",
"",
- "list : List all available themes.",
- "set theme-name : Load the named theme. 'default' will reset to the default theme.",
- "colours : Show the colour values as rendered by the terminal.",
+ "list : List all available themes.",
+ "load theme-name : Load the named theme. 'default' will reset to the default theme.",
+ "colours : Show the colour values as rendered by the terminal.",
"",
"Example: /theme list",
- "Example: /theme set mycooltheme",
+ "Example: /theme load mycooltheme",
NULL } } },
@@ -1293,8 +1293,8 @@ cmd_init(void)
autocomplete_add(autoconnect_ac, "off");
theme_ac = autocomplete_new();
+ autocomplete_add(theme_ac, "load");
autocomplete_add(theme_ac, "list");
- autocomplete_add(theme_ac, "set");
autocomplete_add(theme_ac, "colours");
disco_ac = autocomplete_new();
@@ -2517,7 +2517,7 @@ static char *
_theme_autocomplete(const char * const input)
{
char *result = NULL;
- if ((strncmp(input, "/theme set ", 11) == 0) && (strlen(input) > 11)) {
+ if ((strncmp(input, "/theme load ", 12) == 0) && (strlen(input) > 12)) {
if (theme_load_ac == NULL) {
theme_load_ac = autocomplete_new();
GSList *themes = theme_list();
@@ -2529,7 +2529,7 @@ _theme_autocomplete(const char * const input)
g_slist_free_full(themes, g_free);
autocomplete_add(theme_load_ac, "default");
}
- result = autocomplete_param_with_ac(input, "/theme set", theme_load_ac, TRUE);
+ result = autocomplete_param_with_ac(input, "/theme load", theme_load_ac, TRUE);
if (result != NULL) {
return result;
}
diff --git a/src/command/commands.c b/src/command/commands.c
index 63cdedf7..18f8bf69 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -822,7 +822,7 @@ cmd_theme(gchar **args, struct cmd_help_t help)
g_slist_free_full(themes, g_free);
// load a theme
- } else if (g_strcmp0(args[0], "set") == 0) {
+ } else if (g_strcmp0(args[0], "load") == 0) {
if (args[1] == NULL) {
cons_show("Usage: %s", help.usage);
} else if (theme_load(args[1])) {
From 30b5f112fd81890411d6fe52c1f442f4433e0d01 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Thu, 26 Feb 2015 23:23:15 +0000
Subject: [PATCH 104/252] Updated themes for release
---
theme_template | 72 ++++++++++++++++++++++++++++++++++++++++
themes/advanced | 69 --------------------------------------
themes/aqua | 34 +++++++++++--------
themes/batman | 19 +++++++++--
themes/boothj5 | 75 ++++++++++++++++++++++--------------------
themes/complex | 22 +++++++++++++
themes/forest | 60 ++++++++++++++++-----------------
themes/hacker | 58 ++++++++++++++++----------------
themes/headache | 39 ++++++++++++++--------
themes/joker | 53 ++++++++++++++++++-----------
themes/minimal | 62 ----------------------------------
themes/mono | 58 ++++++++++++++++----------------
themes/orange | 37 ++++++++++++---------
themes/original | 60 ++++++++++++++++-----------------
themes/original_bright | 58 ++++++++++++++++----------------
themes/shade | 41 +++++++++++++++--------
themes/simple | 65 ++++++------------------------------
themes/spawn | 54 ++++++++++++++++++------------
themes/whiteness | 43 +++++++++++++++---------
19 files changed, 499 insertions(+), 480 deletions(-)
create mode 100644 theme_template
delete mode 100644 themes/advanced
create mode 100644 themes/complex
delete mode 100644 themes/minimal
diff --git a/theme_template b/theme_template
new file mode 100644
index 00000000..ece971a8
--- /dev/null
+++ b/theme_template
@@ -0,0 +1,72 @@
+[colours]
+bkgnd=
+titlebar=
+titlebar.text=
+titlebar.brackets=
+titlebar.unencrypted=
+titlebar.encrypted=
+titlebar.untrusted=
+titlebar.trusted=
+titlebar.online=
+titlebar.offline=
+titlebar.away=
+titlebar.chat=
+titlebar.dnd=
+titlebar.xa=
+statusbar=
+statusbar.text=
+statusbar.brackets=
+statusbar.active=
+statusbar.new=
+main.text=
+main.text.me=
+main.text.them=
+main.splash=
+main.time=
+input.text=
+subscribed=
+unsubscribed=
+otr.started.trusted=
+otr.started.untrusted=
+otr.ended=
+otr.trusted=
+otr.untrusted=
+online=
+away=
+chat=
+dnd=
+xa=
+offline=
+incoming=
+typing=
+gone=
+error=
+roominfo=
+roommention=
+me=
+them=
+roster.header=
+occupants.header=
+
+[ui]
+beep=
+flash=
+splash=
+wrap=
+time=
+privileges=
+presence=
+intype=
+otr.warn=
+resource.title=
+resource.message=
+statuses.console=
+statuses.chat=
+statuses.muc=
+roster=
+roster.offline=
+roster.resource=
+roster.by=
+roster.size=
+occupants=
+occupants.size=
\ No newline at end of file
diff --git a/themes/advanced b/themes/advanced
deleted file mode 100644
index a00948d8..00000000
--- a/themes/advanced
+++ /dev/null
@@ -1,69 +0,0 @@
-[colours]
-bkgnd=default
-titlebar=blue
-statusbar=blue
-titlebar.text=bold_white
-titlebar.brackets=white
-statusbar.text=bold_white
-statusbar.brackets=white
-statusbar.active=bold_cyan
-statusbar.new=bold_green
-main.text=white
-main.text.me=cyan
-main.text.them=bold_white
-input.text=bold_green
-main.time=yellow
-main.splash=bold_red
-online=bold_green
-away=bold_cyan
-chat=bold_white
-dnd=magenta
-xa=bold_blue
-offline=red
-typing=yellow
-gone=red
-error=red
-incoming=bold_yellow
-roominfo=yellow
-roommention=bold_red
-me=blue
-them=bold_green
-titlebar.unencrypted=bold_red
-titlebar.encrypted=bold_white
-titlebar.untrusted=bold_yellow
-titlebar.trusted=bold_white
-titlebar.online=bold_green
-titlebar.offline=bold_red
-titlebar.away=bold_cyan
-titlebar.xa=bold_cyan
-titlebar.dnd=bold_red
-titlebar.chat=bold_green
-otr.started.trusted=green
-otr.started.untrusted=yellow
-otr.ended=red
-otr.trusted=green
-otr.untrusted=yellow
-roster.header=bold_yellow
-occupants.header=bold_yellow
-
-[ui]
-intype=true
-beep=false
-flash=false
-privileges=true
-presence=true
-wrap=true
-time=minutes
-statuses.muc=off
-statuses.chat=online
-statuses.console=off
-occupants=true
-occupants.size=15
-roster=true
-roster.size=25
-roster.offline=true
-roster.resource=true
-roster.by=presence
-otr.warn=true
-
-
diff --git a/themes/aqua b/themes/aqua
index 7474d072..fe3fd56a 100644
--- a/themes/aqua
+++ b/themes/aqua
@@ -1,9 +1,19 @@
[colours]
bkgnd=default
titlebar=blue
-statusbar=blue
titlebar.text=bold_white
titlebar.brackets=white
+titlebar.unencrypted=cyan
+titlebar.encrypted=white
+titlebar.untrusted=cyan
+titlebar.trusted=white
+titlebar.online=bold_white
+titlebar.offline=cyan
+titlebar.away=white
+titlebar.chat=bold_white
+titlebar.dnd=cyan
+titlebar.xa=bold_cyan
+statusbar=blue
statusbar.text=bold_white
statusbar.brackets=white
statusbar.active=cyan
@@ -11,31 +21,29 @@ statusbar.new=white
main.text=blue
main.text.me=bold_cyan
main.text.them=bold_white
-input.text=white
-main.time=cyan
main.splash=bold_white
+main.time=cyan
+input.text=white
+subscribed=bold_cyan
+unsubscribed=blue
+otr.started.trusted=white
+otr.started.untrusted=cyan
+otr.ended=cyan
+otr.trusted=white
+otr.untrusted=cyan
online=bold_cyan
away=bold_blue
chat=white
dnd=blue
xa=cyan
offline=bold_black
+incoming=bold_cyan
typing=cyan
gone=blue
error=bold_white
-incoming=bold_cyan
roominfo=white
roommention=bold_blue
me=cyan
them=white
-titlebar.unencrypted=cyan
-titlebar.encrypted=white
-titlebar.untrusted=cyan
-titlebar.trusted=white
-otr.started.trusted=white
-otr.started.untrusted=cyan
-otr.ended=cyan
-otr.trusted=white
-otr.untrusted=cyan
roster.header=bold_white
occupants.header=bold_white
diff --git a/themes/batman b/themes/batman
index fc8ce1be..358fc559 100644
--- a/themes/batman
+++ b/themes/batman
@@ -17,14 +17,13 @@ away=yellow
chat=green
dnd=green
xa=yellow
-offline=grey
+offline=bold_black
typing=cyan
gone=red
error=red
incoming=yellow
roominfo=green
-roommention=cyan
-me=black
+me=black_bold
them=yellow
titlebar.unencrypted=red
titlebar.encrypted=green
@@ -35,3 +34,17 @@ otr.started.untrusted=red
otr.ended=yellow
otr.trusted=green
otr.untrusted=red
+
+titlebar.online=magenta
+titlebar.offline=black
+titlebar.away=magenta
+titlebar.chat=magenta
+titlebar.dnd=magenta
+titlebar.xa=magenta
+main.text.me=white
+main.text.them=white
+subscribed=magenta
+unsubscribed=black_bold
+roommention=cyan
+roster.header=yellow
+occupants.header=yellow
\ No newline at end of file
diff --git a/themes/boothj5 b/themes/boothj5
index 3e086903..cd6379cd 100644
--- a/themes/boothj5
+++ b/themes/boothj5
@@ -1,33 +1,8 @@
[colours]
bkgnd=default
titlebar=blue
-statusbar=blue
titlebar.text=bold_white
titlebar.brackets=white
-statusbar.text=bold_white
-statusbar.brackets=white
-statusbar.active=bold_cyan
-statusbar.new=bold_green
-main.text=white
-main.text.me=cyan
-main.text.them=bold_white
-input.text=bold_green
-main.time=yellow
-main.splash=bold_red
-online=bold_green
-away=bold_cyan
-chat=bold_white
-dnd=magenta
-xa=bold_blue
-offline=red
-typing=yellow
-gone=red
-error=red
-incoming=bold_yellow
-roominfo=yellow
-roommention=bold_red
-me=blue
-them=bold_green
titlebar.unencrypted=bold_red
titlebar.encrypted=bold_white
titlebar.untrusted=bold_yellow
@@ -38,32 +13,62 @@ titlebar.away=bold_cyan
titlebar.xa=bold_cyan
titlebar.dnd=bold_red
titlebar.chat=bold_green
+statusbar=blue
+statusbar.text=bold_white
+statusbar.brackets=white
+statusbar.active=bold_cyan
+statusbar.new=bold_green
+main.text=white
+main.text.me=cyan
+main.text.them=bold_white
+main.splash=bold_red
+main.time=yellow
+input.text=bold_green
+subscribed=bold_green
+unsubscribed=red
otr.started.trusted=green
otr.started.untrusted=yellow
otr.ended=red
otr.trusted=green
otr.untrusted=yellow
+online=bold_green
+away=bold_cyan
+chat=bold_white
+dnd=magenta
+xa=bold_blue
+offline=red
+incoming=bold_yellow
+typing=yellow
+gone=red
+error=red
+roominfo=yellow
+roommention=bold_red
+me=blue
+them=bold_green
roster.header=bold_yellow
occupants.header=bold_yellow
[ui]
-intype=true
beep=false
flash=false
+splash=true
+wrap=true
+time=seconds
privileges=true
presence=true
-wrap=true
-time=minutes
-statuses.muc=none
-statuses.chat=none
-statuses.console=none
-occupants=true
-occupants.size=15
+intype=true
+otr.warn=true
+resource.title=true
+resource.message=true
+statuses.console=all
+statuses.chat=all
+statuses.muc=all
roster=true
-roster.size=25
roster.offline=true
roster.resource=true
roster.by=presence
-otr.warn=true
+roster.size=25
+occupants=true
+occupants.size=15
diff --git a/themes/complex b/themes/complex
new file mode 100644
index 00000000..a2695a1f
--- /dev/null
+++ b/themes/complex
@@ -0,0 +1,22 @@
+[ui]
+beep=false
+flash=false
+splash=true
+wrap=true
+time=seconds
+resource.title=true
+resource.message=true
+statuses.console=all
+statuses.chat=all
+statuses.muc=all
+occupants=true
+occupants.size=15
+roster=true
+roster.offline=true
+roster.resource=true
+roster.by=presence
+roster.size=25
+privileges=true
+presence=true
+intype=true
+otr.warn=true
diff --git a/themes/forest b/themes/forest
index fd170162..d04bc390 100644
--- a/themes/forest
+++ b/themes/forest
@@ -1,35 +1,8 @@
[colours]
bkgnd=default
titlebar=cyan
-statusbar=green
titlebar.text=black
titlebar.brackets=black
-statusbar.text=black
-statusbar.brackets=black
-statusbar.active=bold_green
-statusbar.new=white
-main.text=bold_cyan
-main.text.me=yellow
-main.text.them=green
-input.text=bold_blue
-main.time=bold_green
-main.splash=bold_yellow
-subscribed=green
-unsubscribed=bold_black
-online=green
-away=blue
-chat=green
-dnd=bold_black
-xa=blue
-offline=bold_black
-typing=yellow
-gone=bold_black
-error=bold_black
-incoming=bold_yellow
-roominfo=yellow
-roommention=bold_cyan
-me=blue
-them=bold_blue
titlebar.unencrypted=black
titlebar.encrypted=white
titlebar.untrusted=white
@@ -37,13 +10,40 @@ titlebar.trusted=white
titlebar.online=white
titlebar.offline=white
titlebar.away=white
-titlebar.xa=white
-titlebar.dnd=white
titlebar.chat=white
+titlebar.dnd=white
+titlebar.xa=white
+statusbar=green
+statusbar.text=black
+statusbar.brackets=black
+statusbar.active=bold_green
+statusbar.new=white
+main.text=bold_cyan
+main.text.me=yellow
+main.text.them=green
+main.splash=bold_yellow
+main.time=bold_green
+input.text=bold_blue
+subscribed=green
+unsubscribed=bold_black
otr.started.trusted=green
otr.started.untrusted=yellow
otr.ended=red
otr.trusted=green
otr.untrusted=yellow
+online=green
+away=blue
+chat=green
+dnd=bold_black
+xa=blue
+offline=bold_black
+incoming=bold_yellow
+typing=yellow
+gone=bold_black
+error=bold_black
+roominfo=yellow
+roommention=bold_cyan
+me=blue
+them=bold_blue
roster.header=bold_green
-occupants.header=bold_green
+occupants.header=bold_green
\ No newline at end of file
diff --git a/themes/hacker b/themes/hacker
index 09928f61..a81a635c 100644
--- a/themes/hacker
+++ b/themes/hacker
@@ -1,33 +1,8 @@
[colours]
bkgnd=default
titlebar=green
-statusbar=green
titlebar.text=black
titlebar.brackets=black
-statusbar.text=black
-statusbar.brackets=black
-statusbar.active=black
-statusbar.new=black
-main.text=green
-main.text.me=green
-main.text.them=green
-input.text=bold_green
-main.time=bold_green
-main.splash=bold_green
-online=bold_green
-away=green
-chat=bold_green
-dnd=green
-xa=green
-offline=green
-typing=green
-gone=green
-error=bold_green
-incoming=bold_green
-roominfo=green
-roommention=bold_green
-me=green
-them=bold_green
titlebar.unencrypted=black
titlebar.encrypted=black
titlebar.untrusted=black
@@ -35,13 +10,40 @@ titlebar.trusted=black
titlebar.online=black
titlebar.offline=black
titlebar.away=black
-titlebar.xa=black
-titlebar.dnd=black
titlebar.chat=black
+titlebar.dnd=black
+titlebar.xa=black
+statusbar=green
+statusbar.text=black
+statusbar.brackets=black
+statusbar.active=black
+statusbar.new=black
+main.text=green
+main.text.me=green
+main.text.them=green
+main.splash=bold_green
+main.time=bold_green
+input.text=bold_green
+subscribed=bold_green
+unsubscribed=green
otr.started.trusted=green
otr.started.untrusted=green
otr.ended=green
otr.trusted=green
otr.untrusted=green
+online=bold_green
+away=green
+chat=bold_green
+dnd=green
+xa=green
+offline=green
+incoming=bold_green
+typing=green
+gone=green
+error=bold_green
+roominfo=green
+roommention=bold_green
+me=green
+them=bold_green
roster.header=bold_green
-occupants.header=bold_green
+occupants.header=bold_green
\ No newline at end of file
diff --git a/themes/headache b/themes/headache
index ea5738ce..3a84d976 100644
--- a/themes/headache
+++ b/themes/headache
@@ -1,36 +1,49 @@
[colours]
bkgnd=default
titlebar=magenta
-statusbar=default
titlebar.text=white
titlebar.brackets=white
+titlebar.unencrypted=black
+titlebar.encrypted=cyan
+titlebar.untrusted=yellow
+titlebar.trusted=cyan
+titlebar.online=white
+titlebar.offline=black
+titlebar.away=white
+titlebar.chat=white
+titlebar.dnd=black
+titlebar.xa=white
+statusbar=default
statusbar.text=white
statusbar.brackets=red
statusbar.active=cyan
statusbar.new=white
main.text=blue
-input.text=yellow
-main.time=green
+main.text.me=white
+main.text.them=bold_white
main.splash=red
+main.time=green
+input.text=yellow
+subscribed=bold_magenta
+unsubscribed=bold_black
+otr.started.trusted=cyan
+otr.started.untrusted=yellow
+otr.ended=blue
+otr.trusted=cyan
+otr.untrusted=yellow
online=red
away=cyan
chat=green
dnd=megenta
xa=cyan
offline=green
+incoming=yellow
typing=magenta
gone=yellow
error=red
-incoming=yellow
roominfo=white
+roommention=bold_green
me=white
them=white
-titlebar.unencrypted=black
-titlebar.encrypted=cyan
-titlebar.untrusted=yellow
-titlebar.trusted=cyan
-otr.started.trusted=cyan
-otr.started.untrusted=yellow
-otr.ended=blue
-otr.trusted=cyan
-otr.untrusted=yellow
+roster.header=bold_cyan
+occupants.header=bold_cyan
\ No newline at end of file
diff --git a/themes/joker b/themes/joker
index 3c8adc39..a0986242 100644
--- a/themes/joker
+++ b/themes/joker
@@ -1,36 +1,49 @@
[colours]
bkgnd=default
titlebar=magenta
-statusbar=magenta
titlebar.text=white
titlebar.brackets=cyan
+titlebar.unencrypted=red
+titlebar.encrypted=green
+titlebar.untrusted=red
+titlebar.trusted=green
+titlebar.online=white
+titlebar.offline=black
+titlebar.away=white
+titlebar.chat=white
+titlebar.dnd=black
+titlebar.xa=white
+statusbar=magenta
statusbar.text=green
statusbar.brackets=cyan
statusbar.active=green
statusbar.new=white
main.text=white
-input.text=green
-main.time=white
+main.text.me=white
+main.text.them=white
main.splash=green
-online=green
-away=yellow
-chat=green
-dnd=green
-xa=yellow
-offline=grey
-typing=green
-gone=red
-error=red
-incoming=yellow
-roominfo=green
-me=magenta
-them=green
-titlebar.unencrypted=red
-titlebar.encrypted=green
-titlebar.untrusted=red
-titlebar.trusted=green
+main.time=white
+input.text=green
+subscribed=green
+unsubscribed=white
otr.started.trusted=green
otr.started.untrusted=red
otr.ended=yellow
otr.trusted=green
otr.untrusted=red
+online=green
+away=yellow
+chat=green
+dnd=green
+xa=yellow
+offline=bold_black
+incoming=yellow
+typing=green
+gone=red
+error=red
+roominfo=green
+roommention=green
+me=magenta
+them=green
+roster.header=magenta
+occupants.header=magenta
\ No newline at end of file
diff --git a/themes/minimal b/themes/minimal
deleted file mode 100644
index cabf1887..00000000
--- a/themes/minimal
+++ /dev/null
@@ -1,62 +0,0 @@
-[colours]
-bkgnd=default
-titlebar=blue
-statusbar=blue
-titlebar.text=bold_white
-titlebar.brackets=white
-statusbar.text=bold_white
-statusbar.brackets=white
-statusbar.active=bold_cyan
-statusbar.new=bold_green
-main.text=white
-main.text.me=cyan
-main.text.them=bold_white
-input.text=bold_green
-main.time=yellow
-main.splash=bold_red
-online=bold_green
-away=bold_cyan
-chat=bold_white
-dnd=magenta
-xa=bold_blue
-offline=red
-typing=yellow
-gone=red
-error=red
-incoming=bold_yellow
-roominfo=yellow
-roommention=bold_red
-me=blue
-them=bold_green
-titlebar.unencrypted=bold_red
-titlebar.encrypted=bold_white
-titlebar.untrusted=bold_yellow
-titlebar.trusted=bold_white
-titlebar.online=bold_green
-titlebar.offline=bold_red
-titlebar.away=bold_cyan
-titlebar.xa=bold_cyan
-titlebar.dnd=bold_red
-titlebar.chat=bold_green
-otr.started.trusted=green
-otr.started.untrusted=yellow
-otr.ended=red
-otr.trusted=green
-otr.untrusted=yellow
-roster.header=bold_yellow
-occupants.header=bold_yellow
-
-[ui]
-intype=true
-beep=false
-flash=false
-privileges=false
-presence=false
-wrap=false
-time=off
-statuses.muc=all
-statuses.chat=all
-statuses.console=all
-occupants=false
-roster=false
-otr.warn=false
diff --git a/themes/mono b/themes/mono
index 42beb174..779d04ff 100644
--- a/themes/mono
+++ b/themes/mono
@@ -1,33 +1,8 @@
[colours]
bkgnd=default
titlebar=white
-statusbar=white
titlebar.text=black
titlebar.brackets=black
-statusbar.text=black
-statusbar.brackets=black
-statusbar.active=black
-statusbar.new=black
-main.text=white
-main.text.me=white
-main.text.them=white
-input.text=white
-main.time=white
-main.splash=white
-online=white
-away=white
-chat=white
-dnd=white
-xa=white
-offline=white
-typing=white
-gone=white
-error=white
-incoming=white
-roominfo=white
-roommention=white
-me=white
-them=white
titlebar.unencrypted=black
titlebar.encrypted=black
titlebar.untrusted=black
@@ -35,13 +10,40 @@ titlebar.trusted=black
titlebar.online=black
titlebar.offline=black
titlebar.away=black
-titlebar.xa=black
-titlebar.dnd=black
titlebar.chat=black
+titlebar.dnd=black
+titlebar.xa=black
+statusbar=white
+statusbar.text=black
+statusbar.brackets=black
+statusbar.active=black
+statusbar.new=black
+main.text=white
+main.text.me=white
+main.text.them=white
+main.splash=white
+main.time=white
+input.text=white
+subscribed=white
+unsubscribed=white
otr.started.trusted=white
otr.started.untrusted=white
otr.ended=white
otr.trusted=white
otr.untrusted=white
+online=white
+away=white
+chat=white
+dnd=white
+xa=white
+offline=white
+incoming=white
+typing=white
+gone=white
+error=white
+roominfo=white
+roommention=white
+me=white
+them=white
roster.header=white
-occupants.header=white
+occupants.header=white
\ No newline at end of file
diff --git a/themes/orange b/themes/orange
index cff5f58b..57df02fd 100644
--- a/themes/orange
+++ b/themes/orange
@@ -3,6 +3,16 @@ bkgnd=yellow
titlebar=red
titlebar.text=black
titlebar.brackets=blue
+titlebar.unencrypted=black
+titlebar.encrypted=white
+titlebar.untrusted=white
+titlebar.trusted=green
+titlebar.online=white
+titlebar.offline=black
+titlebar.away=white
+titlebar.chat=white
+titlebar.dnd=black
+titlebar.xa=white
statusbar=green
statusbar.text=black
statusbar.brackets=blue
@@ -11,32 +21,29 @@ statusbar.new=white
main.text=black
main.text.me=black
main.text.them=green
-main.time=blue
main.splash=blue
+main.time=blue
input.text=black
subscribed=blue
-unsubscribed=red
+unsubscribed=white
+otr.started.trusted=green
+otr.started.untrusted=white
+otr.ended=red
+otr.trusted=green
+otr.untrusted=white
online=blue
away=white
chat=blue
dnd=white
xa=white
offline=white
+incoming=blue
typing=black
gone=green
error=red
-incoming=blue
roominfo=blue
-me=blue
-them=green
-titlebar.unencrypted=black
-titlebar.encrypted=white
-titlebar.untrusted=white
-titlebar.trusted=green
-otr.started.trusted=green
-otr.started.untrusted=white
-otr.ended=red
-otr.trusted=green
-otr.untrusted=white
+roommention=blue
+me=black
+them=black
roster.header=black
-occupants.header=black
+occupants.header=black
\ No newline at end of file
diff --git a/themes/original b/themes/original
index db0818c5..33ae041b 100644
--- a/themes/original
+++ b/themes/original
@@ -1,35 +1,8 @@
[colours]
bkgnd=default
titlebar=blue
-statusbar=blue
titlebar.text=white
titlebar.brackets=cyan
-statusbar.text=white
-statusbar.brackets=cyan
-statusbar.active=cyan
-statusbar.new=white
-main.text=white
-main.text.me=white
-main.text.them=white
-input.text=white
-main.time=white
-main.splash=cyan
-subscribed=green
-unsubscribed=red
-online=green
-away=cyan
-chat=green
-dnd=red
-xa=cyan
-offline=red
-typing=yellow
-gone=red
-error=red
-incoming=yellow
-roominfo=yellow
-roommention=yellow
-me=yellow
-them=green
titlebar.unencrypted=red
titlebar.encrypted=white
titlebar.untrusted=yellow
@@ -37,13 +10,40 @@ titlebar.trusted=white
titlebar.online=white
titlebar.offline=white
titlebar.away=white
-titlebar.xa=white
-titlebar.dnd=white
titlebar.chat=white
+titlebar.dnd=white
+titlebar.xa=white
+statusbar=blue
+statusbar.text=white
+statusbar.brackets=cyan
+statusbar.active=cyan
+statusbar.new=white
+main.text=white
+main.text.me=white
+main.text.them=white
+main.splash=cyan
+main.time=white
+input.text=white
+subscribed=green
+unsubscribed=red
otr.started.trusted=green
otr.started.untrusted=yellow
otr.ended=red
otr.trusted=green
otr.untrusted=yellow
+online=green
+away=cyan
+chat=green
+dnd=red
+xa=cyan
+offline=red
+incoming=yellow
+typing=yellow
+gone=yellow
+error=red
+roominfo=yellow
+roommention=yellow
+me=yellow
+them=green
roster.header=yellow
-occupants.header=yellow
+occupants.header=yellow
\ No newline at end of file
diff --git a/themes/original_bright b/themes/original_bright
index ffe0c12c..4ad4af17 100644
--- a/themes/original_bright
+++ b/themes/original_bright
@@ -1,35 +1,8 @@
[colours]
bkgnd=default
titlebar=blue
-statusbar=blue
titlebar.text=bold_white
titlebar.brackets=bold_cyan
-statusbar.text=bold_white
-statusbar.brackets=bold_cyan
-statusbar.active=bold_cyan
-statusbar.new=bold_white
-main.text=bold_white
-main.text.me=bold_white
-main.text.them=bold_white
-input.text=bold_white
-main.time=bold_white
-main.splash=bold_cyan
-subscribed=bold_green
-unsubscribed=bold_red
-online=bold_green
-away=bold_cyan
-chat=bold_green
-dnd=bold_red
-xa=bold_cyan
-offline=bold_red
-typing=bold_yellow
-gone=bold_red
-error=bold_red
-incoming=bold_yellow
-roominfo=bold_yellow
-roommention=bold_yellow
-me=bold_yellow
-them=bold_green
titlebar.unencrypted=bold_red
titlebar.encrypted=bold_white
titlebar.untrusted=bold_yellow
@@ -37,13 +10,40 @@ titlebar.trusted=bold_white
titlebar.online=bold_white
titlebar.offline=bold_white
titlebar.away=bold_white
-titlebar.xa=bold_white
-titlebar.dnd=bold_white
titlebar.chat=bold_white
+titlebar.dnd=bold_white
+titlebar.xa=bold_white
+statusbar=blue
+statusbar.text=bold_white
+statusbar.brackets=bold_cyan
+statusbar.active=bold_cyan
+statusbar.new=bold_white
+main.text=bold_white
+main.text.me=bold_white
+main.text.them=bold_white
+main.splash=bold_cyan
+main.time=bold_white
+input.text=bold_white
+subscribed=bold_green
+unsubscribed=bold_red
otr.started.trusted=bold_green
otr.started.untrusted=bold_yellow
otr.ended=bold_red
otr.trusted=bold_green
otr.untrusted=bold_yellow
+online=bold_green
+away=bold_cyan
+chat=bold_green
+dnd=bold_red
+xa=bold_cyan
+offline=bold_red
+incoming=bold_yellow
+typing=bold_yellow
+gone=bold_yellow
+error=bold_red
+roominfo=bold_yellow
+roommention=bold_yellow
+me=bold_yellow
+them=bold_green
roster.header=bold_yellow
occupants.header=bold_yellow
diff --git a/themes/shade b/themes/shade
index 0b61a0f7..856b2fa4 100644
--- a/themes/shade
+++ b/themes/shade
@@ -1,36 +1,49 @@
[colours]
bkgnd=default
titlebar=default
-statusbar=default
titlebar.text=white
titlebar.brackets=magenta
+titlebar.unencrypted=red
+titlebar.encrypted=green
+titlebar.untrusted=red
+titlebar.trusted=green
+titlebar.online=green
+titlebar.offline=red
+titlebar.away=green
+titlebar.chat=green
+titlebar.dnd=red
+titlebar.xa=green
+statusbar=default
statusbar.text=magenta
statusbar.brackets=magenta
statusbar.active=white
statusbar.new=green
main.text=white
-input.text=white
-main.time=magenta
+main.text.me=white
+main.text.them=white
main.splash=magenta
+main.time=magenta
+input.text=white
+subscribed=green
+unsubscribed=yallow
+otr.started.trusted=green
+otr.started.untrusted=red
+otr.ended=yellow
+otr.trusted=green
+otr.untrusted=red
online=green
away=yellow
chat=green
dnd=green
xa=yellow
offline=white
+incoming=yellow
typing=green
gone=red
error=red
-incoming=yellow
roominfo=green
-me=black
+roommention=green
+me=bold_black
them=magenta
-titlebar.unencrypted=red
-titlebar.encrypted=green
-titlebar.untrusted=red
-titlebar.trusted=green
-otr.started.trusted=green
-otr.started.untrusted=red
-otr.ended=yellow
-otr.trusted=green
-otr.untrusted=red
+roster.header=magenta
+occupants.header=magenta
\ No newline at end of file
diff --git a/themes/simple b/themes/simple
index 44c6977b..0b9baab5 100644
--- a/themes/simple
+++ b/themes/simple
@@ -1,67 +1,22 @@
-[colours]
-bkgnd=default
-titlebar=blue
-statusbar=blue
-titlebar.text=bold_white
-titlebar.brackets=white
-statusbar.text=bold_white
-statusbar.brackets=white
-statusbar.active=bold_cyan
-statusbar.new=bold_green
-main.text=white
-main.text.me=cyan
-main.text.them=bold_white
-input.text=bold_green
-main.time=yellow
-main.splash=bold_red
-online=bold_green
-away=bold_cyan
-chat=bold_white
-dnd=magenta
-xa=bold_blue
-offline=red
-typing=yellow
-gone=red
-error=red
-incoming=bold_yellow
-roominfo=yellow
-roommention=bold_red
-me=blue
-them=bold_green
-titlebar.unencrypted=bold_red
-titlebar.encrypted=bold_white
-titlebar.untrusted=bold_yellow
-titlebar.trusted=bold_white
-titlebar.online=bold_green
-titlebar.offline=bold_red
-titlebar.away=bold_cyan
-titlebar.xa=bold_cyan
-titlebar.dnd=bold_red
-titlebar.chat=bold_green
-otr.started.trusted=green
-otr.started.untrusted=yellow
-otr.ended=red
-otr.trusted=green
-otr.untrusted=yellow
-roster.header=bold_yellow
-occupants.header=bold_yellow
-
[ui]
-intype=false
beep=false
flash=false
-privileges=false
-presence=false
+splash=true
wrap=true
time=minutes
-statuses.muc=off
-statuses.chat=online
-statuses.console=off
+resource.title=false
+resource.message=false
+statuses.console=none
+statuses.chat=none
+statuses.muc=none
occupants=true
occupants.size=15
roster=true
-roster.size=25
roster.offline=false
roster.resource=false
roster.by=presence
+roster.size=25
+privileges=false
+presence=false
+intype=false
otr.warn=false
diff --git a/themes/spawn b/themes/spawn
index 0b403905..44c9f098 100644
--- a/themes/spawn
+++ b/themes/spawn
@@ -1,37 +1,49 @@
[colours]
bkgnd=default
titlebar=red
-statusbar=red
titlebar.text=yellow
titlebar.brackets=green
+titlebar.unencrypted=red
+titlebar.encrypted=green
+titlebar.untrusted=red
+titlebar.trusted=green
+titlebar.online=green
+titlebar.offline=red
+titlebar.away=green
+titlebar.chat=green
+titlebar.dnd=red
+titlebar.xa=green
+statusbar=red
statusbar.text=yellow
statusbar.brackets=green
statusbar.active=white
statusbar.new=green
main.text=white
-input.text=green
-main.time=red
+main.text.me=white
+main.text.them=white
main.splash=red
-online=green
-away=yellow
-chat=green
-dnd=green
-xa=yellow
-offline=grey
-typing=green
-gone=red
-error=red
-incoming=yellow
-roominfo=green
-roommention=red
-me=green
-them=yellow
-titlebar.unencrypted=red
-titlebar.encrypted=green
-titlebar.untrusted=red
-titlebar.trusted=green
+main.time=red
+input.text=green
+subscribed=green
+unsubscribed=red
otr.started.trusted=green
otr.started.untrusted=red
otr.ended=yellow
otr.trusted=green
otr.untrusted=red
+online=green
+away=yellow
+chat=green
+dnd=green
+xa=yellow
+offline=bold_black
+incoming=yellow
+typing=green
+gone=red
+error=red
+roominfo=green
+roommention=red
+me=green
+them=yellow
+roster.header=white
+occupants.header=white
\ No newline at end of file
diff --git a/themes/whiteness b/themes/whiteness
index 597c9c83..c448fcfb 100644
--- a/themes/whiteness
+++ b/themes/whiteness
@@ -1,36 +1,49 @@
[colours]
bkgnd=white
titlebar=blue
-statusbar=blue
titlebar.text=white
titlebar.brackets=white
+titlebar.unencrypted=red
+titlebar.encrypted=white
+titlebar.untrusted=yellow
+titlebar.trusted=white
+titlebar.online=white
+titlebar.offline=red
+titlebar.away=white
+titlebar.chat=white
+titlebar.dnd=red
+titlebar.xa=white
+statusbar=blue
statusbar.text=white
statusbar.brackets=white
statusbar.active=megenta
statusbar.new=red
main.text=black
-input.text=black
-main.time=black
+main.text.me=black
+main.text.them=black
main.splash=black
+main.time=black
+input.text=black
+subscribed=green
+unsubscribed=red
+otr.started.trusted=green
+otr.started.untrusted=yellow
+otr.ended=red
+otr.trusted=green
+otr.untrusted=yellow
online=green
away=cyan
chat=green
dnd=red
xa=cyan
offline=red
+incoming=yellow
typing=yellow
gone=red
error=red
-incoming=yellow
roominfo=yellow
-me=yellow
-them=green
-titlebar.unencrypted=red
-titlebar.encrypted=white
-titlebar.untrusted=yellow
-titlebar.trusted=white
-otr.started.trusted=green
-otr.started.untrusted=yellow
-otr.ended=red
-otr.trusted=green
-otr.untrusted=yellow
+roommention=yellow
+me=black
+them=black
+roster.header=black
+occupants.header=black
\ No newline at end of file
From 6be4b400b80d242538824d626297e1f70ed59b53 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Mar 2015 22:10:01 +0000
Subject: [PATCH 105/252] Fixed swapping windows when in source win
---
src/ui/windows.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/ui/windows.c b/src/ui/windows.c
index dba5290c..b534e973 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -639,20 +639,21 @@ wins_swap(int source_win, int target_win)
{
ProfWin *source = g_hash_table_lookup(windows, GINT_TO_POINTER(source_win));
- if (source != NULL) {
+ if (source) {
ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win));
// target window empty
- if (target == NULL) {
+ if (!target) {
g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
- status_bar_inactive(source_win);
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
+ status_bar_inactive(source_win);
if (win_unread(source) > 0) {
status_bar_new(target_win);
} else {
status_bar_active(target_win);
}
- if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
+ if (wins_get_current_num() == source_win) {
+ wins_set_current_by_num(target_win);
ui_switch_win(1);
}
return TRUE;
From f80689dd3549920c444c9613b72f7fc5901a8c5e Mon Sep 17 00:00:00 2001
From: James Booth
Date: Tue, 3 Mar 2015 22:22:28 +0000
Subject: [PATCH 106/252] Set version to 0.4.6
---
configure.ac | 2 +-
install-all.sh | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 7369f112..a9896555 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ AS_CASE([$host_os],
[cygwin], [PLATFORM="cygwin"],
[PLATFORM="nix"])
-PACKAGE_STATUS="development"
+PACKAGE_STATUS="release"
### Get git branch and revision if in development
if test "x$PACKAGE_STATUS" = xdevelopment; then
diff --git a/install-all.sh b/install-all.sh
index cc32d8fd..7970804b 100755
--- a/install-all.sh
+++ b/install-all.sh
@@ -74,6 +74,7 @@ install_lib_strophe()
echo
git clone git://github.com/strophe/libstrophe.git
cd libstrophe
+ git checkout 0.8.7
./bootstrap.sh
./configure --prefix=$1
make
@@ -102,6 +103,7 @@ cyg_install_lib_strophe()
echo
git clone git://github.com/strophe/libstrophe.git
cd libstrophe
+ git checkout 0.8.7
./bootstrap.sh
./bootstrap.sh # second call seems to fix problem on cygwin
./configure --prefix=/usr
From 0dee898c01c851deeda17602d809c02708483a14 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 4 Mar 2015 00:45:42 +0000
Subject: [PATCH 107/252] Set version to 0.4.7 development
---
configure.ac | 4 ++--
install-all.sh | 2 --
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index a9896555..4665efb9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
-AC_INIT([profanity], [0.4.6], [boothj5web@gmail.com])
+AC_INIT([profanity], [0.4.7], [boothj5web@gmail.com])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([src/config.h])
@@ -20,7 +20,7 @@ AS_CASE([$host_os],
[cygwin], [PLATFORM="cygwin"],
[PLATFORM="nix"])
-PACKAGE_STATUS="release"
+PACKAGE_STATUS="development"
### Get git branch and revision if in development
if test "x$PACKAGE_STATUS" = xdevelopment; then
diff --git a/install-all.sh b/install-all.sh
index 7970804b..cc32d8fd 100755
--- a/install-all.sh
+++ b/install-all.sh
@@ -74,7 +74,6 @@ install_lib_strophe()
echo
git clone git://github.com/strophe/libstrophe.git
cd libstrophe
- git checkout 0.8.7
./bootstrap.sh
./configure --prefix=$1
make
@@ -103,7 +102,6 @@ cyg_install_lib_strophe()
echo
git clone git://github.com/strophe/libstrophe.git
cd libstrophe
- git checkout 0.8.7
./bootstrap.sh
./bootstrap.sh # second call seems to fix problem on cygwin
./configure --prefix=/usr
From 5e1ad0b0d215e11c330ba1e3687119304062d358 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 4 Mar 2015 22:37:42 +0000
Subject: [PATCH 108/252] Added profanity.sh (OSX helper script for codelite)
to .gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 37449348..ba909849 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
# *.[oa]
# *~
profanity
+profanity.sh
*.o
*.log
*.swp
From 7638f379cac3869abdd8530faa09cc7481e99ec6 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Wed, 4 Mar 2015 23:32:47 +0000
Subject: [PATCH 109/252] Fixed tests for --disable-otr
---
Makefile.am | 6 +++++-
tests/testsuite.c | 2 ++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index d9fa9729..809c3eea 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,6 +44,7 @@ tests_sources = \
src/roster_list.c src/roster_list.h \
src/xmpp/xmpp.h src/xmpp/form.c \
src/ui/ui.h \
+ src/otr/otr.h \
src/command/command.h src/command/command.c \
src/command/commands.h src/command/commands.c \
src/tools/parser.c \
@@ -63,7 +64,6 @@ tests_sources = \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
src/server_events.c src/server_events.h \
tests/xmpp/stub_xmpp.c \
- tests/otr/stub_otr.c \
tests/ui/stub_ui.c \
tests/log/stub_log.c \
tests/config/stub_accounts.c \
@@ -104,6 +104,9 @@ otr3_sources = \
otr4_sources = \
src/otr/otrlib.h src/otr/otrlibv4.c src/otr/otr.h src/otr/otr.c
+otr_test_sources = \
+ tests/otr/stub_otr.c
+
themes_sources = themes/*
script_sources = bootstrap.sh configure-debug install-all.sh
@@ -111,6 +114,7 @@ script_sources = bootstrap.sh configure-debug install-all.sh
man_sources = docs/profanity.1
if BUILD_OTR
+tests_sources += $(otr_test_sources)
if BUILD_OTR3
core_sources += $(otr3_sources)
endif
diff --git a/tests/testsuite.c b/tests/testsuite.c
index ddfb45cd..645a1a40 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -346,9 +346,11 @@ int main(int argc, char* argv[]) {
unit_test(cmd_account_set_eval_password_when_password_set),
unit_test(cmd_account_set_muc_sets_muc),
unit_test(cmd_account_set_nick_sets_nick),
+#ifdef HAVE_LIBOTR
unit_test(cmd_account_show_message_for_missing_otr_policy),
unit_test(cmd_account_show_message_for_invalid_otr_policy),
unit_test(cmd_account_set_otr_sets_otr),
+#endif
unit_test(cmd_account_set_status_shows_message_when_invalid_status),
unit_test(cmd_account_set_status_sets_status_when_valid),
unit_test(cmd_account_set_status_sets_status_when_last),
From e361ea69221bded41784b9f4f1682a64baac13ac Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 8 Mar 2015 18:47:01 +0000
Subject: [PATCH 110/252] Added conditional OSX check for readline
---
configure.ac | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index c38c09c3..ec599f7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,8 +135,16 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [],
[AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
PKG_CHECK_MODULES([curl], [libcurl], [],
[AC_MSG_ERROR([libcurl is required for profanity])])
-AC_CHECK_LIB([readline], [main], [],
- [AC_MSG_ERROR([libreadline is required for profanity])])
+
+AS_IF([test "x$PLATFORM" != xosx],
+ [AC_CHECK_LIB([readline], [main], [],
+ [AC_MSG_ERROR([libreadline is required for profanity])])],
+ [AC_CHECK_FILE([/usr/local/opt/readline/lib],
+ [LIBS="-lreadline $LIBS"
+ AM_CPPFLAGS="-I/usr/local/opt/readline/include $AM_CPPFLAGS"
+ AM_LDFLAGS="-L/usr/local/opt/readline/lib $AM_LDFLAGS"
+ AC_SUBST(AM_LDFLAGS)],
+ [AC_MSG_ERROR([libreadline is required for profanity])])])
AS_IF([test "x$PLATFORM" = xosx], [LIBS="-lcurl $LIBS"])
@@ -236,13 +244,6 @@ AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS"
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
LIBS="$glib_LIBS $curl_LIBS $libnotify_LIBS $LIBS"
-### Use brew installed gnu readline
-AS_IF([test "x$PLATFORM" = xosx], [
- LIBS="-lreadline $LIBS"
- AM_CPPFLAGS="-I/usr/local/opt/readline/include $AM_CPPFLAGS"
- AM_LDFLAGS="-L/usr/local/opt/readline/lib $AM_LDFLAGS"
- AC_SUBST(AM_LDFLAGS)])
-
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CPPFLAGS)
From e632f254d3d92d474a664f3bbaf0730032a949e3 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 8 Mar 2015 19:06:38 +0000
Subject: [PATCH 111/252] Added libreadline-dev to install-all.sh for ubuntu
---
install-all.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/install-all.sh b/install-all.sh
index cc32d8fd..e3364ed9 100755
--- a/install-all.sh
+++ b/install-all.sh
@@ -24,7 +24,7 @@ debian_prepare()
echo
echo Profanity installer... installing dependencies
echo
- sudo apt-get -y install git automake autoconf libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr5-dev libtool
+ sudo apt-get -y install git automake autoconf libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr5-dev libreadline-dev libtool
}
From 84de10e7cd940bd0290099f666ceebb5599e87f2 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 8 Mar 2015 19:21:35 +0000
Subject: [PATCH 112/252] Added readline-devel to instal-all.sh for fedora
---
install-all.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/install-all.sh b/install-all.sh
index e3364ed9..0f957dbc 100755
--- a/install-all.sh
+++ b/install-all.sh
@@ -36,7 +36,7 @@ fedora_prepare()
ARCH=`arch`
- sudo yum -y install gcc git autoconf automake openssl-devel.$ARCH expat-devel.$ARCH ncurses-devel.$ARCH glib2-devel.$ARCH libnotify-devel.$ARCH libcurl-devel.$ARCH libXScrnSaver-devel.$ARCH libotr3-devel.$ARCH libtool
+ sudo yum -y install gcc git autoconf automake openssl-devel.$ARCH expat-devel.$ARCH ncurses-devel.$ARCH glib2-devel.$ARCH libnotify-devel.$ARCH libcurl-devel.$ARCH libXScrnSaver-devel.$ARCH libotr3-devel.$ARCH readline-devel.$ARCH libtool
}
opensuse_prepare()
From 8d968884051cec3c6fc4e6b678a3430d4b88daf2 Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 8 Mar 2015 19:32:03 +0000
Subject: [PATCH 113/252] Added readline-devel to install-all.sh for opensuse
---
install-all.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/install-all.sh b/install-all.sh
index 0f957dbc..8972bace 100755
--- a/install-all.sh
+++ b/install-all.sh
@@ -44,7 +44,7 @@ opensuse_prepare()
echo
echo Profanity installer...installing dependencies
echo
- sudo zypper -n in gcc git automake make autoconf libopenssl-devel expat libexpat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel libtool
+ sudo zypper -n in gcc git automake make autoconf libopenssl-devel expat libexpat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool
}
cygwin_prepare()
From 232bf9b7fc80b0f2013359f002d38bc7a4d9c50f Mon Sep 17 00:00:00 2001
From: James Booth
Date: Sun, 8 Mar 2015 19:45:19 +0000
Subject: [PATCH 114/252] Added libreadline-devel to install-all.sh for cygwin
---
install-all.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/install-all.sh b/install-all.sh
index 8972bace..a054e166 100755
--- a/install-all.sh
+++ b/install-all.sh
@@ -60,9 +60,9 @@ cygwin_prepare()
mv apt-cyg /usr/local/bin/
if [ -n "$CYG_MIRROR" ]; then
- apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libtool
+ apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libreadline-devel libtool
else
- apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libtool
+ apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libreadline-devel libtool
fi
}
From 88af6e34559efe93fa241323287631b015ef6f25 Mon Sep 17 00:00:00 2001
From: James Booth