Merge branch 'master' of github.com:irssi/irssi

This commit is contained in:
Todd A. Pratt 2015-12-09 20:48:21 -05:00
commit 5d99a3d59a
46 changed files with 243 additions and 170 deletions

View file

@ -26,6 +26,7 @@
#include "gui-entry.h"
#include "gui-printtext.h"
#include "term.h"
#include "recode.h"
#undef i_toupper
#undef i_tolower
@ -345,6 +346,33 @@ void gui_entry_set_active(GUI_ENTRY_REC *entry)
}
}
/* Return screen length of plain string */
static int scrlen_str(const char *str)
{
int len = 0;
char *stripped;
g_return_val_if_fail(str != NULL, 0);
str = stripped = strip_codes(str);
if (is_utf8() && g_utf8_validate(str, -1, NULL)) {
while (*str != '\0') {
gunichar c;
c = g_utf8_get_char(str);
str = g_utf8_next_char(str);
len += unichar_isprint(c) ? mk_wcwidth(c) : 1;
}
} else {
len = strlen(str);
}
g_free(stripped);
return len;
}
void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const char *str)
{
int oldlen;
@ -355,11 +383,11 @@ void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const char *str)
if (str != NULL) {
g_free_not_null(entry->prompt);
entry->prompt = g_strdup(str);
entry->promptlen = format_get_length(str);
entry->promptlen = scrlen_str(str);
}
if (entry->prompt != NULL)
gui_printtext(entry->xpos, entry->ypos, entry->prompt);
gui_printtext_internal(entry->xpos, entry->ypos, entry->prompt);
if (entry->promptlen != oldlen) {
gui_entry_fix_cursor(entry);

View file

@ -109,6 +109,16 @@ void gui_printtext(int xpos, int ypos, const char *str)
next_xpos = next_ypos = -1;
}
void gui_printtext_internal(int xpos, int ypos, const char *str)
{
next_xpos = xpos;
next_ypos = ypos;
printtext_gui_internal(str);
next_xpos = next_ypos = -1;
}
void gui_printtext_after_time(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str, time_t time)
{
GUI_WINDOW_REC *gui;

View file

@ -17,6 +17,7 @@ void gui_set_default_indent(const char *name);
INDENT_FUNC get_default_indent_func(void);
void gui_printtext(int xpos, int ypos, const char *str);
void gui_printtext_internal(int xpos, int ypos, const char *str);
void gui_printtext_after(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str);
void gui_printtext_after_time(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str, time_t time);

View file

@ -147,7 +147,6 @@ static void window_next_page(void)
static void paste_buffer_join_lines(GArray *buf)
{
#define IS_WHITE(c) ((c) == ' ' || (c) == '\t')
unsigned int i, count, indent, line_len;
unichar *arr, *dest, *last_lf_pos;
int last_lf;
@ -177,15 +176,15 @@ static void paste_buffer_join_lines(GArray *buf)
if (buf->len == 0)
return;
arr = (unichar *) paste_buffer->data;
arr = (unichar *)buf->data;
/* first line */
if (IS_WHITE(arr[0]))
if (isblank(arr[0]))
return;
/* find the first beginning of indented line */
for (i = 1; i < buf->len; i++) {
if (arr[i-1] == '\n' && IS_WHITE(arr[i]))
if (arr[i-1] == '\n' && isblank(arr[i]))
break;
}
if (i == buf->len)
@ -193,7 +192,7 @@ static void paste_buffer_join_lines(GArray *buf)
/* get how much indentation we have.. */
for (indent = 0; i < buf->len; i++, indent++) {
if (!IS_WHITE(arr[i]))
if (!isblank(arr[i]))
break;
}
if (i == buf->len)
@ -203,7 +202,7 @@ static void paste_buffer_join_lines(GArray *buf)
count = indent; last_lf = TRUE;
for (; i < buf->len; i++) {
if (last_lf) {
if (IS_WHITE(arr[i]))
if (isblank(arr[i]))
count++;
else {
last_lf = FALSE;
@ -220,11 +219,11 @@ static void paste_buffer_join_lines(GArray *buf)
get longer than 400 chars */
dest = arr; last_lf = TRUE; last_lf_pos = NULL; line_len = 0;
for (i = 0; i < buf->len; i++) {
if (last_lf && IS_WHITE(arr[i])) {
if (last_lf && isblank(arr[i])) {
/* whitespace, ignore */
} else if (arr[i] == '\n') {
if (!last_lf && i+1 != buf->len &&
IS_WHITE(arr[i+1])) {
isblank(arr[i+1])) {
last_lf_pos = dest;
*dest++ = ' ';
} else {

View file

@ -271,20 +271,6 @@ static void check_files(void)
}
}
#ifdef WIN32
static void winsock_init(void)
{
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD(2, 2);
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
printf("Error initializing winsock\n");
exit(1);
}
}
#endif
int main(int argc, char **argv)
{
@ -315,9 +301,6 @@ int main(int argc, char **argv)
check_files();
#ifdef WIN32
winsock_init();
#endif
#ifdef HAVE_SOCKS
SOCKSinit(argv[0]);
#endif