From mboxrd@z Thu Jan 1 00:00:00 1970 From: cworth@cworth.org (Carl Worth) Date: Wed, 19 Aug 2009 23:31:25 -0700 Subject: [sup-talk] [PATCH] Be less overzealous in moving text to the left column Message-ID: <1250749447-sup-1744@yoom.home.cworth.org> Specifically, scroll as little as possible to get the current message to just fit on the right side. --- This seems to work quite nicely and I think is ready to be comitted as is. It's still not perfect in a few ways though, which I think we can leave for subsequent commits: 1. I *think* that with this change the loose_alignment mode is unnecessary. But I confess that I didn't totally understand the calculation it is making, so I tried to just preserve its behavior rather than ripping it out. 2. In deep threads of short messages, (so that lots of nesting is visible in one screenful), it's easier than it was before for messages other than the current message to be scrolled off to the right, (though the current message is always made to fit if possible). I can imagine someone finding the current patch unacceptable based on this. The fix for this would be to consider the total width of all visible messages when making the calculation made here, rather than just the width of the current message. I'm not sure how readily available that number is. 3. It's still easy to get stuff scrolled off to the left, (which was a symptom of the original bug I'm trying to fix), when doing something like (E: Expand all messages). This command should recompute a left column, so perhaps we should abstract the left-column calculation out to some shared place. Anyway, all feedback is quite welcome, -Carl (happy to finally be running code from git and contributing patches) lib/sup/modes/thread-view-mode.rb | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb index dfe30ff..678b841 100644 --- a/lib/sup/modes/thread-view-mode.rb +++ b/lib/sup/modes/thread-view-mode.rb @@ -423,6 +423,9 @@ EOS 0 end + ## scroll as little as possible to make the message fit + ideal_left = (-(buffer.content_width - l.width - left - 1)).clamp(0, ideal_left) + jump_to_col [ideal_left, 0].max ## either way, move the cursor to the first line -- 1.6.3.3 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: