From 43c528652721519dc3f429a264d39059ad816311 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 30 Mar 2023 22:33:12 -0600 Subject: [PATCH] taro-ls: fix div by zero when resetting scrollbar; taro-ctl: use capped IO to truncate command output before writing message --- README.md | 6 +++--- taro-ctl.cr | 12 +++++++++++- taro-ls.tal | 5 ++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ed68b5b..d1eb567 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ The `config` file is processed into a bunch of constants for `taro-ctl` by the build script. Adjust them to your needs: - `MBOX_ROOT`: the directory where your maildirs are. -- `TARO_LIB`: the directory where your runtime files (`taro-ls` rom, `taro-reader` script, `.theme` and `font.icn` files, etc.) will be installed to; probably just where you clone this repo to. +- `TARO_LIB`: the directory where your runtime files (`taro-ls` rom, `taro-reader` script, `.theme` and `font.icn` files, etc.) will be installed to, as well as a copy of `uxnemu` - `TARO_DOWNLOADS`: directory where attachments are downloaded to. -- `UXN_EMU`: name of the `uxnemu` executable. You can copy `uxnemu` to, eg `taro` and it will have that `_NET_WM_CLASS`. +- `UXN_EMU`: name the `uxnemu` will be copied to - this is a hack to set the `_NET_WM_CLASS`. - `TARO_ENV`: environment variables as you type them in the terminal, that you can use for the `READER_PROG` and `COMPOSE_PROG` commands - `READER_PROG`: command to spawn to read mail - by default it calls the `st` terminal with some environment variables and options set, and runs `taro-reader` - `COMPOSE_PROG`: command to spawn to write mail - by default it calls the `st` terminal with some environment variables and options set and runs `mcom` from `mblaze` @@ -126,7 +126,7 @@ Odd messages go from the `uxn` windows to `taro-ctl` (or from `taro-ctl` to itse - `9`: trash mail; payload is the beginning and end of the `mmsg` range in u16 - `11`: read mail; payload is a single u16 `mmsg` number in the current sequence - `13`: compose mail; no payload -- `15`: push view update (keeps search query, for after replying/writing mail or when new mail comes in) +- `15`: push view update (keeps search query, for after replying/writing mail or when new mail comes in); no payload ## socket (other IPC) diff --git a/taro-ctl.cr b/taro-ctl.cr index 7d24e31..7778a39 100644 --- a/taro-ctl.cr +++ b/taro-ctl.cr @@ -166,6 +166,16 @@ module Taro end + class CappedIO < IO::Memory + def write(slice : Bytes) + if slice.size >= MSG_SIZES[MsgType::MAIL_LIST] + super(slice[0..MSG_SIZES[MsgType::MAIL_LIST] - 1]) + else + super(slice) + end + end + end + class MblazeProxy @@mailbox : String = "INBOX" @@search_regex : String = "" @@ -179,7 +189,7 @@ module Taro end private def run_cmd(cmdtxt : String) : IO::Memory - io = IO::Memory.new + io = CappedIO.new Process.run(cmdtxt, shell: true, output: io) return io end diff --git a/taro-ls.tal b/taro-ls.tal index 3954f99..36cb542 100644 --- a/taro-ls.tal +++ b/taro-ls.tal @@ -1118,7 +1118,10 @@ JMP2r JMP2r @update_sb_pos ( list -- ) - + DUP SB_STEP LDZ2 #0000 NEQ2 ,&safe_to_divide JCN + POP JMP2r + + &safe_to_divide DUP DUP LB_TOP LDZ2 ROT SB_STEP LDZ2 DIV2 ROT SB_POS STZ2