Skip to content

Instantly share code, notes, and snippets.

@poochin
Created April 26, 2012 02:03
Show Gist options
  • Select an option

  • Save poochin/2495180 to your computer and use it in GitHub Desktop.

Select an option

Save poochin/2495180 to your computer and use it in GitHub Desktop.
ViChrome で不明なコマンド入力がされた際に例外を飛ばすか飛ばさないかをオプションで設定できるようにするパッチを書きました(パッチ部分はMITで)
diff -cr 0.11.0_0/command.js 0.11.0_0p/command.js
*** 0.11.0_0/command.js 2012-04-26 10:54:01.323464160 +0900
--- 0.11.0_0p/command.js 2012-04-26 10:56:23.351463806 +0900
***************
*** 358,364 ****
event.stopPropagation();
return event.preventDefault();
default:
! this.execCommand(com);
event.stopPropagation();
return event.preventDefault();
}
--- 358,371 ----
event.stopPropagation();
return event.preventDefault();
default:
! try {
! this.execCommand(com);
! } catch (e) {
! if (e == "invalid command" && g.model.getSetting("throwExceptionInvalidCommand")) {
! throw e;
! }
! break;
! }
event.stopPropagation();
return event.preventDefault();
}
diff -cr 0.11.0_0/options.html 0.11.0_0p/options.html
*** 0.11.0_0/options.html 2012-04-26 10:54:01.323464160 +0900
--- 0.11.0_0p/options.html 2012-04-26 10:56:37.767463771 +0900
***************
*** 105,110 ****
--- 105,118 ----
</span>
</label>
</div>
+ <div>
+ <label>
+ <input id="throwExceptionInvalidCommand" type="checkbox" />
+ <span class="option">
+ Throw Exception input Invalid Command (JavaScript Console)
+ </span>
+ </label>
+ </div>
</div>
</section>
<section>
diff -cr 0.11.0_0/options.js 0.11.0_0p/options.js
*** 0.11.0_0/options.js 2012-04-26 10:54:01.323464160 +0900
--- 0.11.0_0p/options.js 2012-04-26 10:56:49.903463737 +0900
***************
*** 147,152 ****
--- 147,153 ----
initCheckBox("useMigemo");
initCheckBox("fModeIgnoreCase");
initCheckBox("notifyUpdateSucceeded");
+ initCheckBox("throwExceptionInvalidCommand");
initCheckBox("useFModeAnimation");
initDropDown("commandBoxAlign");
initDropDown("searchEngine");
diff -cr 0.11.0_0/settings.js 0.11.0_0p/settings.js
*** 0.11.0_0/settings.js 2012-04-26 10:54:01.323464160 +0900
--- 0.11.0_0p/settings.js 2012-04-26 10:56:58.895463717 +0900
***************
*** 39,44 ****
--- 39,45 ----
"hintColorSelected": "#DD4848",
"useFModeAnimation": true,
"notifyUpdateSucceeded": true,
+ "throwExceptionInvalidCommand": true,
"keyMappingAndAliases": "### Sample Settings\n\n# aliases\n# in this example you can open extensions page by the command ':ext'\n# and Chrome's option page by the command ':option'\nalias ext TabOpenNew chrome://extensions/\nalias option TabOpenNew chrome://settings/browser\nalias downloads TabOpenNew chrome://downloads\nalias history TabOpenNew chrome://history\n\n# mappings for opening your favorite web page\nnmap <Space>tw :TabOpenNew http://www.twitter.com\nnmap <Space>gr :TabOpenNew http://www.google.com/reader\nnmap <Space>m :TabOpenNew https://mail.google.com/mail/#inbox\n\n# F for continuous f-Mode\n# this is recomended setting but commented out by default.\n# if you want to use this setting, use the following\n#nmap F :GoFMode --newtab --continuous\n\n# you can use <DISCARD> to discard the key so that chrome's default\n# action isn't triggered.\n#nmap <BS> <DISCARD>\n\n# if you want to change the key used to escape EmergencyMode mode,\n# use emap like the following\n#emap <ESC> :Escape\n\n## pagecmd offers you page specific key mapping.\n# in this example you can use <C-l>, <C-h> for moving between tabs\n# on all web pages regardless of your ignored list setting\n# because pagecmd has higher priority than ignored URLs.\npagecmd * nmap <C-l> :TabFocusNext\npagecmd * nmap <C-h> :TabFocusPrev\n\n# almost all Vichrome functions don't work properly for pdf contents\n# so it's useful to enable default key bindings for pdf file.\npagecmd *.pdf nmap <C-f> <NOP>\n\n# if you want to use twitter web's key binding, write settings like below\n#pagecmd http*://twitter.com/* nmap f <NOP>\n#pagecmd http*://twitter.com/* nmap r <NOP>",
"keyMappingNormal": {
"j": "ScrollDown",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment