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

List:       kde-edu-devel
Subject:    Re: [kde-edu]: Review Request: Syntax Hightlighting in Cantor
From:       "Alexander Rieder" <alexanderrieder () gmail ! com>
Date:       2010-08-24 19:06:07
Message-ID: 20100824190607.20262.50690 () vidsolbach ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.kde.org/r/5079/#review7199
-----------------------------------------------------------


Hi,
some more comments:
- the apidoc has a typo: DefualtHighlighter , spicific
- is qHash(const QRegExp& regExp) still needed?
- you should use a foreach for iterating over the regexpRules
- i think the "position changed, rehighlight block" and "cleaning up last b=
lock" should be removed/commented out. they just slow things down. The code=
 there should be solid and not need this debugging anymore

otherwise it looks good

- Alexander


On 2010-08-24 18:34:08, Miha Cancula wrote:
> =

> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.kde.org/r/5079/
> -----------------------------------------------------------
> =

> (Updated 2010-08-24 18:34:08)
> =

> =

> Review request for KDE-Edu and Alexander Rieder.
> =

> =

> Summary
> -------
> =

> As discussed on email, I implemented a different approach to highlighting=
 in Cantor. I'd like some feedback before committing it. =

> =

> I introduced additional API in DefaultHighlighter and moved most of the l=
ogic in it, so the individual backend-specific highlighters only specify co=
nditions (either QString or QRegExp) and matching text formats. The code lo=
oks much cleaner this way.
> =

> As Alexander and Oleksiy already determined, breaking the text into words=
 and looking for these words is faster than iterating over a huge list of r=
egexes and looking for each of them in the text. That's why functions, vari=
ables and keywords are implemented this way. OTOH, thing like comments and =
strings are easier done using Regexes, so this functionality is still there=
.  =

> =

> The implementation uses a QHash<QString, QTextCharFormat> and a QHash<QRe=
gExp, QTextCharFormat>. If anyone knows of a way to make it faster, please =
say so. =

> =

> I also updated highlighters for Octave, Maxima and Sage to use the word-b=
ased API as much as possible. Most of their code was also removed, because =
it's now in DefaultHighlighter. I left R alone because Oleksiy's work is no=
t yet in trunk. =

> =

> =

> Diffs
> -----
> =

>   /trunk/KDE/kdeedu/cantor/src/backends/maxima/maximahighlighter.h 116676=
2 =

>   /trunk/KDE/kdeedu/cantor/src/backends/maxima/maximahighlighter.cpp 1166=
762 =

>   /trunk/KDE/kdeedu/cantor/src/backends/octave/octavehighlighter.h 116676=
2 =

>   /trunk/KDE/kdeedu/cantor/src/backends/octave/octavehighlighter.cpp 1166=
762 =

>   /trunk/KDE/kdeedu/cantor/src/backends/sage/sagehighlighter.h 1166762 =

>   /trunk/KDE/kdeedu/cantor/src/backends/sage/sagehighlighter.cpp 1166762 =

>   /trunk/KDE/kdeedu/cantor/src/lib/defaulthighlighter.h 1166762 =

>   /trunk/KDE/kdeedu/cantor/src/lib/defaulthighlighter.cpp 1166762 =

> =

> Diff: http://reviewboard.kde.org/r/5079/diff
> =

> =

> Testing
> -------
> =

> I tested Maxima and Sage and they seem to be faster than before for large=
 blocks. I used to have problems with non-smooth scrolling in Octave due to=
 the large number of functions, but now it feels normal. I didn't notice an=
y regressions (yet). =

> =

> It all works both on trunk and 4.4.  =

> =

> =

> Thanks,
> =

> Miha
> =

>


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://reviewboard.kde.org/r/5079/">http://reviewboard.kde.org/r/5079/</a>
  </td>
    </tr>
   </table>
   <br />





 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Hi, some more comments:
- the apidoc has a typo: DefualtHighlighter , spicific
- is qHash(const QRegExp&amp; regExp) still needed?
- you should use a foreach for iterating over the regexpRules
- i think the &quot;position changed, rehighlight block&quot; and &quot;cleaning up \
last block&quot; should be removed/commented out. they just slow things down. The \
code there should be solid and not need this debugging anymore

otherwise it looks good</pre>
 <br />







<p>- Alexander</p>


<br />
<p>On August 24th, 2010, 6:34 p.m., Miha Cancula wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://reviewboard.kde.orgrb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for KDE-Edu and Alexander Rieder.</div>
<div>By Miha Cancula.</div>


<p style="color: grey;"><i>Updated 2010-08-24 18:34:08</i></p>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">As discussed on email, I implemented a different approach to \
highlighting in Cantor. I&#39;d like some feedback before committing it. 

I introduced additional API in DefaultHighlighter and moved most of the logic in it, \
so the individual backend-specific highlighters only specify conditions (either \
QString or QRegExp) and matching text formats. The code looks much cleaner this way.

As Alexander and Oleksiy already determined, breaking the text into words and looking \
for these words is faster than iterating over a huge list of regexes and looking for \
each of them in the text. That&#39;s why functions, variables and keywords are \
implemented this way. OTOH, thing like comments and strings are easier done using \
Regexes, so this functionality is still there.  

The implementation uses a QHash&lt;QString, QTextCharFormat&gt; and a \
QHash&lt;QRegExp, QTextCharFormat&gt;. If anyone knows of a way to make it faster, \
please say so. 

I also updated highlighters for Octave, Maxima and Sage to use the word-based API as \
much as possible. Most of their code was also removed, because it&#39;s now in \
DefaultHighlighter. I left R alone because Oleksiy&#39;s work is not yet in trunk. \
</pre>  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">I tested Maxima and Sage and they seem to be faster than before for \
large blocks. I used to have problems with non-smooth scrolling in Octave due to the \
large number of functions, but now it feels normal. I didn&#39;t notice any \
regressions (yet). 

It all works both on trunk and 4.4.  </pre>
  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/trunk/KDE/kdeedu/cantor/src/backends/maxima/maximahighlighter.h <span \
style="color: grey">(1166762)</span></li>

 <li>/trunk/KDE/kdeedu/cantor/src/backends/maxima/maximahighlighter.cpp <span \
style="color: grey">(1166762)</span></li>

 <li>/trunk/KDE/kdeedu/cantor/src/backends/octave/octavehighlighter.h <span \
style="color: grey">(1166762)</span></li>

 <li>/trunk/KDE/kdeedu/cantor/src/backends/octave/octavehighlighter.cpp <span \
style="color: grey">(1166762)</span></li>

 <li>/trunk/KDE/kdeedu/cantor/src/backends/sage/sagehighlighter.h <span style="color: \
grey">(1166762)</span></li>

 <li>/trunk/KDE/kdeedu/cantor/src/backends/sage/sagehighlighter.cpp <span \
style="color: grey">(1166762)</span></li>

 <li>/trunk/KDE/kdeedu/cantor/src/lib/defaulthighlighter.h <span style="color: \
grey">(1166762)</span></li>

 <li>/trunk/KDE/kdeedu/cantor/src/lib/defaulthighlighter.cpp <span style="color: \
grey">(1166762)</span></li>

</ul>

<p><a href="http://reviewboard.kde.org/r/5079/diff/" style="margin-left: 3em;">View \
Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>



_______________________________________________
kde-edu mailing list
kde-edu@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-edu


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

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