taro-ls: generalize nav_list_by_key

This commit is contained in:
Iris Lightshard 2023-03-26 15:57:37 -06:00
parent a25d225fa5
commit baeb19bcae
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398

View file

@ -328,7 +328,7 @@ JMP2r
send_reader
&no_reader
DUP #09 NEQ ,&no_tab JCN
change_mbox_by_key
;mbox_select_handler .mboxes [ .Controller/button DEI #04 AND ] nav_list_by_key
&no_tab
&check_btns
POP
@ -339,31 +339,32 @@ JMP2r
&no_down
BRK
@change_mbox_by_key ( -> )
.Controller/button DEI #04 AND ,&back JCN
@nav_list_by_key ( onchange* list up? -- )
,&back JCN
( fwd )
.mboxes/select_index LDZ2 INC2 .mboxes/len LDZ2 NEQ2 ,&can_go_fwd JCN
STHk LB_SELECT_IDX LDZ2 INC2 STHkr LB_LEN LDZ2 NEQ2 ,&can_go_fwd JCN
( jump to first )
#0000 .mboxes/select_index STZ2
#0000 .mboxes/top STZ2
,&end JMP
#0000 STHkr LB_SELECT_IDX STZ2
#0000 STHkr LB_TOP STZ2
,&no_scroll_down JMP
&can_go_fwd
.mboxes/select_index LDZ2 INC2 .mboxes/select_index STZ2
.mboxes/select_index LDZ2 #00 .mboxes/height LDZ .mboxes/top LDZ2 ADD2 LTH2 ,&no_scroll_down JCN
.mboxes/top LDZ2 INC2 .mboxes/top STZ2
STHkr LB_SELECT_IDX LDZ2 INC2 STHkr LB_SELECT_IDX STZ2
STHkr LB_SELECT_IDX LDZ2 #00 STHkr LB_HEIGHT LDZ STHkr LB_TOP LDZ2 ADD2 LTH2 ,&no_scroll_down JCN
STHkr LB_TOP LDZ2 INC2 STHkr LB_TOP STZ2
&no_scroll_down ,&end JMP
&back
.mboxes/select_index LDZ2 #0000 NEQ2 ,&can_go_back JCN
.mboxes/len LDZ2 #0001 SUB2 .mboxes/select_index STZ2
.mboxes/len LDZ2 #00 .mboxes/height LDZ SUB2 .mboxes/top STZ2
STHk LB_SELECT_IDX LDZ2 #0000 NEQ2 ,&can_go_back JCN
STHkr LB_LEN LDZ2 #0001 SUB2 STHkr LB_SELECT_IDX STZ2
STHkr LB_LEN LDZ2 #00 STHkr LB_HEIGHT LDZ SUB2 STHkr LB_TOP STZ2
,&end JMP
&can_go_back
.mboxes/select_index LDZ2 #0001 SUB2 .mboxes/select_index STZ2
.mboxes/select_index LDZ2 INC2 .mboxes/top LDZ2 GTH2 ,&no_scroll_up JCN
.mboxes/top LDZ2 #0001 SUB2 .mboxes/top STZ2
STHkr LB_SELECT_IDX LDZ2 #0001 SUB2 STHkr LB_SELECT_IDX STZ2
STHkr LB_SELECT_IDX LDZ2 INC2 STHkr LB_TOP LDZ2 GTH2 ,&no_scroll_up JCN
STHkr LB_TOP LDZ2 #0001 SUB2 STHkr LB_TOP STZ2
&no_scroll_up ,&end JMP
&end
.mboxes mbox_select_handler
( onchange )
STHr ROT ROT JSR2
#01 .refresh/mboxes STZ
#01 .refresh/list STZ
JMP2r