Styling in the wxPython2424 demo, a patch

Hi Neil,

win9se, Py 2.3.0, wxPy 2.4.2.4 (non Unicode)

Motion of the caret

···

-------------------
I think I understand what is going wrong. Let's condider the first code
line
    import sys, os, time
in wxStyledTextCtrl_2.py from the demo. The style of the "import" keyword
is Arial, bold, blue.

n == expected caret position, in front of the char
p == char position in the line, from 0 to ...

Now, when moving the caret from left to the right the following
algorithm happens:
displayed__caret_postition = n + (p * one_pixel)
If I take the "import" example, when moving the caret from left to
right I get:
for "i" : caret pos ok
for "m" : difficult to see
for "p" : caret in the char
for "o" : caret in the middle of the char
for "r" : caret practically at the end of the char
form"t" : caret after the "t"

This happens only for the bold "import" word, and and not for the words
sys, os, time.

If there are several words separated by white spaces, the algorithm
apply to each word separately. Eg, in the expression "class MyLog(wx.PyLog):"
the algorithm applies to "class" and to "MyLog". The reference is no more
the begin of the line but the begin of the word.

Underlining issue
-----------------
This is probably due to the effect, I mentioned above.

Selection
---------
In bold texts. I also notice, that if you select n chars in a word,
the width in pixels of this word is incremented by:
number_of_selected_chars * one_pixel

Margin stuff
------------
I wrote:

If I insert the line in the demo code
    self.SetMarginWidth(1, 120)
the width (120) does not change.

Yor wrote:

  Works for me.

Sorry, it is working to me too.

I spent yesteday a couple of hours playing with margins.
Now I understand it better. It is not so obvious and sometimes
confusing. Some remarks:
- It is possible to have line numbering in two margins, but it's
impossible to have markers in two margins.
- If you (pre)define the margin i (i=0 or 1) to hold symbols (markers?),
why should I specifiy the margin number in a statement like
    self.MarkerAdd(i, self.MARKERa)

Ok, for me the is a solved problem

For Robin, you wrote:
---------------------
   > There is a small bug in the wsSTC demo: StyleClearAll should be called

after "StyleSetSpec(wxSTC_STYLE_DEFAULT" to copy that default style to all
the others.

This is one point, I corrected in my patch

For Robin, from jm:
-------------------

Small bug in ..\samples\StyleEditor\STCStyleEditor.py

c:\python23\pythonw -u STCStyleEditor.py

Traceback (most recent call last):
  File "STCStyleEditor.py", line 1320, in ?
    config = os.path.abspath(os.path.join(home, 'stc-styles.rc.cfg'))
  File "C:\PYTHON23\lib\ntpath.py", line 90, in join
    if path[-1] in "/\\":
TypeError: unsubscriptable object

Exit code: 1

To come back to the demo story. Displaying source code with a
mono font and playing with fore/back colours attributes seems to
to be best choice for the while. The question is not colour
preferences, the key point is to make the code *readable*.

Have all a nice day

Jean-Michel Fauth, Switzerland

Jean-Michel Fauth:

I think I understand what is going wrong. Let's condider the first code
line
    import sys, os, time
in wxStyledTextCtrl_2.py from the demo. The style of the "import" keyword
is Arial, bold, blue.

   I think it is actually Verdana. If you change the keyword style to
explicitly be Arial, then the 'p' and 'o' have two pixel wide holes rather
than 3 pixels wide. The text is also Antialiased for Arial at this size for
me. There is something to look into: are your results different when turning
"font smoothing" on or off?

Now, when moving the caret from left to the right the following
algorithm happens:
displayed__caret_postition = n + (p * one_pixel)
If I take the "import" example, when moving the caret from left to
right I get:
for "i" : caret pos ok
for "m" : difficult to see
for "p" : caret in the char
for "o" : caret in the middle of the char
for "r" : caret practically at the end of the char
form"t" : caret after the "t"

   Looks like a disagreement between the drawing and measurement APIs on
Windows 9x that isn't present on Windows 2000.

- It is possible to have line numbering in two margins, but it's
impossible to have markers in two margins.

   It is possible but you need to set separate masks for the two margins.
For example you may want to display a debug margin (stop sign and arrow) and
a bookmark margin, assigning 0=stop, 1=arrow, 2=bookmark and then having a
mask of 3 = b0011 for the debug margin and a mask of 4 = b0100 for the
bookmarks.

   Neil

Jean-Michel Fauth wrote:

Small bug in ..\samples\StyleEditor\STCStyleEditor.py

c:\python23\pythonw -u STCStyleEditor.py

Traceback (most recent call last):
  File "STCStyleEditor.py", line 1320, in ?
    config = os.path.abspath(os.path.join(home, 'stc-styles.rc.cfg'))
  File "C:\PYTHON23\lib\ntpath.py", line 90, in join
    if path[-1] in "/\\":
TypeError: unsubscriptable object

At first glance it works fine here. How do I reproduce this?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!