Skip to content
This repository was archived by the owner on Dec 9, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
[ -z $EM_DIR] && EM_DIR=~/src/emscripten
[ -z "$EM_DIR" ] && EM_DIR=~/src/emscripten

do_config() {
echo config
Expand Down
2 changes: 2 additions & 0 deletions web/usr/local/share/vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ set wildmenu
set tabstop=4
set expandtab
set nocompatible
set encoding=utf8
set termencoding=utf8
set fileencodings=utf8
set backspace=indent,eol,start
set wildmode=longest,list,full
Expand Down
27 changes: 22 additions & 5 deletions web/vim_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,19 @@ var LibraryVIM = {
}
}

if(!handled)
vimjs.gui_web_handle_key(charCode || keyCode, modifiers, 0, 0);
if(!handled) {
var MAX_UTF8_BYTES = 6;
var chars = new Uint8Array(MAX_UTF8_BYTES + 1); // null-terminated
var charLen = stringToUTF8Array(String.fromCharCode(charCode), chars, 0, MAX_UTF8_BYTES);
if (charLen == 1) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this if clause?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into it today. Maybe it's not necessary. Sorry for taking so long to respond.

vimjs.gui_web_handle_key(chars[0], modifiers, 0, 0);
} else {
// no modifers for UTF-8, should be handled in chars already
for (var i = 0; i < charLen; i++) {
vimjs.gui_web_handle_key(chars[i], 0, 0, 0);
}
}
}

},//VIMJS_FOLD_END

Expand Down Expand Up @@ -778,7 +789,15 @@ var LibraryVIM = {
},

vimjs_draw_string__deps: ['vimjs_clear_block'],
vimjs_draw_string: function(row, col, s, len, flags) {
vimjs_draw_string: function(row, col, s_ptr, len, flags) {
var byteArray = [];
for (var i = 0; i < len; i++) {
c = getValue(s_ptr + i, 'i8', true);
byteArray.push(c);
}
byteArray.push(0);
var s = UTF8ArrayToString(byteArray, 0);
len = s.length;

// TODO: use macros for flag constants
if(!(flags & 0x01)) {
Expand All @@ -788,8 +807,6 @@ var LibraryVIM = {
var font = vimjs.font;
if(flags & 0x02) font = 'bold ' + font;

s = Pointer_stringify(s, len);

var ctx = vimjs.canvas_ctx;

ctx.font = font;
Expand Down