From ad0d62741889e1e984c58c5f0a88246aacd62ed7 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 16 Mar 2023 22:44:39 -0600 Subject: [PATCH] getting ready to add complexity --- README.md | 14 ++++++++++++++ taro-ctl.cr | 15 +++++++++++++-- taro-ls.tal | 36 ++++++++++++++++++++++-------------- 3 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8ed38cb --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# taro + +`mblaze` frontend in `uxn` and `crystal` + +## messages + +Even messages go from `taro-ctl` to the `uxn` windows. + +- `0`: mailbox list +- `2`: list mail in mailbox + +Odd messages go from the `uxn` windows to `taro-ctl`. + +- `1`: change/refresh mailbox \ No newline at end of file diff --git a/taro-ctl.cr b/taro-ctl.cr index 4795a52..d534c9c 100644 --- a/taro-ctl.cr +++ b/taro-ctl.cr @@ -22,7 +22,6 @@ module Taro end def initialize(@type, @data) - end end @@ -114,6 +113,12 @@ module Taro end class MblazeProxy + @mailbox : String + + def initialize + @mailbox = "INBOX" + end + def list_mail(box : String = "INBOX") mailCmd = " mbox=${MBOX_ROOT}/#{box} @@ -133,6 +138,10 @@ module Taro Process.run(mailCmd, shell: true, output: io) return io.to_s end + + def set_mbox(box : String) + @mailbox = box + end end class TaroCtl @@ -179,6 +188,8 @@ loop do when taro.mainWindow.lifetime.receive? exit when m = taro.mainWindow.msg.receive - # do something + case m.type + when 1 then taro.mblaze.set_mbox(m.data.to_s) + end end end \ No newline at end of file diff --git a/taro-ls.tal b/taro-ls.tal index ee2d011..a8a13de 100644 --- a/taro-ls.tal +++ b/taro-ls.tal @@ -1,6 +1,13 @@ ( taro-ls: list mail, navigate mailboxes, and perform actions on mail ) +( message types ) + +%MBOX_LIST { #00 } +%GET_MBOX { #01 } %MAIL_LIST { #02 } + +( UI constants ) + %TOP_SECTION { #0020 } %BOTTOM_SECTION { #0040 } @@ -21,10 +28,11 @@ |0000 -@wipe_fg [ $1 ] +@refresh [ &mboxes $1 &list $1 &fg $1 ] @resizing [ $1 &x $2 &y $2 &dx $2 &dy $2 ] @decoding [ $1 &msg_type $1 &counting $1 &count $2 &processed $2 ] -@list [ &bytes $2 &len $1 &offset $2 &elem_offset $1 &top $2 &height $1 &select_index $2 &update $1 ] +@mboxes [ &bytes $2 &len $1 &offset $2 &elem_offset $1 &top $2 &height $1 &select_index $2 &sb_len $1 &sb_pos $2 &sb_step $2 ] +@list [ &bytes $2 &len $1 &offset $2 &elem_offset $1 &top $2 &height $1 &select_index $2 &sb_len $1 &sb_pos $2 &sb_step $2 ] @sb [ &len $1 &pos $2 &step $2 ] ( program ) @@ -40,7 +48,7 @@ #0200 .Screen/height DEO2 .Screen/height DEI2 TOP_SECTION BOTTOM_SECTION ADD2 SUB2 #03 SFT2 NIP .list/height STZ - #01 .wipe_fg STZ + #01 .refresh/fg STZ ;on_screen .Screen/vector DEO2 ;on_mouse .Mouse/vector DEO2 @@ -67,7 +75,7 @@ BRK POP ;list_data .decoding/processed LDZ2 ADD2 STA decode_inc_count .list/bytes STZ2 ,&count JMP - #01 .list/update STZ + #01 .refresh/list STZ &no_mail_list POP @@ -93,12 +101,12 @@ BRK JMP2r @decode_is_done ( -- bit ) - #01 .list/update STZ + #01 .refresh/list STZ .decoding/processed LDZ2 .decoding/count LDZ2 EQU2 JMP2r @on_mouse ( -> ) - #01 .wipe_fg STZ + #01 .refresh/fg STZ get_select_idx_by_mouse .resizing LDZ #00 EQU ,&resz_check JCN @@ -150,7 +158,7 @@ BRK ,&chk_release JMP &chk_release - #01 .list/update STZ + #01 .refresh/list STZ .Screen/height DEI2 TOP_SECTION BOTTOM_SECTION ADD2 SUB2 #03 SFT2 NIP .list/height STZ .Mouse/state DEI @@ -159,16 +167,16 @@ JMP2r @on_screen ( -> ) - .list/update LDZ #00 EQU ,&no_list JCN + .refresh/list LDZ #00 EQU ,&no_list JCN draw_mail_list draw_scrollbar - #00 .list/update STZ + #00 .refresh/list STZ &no_list - .wipe_fg LDZ #00 EQU ,&no_fg JCN + .refresh/fg LDZ #00 EQU ,&no_fg JCN clear_fg draw_resize_handle draw_cursor - #00 .wipe_fg STZ + #00 .refresh/fg STZ &no_fg BRK @@ -349,7 +357,7 @@ JMP2r .Mouse/y DEI2 TOP_SECTION SUB2 #03 SFT2 .list/top LDZ2 ADD2 .list/select_index STZ2 - #01 .list/update STZ + #01 .refresh/list STZ .Mouse/state DEI #00 EQU ,&no_click JCN .list/select_index LDZ2 .list/len LDZ2 GTH2 ,&no_click JCN &no_click @@ -364,7 +372,7 @@ JMP2r .list/top LDZ2 #0000 EQU2 ,&no_scroll_up JCN .list/top LDZ2 #0001 SUB2 .list/top STZ2 ;update_sb_pos JSR2 - #01 .list/update STZ + #01 .refresh/list STZ &no_scroll_up JMP2r @@ -373,7 +381,7 @@ JMP2r .list/top LDZ2 #00 .list/height LDZ ADD2 .list/len LDZ2 EQU2 ,&no_scroll_down JCN .list/top LDZ2 INC2 .list/top STZ2 ;update_sb_pos JSR2 - #01 .list/update STZ + #01 .refresh/list STZ &no_scroll_down JMP2r