Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize ui #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions ime.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.3.0",
"guid": "{A381D463-9338-4FBD-B83D-66FFB03523B3}",
"locale": "zh-TW",
"fallbackLocale": "zh-TW",
"icon": "icon.ico",
"win8_icon": "",
"moduleName": "index",
Expand Down
3 changes: 3 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
candPerRow: 3
}
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

let emojione = require('emojione');
let debug = require('debug')('nime:emojime');
let config = require('./config');

let {
reduceOnKeyDown,
Expand Down Expand Up @@ -40,11 +41,14 @@ module.exports = {
},

response(request, state) {
let res = {success: true, seqNum: request['seqNum']};
if (request['method'] === 'filterKeyDown') {
return respOnFilterKeyDown(request, state);

} else if (request['method'] === 'onKeyDown') {
return respOnKeyDown(request, state);
} else if (request['method'] === 'onActivate') {
return Object.assign({}, res, { customizeUI: { candPerRow: config.candPerRow, candUseCursor: true }})
}
return {success: true, seqNum: request['seqNum']};
}
Expand Down
5 changes: 3 additions & 2 deletions src/reducer/candidateMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

let debug = require('debug')('nime:emojime:composition');
let KEYCODE = require('nime/lib/keyCodes');
let config = require('../config');

function candidateMode(request, preState) {

Expand All @@ -23,15 +24,15 @@ function candidateMode(request, preState) {
}

if (keyCode === KEYCODE.VK_DOWN) {
candidateCursor = (candidateCursor + 3) % candidateList.length;
candidateCursor = (candidateCursor + config.candPerRow) % candidateList.length;
return Object.assign({}, preState, {
action: 'UPDATE_CANDIDATE',
candidateCursor
});
}

if (keyCode === KEYCODE.VK_UP) {
candidateCursor = candidateCursor < 3 ? 0 : candidateCursor - 3;
candidateCursor = candidateCursor < config.candPerRow ? 0 : candidateCursor - config.candPerRow;
return Object.assign({}, preState, {
action: 'UPDATE_CANDIDATE',
candidateCursor
Expand Down