Discussion:
modmask
(too old to reply)
Valentin Valchev
2004-02-09 10:12:40 UTC
Permalink
Hello,
I was workining on JiTE (java wrapper for scintilla) this weekend and I found somethig curious.
I'm setting MODEVENTMASK to SC_MOD_CHANGEFOLD and I expect to receive only SCN_MARGINCLICK notifications.
Unfortunately I receive a LOT of ALL kind of notifications.

Here is a sample list:
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_UPDATEUI, modmask=8}
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_USERLISTSELECTION, modmask=8}
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_SAVEPOINTLEFT, modmask=8}
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_UPDATEUI, modmask=8}
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_USERLISTSELECTION, modmask=8}
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_SAVEPOINTREACHED, modmask=8}
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_USERLISTSELECTION, modmask=8}
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_MODIFIED, modmask=8}
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY {code=SCN_MARGINCLICK, modmask=8}

The most nasty is SCN_USERLISTSELECTION - It comes in a regular periods - 2-3 times a second.
This however puts me in trouble because I have to call the Java function from within the native at least 3 times a second - this will dramatically reduce the performance.

Here is my window proc:
LRESULT CALLBACK MyWindowProcedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if( WM_NOTIFY == uMsg ) {
ThParam *info = (ThParam*)GetWindowLong(hwnd, GWL_USERDATA);
NMHDR *n = (LPNMHDR) lParam;

if( info != NULL && n != NULL && info->hwndScintilla == n->hwndFrom ) {
int modmask = SendMessage(info->hwndScintilla, SCI_GETMODEVENTMASK, 0, 0);
LOG(LOG_DEBUG, "WM_NOTIFY {code=%s, modmask=%d}\n" _ SCN_NAMES[n->code-2000] _ modmask);
}
}

return DefWindowProc(hwnd, uMsg, wParam, lParam);
}


..
Actually I can fix that problem easy - I can get the mask and mask the event myself, but I suppose that this should be done by scintillaa, or why this modeventmask is added?
---------------------------------------------------------------
ProSyst Bulgaria Ltd. Valentin Valchev
48 Vladajska Str. Project Manager
Sofia 1606, Bulgaria Dept: mBedded Server/Broadband
http://www.prosyst.com/ Phone: +359 (2) 9523581-107
---------------------------------------------------------------
Leading Software Technology for Open Service Gateways
Neil Hodgson
2004-02-09 21:12:55 UTC
Permalink
Hi Valentin,
Post by Valentin Valchev
I'm setting MODEVENTMASK to SC_MOD_CHANGEFOLD
and I expect to receive only SCN_MARGINCLICK notifications.
Unfortunately I receive a LOT of ALL kind of notifications.
LOG_DEBUG, SciJNI.c:#109 --> WM_NOTIFY
{code=SCN_UPDATEUI, modmask=8}
...
The MODEVENTMASK controls only *document* modification messages. That is,
SCN_MODIFIED and SCEN_CHANGE.
Post by Valentin Valchev
The most nasty is SCN_USERLISTSELECTION - It comes in a regular
periods - 2-3 times a second.
That sounds like a bug. Placing a breakpoint on SCN_USERLISTSELECTION in
SciTE shows it is not received. Possibly you are off by one and seeing
SCN_PAINTED.
Post by Valentin Valchev
Actually I can fix that problem easy - I can get the mask and
mask the event myself, but I suppose that this should be done
by scintillaa, or why this modeventmask is added?
The mask was added to prevent containers being overwhelmed by document
change notifications when performing a large number of edits such as a
replace all.

Neil
Andy Jeffries
2004-02-10 08:22:00 UTC
Permalink
Hi all,

I'm using the Scintilla component (actually GtkScintilla2) in a GTK+ 2.x
app. It renders the font in Pango style (nicely anti-aliased), but I'm
having trouble doing the preferences dialog box.

I've got code that lists the available fonts using:
pango_context_list_families and pango_font_family_get_name.

However, when I insert the name found in to a font line for setting using
SCI_STYLESETFONT (like "!-*-Nimbus Roman 9-*-*-12-*-*-*-*-*-*") it doesn't
make any difference - it continues to use the default font.

So my questions are (in order that I think this list may be able to help):

1)What is the correct format for a font name for Pango rendering? Is it
as above but using a different name?

2)If it is using a different name (i.e. the name of a "font" not a
"family", although I'm new to all this) can you give me an example of one
so I can test that side of my app.

3)If 2 is true, any idea how I can get a list of the names available
(along with any human readable versions) in GTK+ 2.x ?

Thanks everyone,


Andy (gPHPEdit)
Neil Hodgson
2004-02-11 12:18:09 UTC
Permalink
Post by Andy Jeffries
However, when I insert the name found in to a font line for setting using
SCI_STYLESETFONT (like "!-*-Nimbus Roman 9-*-*-12-*-*-*-*-*-*") it doesn't
make any difference - it continues to use the default font.
The 'font' SCI_STYLESETFONT is what some environments call the face name:
in this example I would expect "Nimbus Roman" although it could be "Nimbus
Roman 9". By separating the parts of the font specification, you can change
aspects independently such as changing the size when the zoom key is
pressed.

There is also a back door where you can jam XLFDs into Scintilla by
adding a '-' prefix although that was never the preferred way and may have
rotted.
Post by Andy Jeffries
2)If it is using a different name (i.e. the name of a "font" not a
"family", although I'm new to all this) can you give me an example of one
so I can test that side of my app.
Sans
Post by Andy Jeffries
3)If 2 is true, any idea how I can get a list of the names available
(along with any human readable versions) in GTK+ 2.x ?
Haven't done this.

Neil
Andy Jeffries
2004-02-11 12:33:14 UTC
Permalink
Post by Neil Hodgson
Post by Andy Jeffries
However, when I insert the name found in to a font line for setting using
SCI_STYLESETFONT (like "!-*-Nimbus Roman 9-*-*-12-*-*-*-*-*-*") it doesn't
make any difference - it continues to use the default font.
in this example I would expect "Nimbus Roman" although it could be "Nimbus
Roman 9". By separating the parts of the font specification, you can change
aspects independently such as changing the size when the zoom key is
pressed.
There is also a back door where you can jam XLFDs into Scintilla by
adding a '-' prefix although that was never the preferred way and may have
rotted.
Ahh, OK so I just send the Font Family (from what I've seen of Pango
code) name in. How do I set the font size and bold/italic (oblique)
characteristics to use?

I'm used to using the old style "-*-*-bold-*....".
Post by Neil Hodgson
Post by Andy Jeffries
2)If it is using a different name (i.e. the name of a "font" not a
"family", although I'm new to all this) can you give me an example of one
so I can test that side of my app.
Sans
Thanks.
Post by Neil Hodgson
Post by Andy Jeffries
3)If 2 is true, any idea how I can get a list of the names available
(along with any human readable versions) in GTK+ 2.x ?
Haven't done this.
It's OK, if I can use the family name, I can get it using the functions
in my original post.

Thanks Neil,


Andy
Andy Jeffries
2004-02-11 13:05:41 UTC
Permalink
Post by Neil Hodgson
Post by Andy Jeffries
However, when I insert the name found in to a font line for setting using
SCI_STYLESETFONT (like "!-*-Nimbus Roman 9-*-*-12-*-*-*-*-*-*") it doesn't
make any difference - it continues to use the default font.
in this example I would expect "Nimbus Roman" although it could be "Nimbus
Roman 9". By separating the parts of the font specification, you can change
aspects independently such as changing the size when the zoom key is
pressed.
OK, I've tried this (along with setting a default size) in Scintilla but
the app now segfaults when you open a file.

I've included a backtrace below.

Any ideas?



Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1087919936 (LWP 5319)]
0x4207493f in malloc_consolidate () from /lib/tls/libc.so.6
(gdb) backtrace
#0 0x4207493f in malloc_consolidate () from /lib/tls/libc.so.6
#1 0x42073f99 in _int_malloc () from /lib/tls/libc.so.6
#2 0x4207335b in malloc () from /lib/tls/libc.so.6
#3 0x40b31e9e in operator new(unsigned) () from /usr/lib/libstdc++.so.5
#4 0x40b31fef in operator new[](unsigned) () from /usr/lib/libstdc++.so.5
#5 0x403444d0 in LineVector::ExpandLevels(int) () from
/usr/lib/libgtkscintilla2.so
#6 0x40345e2e in CellBuffer::SetLevel(int, int) () from
/usr/lib/libgtkscintilla2.so
#7 0x40347236 in Document::SetLevel(int, int) () from
/usr/lib/libgtkscintilla2.so
#8 0x40321738 in ColouriseHyperTextDoc(unsigned, int, int, WordList**,
Accessor&) () from /usr/lib/libgtkscintilla2.so
#9 0x4033a9b0 in LexerModule::Lex(unsigned, int, int, WordList**,
Accessor&) const () from /usr/lib/libgtkscintilla2.so
#10 0x4034bfa0 in ScintillaBase::Colourise(int, int) () from
/usr/lib/libgtkscintilla2.so
#11 0x4034c46b in ScintillaBase::WndProc(unsigned, unsigned long, long)
() from /usr/lib/libgtkscintilla2.so
#12 0x40343de7 in scintilla_send_message () from
/usr/lib/libgtkscintilla2.so
#13 0x4030c7a0 in gtk_scintilla_colourise (sci=0x82293f0, start=0,
end=-1) at gtkscintilla.c:2662
Neil Hodgson
2004-02-11 23:03:59 UTC
Permalink
Post by Andy Jeffries
OK, I've tried this (along with setting a default size) in Scintilla but
the app now segfaults when you open a file.
I've included a backtrace below.
Any ideas?
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1087919936 (LWP 5319)]
0x4207493f in malloc_consolidate () from /lib/tls/libc.so.6
(gdb) backtrace
#0 0x4207493f in malloc_consolidate () from /lib/tls/libc.so.6
#1 0x42073f99 in _int_malloc () from /lib/tls/libc.so.6
#2 0x4207335b in malloc () from /lib/tls/libc.so.6
Looks like a classic memory bug. As ColouriseHyperTextDoc works in other
applications, I'd first look into your application's memory allocation and
use. Possibly use valgrind
http://valgrind.kde.org/

Neil
Andy Jeffries
2004-02-12 09:27:12 UTC
Permalink
Post by Neil Hodgson
Post by Andy Jeffries
OK, I've tried this (along with setting a default size) in Scintilla but
the app now segfaults when you open a file.
I've included a backtrace below.
Any ideas?
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1087919936 (LWP 5319)]
0x4207493f in malloc_consolidate () from /lib/tls/libc.so.6
(gdb) backtrace
#0 0x4207493f in malloc_consolidate () from /lib/tls/libc.so.6
#1 0x42073f99 in _int_malloc () from /lib/tls/libc.so.6
#2 0x4207335b in malloc () from /lib/tls/libc.so.6
Looks like a classic memory bug. As ColouriseHyperTextDoc works in other
applications, I'd first look into your application's memory allocation and
use. Possibly use valgrind
http://valgrind.kde.org/
Thanks for the tip.

I've never used valgrind before, but I'll give it a go.

Cheers,


Andy
Andy Jeffries
2004-02-12 09:56:58 UTC
Permalink
Post by Andy Jeffries
Post by Neil Hodgson
Post by Andy Jeffries
OK, I've tried this (along with setting a default size) in Scintilla but
the app now segfaults when you open a file.
Looks like a classic memory bug. As ColouriseHyperTextDoc works in other
applications, I'd first look into your application's memory
allocation and
use. Possibly use valgrind
http://valgrind.kde.org/
I've never used valgrind before, but I'll give it a go.
Neil, you're a star!!! Found out it was segfaulting in the routine
merge_font (in my app), which it obviously shouldn't have been calling
with a font like "!Sans".

It now works a treat!!!

Thanks a googol,


Andy

Andy Jeffries
2004-02-11 12:34:45 UTC
Permalink
Doh!!!

Ignore my previous email - I've now seen the other SCI messages for
SIZE, BOLD and ITALIC.

<NOTE TO SELF>Slap - read the documentation before posting twatty
messages</NOTE TO SELF>

Thanks again,


Andy
Iago Rubio
2004-02-11 13:08:19 UTC
Permalink
Post by Andy Jeffries
3)If 2 is true, any idea how I can get a list of the names available
(along with any human readable versions) in GTK+ 2.x ?
Check this:
http://developer.gnome.org/doc/API/2.0/gtk/GtkFontSelectionDialog.html

Remember to add "!" to the font name to pass to scintilla, as it will
return a Pango font name.
--
Iago Rubio http://www.iagorubio.com
GPGkey pgp.rediris.es id 0x909BD4DD fingerprint =
D18A B950 5F03 BB9A DD89 AA75 FEDF 1978 909B D4DD
********** iago.rubio(AT)hispalinux.es **********
--------------------------------------------------
Andy Jeffries
2004-02-11 13:23:57 UTC
Permalink
Post by Iago Rubio
Post by Andy Jeffries
3)If 2 is true, any idea how I can get a list of the names available
(along with any human readable versions) in GTK+ 2.x ?
http://developer.gnome.org/doc/API/2.0/gtk/GtkFontSelectionDialog.html
Does that dialog ask for font size and bold/italic status (before I go
and implement it)? And if so, how do I a)set the initial values
(remembered in prefs) and b)get their status afterwards.
Post by Iago Rubio
Remember to add "!" to the font name to pass to scintilla, as it will
return a Pango font name.
That much I got! Getting it to work would be nicer :-)

For now, the segfault (another post is awaiting approval) is my main
worry...

Cheers,


Andy
Neil Hodgson
2004-02-11 23:08:17 UTC
Permalink
Post by Andy Jeffries
For now, the segfault (another post is awaiting approval) is my main
worry...
You can have your mails go through automatically by subscribing to the
list and setting that account to nomail.

Neil
Andy Jeffries
2004-02-12 09:26:29 UTC
Permalink
Post by Neil Hodgson
Post by Andy Jeffries
For now, the segfault (another post is awaiting approval) is my main
worry...
You can have your mails go through automatically by subscribing to the
list and setting that account to nomail.
OK, I've done this so hopefully this message will go straight through.

Cheers,


Andy
Continue reading on narkive:
Loading...