Skip to content

Commit 8d5c2a3

Browse files
authored
Merge pull request #7 from tomoemon/naginatashiki
薙刀式のサポート(同時押し系配列の一般的なサポート)
2 parents eef3327 + 100b673 commit 8d5c2a3

31 files changed

+2084
-410
lines changed

examples/react-simple/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ function Typing(props: { layout: KeyboardLayout }) {
2727
return activate(window, (e) => {
2828
setLastInputKey(e.input);
2929
const result = automatons[wordIndex].input(e);
30+
console.log(e.input.key.toString(), e.input.type, result);
3031
if (result.isFinished) {
3132
automatons[wordIndex].reset();
3233
setWordIndex((current) => (current + 1) % words.length);
3334
}
3435
});
3536
}, [wordIndex, automatons]);
3637
const automaton = automatons[wordIndex];
37-
console.log(automaton);
3838
return (
3939
<>
4040
<h1>

examples/react-stroke-graph/src/App.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import cytoscape from "cytoscape";
22
import dagre from "cytoscape-dagre";
3-
import { Automaton, detectKeyboardLayout, KeyboardLayout, loadPresetRuleJisKana, loadPresetRuleNicola, loadPresetRuleRoman } from "emiel";
3+
import { Automaton, detectKeyboardLayout, KeyboardLayout, loadPresetRuleJisKana, loadPresetRuleNaginatashikiV15, loadPresetRuleNicola, loadPresetRuleRoman } from "emiel";
44
import { useCallback, useEffect, useMemo, useState } from "react";
55
import "./App.css";
66
import { TypingGraph } from "./typingGraph";
@@ -21,6 +21,7 @@ function Typing(props: { layout: KeyboardLayout }) {
2121
{ name: "ローマ字", rule: loadPresetRuleRoman(props.layout) },
2222
{ name: "JISかな", rule: loadPresetRuleJisKana(props.layout) },
2323
{ name: "NICOLA", rule: loadPresetRuleNicola(props.layout) },
24+
{ name: "薙刀式", rule: loadPresetRuleNaginatashikiV15(props.layout) },
2425
], [props.layout]);
2526
const [automaton, setAutomaton] = useState<Automaton | undefined>(
2627
undefined
@@ -29,7 +30,7 @@ function Typing(props: { layout: KeyboardLayout }) {
2930
const [wordIndex, setWordIndex] = useState(0);
3031
const [ruleIndex, setRuleIndex] = useState(0);
3132
const onFinished = useCallback(() => {
32-
const words = ["おをひく", "こんとん", "がっこう", "aから@"];
33+
const words = ["じょをひく", "しるため", "しょうがっこう"];
3334
const automaton = rules[ruleIndex].rule.build(words[wordIndex]);
3435
setAutomaton(automaton);
3536
setRuleName(rules[ruleIndex].name);

examples/react-stroke-graph/src/graphData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ function strokeToString(stroke: emiel.StrokeEdge): string {
5252
v === emiel.VirtualKeys.ShiftLeft ||
5353
v === emiel.VirtualKeys.ShiftRight
5454
) {
55-
return "Sft";
55+
return "";
5656
}
5757
return keyToString(v);
5858
})
5959
)
60-
).join(",");
61-
return keyToString(key) + (modStr.length > 0 ? `/${modStr}` : "");
60+
).join("|");
61+
return (modStr.length > 0 ? `${modStr}|` : "") + keyToString(key);
6262
}
6363

6464
function keyToString(key: emiel.VirtualKey): string {

examples/react-stroke-graph/src/typingGraph.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import cytoscape from "cytoscape";
2+
import dagre from "cytoscape-dagre";
3+
import * as emiel from "emiel";
14
import { useEffect, useRef, useState } from "react";
25
import { buildGraphData } from "./graphData";
3-
import dagre from "cytoscape-dagre";
4-
import cytoscape from "cytoscape";
56
import { cyStylesheet } from "./grpahStyle";
6-
import * as emiel from "emiel";
77

88
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
99
cytoscape.use(dagre);
@@ -33,6 +33,7 @@ export function TypingGraph(props: {
3333
return emiel.activate(window, (e) => {
3434
setLastInputKey(e.input);
3535
const result = automaton.input(e);
36+
console.log(e.input.key.toString(), e.input.type, result);
3637
if (result.isFinished) {
3738
props.onFinished();
3839
} else if (result.isSucceeded) {

src/assets/rules/jis_kana.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"extendCommonPrefixEntry": false,
3-
"modifiers": ["ShiftLeft", "ShiftRight"],
43
"entries": [
54
{
65
"input": [

0 commit comments

Comments
 (0)