Re: Making syntax coloring more responsive

2014-08-26 Thread Edward K. Ream
On Tuesday, August 26, 2014 3:46:10 PM UTC-5, Edward K. Ream wrote:

> The PQSH class now controls Leo's syntax-coloring code *exactly* as QSH 
did/does...
> No coloring actually happens yet, but...it may happen this evening.
> BTW, the code keeps getting simpler.  It's almost embarrassing how little 
QSH actually does.

Omg: Everything appears to work with these two dirt simple methods::

def setFormat(self,start,count,format):
'''Remember the requested formatting.'''
if start >= 0:
r = QtGui.QTextLayout.FormatRange()
r.start,r.length,r.format = start,count,format
self.formats.append(r)

def applyFormatChanges(self):
'''Apply self.formats to self._currentBlock.layout().'''
if self.formats:
layout = self._currentBlock.layout() # A QTextLayout.
layout.setAdditionalFormats(self.formats)
self.formats = []
cb = self._currentBlock
self._document.markContentsDirty(cb.position(),cb.length())

The contrast between the original C++ code and the code above is striking.  
All the blah, blah, blah is gone! 

To be fair, the original applyFormatChanges code messes with some fancy 
additional layout features that I have completely ignored ;-)  Only time 
will tell if more complications are needed, but I suspect not.

Clearly, the code above adds no significant extra time to syntax coloring.  
If you doubt this, consider all the work the Leo colorizer does before 
calling setFormat!

We now appear to have a complete replacement for QSH, written entirely in 
Python, and functionally just as fast as the original.  Hurray!

The next step: PQSH.reformatBlocks will queue up smallish chunks for 
coloring at idle time.  This should allow Leo to respond to user events 
with no noticeable delay.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Making syntax coloring more responsive

2014-08-26 Thread Edward K. Ream
On Tuesday, August 26, 2014 7:04:59 AM UTC-5, Edward K. Ream wrote:

> The only solution is to transliterate QSyntaxHighlighter into Python! 
> [The new code] is not connected *in any way* to Leo's actual code.

It is now :-) The python_qsh switch at the start of qtGui.py determines 
whether to use the PythonQSyntaxHighlighter code.

It took less than an hour to get the code so that it didn't crash on 
startup.  It was almost too easy.  I just loaded Leo, fixing crashes until 
there weren't any more.  Hehe.  Just do it, indeed.  This approach would be 
10 to 100 times harder in C.

The PQSH class now controls Leo's syntax-coloring code *exactly* as QSH 
did/does.  Amazing. At no time has there been a hard crash, though that 
could happen later :-)  It's a hoot to trace through coloring from the 
"other side", that is, from the controlling code rather than the controlled 
code.  

No coloring actually happens yet, but there are a few obvious 
transliteration problems.  It may happen this evening.  BTW, the code keeps 
getting simpler.  It's almost embarrassing how little QSH actually does.

For now, though, it's time for a walk.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Making syntax coloring more responsive

2014-08-26 Thread Fidel N
nav tab rules the searches for me too Kent, nothing to be ashamed of.


On Tue, Aug 26, 2014 at 5:31 PM, Kent Tenney  wrote:

> confession:
> I use the nav tab for searching, vim for replacing
>
> On Tue, Aug 26, 2014 at 9:43 AM, 'Terry Brown' via leo-editor
>  wrote:
> > On Tue, 26 Aug 2014 07:33:49 -0700 (PDT)
> > "Edward K. Ream"  wrote:
> >
> >> On Tuesday, August 26, 2014 7:04:59 AM UTC-5, Edward K. Ream wrote:
> >>
> >> > Before fixing bug 28, I must fix some very serious problems with
> >> > tab
> >> completion and the change command.
> >>
> >> Rev b3d404a fixes the problem with the change command.  This bug
> >> basically ruined the change command.  Am I the only one using Leo's
> >> minibuffer-oriented find/change commands?
> >
> > Quite possibly :-)  I use Ctrl-f
> >
> > Cheers -Terry
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "leo-editor" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to leo-editor+unsubscr...@googlegroups.com.
> > To post to this group, send email to leo-editor@googlegroups.com.
> > Visit this group at http://groups.google.com/group/leo-editor.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to leo-editor+unsubscr...@googlegroups.com.
> To post to this group, send email to leo-editor@googlegroups.com.
> Visit this group at http://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Making syntax coloring more responsive

2014-08-26 Thread Kent Tenney
confession:
I use the nav tab for searching, vim for replacing

On Tue, Aug 26, 2014 at 9:43 AM, 'Terry Brown' via leo-editor
 wrote:
> On Tue, 26 Aug 2014 07:33:49 -0700 (PDT)
> "Edward K. Ream"  wrote:
>
>> On Tuesday, August 26, 2014 7:04:59 AM UTC-5, Edward K. Ream wrote:
>>
>> > Before fixing bug 28, I must fix some very serious problems with
>> > tab
>> completion and the change command.
>>
>> Rev b3d404a fixes the problem with the change command.  This bug
>> basically ruined the change command.  Am I the only one using Leo's
>> minibuffer-oriented find/change commands?
>
> Quite possibly :-)  I use Ctrl-f
>
> Cheers -Terry
>
> --
> You received this message because you are subscribed to the Google Groups 
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to leo-editor+unsubscr...@googlegroups.com.
> To post to this group, send email to leo-editor@googlegroups.com.
> Visit this group at http://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Making syntax coloring more responsive

2014-08-26 Thread 'Terry Brown' via leo-editor
On Tue, 26 Aug 2014 07:33:49 -0700 (PDT)
"Edward K. Ream"  wrote:

> On Tuesday, August 26, 2014 7:04:59 AM UTC-5, Edward K. Ream wrote:
> 
> > Before fixing bug 28, I must fix some very serious problems with
> > tab 
> completion and the change command.
> 
> Rev b3d404a fixes the problem with the change command.  This bug
> basically ruined the change command.  Am I the only one using Leo's 
> minibuffer-oriented find/change commands?

Quite possibly :-)  I use Ctrl-f

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Making syntax coloring more responsive

2014-08-26 Thread Edward K. Ream
On Tuesday, August 26, 2014 7:04:59 AM UTC-5, Edward K. Ream wrote:

> Before fixing bug 28, I must fix some very serious problems with tab 
completion and the change command.

Rev b3d404a fixes the problem with the change command.  This bug basically 
ruined the change command.  Am I the only one using Leo's 
minibuffer-oriented find/change commands?

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Making syntax coloring more responsive

2014-08-26 Thread Edward K. Ream
On Tue, Aug 26, 2014 at 8:33 AM, 'Terry Brown' via leo-editor
 wrote:
> On Tue, 26 Aug 2014 05:04:59 -0700 (PDT)
> "Edward K. Ream"  wrote:
>
>> The only solution is to transliterate QSyntaxHighlighter into Python!
>
> Which part of the job is QSyntaxHighlighter doing?  Working out how to
> color the text, or applying the colors to the text in the QTextEditor?

The latter.  QSH doesn't do all that much, but what it does is tricky.

Leo's own python code determines the colors to apply to the document.
Eventually, all that computation comes down to calling QSH.setFormat
on a range of text.

> Because http://pygments.org/ is an option for the first part, although
> maybe Leo already does the first part itself anyway?

pygments is interesting, but it doesn't solve any of our problems :-)

Most importantly, no matter what pygments produces, it would still
have to interact with Qt *somehow*.  In effect, the interface would be
what I am going to develop: a Python version of QSH.

Really, there is no way around the fundamental tasks that must be done:

1. Any syntax colorer must interact with QTextDocument (or
equivalently, QTextEdit). That's what QSH.applyFormatChanges does.

2. Any syntax colorer must interact with Leo's existing state-oriented
and pattern-oriented code.  That's what QSH.reformatBlocks does.

3. We want our syntax colorer to divvy up work for idle time.  That's
what the new PQSH.reformatBlocks will do.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Making syntax coloring more responsive

2014-08-26 Thread 'Terry Brown' via leo-editor
On Tue, 26 Aug 2014 05:04:59 -0700 (PDT)
"Edward K. Ream"  wrote:

> The only solution is to transliterate QSyntaxHighlighter into Python!

Which part of the job is QSyntaxHighlighter doing?  Working out how to
color the text, or applying the colors to the text in the QTextEditor?
Because http://pygments.org/ is an option for the first part, although
maybe Leo already does the first part itself anyway?

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.