Skip to content

Commit

Permalink
feat: add downcaseMap option for fix can't use symbol as kana with sh…
Browse files Browse the repository at this point in the history
…ift (#212)

* feat: add downcaseMap option for fix can't use symbol as kana with shift

* feat: s/down/lower/
  • Loading branch information
kuuote authored Oct 13, 2024
1 parent 438737e commit 2cdd414
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions denops/skkeleton/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const config: Omit<ConfigOptions, "globalDictionaries"> & {
kanaTable: "rom",
keepMode: false,
keepState: false,
lowercaseMap: {},
markerHenkan: "▽",
markerHenkanSelect: "▼",
registerConvertResult: false,
Expand Down Expand Up @@ -94,6 +95,7 @@ const validators: Validators = {
},
keepMode: (x) => ensure(x, is.Boolean),
keepState: (x) => ensure(x, is.Boolean),
lowercaseMap: (x) => ensure(x, is.RecordOf(is.String)),
markerHenkan: (x) => ensure(x, is.String),
markerHenkanSelect: (x) => ensure(x, is.String),
registerConvertResult: (x) => ensure(x, is.Boolean),
Expand Down
2 changes: 1 addition & 1 deletion denops/skkeleton/function/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function kanaInput(context: Context, char: string) {
context.state.type = "input";
const state = context.state as InputState;

const lower = char.toLowerCase();
const lower = config.lowercaseMap[char] ?? char.toLowerCase();
if (!state.directInput && char !== lower) {
const withShift = `<s-${lower}>`;
if (state.table.some((e) => e[0].startsWith(state.feed + withShift))) {
Expand Down
10 changes: 10 additions & 0 deletions denops/skkeleton/function/input_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ Deno.test({
},
});

Deno.test({
name: "upper case input with lowercaseMap",
async fn() {
config.lowercaseMap = { "+": "a" };
const context = new Context();
await dispatch(context, "+");
assertEquals(context.toString(), "▽あ");
},
});

Deno.test({
name: "delete char",
async fn() {
Expand Down
1 change: 1 addition & 0 deletions denops/skkeleton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type ConfigOptions = {
kanaTable: string;
keepMode: boolean;
keepState: boolean;
lowercaseMap: Record<string, string>;
markerHenkan: string;
markerHenkanSelect: string;
registerConvertResult: boolean;
Expand Down
14 changes: 14 additions & 0 deletions doc/skkeleton.jax
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,20 @@ keepState *skkeleton-config-keepState*
このオプションを有効にすると
Insertモードを抜けても前回の状態を保持するようになります。

lowercaseMap *skkeleton-config-lowercaseMap*
(デフォルト {})
仮名入力時に大文字を打つと、通常は対応する小文字に変換した上で変換ポイ
ントと同時に入力しますが、仮名テーブルをカスタマイズし、記号と被せてい
る場合、変換が上手く行きません。その場合、このオプションを指定すること
で変換規則を指定できます。
>
値の例: {
\ '+': ';',
\ ':': ';',
\ }
これは AZIK で「っ」を打つための JIS 及び US キーボード用の設定です
<

markerHenkan *skkeleton-config-markerHenkan*
(デフォルト "▽")
変換入力中であることを示すため文字を指定します。
Expand Down

0 comments on commit 2cdd414

Please sign in to comment.