mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
Merge pull request #973 from ailin-nemui/perl-wcwidth
expose wcwidth and related to perl
This commit is contained in:
commit
1c6f256098
@ -2,6 +2,8 @@
|
||||
#include "module.h"
|
||||
#include "irssi-version.h"
|
||||
#include "core.h"
|
||||
#include "utf8.h"
|
||||
#include "recode.h"
|
||||
|
||||
#include "pidwait.h"
|
||||
#include "session.h"
|
||||
@ -687,6 +689,25 @@ CODE:
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
int
|
||||
string_width(str)
|
||||
char *str
|
||||
C_ARGS:
|
||||
str, is_utf8() ? TREAT_STRING_AS_UTF8 : TREAT_STRING_AS_BYTES
|
||||
|
||||
void
|
||||
string_chars_for_width(str, width)
|
||||
char *str
|
||||
unsigned int width
|
||||
PREINIT:
|
||||
int retval;
|
||||
unsigned int bytes;
|
||||
PPCODE:
|
||||
retval = string_chars_for_width(str, is_utf8() ? TREAT_STRING_AS_UTF8 : TREAT_STRING_AS_BYTES, width, &bytes);
|
||||
mXPUSHi(retval);
|
||||
mXPUSHu(bytes);
|
||||
|
||||
|
||||
#*******************************
|
||||
MODULE = Irssi::Core PACKAGE = Irssi::Server
|
||||
#*******************************
|
||||
|
@ -205,6 +205,28 @@ gui_input_set_pos(pos)
|
||||
CODE:
|
||||
gui_entry_set_pos(active_entry, pos);
|
||||
|
||||
int
|
||||
wcwidth(c)
|
||||
char *c
|
||||
CODE:
|
||||
if (term_type == TERM_TYPE_UTF8) {
|
||||
unichar chr = g_utf8_get_char_validated((const char *) c, -1);
|
||||
|
||||
if (chr & 0x80000000) {
|
||||
RETVAL = 1;
|
||||
} else {
|
||||
RETVAL = i_wcwidth(chr);
|
||||
}
|
||||
} else if (term_type != TERM_TYPE_BIG5 ||
|
||||
c[1] == '\0' ||
|
||||
!is_big5((unsigned char) c[0], (unsigned char) c[1])) {
|
||||
RETVAL = i_wcwidth((unsigned char) *c);
|
||||
} else {
|
||||
RETVAL = 2;
|
||||
}
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
MODULE = Irssi::TextUI PACKAGE = Irssi::UI::Window
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user