Skip to content

Commit

Permalink
SQUASH: feat(ui/walk): 用小键盘走路
Browse files Browse the repository at this point in the history
  • Loading branch information
dzpao committed Apr 17, 2024
1 parent 348b950 commit c9b0be7
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 13 deletions.
35 changes: 26 additions & 9 deletions etc/ui-settings.tin
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,32 @@ VAR {命令提示符,默认为空} prompt-prompt {};
{{key}{\cok} {meaning}{开启/关闭小键盘走路} {action}{option.Toggle KeypadWalk}}
};

VAR {小键盘走路的键盘扫描码} {global-keypad-walking} {
{north} {\e[A}
{south} {\e[B}
{east} {\e[C}
{west} {\e[D}
{northeast} {\e[5~}
{southeast} {\e[6~}
{northwest} {\e[H}
{southwest} {\e[F}
VAR {小键盘走路的键盘扫描码} {global-keypad-code} {
{Home} {\e[H}
{End} {\e[F}
{Up} {\e[A}
{Down} {\e[B}
{Left} {\e[D}
{Right} {\e[C}
{Center} {\e[G}
{PageUp} {\e[5~}
{PageDown} {\e[6~}
{Enter} {\n}
};

VAR {小键盘走路的功能映射表} {global-keypad-walking} {};

#list {global-keypad-walking} create {
{{key}{Up} {type}{dir} {args}{north;northdown;northup;up;northwest;northeast}}
{{key}{Down} {type}{dir} {args}{south;southdown;southup;down;southwest;southeast}}
{{key}{Left} {type}{dir} {args}{west;westdown;westup;out;northwest;southwest}}
{{key}{Right} {type}{dir} {args}{east;eastdown;eastup;enter;northeast;southeast}}
{{key}{Home} {type}{dir} {args}{northwest;westup;northup}}
{{key}{End} {type}{dir} {args}{southwest;westdown;southup}}
{{key}{PageUp} {type}{dir} {args}{northeast;eastup;northdown}}
{{key}{PageDown} {type}{dir} {args}{southeast;eastdown;southdown}}
{{key}{Enter} {type}{cmd} {args}{get all}}
{{key}{Center} {type}{cmd} {args}{look}}
};

VAR {HP摘要刷新时机,三选一:{总是|从不|自动}} char.HPSummarize.Echo {自动};
Expand Down
44 changes: 40 additions & 4 deletions plugins/lib/ui/walk.tin
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,47 @@ VAR {触屏走路插件的走路命令,默认为 go} ui.walk.cmd {go};
#else {
okLog 小键盘走路已开启。;
#class ui.walk.Keypad open;
#local dir {};
#foreach {*global-keypad-walking[]} {dir} {
#local code {$global-keypad-walking[$dir]};
#line sub var #macro {$code} {ui.walk.go $dir};
#local idx {};
#foreach {*global-keypad-walking[]} {idx} {
#local entry {$global-keypad-walking[$idx]};
#local name {$entry[key]};
#local type {$entry[type]};
#local args {$entry[args]};
#if { &global-keypad-code[$name] == 0 } {
#continue;
};
#local code {$global-keypad-code[$name]};
#line sub var #macro {$code} {ui.walk.keypad.do $name $type {$args}};
};
#class ui.walk.Keypad close;
};
};

#alias {ui.walk.keypad.do} {
#local key {%1};
#local type {%2};
#local args {%3};

#if { "$key" == "Enter" } {
#local input {};
#cursor get input;
#if { {$input} !== {} } {
#cursor clear;
$input;
#return;
};
};

#if { "$type" == "cmd" } {
$args;
#return;
};

#local dir {};
#foreach {$args} {dir} {
#if { @sset.Contains{{$gMapRoom[exits]};$dir} } {
ui.walk.go $dir;
#return;
};
};
};

0 comments on commit c9b0be7

Please sign in to comment.