aboutsummaryrefslogtreecommitdiffstats
path: root/vim-mode/vim_mode.pl
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2010-09-27 21:07:39 +0000
committerSimon Ruderich <simon@ruderich.org>2010-09-27 21:07:39 +0000
commitc4c227c4aeaaad3a8b84cd8a1779d8b8aec1b510 (patch)
tree36f94554085a19a16ee8277685576f5b105c1d0a /vim-mode/vim_mode.pl
parentvim_mode: Fix e at end of the line and b at beginning of line with leading sp... (diff)
downloadirssi-scripts-c4c227c4aeaaad3a8b84cd8a1779d8b8aec1b510.tar.gz
irssi-scripts-c4c227c4aeaaad3a8b84cd8a1779d8b8aec1b510.zip
vim_mode: Add support for utf-8 manipulation, on by default.
Diffstat (limited to 'vim-mode/vim_mode.pl')
-rw-r--r--vim-mode/vim_mode.pl20
1 files changed, 17 insertions, 3 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl
index 40088fe..ef38daf 100644
--- a/vim-mode/vim_mode.pl
+++ b/vim-mode/vim_mode.pl
@@ -45,6 +45,7 @@
use strict;
use warnings;
+use Encode;
use List::Util;
use Irssi;
@@ -74,8 +75,8 @@ sub M_INS() { 0 } # insert mode
sub M_EX () { 2 } # extended mode (after a :?)
# word and non-word regex
-my $word = '[a-zA-Z0-9_]';
-my $non_word = '[^a-zA-Z0-9_\s]';
+my $word = '[\w_]';
+my $non_word = '[^\w_\s]';
# GLOBAL VARIABLES
@@ -84,6 +85,9 @@ my $DEBUG_ENABLED = 0;
sub DEBUG { $DEBUG_ENABLED }
+# use UTF-8 internally for string calculations/manipulations
+my $utf8 = 1;
+
# buffer to keep track of the last N keystrokes, used for Esc detection and
# insert mode mappings
my @input_buf;
@@ -1040,6 +1044,7 @@ sub vim_mode_init {
Irssi::settings_add_str('vim_mode', 'vim_mode_cmd_seq', '');
Irssi::settings_add_bool('vim_mode', 'vim_mode_debug', 0);
+ Irssi::settings_add_bool('vim_mode', 'vim_mode_utf8', 1);
setup_changed();
}
@@ -1062,6 +1067,8 @@ sub setup_changed {
}
$DEBUG_ENABLED = Irssi::settings_get_bool('vim_mode_debug');
+
+ $utf8 = Irssi::settings_get_bool('vim_mode_utf8');
}
sub UNLOAD {
@@ -1121,12 +1128,19 @@ sub _input {
my ($data, $ignore) = @_;
my $current_data = Irssi::parse_special('$L', 0, 0);
+ if ($utf8) {
+ $current_data = decode_utf8($current_data);
+ }
if (defined $data) {
if (!$ignore && ($data ne $current_data)) {
_add_undo_entry($current_data, _input_pos());
}
- Irssi::gui_input_set($data);
+ if ($utf8) {
+ Irssi::gui_input_set(encode_utf8($data));
+ } else {
+ Irssi::gui_input_set($data);
+ }
} else {
$data = $current_data;
}