Styling in the wxPython2424 demo, a patch

Hi all,

Thanks for your replies.

First, I should say, I have nothing against the "official" demo styling.
I proposed this patch, because its styling suites better my eyes.
Nobody is forced to use it!

I see two two kinds of problems, a) the demo code, and b) the stc
control.

The main issue is due to the use of a proportional font. When using
a proportional font, the caret is not moving properly. It is
not stopping in front of a char. This is specially true for bold styles.
The caret stops in the middle of a "o" or "u", and even after an "i" or
an "l". Just to make things a little bit complicate, this depends on
the position of the char in the line.

I am not very happy with underlined (proportioanl font) styles.
When using narrrow chars like ")", rendering is not perfect. I never
know what stands before/after the ")". Is it char, a white char,
an underlined char or an underscore. Besides this effect, the code
has sometimes a white space before a "(", event if it's not necessary.
Eg def aa (...) instead of def aa(...). This applies to class
definition too.
Q. Does the width of the underline follow the width of the char
itself in proportional fonts? It seems not.

My post was a long because it proposed a replacement of the
whole module wxStyledTextCtrl_2.py, making the replacement
ready to use.

To Robin

···

--------

2.4.2.3 was one of the prerelease iterations used for release testing.
When I get in that mode new builds can come every day or two as the
final little nasties get ironed out.
Did you change anything besides the style settings? (If you had sent a
patch as prefered instead of the whole file I wouldn't have to ask that!
:wink: )

You know, with my phone connection...

Did you change anything besides the style settings?

The only line of code I inserted is the self.SetViewEOL(True)
line, now commented. Others mofificatiosns have to do solely with
styling.
- I did not change the faces dictionary.
- I modified the styles definition, SetStyleSpec(...)
- I reorder the definition of the styles in the code.
  If I define the styles in "my" order, everything in
  working ok. If I use "your" order, some styles are not
  working correctly, eg matching braces. Do not ask
  why, this is the result of a long "trial and error"
  experience. I got enough experience with "psi".
  
The demo is importing the styles from wxStyledTextCtrl_2.py,
but some features are not imported or overridden. Eg. Colour
of a selected text. I did not check this into details.
I did not make any change in other demo files.

I tried to play with margin widths, but I got problems, see below.

To Neil
-------

The indentation white space is styled in the wxSTC_P_DEFAULT style so the
size can be changed without changing the fonts for other elements.

I agree. I just wanted to say, that navigating with arrows keys is much
easier with a monospace font.

If you are reading this post, I have questions about the margins.
How many predifined margins are there in the stc? Two or three?
Which margin contains what? I have problems with margin widths too.
If I insert the line in the demo code
    self.SetMarginWidth(1, 120)
the width (120) does not change.
But after a
    self.SetMarginWidth(0, 120)
insetion, I have twice the line numbering!

To UC
-----

Well, there's some people that stick to good old diffs and don't use
any M$ Software in development :slight_smile:

M$? Sorry, our single family PC is a win98 platform. I never succeed to
install Linux properly. I prefer to spend my finite hobby time with
Python/wxPython on windows, than trying to configure one of the 1000
Linux distros.

To UC and all others
---------------------
Thanks for the links, I did not know all the proposed tools.

Jean-Michel Fauth, Switzerland

First, I should say, I have nothing against the "official" demo styling.
I proposed this patch, because its styling suites better my eyes.

Firstly, might I say I agree with you that the styling is not what I would
have chosen, either.

Having said that, a couple of things.

1) I think that it is important to use the different styles in the actual
wxStyledTextCtrl demos because the demo is supposed to showcase the
capabilities of the control, not please anyone's particular sensibilities.
Demos tend to be gaudy and that, I think, is a perfectly reasonable thing to
expect for a demo. Nobody would use every feature of a control in normal use
(there are I am sure exceptions) but its capabilities must be showcased in
the demo both to show what it CAN do as well as show HOW to do it.

2) For the actual demo code notebook pages, on the other hand, I think the
style should be what is considered sensible for source code. To me this is
mono font, etc, but that doesn't mean there aren't people that prefer
otherwise.

3) To me, the solution seems obvious: create, for the 'demo code' notebook
pages ONLY, either a tweakable config dictionary or just a small config file
and use THAT. Leave the actual wxSyledTextCtl demos alone, they're fine,
but let the geeks among us alter the source code windows to suit. The
EASIEST way to do this would be to implement a dict in the main demo code
and pass that in to the code snippet at runtime.

I can certainly implement #3 if nobody else wants to, though it appears this
is a hot subject for at least one person that has the means to do something
about it, so I'll keep my editor on standby. :slight_smile:

Hi Jean-Michel,

The main issue is due to the use of a proportional font. When using
a proportional font, the caret is not moving properly. It is
not stopping in front of a char. This is specially true for bold styles.
The caret stops in the middle of a "o" or "u", and even after an "i" or
an "l". Just to make things a little bit complicate, this depends on
the position of the char in the line.

   I can't reproduce this using the standard (non Unicode) 2.4.2.4 on Python
2.3.1 with Windows 2000. For "o" and "u", the caret is displayed in the gap
between the characters. There is mostly a two pixel gap between characters
and the caret is in the right-hand column of that gap. Thus, it touches the
left-hand side of the "o" or "u". The bolded text looks to be in Verdana and
the other text mostly in Arial. Make sure you have these fonts installed by
looking in the wxFontDialog demo.

I am not very happy with underlined (proportioanl font) styles.
When using narrrow chars like ")", rendering is not perfect. I never
know what stands before/after the ")". Is it char, a white char,
an underlined char or an underscore.

   The only underlined text I see is for class names. If there is an
underscore at the end of the class name it will be thick rather than thin
and will be quite visible.

Q. Does the width of the underline follow the width of the char
itself in proportional fonts? It seems not.

   It should. Are you talking about the overstrike mode horizontal caret
here? That should also follow the character width.

If you are reading this post, I have questions about the margins.
How many predifined margins are there in the stc? Two or three?
Which margin contains what? I have problems with margin widths too.

   Three with the normal definition being Line Numbers, Selection Margin,
and Fold Margin but they can be defined in a different order or with
different roles.

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

   Works for me.

For Robin:

   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.

   In the demo STC, the fold margin lines don't connect with the boxes like
they do in SciTE in fold.symbols=3 mode.

   Neil

Jean-Michel Fauth wrote:

To Robin
--------

2.4.2.3 was one of the prerelease iterations used for release testing. When I get in that mode new builds can come every day or two as the final little nasties get ironed out.
Did you change anything besides the style settings? (If you had sent a patch as prefered instead of the whole file I wouldn't have to ask that! :wink: )

You know, with my phone connection...

What does that have to do with anything? If you dan't want to use CVS then just keep a copy of the original file and then run it and your changed file through a standard diff tool, (command-line versions can be found for DOS.)

  diff -u old_file new_file > file.diff

···

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

Jeff Grimmett wrote:

3) To me, the solution seems obvious: create, for the 'demo code' notebook
pages ONLY, either a tweakable config dictionary or just a small config file
and use THAT. Leave the actual wxSyledTextCtl demos alone, they're fine,
but let the geeks among us alter the source code windows to suit. The
EASIEST way to do this would be to implement a dict in the main demo code
and pass that in to the code snippet at runtime.

I can certainly implement #3 if nobody else wants to, though it appears this
is a hot subject for at least one person that has the means to do something
about it, so I'll keep my editor on standby. :slight_smile:

Sounds good to me. Perhaps also a menu item for the demo that lets the users update their config file using the StyleEditor from the samples dir.

···

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

Neil Hodgson wrote:

For Robin:

   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.

Okay.

   In the demo STC, the fold margin lines don't connect with the boxes like
they do in SciTE in fold.symbols=3 mode.

Thanks. I think I was using the wrong mark for one of them. I just redid it based on the current scite code and it is now correct.

···

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