[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: KDE/kdelibs/kate/part
From:       "Michel Hermier" <michel.hermier () gmail ! com>
Date:       2006-10-01 8:43:18
Message-ID: 2e631f490610010143vb5f9130je78a01f6bcd768e8 () mail ! gmail ! com
[Download RAW message or body]

Why using an ugly goto instead of using break. Also why not enforce
the direction for QChar::DirL, QChar::DirLRO and QChar::DirLRE, to
overide default values (which may be locale dependant). Also the
default should warn the dev for unhandled values (if any, else remove
the default)


2006/10/1, Hamish Rodda <rodda@kde.org>:
> SVN commit 590890 by rodda:
>
> Search for the first strong RTL character to determine a line's text
> direction.
>
> Thanks to Assaf Gordon for the patch.
>
> CCMAIL:assafgordon@gmail.com
>
>
>  M  +30 -1     katerenderer.cpp
>
>
> --- trunk/KDE/kdelibs/kate/part/katerenderer.cpp #590889:590890
> @@ -257,7 +257,7 @@
>   pen.setWidthF(spaceWidth() / 3.5);
>   pen.setCapStyle(Qt::RoundCap);
>   paint.setPen( pen );
> -
> +
>   paint.drawPoint( QPointF(x, y) );
>   paint.setPen( penBackup );
>  }
> @@ -805,6 +805,35 @@
>   opt.setFlags(QTextOption::IncludeTrailingSpaces);
>   opt.setTabStop(m_tabWidth * config()->fontMetrics().width(spaceChar));
>   opt.setWrapMode(QTextOption::WrapAnywhere);//QTextOption::WrapAtWordBoundaryOrAnywhere);
> +
> +  // Find the first strong character in the string.
> +  // If it is an RTL character, set the base layout direction of the string to RTL.
> +  //
> +  // See http://www.unicode.org/reports/tr9/#The_Paragraph_Level (Sections P2 & P3).
> +  // Qt's text renderer ("scribe") version 4.2 assumes a "higher-level protocol"
> +  // (such as KatePart) will specify the paragraph level, so it does not apply P2 & P3
> +  // by itself. If this ever change in Qt, the next code block could be removed.
> +  for (int i=0; i < lineLayout->textLine()->string().length(); i++) {
> +    switch (lineLayout->textLine()->string().at(i).direction()) {
> +      case QChar::DirL:
> +      case QChar::DirLRO:
> +      case QChar::DirLRE:
> +        goto end;
> +
> +      case QChar::DirR:
> +      case QChar::DirAL:
> +      case QChar::DirRLO:
> +      case QChar::DirRLE:
> +        opt.setTextDirection(Qt::RightToLeft);
> +        goto end;
> +
> +      default:
> +        break;
> +    }
> +  }
> +
> +  end:
> +
>   l->setTextOption(opt);
>
>   // Syntax highlighting, inbuilt and arbitrary
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic