This repository has been archived by the owner on Dec 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 272
Feature/o3opt -O3 : 44 MB -> 37 MB #28
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,13 +86,27 @@ var LibraryVIM = { | |
if(charCode == 0) { | ||
var special = vimjs.special_keys[keyCode]; | ||
if(special !== undefined) { | ||
vimjs.gui_web_handle_key(charCode || keyCode, modifiers, special.charCodeAt(0), special.charCodeAt(1)); | ||
vimjs.gui_web_handle_key(keyCode, modifiers, special.charCodeAt(0), special.charCodeAt(1)); | ||
handled = true; | ||
} | ||
} else { | ||
vimjs.gui_web_handle_key(keyCode, modifiers, 0, 0); | ||
handled = true; | ||
} | ||
} | ||
|
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this if clause useful? |
||
vimjs.gui_web_handle_key(chars[0], 0, 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 | ||
|
||
|
@@ -685,6 +699,7 @@ var LibraryVIM = { | |
* C means "needed for Chrome" | ||
*/ | ||
var keys_to_intercept_upon_keydown = {}; | ||
var ctrl_keys_to_intercept_upon_keydown = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this line right before it is assigned. |
||
[ KeyEvent.DOM_VK_ESCAPE, // CF | ||
KeyEvent.DOM_VK_TAB, // C | ||
KeyEvent.DOM_VK_BACK_SPACE, // C | ||
|
@@ -695,14 +710,24 @@ var LibraryVIM = { | |
KeyEvent.DOM_VK_DELETE, // C | ||
KeyEvent.DOM_VK_PAGE_UP, // C | ||
KeyEvent.DOM_VK_PAGE_DOWN, // C | ||
KeyEvent.DOM_VK_HOME, // C | ||
KeyEvent.DOM_VK_END, // C | ||
].forEach(function(k) { | ||
keys_to_intercept_upon_keydown[k] = 1; | ||
}); | ||
[ | ||
KeyEvent.DOM_VK_F, | ||
KeyEvent.DOM_VK_B, | ||
].forEach(function(k) { | ||
ctrl_keys_to_intercept_upon_keydown[k] = 1; | ||
}); | ||
|
||
|
||
/* capture some special keys that won't trigger 'keypress' */ | ||
document.addEventListener('keydown', function(e) { | ||
if (ignoreKeys()) return true; | ||
if(e.keyCode in keys_to_intercept_upon_keydown) { | ||
if((e.keyCode in keys_to_intercept_upon_keydown) || | ||
(e.ctrlKey && (e.keyCode in ctrl_keys_to_intercept_upon_keydown))) { | ||
e.preventDefault(); | ||
vimjs.handle_key(0, e.keyCode, e); | ||
} | ||
|
@@ -778,7 +803,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)) { | ||
|
@@ -788,8 +821,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; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember that
emcc -E
does not work well. Did you try this on a fresh clone ofvim.js
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I think it worked. But for emterpreter I had to use emscripten 1.29 for the configure step and the latest version for make and link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I think it's better to use
gcc
here.