Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANNOUNCE: SText 0.1

9 views
Skip to first unread message

Tim Baker

unread,
Jan 8, 2007, 6:47:51 PM1/8/07
to
SText is an extended Tk Text widget with features suitable for
source-code displaying and editing. Features include displaying line
numbers, syntax highlighting, code folding and linemarkers.

Home page and source download:

http://members.shaw.ca/tnbaker/stext01/stext.html

-- Tim Baker


Gerald W. Lester

unread,
Jan 8, 2007, 11:45:14 PM1/8/07
to

What license terms?

--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

Tim Baker

unread,
Jan 9, 2007, 1:32:51 AM1/9/07
to

Tcl license. There's also a copyright statement regarding the
use of Scintilla code in some of the files.

-- Tim Baker


sleb...@gmail.com

unread,
Jan 9, 2007, 5:15:55 AM1/9/07
to
Tim Baker wrote:
> >> SText is an extended Tk Text widget with features suitable for
> >> source-code displaying and editing. Features include displaying line
> >> numbers, syntax highlighting, code folding and linemarkers.
> >>
> >> Home page and source download:
> >>
> >> http://members.shaw.ca/tnbaker/stext01/stext.html
> >
> > What license terms?
> >
>
>
> Tcl license. There's also a copyright statement regarding the
> use of Scintilla code in some of the files.

So this is a Scintilla binding for Tcl? Sweet! I've always wanted to
create a Scintilla module for Tcl but kept putting it off. What OSes
are supported?

Googie

unread,
Jan 9, 2007, 7:44:37 AM1/9/07
to

I've tried to compile on Slackware 11, Tcl/Tk 8.4.14, gcc 3.4.6, results:

./generic/tkTextMargin.c: In function `MarginConfigure':
./generic/tkTextMargin.c:193: error: dereferencing pointer to incomplete
type
make: *** [tkTextMargin.o] Error 1

Btw. include a file is searched in wrong directory: tkUnixDefault.h is
expected in ./generic/ and it should be in ./unix/.

--
Pozdrawiam! (Regards!)
Googie

Tim Baker

unread,
Jan 9, 2007, 1:33:49 PM1/9/07
to


It isn't a binding. I tried a few approaches to creating a wrapper
around scintilla but they weren't really workable. I also tried
creating a Tk "backend" to scintilla (another platform module like
Win32 or GTK) but it was very slow.

This is a modified Tk text widget, it should work on every OS.

-- Tim Baker


Tim Baker

unread,
Jan 9, 2007, 4:14:05 PM1/9/07
to


A new source archive is available at the site which should fix the
error in tkTextMargin.c under X11. Also included a license file and
fixed some font/color issues in the demo.

I'm not sure why it is looking in generic/ for that file. Is the unix/
directory being passed to the compiler correctly?

-- Tim Baker


Koen Danckaert

unread,
Jan 10, 2007, 10:22:17 AM1/10/07
to
> A new source archive is available at the site which should fix the
> error in tkTextMargin.c under X11. Also included a license file and
> fixed some font/color issues in the demo.

I get the following compile error:

generic/tkTextMargin.c: In function `MarginConfigure':
generic/tkTextMargin.c:202: parse error before "mask"


make: *** [tkTextMargin.o] Error 1

After adding a missing parenthesis on line 200, compilation went ok.
However, I always get a segmentation fault when packing or gridding the widget:

> wish
% package require stext
0.1
% stext .t
.t
% pack .t
% Segmentation fault

I'm working on Linux with Tcl/Tk 8.4.12

-- Koen

Tim Baker

unread,
Jan 10, 2007, 1:00:07 PM1/10/07
to


I uploaded another version to fix the compile issue (sorry about that,
last minute change). It also improves comment handling with the tcl
lexer. I tested the X11 version under Cygwin/X11. Any chance you can
"make gdb" and see where the segfault is?

-- Tim Baker


Koen Danckaert

unread,
Jan 11, 2007, 6:01:18 AM1/11/07
to
> I uploaded another version to fix the compile issue (sorry about that,
> last minute change). It also improves comment handling with the tcl
> lexer. I tested the X11 version under Cygwin/X11. Any chance you can
> "make gdb" and see where the segfault is?

(gdb) run
Starting program: /target/staff/koen/install/tcltk8.4.12/LNx86/bin/wish8.4 ./demos/demo.tcl
***** TkTextRelayoutWindow
AsyncUpdateLineMetrics .w1.text REDRAW_PENDING
DINFO_RELAYOUT_WINDOW .w1.text
***** TkTextRelayoutWindow
***** TkTextRelayoutWindow

Program received signal SIGSEGV, Segmentation fault.
0x400c9f7f in CharDisplayProc (chunkPtr=0x8108fd0, x=135391896, y=52,
height=0, baseline=13, display=0xa, dst=134617784, screenY=48234565)
at /target/staff/koen/src/tk8.4.12/generic/tkTextDisp.c:4625
4625 sValuePtr = stylePtr->sValuePtr;
(gdb) quit


Note: the segfault is in tk's original tkTextDisp.c, not in stext's.
I don't know if that's the cause of the error, but it is at least a bit confusing to use the same filenames and function-names as in tk...

-- Koen

Joe English

unread,
Jan 11, 2007, 4:17:10 PM1/11/07
to
Koen Danckaert <danc...@retarget.com> wrote:
>> [Tim Baker]

>> I uploaded another version to fix the compile issue (sorry about that,
>> last minute change). It also improves comment handling with the tcl
>> lexer. I tested the X11 version under Cygwin/X11. Any chance you can
>> "make gdb" and see where the segfault is?
>
>(gdb) run

[...]

>Program received signal SIGSEGV, Segmentation fault.
>0x400c9f7f in CharDisplayProc (chunkPtr=0x8108fd0, x=135391896, y=52,
> height=0, baseline=13, display=0xa, dst=134617784, screenY=48234565)
> at /target/staff/koen/src/tk8.4.12/generic/tkTextDisp.c:4625
>4625 sValuePtr = stylePtr->sValuePtr;

[...]

>Note: the segfault is in tk's original tkTextDisp.c, not in stext's.

I can explain what's going on:

On ELF-based systems (like Linux and most modern Unices),
when you dynamically load a shared library, global symbols
that are defined in the main executable (or in a different,
previously dlopen()ed shared library) will override global
symbols of the same name defined in the .so. (This is
presumably to make shared library semantics the same as
for static libraries).

So when Stext calls CharDisplayProc() -- or rather, something
higher up in the call chain, probably TkTextRedrawRegion --
it thinks it's getting *it's* copy of the function but instead
it's getting *Tk's* copy. Conversely, CharDisplayProc
thinks it's getting data structures from a Tk text widget,
when it's actually getting data structures from an SText widget.
Since the data structures are different, all heck breaks loose.

The reason Tim can't replicate the problem is -- I'm guessing,
but it's a pretty good bet -- is that he develops on Windows,
where shared libraries work differently.


>I don't know if that's the cause of the error, but it is at least a bit
>confusing to use the same filenames and function-names as in tk...

That's exactly the cause of the error.

The best solution is probably to rename all of the public functions
in the SText widget from TkTextWhatever() to STextWhatever().
This will avoid nameclashes with the core, and all should
be well again.


--Joe English

Tim Baker

unread,
Jan 11, 2007, 1:56:36 PM1/11/07
to


That is definitely the cause of the error. I have used macros
to redefine TkTextXXX to STextXXX to make it easier to patch
the stext sources. The package uses stubs so there should be
no linking against Tcl or Tk. I don't understand why any
linking is occurring against the original tktTextDisp.c, unless
it is happening at run-time, but CharDisplayProc is static.

-- Tim Baker


Tim Baker

unread,
Jan 11, 2007, 10:29:43 PM1/11/07
to

Joe English wrote:
> Koen Danckaertwrote:


It was the global variables tkTextXXX that I hadn't renamed.
It should all work now on X11. I installed Ubuntu using the free
VMWare Player and built SText succesfully. The updated archive
is available from:

http://members.shaw.ca/tnbaker/stext01/stext01.tar.gz

Good luck! ;-}
-- Tim Baker


Koen Danckaert

unread,
Jan 12, 2007, 5:25:32 AM1/12/07
to
> It was the global variables tkTextXXX that I hadn't renamed.
> It should all work now on X11. I installed Ubuntu using the free
> VMWare Player and built SText succesfully. The updated archive
> is available from:
>
> http://members.shaw.ca/tnbaker/stext01/stext01.tar.gz
>
> Good luck! ;-}

Still having bad luck... :-(

The link above is stale, and when I correct the name to stext0.1.tar.gz, I get the same archive as yesterday.

Good luck! ;-))

-- Koen

ctasada

unread,
Jan 12, 2007, 8:24:04 AM1/12/07
to
I've tried to compile it in Linux and Windows.

- Linux: Compiles correctly, but for some reason the -tabwidth
parameter is not available
- Windows: Doesn't compile, tons of errors

c:\wifesrc\src\stext\generic\lexpython.c(361) : error C2143: syntax
error : missing ';' before 'type'
c:\wifesrc\src\stext\generic\lexpython.c(364) : error C2143: syntax
error : missing ';' before 'type'
c:\wifesrc\src\stext\generic\lexpython.c(366) : error C2065:
'prev_state' : undeclared identifier
c:\wifesrc\src\stext\generic\lexpython.c(367) : error C2143: syntax
error : missing ';' before 'type'
c:\wifesrc\src\stext\generic\lexpython.c(368) : error C2143: syntax
error : missing ';' before 'type'
c:\wifesrc\src\stext\generic\lexpython.c(370) : error C2065:
'prevComment' : undeclared identifier
c:\wifesrc\src\stext\generic\lexpython.c(376) : error C2065:
'prevQuote' : undeclared identifier
c:\wifesrc\src\stext\generic\lexpython.c(390) : error C2143: syntax
error : missing ';' before 'type'
c:\wifesrc\src\stext\generic\lexpython.c(391) : error C2065: 'style' :
undeclared identifier
c:\wifesrc\src\stext\generic\lexpython.c(393) : error C2143: syntax
error : missing ';' before 'const'
c:\wifesrc\src\stext\generic\lexpython.c(394) : error C2143: syntax
error : missing ';' before 'const'
c:\wifesrc\src\stext\generic\lexpython.c(395) : error C2143: syntax
error : missing ';' before 'const'
c:\wifesrc\src\stext\generic\lexpython.c(396) : error C2143: syntax
error : missing ';' before 'const'
c:\wifesrc\src\stext\generic\lexpython.c(398) : error C2143: syntax
error : missing ';' before 'const'
c:\wifesrc\src\stext\generic\lexpython.c(399) : error C2065: 'comment'
: undeclared identifier

.....

Any idea?

Tim Baker

unread,
Jan 12, 2007, 1:50:43 PM1/12/07
to


I downloaded it and it seems like the updated version: Do you see these
lines in the tkText.h file? That's the fix anyway, put these at line 1093.

#ifdef STEXT_DIFF
#define tkBTreeDebug STextBTreeDebug
#define tkTextDebug STextDebug
#define tkTextCharType STextCharType
#define tkTextLeftMarkType STextLeftMarkType
#define tkTextRightMarkType STextRightMarkType
#define tkTextToggleOnType STextToggleOnType
#define tkTextToggleOffType STextToggleOffType
#endif

Strange how the archive is dated 12/01/2007 03:22. I posted to the newsgroup
at 7:30. Gremlins. I blame gremlins.

-- Tim Baker


Tim Baker

unread,
Jan 12, 2007, 1:59:47 PM1/12/07
to


Download the archive again if you got it before 3AM on the 12th. I
*know* I uploaded it around 7PM on the 11th but there are dark forces at
work keeping SText out of the hands of the good peoples of the Earth,
who desperately need my cool hax.

The compile errors on Windows are due to the conversion of C++ to C
code. There are variable declarations mixed in after other statements
which your compiler doesn't like, but GCC passed even with -ansi turned
on (C99 I suppose). I'll clean those up and ... upload ... again.

-- Tim Baker


Tim Baker

unread,
Jan 12, 2007, 4:02:30 PM1/12/07
to


Okay it really is there now. I renamed it to stext0.1-Jan-12-2007.tar.gz
and that did the trick. My ISP's FTP server is 8 hours ahead of the rest of
the world apparently so it wasn't seeing the changed file. Renaming it did
the
trick.

-- Tim Baker


Koen Danckaert

unread,
Jan 15, 2007, 6:54:22 AM1/15/07
to
Hi,

Thanks for the update, I'm now able to create and display an stext widget. However, there are still some problems when running the demos.

The following happens when running demo.tcl:
$ wish demo.tcl

***** TkTextRelayoutWindow
AsyncUpdateLineMetrics .w1.text REDRAW_PENDING
DINFO_RELAYOUT_WINDOW .w1.text
***** TkTextRelayoutWindow
***** TkTextRelayoutWindow

AsyncUpdateLineMetrics .w1.text REDRAW_PENDING
DINFO_UPDATE_METRICS .w1.text
AsyncUpdateLineMetrics .w1.text ended at lineNum 0
***** TkTextRelayoutWindow
***** TkTextRelayoutWindow
Error in startup script: bad tabstyle "": must be tabular, wordprocessor, or
(processing "-tabstyle" option)
invoked from within
".w1.text tag configure whitespace -underline {} -spacing1 {} -borderwidth 0 -sp
acing2 {} -font {} -offset {} -tabstyle {} -spacing3 {} -rmargin {} -ba..."
("eval" body line 1)
invoked from within
"eval $w tag configure $style [StyleToTagOptions $w $language $style $defaultFon
t $mono]"
(procedure "StylesToTags" line 12)
invoked from within
"StylesToTags $w.text $::Options($w,monospace)"
(procedure "ReadFile" line 13)
invoked from within
"ReadFile [NewWindow] [info script]"
(file "demo.tcl" line 1026)


When running minimal.tcl, I still get a segmentation fault:

(gdb) run
Starting program: /target/staff/koen/bin/LNx86bin/wish minimal.tcl

Program received signal SIGSEGV, Segmentation fault.

0x4207c1a5 in memcpy () from /lib/tls/libc.so.6

(gdb) backtrace
#0 0x4207c1a5 in memcpy () from /lib/tls/libc.so.6
#1 0x4018334f in Tcl_NewStringObj ()
from /target/staff/koen/install/tcltk8.4.12/LNx86/lib/libtcl8.4.so
#2 0x4005ca32 in TkUndoPushAction (stack=0x80df718, actionScript=0x80e5d00,
revertScript=0x80e5d48)
at /target/staff/koen/src/tk8.4.12/generic/tkUndo.c:134
#3 0x4030086d in TextPushUndoAction (textPtr=0x8090418, undoString=0x80ab328,
insert=1, index1Ptr=0xbfffd470, index2Ptr=0xbfffb440)
at generic/tkText.c:3086
#4 0x403002b5 in InsertChars (sharedTextPtr=0x8073e30, textPtr=0x8090418,
indexPtr=0xbfffd470, stringPtr=0x80ab328, viewUpdate=1)
at generic/tkText.c:2924
#5 0x4030182e in TextInsertCmd (sharedTextPtr=0x8073e30, textPtr=0x8090418,
interp=0x804a1f0, objc=1, objv=0xbfffd5dc, indexPtr=0x80e59a0,
viewUpdate=1) at generic/tkText.c:3926
#6 0x402fdc04 in TextWidgetObjCmd (clientData=0x8090418, interp=0x804a1f0,
objc=4, objv=0xbfffd5d0) at generic/tkText.c:1488
#7 0x4012ed6e in TclEvalObjvInternal ()
from /target/staff/koen/install/tcltk8.4.12/LNx86/lib/libtcl8.4.so
#8 0x4012f7ee in Tcl_EvalEx ()
from /target/staff/koen/install/tcltk8.4.12/LNx86/lib/libtcl8.4.so
#9 0x4016b782 in Tcl_FSEvalFile ()
from /target/staff/koen/install/tcltk8.4.12/LNx86/lib/libtcl8.4.so
#10 0x4016a866 in Tcl_EvalFile ()
from /target/staff/koen/install/tcltk8.4.12/LNx86/lib/libtcl8.4.so
#11 0x4004fb72 in Tk_MainEx (argc=-1, argv=0xbfffdc1c,
appInitProc=0x8048826 <Tcl_AppInit>, interp=0x804a1f0)
at /target/staff/koen/src/tk8.4.12/generic/tkMain.c:248
#12 0x08048819 in main (argc=2, argv=0xbfffdc14)
at /target/staff/koen/src/tk8.4.12/unix/tkAppInit.c:68
#13 0x42015574 in __libc_start_main () from /lib/tls/libc.so.6

(gdb) quit


As you can see, the problem is probably again that tk's TkUndoPushAction is called, not stext's.

I can run minimal.tcl without the undo feature, and it definitely looks great! Really a huge improvement over the ctext widget in tklib.

-- Koen

ctasada

unread,
Jan 15, 2007, 7:25:56 AM1/15/07
to
Hi Tim,

Now I'm trying with your last version :)

I've done more work trying to compile it with Windows:

- I've created a VS8 project and I've the next problems:

..\generic\LexRuby.c(120) : error C2039: 'wordListPtrs' : is not a
member of 'TkSharedText'

I've "fixed" it removing the LexRuby.c from the project. Then I can
compile and load the library, but like Koen, when I pack the stext, I
get a segmentation fault. The debugger seems to indicate that the
problem is in tktextdisp.c line 9585: return
(linePtr->peerData[ref].flags & LINE_FLAG_HIDDEN) == 0;

- I've also created an nmake project. This project has the same LexRuby
problem and another tktextdisp compile error:
..\generic\tkTextDisp.c(2217) : error C2065: '__FUNCTION__' :
undeclared identifier

I can send you the project files, if you want.

Cheers,
Carlos Tasada.

ctasada

unread,
Jan 15, 2007, 7:43:01 AM1/15/07
to
Hi Tim,

Still no change in Linux. I still get the "unknown option "-tabwidth""
:(

But I can pack an stext component in a frame :)

Cheers,

Tim Baker

unread,
Jan 15, 2007, 3:44:51 PM1/15/07
to
> Thanks for the update, I'm now able to create and display an stext
> widget. However, there are still some problems when running the demos.
>
> The following happens when running demo.tcl:
> Error in startup script: bad tabstyle "": must be tabular,
> wordprocessor, or (processing "-tabstyle" option)


8.4.12 doesn't like "" being passed to Tcl_GetIndexFromObj, while 8.4.14
doesn't seem to mind. I worked around this.


> When running minimal.tcl, I still get a segmentation fault:

> As you can see, the problem is probably again that tk's
> TkUndoPushAction is called, not stext's.


Yeah I missed those. For some reason it didn't bomb under my
Ubuntu/VMWare setup though.


> I can run minimal.tcl without the undo feature, and it definitely
> looks great! Really a huge improvement over the ctext widget in tklib.
>
> -- Koen


January 15th edition is here:
http://members.shaw.ca/tnbaker/stext01/stext.html

Now includes a Makefile lexer!!!
Warning: may bomb while parsing Makefiles. ;-}

-- Tim Baker


Tim Baker

unread,
Jan 15, 2007, 3:55:36 PM1/15/07
to
> I've done more work trying to compile it with Windows:
>
> - I've created a VS8 project and I've the next problems:
>
> ..\generic\LexRuby.c(120) : error C2039: 'wordListPtrs' : is not a
> member of 'TkSharedText'


LexRuby.c is obsolete, just leave it out. It gets packed in there
when I run "make dist".


> I've "fixed" it removing the LexRuby.c from the project. Then I can
> compile and load the library, but like Koen, when I pack the stext, I
> get a segmentation fault. The debugger seems to indicate that the
> problem is in tktextdisp.c line 9585: return
> (linePtr->peerData[ref].flags & LINE_FLAG_HIDDEN) == 0;
>
> - I've also created an nmake project. This project has the same LexRuby
> problem and another tktextdisp compile error:
> ..\generic\tkTextDisp.c(2217) : error C2065: '__FUNCTION__' :
> undeclared identifier
>
> I can send you the project files, if you want.


__FUNCTION__ is GCC thing, I've fixed it now.
Try the Jan 15th version and see if it builds/runs ok.

And thanks for reporting these errors.

-- Tim Baker


ctasada

unread,
Jan 16, 2007, 9:01:41 AM1/16/07
to
Hi Tim,

To compile the new code I needed to comment-out all the "lmMake"
references, but I still have the segmentation fault :(

I'm compiling using VS2005 aka VS8 against Tcl 8.5a5.

Later I'll try with Linux to see what happens :(

It's a bit frustrating not to be able to use it. Can you add to you
website a compiled version to test it?

Thanks a lot for you hard work :)

ctasada

unread,
Jan 16, 2007, 9:38:38 AM1/16/07
to
Hi again Tim :)

I've tested in Linux (Ubuntu 6.10/Edgy)

If I run the minimal.tcl test I get a "Segmentation fault" as soon as
the mouse moves on top of the window
If I run the demo.tcl then I get

***** TkTextRelayoutWindow
AsyncUpdateLineMetrics .w1.text REDRAW_PENDING
DINFO_RELAYOUT_WINDOW .w1.text
***** TkTextRelayoutWindow
***** TkTextRelayoutWindow
AsyncUpdateLineMetrics .w1.text REDRAW_PENDING
DINFO_UPDATE_METRICS .w1.text

***** TkTextRelayoutWindow
***** TkTextRelayoutWindow
***** TkTextRelayoutWindow
TkTextMarginLineCountChanged: +266 lines, relayout whole window
TkTextMarginLineCountChanged: +337 lines, relayout whole window
Segmentation fault

:(

Koen Danckaert

unread,
Jan 16, 2007, 11:16:10 AM1/16/07
to
> January 15th edition is here:
> http://members.shaw.ca/tnbaker/stext01/stext.html
>
> Now includes a Makefile lexer!!!
> Warning: may bomb while parsing Makefiles. ;-}

Thanks, it's working now!

I can run the demos, I tried to load a C file, a Tcl file and a Makefile, and everything works fine. The lexers seem to be very fast and accurate, even for multi-line strings etc.

This is really an impressive widget, I'm certainly going to experiment more with it!

-- Koen

Tim Baker

unread,
Jan 17, 2007, 1:00:35 PM1/17/07
to
> Hi Tim,
>
> To compile the new code I needed to comment-out all the "lmMake"
> references, but I still have the segmentation fault :(
>
> I'm compiling using VS2005 aka VS8 against Tcl 8.5a5.
>
> Later I'll try with Linux to see what happens :(
>
> It's a bit frustrating not to be able to use it. Can you add to you
> website a compiled version to test it?
>
> Thanks a lot for you hard work :)


Here is a Windows package with demo:

http://members.shaw.ca/tnbaker/stext01/stext0.1-Jan-17-2007-win32.zip

-- Tim Baker


ctasada

unread,
Jan 18, 2007, 5:16:10 AM1/18/07
to
Thanks a lot!!!

Your dll works ok, no crash. I've recompiled the component in my system
and I see that my dll is 258,048 bytes, while yours is 220,160 bytes.
Anyway, compiling in debug mode it works fine .... I hate this
compilation problems :(

Looking further to the compilation options I see that compiling with
the /O2 flag causes the problem. If I use a /Od (as in debug) it works.
That means that some of the optimizations seem to be causing the
problem.

Has someone else tried to compile it using VS2005?

I'll try to continue investigating, anyway, any idea is welcome ;)

Best Regards,
Carlos Tasada.

0 new messages