Skip to content

Commit

Permalink
Fixed #936 Ace editor theme to be selectable
Browse files Browse the repository at this point in the history
  • Loading branch information
kawamataryo committed Sep 18, 2022
1 parent ce9ff79 commit 8487d89
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ Some functionalities are also available when you're using original pdf viewer, b
| settings.editableBodyCare | true | Insert mode is activated automatically when an editable element is focused, so if document.body is editable for some window/iframe (such as docs.google.com), Insert mode is always activated on the window/iframe, which means all shortcuts from Normal mode will not be available. With `editableBodyCare` as `true`, Insert mode will not be activated automatically in this case. |
| settings.ignoredFrameHosts | ["https://tpc.googlesyndication.com"] | When using `w` to loop through frames, you could use this settings to exclude some of them, such as those for advertisements. |
| settings.aceKeybindings | "vim" | Set it "emacs" to use emacs keybindings in the ACE editor. |
| settings.aceTheme | "chrome" | Set the theme of the ACE editor. |
| settings.caretViewport | null | Set it in format `[top, left, bottom, right]` to limit hints generation on `v` for entering visual mode, such as `[window.innerHeight / 2 - 10, 0, window.innerHeight / 2 + 10, window.innerWidth]` will make Surfingkeys generate Hints only for text that display on vertically middle of window. |
| settings.mouseSelectToQuery | [] | All hosts that have enable feature -- mouse selection to query. |
| settings.autoSpeakOnInlineQuery | false | Whether to automatically speak the query string with TTS on inline query. |
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ Surfingkeys默认使用[这个markdown分析器](https://github.com/chjj/marked)
| settings.editableBodyCare | true | 当焦点定位到一个可编辑的元素时,Insert模式会自动激活,所以如果某个window/iframe里的document.body本身就是可编辑的(例如docs.google.com),Insert模式会一直处于激活状态,这样所有Normal模式下的按键都不可用了。当`editableBodyCare``true`时,Insert模式在这种情况下不会自动激活。|
| settings.ignoredFrameHosts | ["https://tpc.googlesyndication.com"] | 当用`w`切换frame时,你可以用这个设置来过滤掉某些frame,比如那些做广告的frame。|
| settings.aceKeybindings | "vim" | 改为"emacs"可以在ACE编辑器里使用Emacs按键。 |
| settings.aceTheme | "chrome" | 你可以指定ACE编辑器的主题。 |
| settings.caretViewport | null |`[top, left, bottom, right]`格式设置,可以限制按`v`进入可视模式时的选择范围。比如`[window.innerHeight / 2 - 10, 0, window.innerHeight / 2 + 10, window.innerWidth]`会使Surfingkeys只会为显示在窗口中间的文字生成拨号盘字符。|
| settings.mouseSelectToQuery | [] | 所有启用鼠标选择查询功能的网站列表。 |
| settings.autoSpeakOnInlineQuery | false | 是否在使用inline query时自动发声。 |
Expand Down
44 changes: 44 additions & 0 deletions src/content_scripts/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,47 @@ import "ace-builds/src-noconflict/ext-language_tools";
import "ace-builds/src-noconflict/keybinding-vim";
import "ace-builds/src-noconflict/mode-javascript";
import "ace-builds/src-noconflict/theme-chrome";
import "ace-builds/src-noconflict/theme-ambiance.js";
import "ace-builds/src-noconflict/theme-chaos.js";
import "ace-builds/src-noconflict/theme-chrome.js";
import "ace-builds/src-noconflict/theme-cloud9_day.js";
import "ace-builds/src-noconflict/theme-cloud9_night.js";
import "ace-builds/src-noconflict/theme-cloud9_night_low_color.js";
import "ace-builds/src-noconflict/theme-clouds.js";
import "ace-builds/src-noconflict/theme-clouds_midnight.js";
import "ace-builds/src-noconflict/theme-cobalt.js";
import "ace-builds/src-noconflict/theme-crimson_editor.js";
import "ace-builds/src-noconflict/theme-dawn.js";
import "ace-builds/src-noconflict/theme-dracula.js";
import "ace-builds/src-noconflict/theme-dreamweaver.js";
import "ace-builds/src-noconflict/theme-eclipse.js";
import "ace-builds/src-noconflict/theme-github.js";
import "ace-builds/src-noconflict/theme-gob.js";
import "ace-builds/src-noconflict/theme-gruvbox.js";
import "ace-builds/src-noconflict/theme-gruvbox_dark_hard.js";
import "ace-builds/src-noconflict/theme-gruvbox_light_hard.js";
import "ace-builds/src-noconflict/theme-idle_fingers.js";
import "ace-builds/src-noconflict/theme-iplastic.js";
import "ace-builds/src-noconflict/theme-katzenmilch.js";
import "ace-builds/src-noconflict/theme-kr_theme.js";
import "ace-builds/src-noconflict/theme-kuroir.js";
import "ace-builds/src-noconflict/theme-merbivore.js";
import "ace-builds/src-noconflict/theme-merbivore_soft.js";
import "ace-builds/src-noconflict/theme-mono_industrial.js";
import "ace-builds/src-noconflict/theme-monokai.js";
import "ace-builds/src-noconflict/theme-nord_dark.js";
import "ace-builds/src-noconflict/theme-one_dark.js";
import "ace-builds/src-noconflict/theme-pastel_on_dark.js";
import "ace-builds/src-noconflict/theme-solarized_dark.js";
import "ace-builds/src-noconflict/theme-solarized_light.js";
import "ace-builds/src-noconflict/theme-sqlserver.js";
import "ace-builds/src-noconflict/theme-terminal.js";
import "ace-builds/src-noconflict/theme-textmate.js";
import "ace-builds/src-noconflict/theme-tomorrow.js";
import "ace-builds/src-noconflict/theme-tomorrow_night.js";
import "ace-builds/src-noconflict/theme-tomorrow_night_blue.js";
import "ace-builds/src-noconflict/theme-tomorrow_night_bright.js";
import "ace-builds/src-noconflict/theme-tomorrow_night_eighties.js";
import "ace-builds/src-noconflict/theme-twilight.js";
import "ace-builds/src-noconflict/theme-vibrant_ink.js";
import "ace-builds/src-noconflict/theme-xcode.js";
1 change: 1 addition & 0 deletions src/content_scripts/common/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ var runtime = (function() {
ignoredFrameHosts: ["https://tpc.googlesyndication.com"],
scrollFriction: 0,
aceKeybindings: "vim",
aceTheme: "chrome",
caretViewport: null,
mouseSelectToQuery: [],
useNeovim: false,
Expand Down
3 changes: 1 addition & 2 deletions src/content_scripts/ui/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ function createAceEditor(normal, front) {
_ace.$emacsModeHandler.bindKey("C-x C-s", "closeAndSave");
return _ace.$emacsModeHandler;
}
_ace.setTheme("ace/theme/chrome");
_ace.setTheme(`ace/theme/${runtime.conf.aceTheme}`);
var keybindingsDeferred = new Promise(function(resolve, reject) {
var aceKeyboardLoaded = aceKeyboardVimLoaded;
if (runtime.conf.aceKeybindings === "emacs") {
Expand All @@ -1078,7 +1078,6 @@ function createAceEditor(normal, front) {
resolve(aceKeyboardLoaded());
});
});
_ace.container.style.background = "#f1f1f1";
_ace.$blockScrolling = Infinity;

self.show = function(message) {
Expand Down

0 comments on commit 8487d89

Please sign in to comment.