taro-ctl: make message channel global; taro-ls: start search handling

This commit is contained in:
Iris Lightshard 2023-03-21 23:06:29 -06:00
parent f9ee51b9c9
commit 09b089fe75
Signed by: nilix
GPG key ID: 3B7FBC22144E6398
2 changed files with 122 additions and 15 deletions

View file

@ -26,8 +26,15 @@ module Taro
end
class ChildWindow
@@msg : Channel(Mesg) = Channel(Mesg).new
@@id : UInt16 = 0_u16
def self.msg
@@msg
end
@id : UInt16
@lifetime : Channel(UInt8)
@msg : Channel(Mesg)
@stdout_w : IO::FileDescriptor
@stdout_r : IO::FileDescriptor
@stdin_w : IO::FileDescriptor
@ -40,7 +47,8 @@ module Taro
@stdout_r, @stdout_w = IO.pipe
@stdin_r, @stdin_w = IO.pipe
@lifetime = Channel(UInt8).new
@msg = Channel(Mesg).new
@id = @@id
@@id += 1
uxnrom : String = ""
@ -58,19 +66,19 @@ module Taro
end
spawn do
loop do
@msg.send(read_msg)
@@msg.send(read_msg)
end
end
end
def id
@id
end
def lifetime
@lifetime
end
def msg
@msg
end
def write_msg(msgtype : UInt8, data : Slice)
msgsz = UInt16.new(data.size > 16384 ? 16384 : data.size)
msgtype.to_io(@stdin_w, IO::ByteFormat::BigEndian)
@ -163,7 +171,8 @@ module Taro
end
def trash_mail(range : String)
cmd = "mflag -T #{range}; mlist ${MBOX_ROOT}/#{@mailbox} | mseq -S | mpick -t 'trashed' | mrefile ${MBOX_ROOT}/Trash"
cmd = "mlist ${MBOX_ROOT}/#{@mailbox} | mseq -S | mpick #{range} | mrefile ${MBOX_ROOT}/Trash"
run_cmd(cmd)
end
@ -222,7 +231,7 @@ loop do
select
when taro.mainWindow.lifetime.receive?
exit
when m = taro.mainWindow.msg.receive
when m = Taro::ChildWindow.msg.receive
case m.type
when 1 then
taro.mblaze.set_mbox(String.new(m.data))

View file

@ -26,6 +26,12 @@
%SB_POS { #11 ADD }
%SB_STEP { #13 ADD }
( entry modes )
%ENTRY_OFF { #00 }
%ENTRY_REFILE { #01 }
%ENTRY_SEARCH { #02 }
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
@ -43,9 +49,10 @@
|0000
@refresh [ &mboxes $1 &list $1 &fg $1 &btns $1 ]
@refresh [ &mboxes $1 &list $1 &fg $1 &btns $1 &textbox $1 ]
@resizing [ $1 &x $2 &y $2 &dx $2 &dy $2 ]
@decoding [ $1 &msg_type $1 &counting $1 &count $2 &processed $2 ]
@textbox [ &mode $1 &len $1 &cursor $1 &msg $2 ]
@mboxes [ &bytes $2 &data $2 &len $2 &offset $2 &elem_offset $1
&top $2 &height $1 &select_index $2 &select_len $2
&sb_len $1 &sb_pos $2 &sb_step $2 ]
@ -88,7 +95,7 @@
;noop_button_click .btn_fns/compose STZ2
;send_get_mbox .btn_fns/refresh STZ2
;send_mark_all_read .btn_fns/read_all STZ2
;noop_button_click .btn_fns/search STZ2
;enter_search_mode .btn_fns/search STZ2
;noop_button_click .btn_fns/refile STZ2
;noop_button_click .btn_fns/trash STZ2
@ -210,9 +217,55 @@ JMP2r
( -== input ==- )
@on_key ( -> )
.Controller/key DEI .Console/error DEO
.textbox/mode LDZ #00 EQU ,&no_text_entry JCN
insert_char_textbox
&no_text_entry
BRK
@insert_char_textbox ( -> )
.Controller/key DEI DUP #00 EQU ,&no_key JCN
DUP check_enter_or_esc
DUP #08 NEQ ,&no_delete JCN
POP
( handle backspace )
.textbox/cursor LDZ #00 EQU ,&also_done JCN
.textbox/cursor LDZ #01 SUB .textbox/cursor STZ
.textbox/len LDZ #01 SUB .textbox/len STZ
#00 ;textbox_text .textbox/cursor LDZ #00 SWP ADD2 STA
,&done JMP
&no_delete
( TODO: handle inserting character when bone is in middle of string )
( or when string is already max length )
;textbox_text .textbox/cursor LDZ #00 SWP ADD2 STA
.textbox/len LDZk INC SWP STZ
#00 ;textbox_text .textbox/len LDZ #00 SWP ADD2 STA
.textbox/cursor LDZk INC SWP STZ
&also_done
,&done JMP
&no_key
POP
.Controller/button DEI DUP #00 EQU ,&no_btn JCN
DUP #40 AND #00 EQU ,&no_left JCN
.textbox/cursor LDZ #00 EQU ,&no_btn JCN
.textbox/cursor LDZ #01 SUB .textbox/cursor STZ
&no_left
DUP #80 AND #00 EQU ,&no_right JCN
.textbox/cursor LDZ .textbox/len LDZ EQU ,&no_btn JCN
.textbox/cursor LDZk INC SWP STZ
&no_right
&no_btn
POP
&done
#01 .refresh/textbox STZ
JMP2r
@check_enter_or_esc ( key -- )
POP
( check mode and either cancel or send appropriate message )
JMP2r
@on_mouse ( -> )
;mbox_select_handler .mboxes .refresh/mboxes #0000 #00 mouse_event_list
@ -304,6 +357,7 @@ JMP2r
&chk_release
#01 .refresh/list STZ
#01 .refresh/mboxes STZ
#01 .refresh/btns STZ
.Screen/height DEI2 TOP_SECTION BOTTOM_SECTION ADD2 MID_SEPARATOR ADD2 SUB2 #03 SFT2 NIP .list/height STZ
.Mouse/state DEI
@ -410,6 +464,17 @@ JMP2r
send_get_mbox
JMP2r
@enter_search_mode ( -> )
ENTRY_SEARCH .textbox/mode STZ
#00 .textbox/len STZ
#00 .textbox/cursor STZ
#00 ;textbox_text STA
;search_lbl .textbox/msg STZ2
#01 .refresh/textbox STZ
JMP2r
@noop_list_click ( list -- )
POP
@ -472,6 +537,14 @@ JMP2r
#00 .refresh/btns STZ
&no_btns
.refresh/textbox LDZ #00 EQU ,&no_textbox JCN
.textbox/mode LDZ #00 EQU ,&no_textbox JCN
clear_textbox
;textbox_text #0008 .Screen/height DEI2 #0018 SUB2 #03 draw_str
draw_bone
.textbox/msg LDZ2 #0008 .Screen/height DEI2 #0010 SUB2 #02 draw_str
&no_textbox
.refresh/fg LDZ #00 EQU ,&no_fg JCN
clear_fg
draw_resize_handle
@ -481,6 +554,26 @@ JMP2r
BRK
@draw_bone ( -> )
#0008 .textbox/cursor LDZ #00 SWP #30 SFT2 ADD2 .Screen/x DEO2
.Screen/height DEI2 #0018 SUB2 .Screen/y DEO2
;bone .Screen/addr DEO2
#05 .Screen/sprite DEO
JMP2r
@clear_textbox ( -> )
.Screen/height DEI2 #0018 SUB2 .Screen/y DEO2
.Screen/width DEI2 #0008 &while EQU2k ,&end JCN
DUP2 .Screen/x DEO2
;blank .Screen/addr DEO2
#01 .Screen/sprite DEO
#0008 ADD2 ,&while JMP &end POP2 POP2
JMP2r
@clear_fg ( -> )
;blank .Screen/addr DEO2
@ -751,6 +844,9 @@ JMP2r
( -== data ==- )
@search_lbl "SEARCHING: 20 "type 20 "query 20 "and 20 "press 20 "{enter}; 20 "{esc} 20 "to 20 "go 20 "back 00
@refile_lbl "REFILING: 20 "type 20 "destination 20 "and 20 "press 20 "{enter}; 20 "{esc} 20 "to 20 "go 20 "back 00
@resize_handle [ e2c2 aa1a 3a02 fe00 ]
@cursor [ f8e0 e090 8804 0000 ]
@scrollbar [ 0707 0707 0707 0707 ]
@ -786,6 +882,8 @@ JMP2r
0408 191e 1d00 0000 4080 00a8 5000 0000
]
@bone [ e040 4040 4040 40e0 ]
@font [
00 00 00 00 00 00 00 00 00 18 18 18 08 00 08 00 00 14 14 00 00 00 00 00 00 24 7e 24 24 7e 24 00
00 10 3c 50 38 14 78 10 00 00 44 08 10 20 44 00 00 18 20 32 2c 24 1a 00 00 18 10 20 00 00 00 00
@ -813,7 +911,7 @@ JMP2r
00 10 10 10 10 10 10 00 00 00 00 08 08 08 78 00 00 00 00 32 4c 00 00 00 3c 42 99 a1 a1 99 42 3c
]
@textbox_text $ff
@word $ff
@selected_mbox "INBOX 00 $f9 ( default mailbox is INBOX, total space #06 + #f9 = #ff bytes )
@list_data $4000