all repos — taro @ 09b089fe751e58a40e2f8fb401a5023d681a322c

mblaze frontend in uxn + crystal

taro-ctl: make message channel global; taro-ls: start search handling
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmQajNYACgkQO3+8IhRO
Y5i7jA/9Gw2geUH3IYWwaZ+YQb/LkeJWQEobeKL4bCE3cMHViUx/GF/08yuewXK+
PpyXHCOID2sMVwpmhzMPWefyXtA91eMGPFG4JrXmrc38GriNR3//Mnhy+6tUvbHj
eo3py3Xql0q1f94I3G20GHF4//rUtQirSI5c6V8KNtJ7lBRxGuzrrVCJtN7QuL8K
cwGiJm0lf55GpSrV92GRa7nuFYT3EajMg37X5+CSzjFkpi4KKX7QiQawdT0ezT/X
cQXMUgI63NgWwkMhC8vbLC59yys8t9rOu/TiDzcsUpJs9rTiIOT6MxSmtWHlogwd
bDq95EsLqsBQNSb1ey1T0THjrPiGe7IhmZnPbf2PZxy9jH4HShvFnSEPbrSqjxf9
moxhwFBLGLaiVzzPYEJBFbtG3bbTEyDT984JltIA0B2GIaY8JIsNIbkGt2nCc/qn
zG0EsyRxHU/RsGLKVw4CCHxhOLY1TdAj25jYy64X2G8hY7V9k/SH3PgvFVCeTd5v
Xr07Kbd4x2a1xx1hIELKZf6u2sljVHNfcEGpILxxVeRVpXccIpOsJg5nqyPfkotb
1KqP+X9c0cUv77z0dTx+K/y0jWTUZsuKkCv7B4n+E0yR15p4YAuwXvEx1yXKNNUb
ZRfztJlPEeVVyWPogGh736rJFCidv72aA8oHARSYMgfxpJBr2h0=
=uXnG
-----END PGP SIGNATURE-----
commit

09b089fe751e58a40e2f8fb401a5023d681a322c

parent

f9ee51b9c9ad1d9902a019d259efacf3a8f7c283

2 files changed, 122 insertions(+), 15 deletions(-)

jump to
M taro-ctl.crtaro-ctl.cr

@@ -26,8 +26,15 @@ end

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 @@ def initialize(w : WinType = WinType::LIST)

@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,17 +66,17 @@ @lifetime.send(0)

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)

@@ -163,7 +171,8 @@ @mailbox = box

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))

@@ -232,4 +241,4 @@ taro.mblaze.mark_all_read

taro.mainWindow.write_msg(2_u8, taro.mblaze.list_mail.to_slice) end end -end+end
M taro-ls.taltaro-ls.tal

@@ -26,6 +26,12 @@ %SB_LEN { #10 ADD }

%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 @@ ( variables )

|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 @@

( -== 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 @@

&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 @@ POPr

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,15 +537,43 @@ .btn_colors/trash LDZ ;trash_button #0058 .Screen/height DEI2 #0030 SUB2 draw_2x2

#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 draw_cursor #00 .refresh/fg STZ &no_fg - + 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 @@ 0010 107c 1010 0102 0000 0020 5088 1020

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 @@ 00 00 44 28 10 28 44 00 00 00 44 44 3c 04 78 00 00 00 7c 04 38 40 7c 00 00 1e 10 10 10 00 00 00

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