Non ascii characters in black, howto?

317 views
Skip to first unread message

jmfauth

unread,
Sep 25, 2011, 11:10:44 AM9/25/11
to scite-interest
Windows all version, SciTE v 2.12 (should not be significant).

Despite the excellent doc and my web researches, I'm bumping
on a stupid problem. How can I configure SciTE to display
non ascii chars in black and not in gray (I have more and
more problems to read them, white background).

I'm opening SciTE, untitled document. If I type ascii chars,
they look black, non ascii chars gray.

Which properties file should I modify and which options
are relevant?

I have no problem to configure the styles of a lexer. But
even within a used lexer (eg Python), non ascii chars supposed to
be black, are still in gray.

I have toyed with all "default" properties files,
Global properties, ...

No way, I simply can not figure how to solve this.

Thanks,
jmf

Philippe Lhoste

unread,
Sep 25, 2011, 12:59:39 PM9/25/11
to scite-i...@googlegroups.com
On 25/09/2011 17:10, jmfauth wrote:
> Despite the excellent doc and my web researches, I'm bumping
> on a stupid problem. How can I configure SciTE to display
> non ascii chars in black and not in gray (I have more and
> more problems to read them, white background).

I always saw them in black.
The style of these chars is set at the number 36.
I have:

style.*.36=font:Arial Narrow,size:10

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

jmfauth

unread,
Sep 25, 2011, 2:11:38 PM9/25/11
to scite-interest


On 25 sep, 18:59, Philippe Lhoste <Phi...@GMX.net> wrote:
> On 25/09/2011 17:10, jmfauth wrote:
>
> > Despite the excellent doc and my web researches, I'm bumping
> > on a stupid problem. How can I configure SciTE to display
> > non ascii chars in black and not in gray (I have more and
> > more problems to read them, white background).
>
> I always saw them in black.
> The style of these chars is set at the number 36.
> I have:
>
> style.*.36=font:Arial Narrow,size:10
>
> --
As far as I know, the style 36 is for control characters.

By non ascii, one should understand "non ascii printable
characters". Eg the characters/glyphs corresponding to
the code points 128-255 in a cp1252 encoding scheme.

I did not mention in my previous post. My problem
is not related to the coding of a file/text stream.

Anyway, thanks for the answer.
jmf


jmfauth

unread,
Sep 25, 2011, 2:38:50 PM9/25/11
to scite-interest
I narrowed (attempted to) a little bit my problem.

1) I created a dir containig only SciTE.exe + dll's.
No problem.

2) I added the SciTEGlobal.properties file. Everything
works fine.

3) I added the python.properties files. Now, it's no
more working.

I'am confused here. Where is the bottleneck?

Is there something missing in the python.properties?
If yes, what?

or

Is the the setup defined by SciTEGlobal.properties somehow
altered by the fact, it is "importing" the python.properties
file?
If yes, what's wrong in the SciTEGlobal.properties.

I toyed with the "dafault" files.

jmf

Neil Hodgson

unread,
Sep 25, 2011, 6:04:34 PM9/25/11
to scite-i...@googlegroups.com
jmfauth:

> I have no problem to configure the styles of a lexer. But
> even within a used lexer (eg Python), non ascii chars supposed to
> be black, are still in gray.

The Python lexer does not treat non-ASCII characters as valid
identifier characters so uses the default Python style, 0, which is
grey. You could change style.python.0.

Neil

Robin

unread,
Oct 1, 2011, 11:17:35 AM10/1/11
to scite-interest
Here is how I handled changing the non-ascii characters (below #32) to
non-black (i.e., non-reverse). The context was that I needed to mimic
the appearance and underlying control characters (i.e., hidden codes)
used by the Borland Sprint editor. That editor, dating from 1988, was/
is a fully programmable and customizable editor/formatter/printer
combination for which I have 20,000+ documents/programs in this
format. In moving to Windows 7, I needed a replacement editor - and
SciTE with Lua became the best option. These code changes below could
be abstracted to be customizable from properties and/or Lua, but I
needed the changes immediately so I just change the source and
recompile for each SciTE version. Here are the changes.

#1. The default control character is now a space (#32). In conjunction
with change #4 (below), an annoying flicker/change between states that
would otherwise happen when files are loaded and/or closed is avoided.

In Scintilla\Editor.cxx:

old:

controlCharSymbol = 0; /* Draw the control characters */

new:

controlCharSymbol = 32; /* Draw the control characters */


#2. The default control character text is replaced with a "^" version
(i.e., the hidden codes to be displayed) to mimic the Borland Sprint
edition (when revealing the underlying codes).

In Scintilla\Editor.cxx:

old:

const char *reps[] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"
};

new:

const char *reps[] = {
"^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G",
"^H", "^I", "^J", "^K", "^L", "^M", "^N", "^O",
"^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W",
"^X", "^Y", "^Z", "^[", "^\\", "^]", "^^", "^_"
};

#3. The control characters should be in the same background style as
the other characters, so undo the reverse video (i.e., switch textBack
and textFore).

In Scintilla\Editor.cxx:

old:

if (controlCharSymbol < 32) {
// Draw the character
const char *ctrlChar = ControlCharacterString(ll->chars[i]);
DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack,
textFore, twoPhaseDraw);
} else {
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
surface->DrawTextNoClip(rcSegment, ctrlCharsFont, rcSegment.top +
vsDraw.maxAscent, cc, 1, textBack, textFore);
}

new:

if (controlCharSymbol < 32) {
// Draw the character
const char *ctrlChar = ControlCharacterString(ll->chars[i]);
DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textFore,
textBack, twoPhaseDraw);
} else {
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
surface->DrawTextNoClip(rcSegment, ctrlCharsFont, rcSegment.top +
vsDraw.maxAscent, cc, 1, textFore, textBack);
}

#4. The default is changed so as to not display control characters
except with a space, done in conjunction with change #1 (above) to
avoid unnecessary flicker between modes.

SciTEGlobal.properties:

old:

control.char.symbol=.

new:

control.char.symbol=

#5. The Lua function to switch between normal text and reveal codes is
the following. The only way I have found to reliably update the screen
is by calling ZoomIn and then ZoomOut.

function flipCodes()
local new1
-- #SCI_GETCONTROLCHARSYMBOL = 2389
local old1 = scite.SendEditor(2389)
if old1 == 32 then
new1 = 0
else
new1 = 32
end

-- #SCI_SETCONTROLCHARSYMBOL = 2388
scite.SendEditor(2388,new1)

-- hack to toggle to/from normal and reveal code
editor:ZoomIn()
editor:ZoomOut()
end


#6. A Lua lexer/styler is used to create the same nested control-
character text color coding as used in the original Borland Sprint
editor. It is somewhat tricky to retain state from text segment to
text segment, but it works pretty well. The main difference is that
the original Borland Sprint editor did not use a space for a control
character but the SciTE colorized space (when codes are hidden) is
actually an improvement in visual feedback.

Aside: The motivation for the underlying control characters is the
following.

Editor text (^B, ^E, ^N, etc., do not appear but the text is color-
coded):

The output can display ^Bbold^N and ^Eitalic^N text.

Example (simplified) formatter definitions:

@MACRO(B()=[<b>@EVAL()</b>])
@MACRO(E()=[<i>@EVAL()</i>])

The argument to such a macro is the text from the control character up
to the ^N in the text. The output through the formatter can then be
modified by changing the macro definitions for B, E, etc., to do quite
sophisticated formatting - and all this was possible in 1988! I use
different dynamically included definitions depending on whether the
output is HTML, Word, TeX, PostScript, etc. But the source document
(i.e., any of my 20,000+ documents) can remain the same over time.
Reply all
Reply to author
Forward
0 new messages