Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [issue53] Error if the composed text has tabs in the first character
@ 2010-01-27 21:11 Anirudh Sanjeev
  2010-01-27 21:57 ` Mark Alexander
  2010-01-27 22:15 ` Tero Tilus
  0 siblings, 2 replies; 4+ messages in thread
From: Anirudh Sanjeev @ 2010-01-27 21:11 UTC (permalink / raw)
  To: sup-devel


New submission from Anirudh Sanjeev <anirudh@anirudhsanjeev.org>:

Steps to reproduce:
1. Compose message with a tab as a first character
2. View composed message in the compose-mode

It looks like this in my text editor:
http://imgur.com/NH2Rz.png

Here's how it looks like in compose mode. Note how the last few characters of
the compose mode is truncated.
http://imgur.com/xdL0U.png

----------
messages: 124
nosy: anirudhs
priority: bug
ruby_version: 1.8
status: unread
sup_version: next
title: Error if the composed text has tabs in the first character

_________________________________________
Sup issue tracker <sup-bugs@masanjin.net>
<http://masanjin.net/sup-bugs/issue53>
_________________________________________
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sup-devel] [issue53] Error if the composed text has tabs in the first character
  2010-01-27 21:11 [sup-devel] [issue53] Error if the composed text has tabs in the first character Anirudh Sanjeev
@ 2010-01-27 21:57 ` Mark Alexander
  2010-01-27 22:29   ` Rich Lane
  2010-01-27 22:15 ` Tero Tilus
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Alexander @ 2010-01-27 21:57 UTC (permalink / raw)
  To: Sup issue tracker, Sup developer discussion

I've been noticing this problem for a long time now.
I think it happens with tabs anywhere in the
message, or perhaps at the beginning of lines,
but I haven't played with it enough to know for sure.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sup-devel] [issue53] Error if the composed text has tabs in the first character
  2010-01-27 21:11 [sup-devel] [issue53] Error if the composed text has tabs in the first character Anirudh Sanjeev
  2010-01-27 21:57 ` Mark Alexander
@ 2010-01-27 22:15 ` Tero Tilus
  1 sibling, 0 replies; 4+ messages in thread
From: Tero Tilus @ 2010-01-27 22:15 UTC (permalink / raw)
  To: Anirudh Sanjeev; +Cc: sup-devel

[-- Attachment #1: Type: text/plain, Size: 377 bytes --]

Anirudh Sanjeev, 2010-01-27 23:11:
> Steps to reproduce:
> 1. Compose message with a tab as a first character
> 2. View composed message in the compose-mode

Looks like tabs are counted as 1 (instead of 8) when calculating
string display width.  Dunno why this did not affect thread-view-mode
thought.  Patch attached.

-- 
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/

[-- Attachment #2: 0001-Count-tabs-as-8-chars-when-calculating-display-lengt.patch --]
[-- Type: application/octet-stream, Size: 620 bytes --]

From 2a0209b9dbd246e1791b08f0906f27327a1d5f39 Mon Sep 17 00:00:00 2001
From: Tero Tilus <tero@tilus.net>
Date: Thu, 28 Jan 2010 00:05:25 +0200
Subject: [PATCH] Count tabs as 8 chars when calculating display length

Signed-off-by: Tero Tilus <tero@tilus.net>
---
 lib/sup/util.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/sup/util.rb b/lib/sup/util.rb
index 861db7f..6757973 100644
--- a/lib/sup/util.rb
+++ b/lib/sup/util.rb
@@ -181,7 +181,7 @@ class String
       scan(/./u).size
     else
       size
-    end
+    end + 7 * (count "\t")
   end
 
   def camel_to_hyphy
-- 
1.5.6.5


[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [sup-devel] [issue53] Error if the composed text has tabs in the first character
  2010-01-27 21:57 ` Mark Alexander
@ 2010-01-27 22:29   ` Rich Lane
  0 siblings, 0 replies; 4+ messages in thread
From: Rich Lane @ 2010-01-27 22:29 UTC (permalink / raw)
  To: Mark Alexander; +Cc: Sup issue tracker, Sup developer discussion

Excerpts from Mark Alexander's message of 2010-01-27 16:57:33 -0500:
> I've been noticing this problem for a long time now.
> I think it happens with tabs anywhere in the
> message, or perhaps at the beginning of lines,
> but I haven't played with it enough to know for sure.

Sup assumes that 1 codepoint == 1 screen cell. This also causes problems
with double-width Chinese(?) characters. William has suggested using
wc[s]width, and now that we've got our own fork of ncurses-ruby we might
as well stick it in there. I looked at it briefly and iirc the
troublesome part was getting a wchar_t from the bytes in a Ruby string.

Tabs are funny because their width depends on their position. I say
replace all tabs with 2 spaces before calling ncurses.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-01-27 22:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-27 21:11 [sup-devel] [issue53] Error if the composed text has tabs in the first character Anirudh Sanjeev
2010-01-27 21:57 ` Mark Alexander
2010-01-27 22:29   ` Rich Lane
2010-01-27 22:15 ` Tero Tilus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox