From f079c4e60ac56f34f12f296a1b6ac7ca72f03101 Mon Sep 17 00:00:00 2001 From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Tue, 21 Sep 2010 12:34:38 +0000 Subject: [PATCH] Fix AlignmentHandle::ToString for long sequence names If the sequence name is longer than width/4, we chop the rightmost characters of the sequence name and add an ellipsis. git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2710 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/seq/base/src/impl/sequence_list_impl.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/seq/base/src/impl/sequence_list_impl.cc b/modules/seq/base/src/impl/sequence_list_impl.cc index e1e152059..b955d8b4c 100644 --- a/modules/seq/base/src/impl/sequence_list_impl.cc +++ b/modules/seq/base/src/impl/sequence_list_impl.cc @@ -68,6 +68,9 @@ String SequenceListImpl::ToString(int width) const label_size=std::max(label_size, static_cast<int>((*i)->GetName().size())); } label_size+=2; + if (label_size>width/4) { + label_size=width/4; + } int offset=0; bool done=false; int text_len=width-label_size; @@ -76,7 +79,12 @@ String SequenceListImpl::ToString(int width) const for (std::vector<SequenceImplPtr>::const_iterator i=list_.begin(), e=list_.end(); i!=e; ++i) { SequenceImplPtr s=*i; - buffer << s->GetName() << String(label_size-s->GetName().size(), ' '); + if (static_cast<int>(s->GetName().size())>label_size-2) { + buffer << s->GetName().substr(0, label_size-4) << "... "; + } else { + buffer << s->GetName() << String(label_size-s->GetName().size(), ' '); + } + if (offset<s->GetLength()) { int rem=s->GetLength()-offset; int actual=text_len>rem ? rem : text_len; -- GitLab