aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-01-13 05:34:03 +0000
committerGitHub <noreply@github.com>2018-01-13 05:34:03 +0000
commit4d4a959162da0a4f1eb16c3ce94e83da0465f865 (patch)
tree9a245cbffb30c21b3015b62a4f766f1a544f9bd6
parentf5dfdb0bd7ab850c77cae523928c876fe5e002fa (diff)
parent03bb124cce7acf3a245baca1c109e5136979162e (diff)
Merge pull request #306 from ueokande/custom-hint-keys
support custom chars as hintchars
-rw-r--r--src/content/components/top-content/follow-controller.js12
-rw-r--r--src/shared/settings/properties.js15
2 files changed, 15 insertions, 12 deletions
diff --git a/src/content/components/top-content/follow-controller.js b/src/content/components/top-content/follow-controller.js
index d373177..1e7f3cd 100644
--- a/src/content/components/top-content/follow-controller.js
+++ b/src/content/components/top-content/follow-controller.js
@@ -1,8 +1,7 @@
import * as followControllerActions from 'content/actions/follow-controller';
import messages from 'shared/messages';
import HintKeyProducer from 'content/hint-key-producer';
-
-const DEFAULT_HINT_CHARSET = 'abcdefghijklmnopqrstuvwxyz';
+import * as properties from 'shared/settings/properties';
const broadcastMessage = (win, message) => {
let json = JSON.stringify(message);
@@ -84,7 +83,7 @@ export default class FollowController {
this.store.dispatch(followControllerActions.backspace());
break;
default:
- if (DEFAULT_HINT_CHARSET.includes(key)) {
+ if (this.hintchars().includes(key)) {
this.store.dispatch(followControllerActions.keyPress(key));
}
break;
@@ -93,7 +92,7 @@ export default class FollowController {
}
count() {
- this.producer = new HintKeyProducer(DEFAULT_HINT_CHARSET);
+ this.producer = new HintKeyProducer(this.hintchars());
let doc = this.win.document;
let viewWidth = this.win.innerWidth || doc.documentElement.clientWidth;
let viewHeight = this.win.innerHeight || doc.documentElement.clientHeight;
@@ -135,4 +134,9 @@ export default class FollowController {
type: messages.FOLLOW_REMOVE_HINTS,
});
}
+
+ hintchars() {
+ return this.store.getState().setting.properties.hintchars ||
+ properties.defaults.hintchars;
+ }
}
diff --git a/src/shared/settings/properties.js b/src/shared/settings/properties.js
index ff8039b..f695c58 100644
--- a/src/shared/settings/properties.js
+++ b/src/shared/settings/properties.js
@@ -1,15 +1,14 @@
+// describe types of a propety as:
+// mystr: 'string',
+// mynum: 'number',
+// mybool: 'boolean',
const types = {
- // TODO describe property types here
- // mystr: 'string',
- // mynum: 'number',
- // mybool: 'boolean',
+ hintchars: 'string',
};
+// describe default values of a property
const defaults = {
- // TODO describe property defaults values
- // mystr: 'hello',
- // mynum: 123,
- // mybool: true,
+ hintchars: 'abcdefghijklmnopqrstuvwxyz',
};
export { types, defaults };