PDA

View Full Version : a Text Editor with line numbers...



fullmetalcoder
12th January 2006, 16:34
hi,
I'm working on a C++ IDE with build-in support for Qt4.
Basic GUI is working but QTextEdit does not match my requirements:
I'm looking for an editor which would show lines number, allow search and replace and so on...
QScintilla may have be fine but it hasn't been ported to Qt4 yet. :(
QSA implements a similar text editor but I have troubles customizing it!!! :mad:
Any ideas???

elcuco
12th January 2006, 22:48
can you post any code..?

I am loking for such beast myself

fullmetalcoder
13th January 2006, 16:10
still working on it when I've got time and nothing to post.

about IDE also:
how to customize a QTreeWidget (or QTreeView as well) so as to allow each item to have a working context menu???

Corran
13th January 2006, 18:56
Connect the customContextMenuRequested signal to a slot where you look at the x,y co-ordinates to find out which cell the menu was requested from using QTableWidget::itemAt(QPoint).

elcuco
13th January 2006, 19:00
If you cannot release code, then some questions instead:

How are you handeling the tabs->convertion (show tabs as 8 spaces, etc)
Are displaying the current line in another color?

What other goodies do you have implemented?

fullmetalcoder
16th January 2006, 10:25
Connect the customContextMenuRequested signal to a slot where you look at the x,y co-ordinates to find out which cell the menu was requested from using QTableWidget::itemAt(QPoint).


Thanks but I have already done it by myself. I asked the question before thinking about the answer!!!:rolleyes:

Dear elcuco, your beast appeared to me!!!
Looks nice but still needs a little work.


If you cannot release code, then some questions instead:

How are you handeling the tabs->convertion (show tabs as 8 spaces, etc)
Are displaying the current line in another color?

What other goodies do you have implemented?


Let's describe the "Graal" I made starting from QSA's editor ;)

DevEdit : inherits QTextEdit
- custom contextMenu
- some additional signals and slots for convinience

DevStatus : inherits QStatusBar
- additional slot to write right aligned message (in my case its colum and row)

DevLineNumber : inherits QWidget
- draws line number (note : taken verbatim from QSA)
- additional signals and slots are planned for integrated debugging purpose

DevEditor : inherits QWidget
- All the widgets described above are put into a QGridLayout and signals are properly connected to have those widgets working together
following signals are wrapped for convinience:
- QTextEdit's signals
- QStatusBar signal
- QTextEdit's scrollbar's signals

The description I give may not be very clear but you'll understand with the code.
I'm gonna post it during the week. Wait...

edit :
posted a screenshot.

After thinking a bit I decided to reimplement my DevEdit as clone of QTextEdit but without any HTML stuff making it slow and with a custom highlighting mechanism.

You'll have to wait more before the final version but if anyone is interested in the current one he can e-mail me to get it. :)

edit 2:
WTF !!! I looked into Qt's source and QTextedit would be quite hard to reimplement using inheritance... I'll try to craft a widget with a QAbstractScrollArea inside and custom paint, keypress, context menu (...)events.
I do not like the idea of starting from scratch but...

elcuco
17th January 2006, 22:57
Ok, nice. So it can be done... :)

I see you have exactly the same problem I have.
I am using a QTabWidget, I seem to have an orrible space on the right side, which means the right scrollbar is not on the "infinite-right". I have looked into Qt-Assistant code for some ideas about how they did it, and I "borrowed" that code, but still the internal editor is way from from the sides of the window.

Again, a few questions if you do not mind:
1) "display tab as X spaces", did you implement it? If so how? if not, how are you planning?
2) The syntax highlighter. It's based on the examples from the trolls? See notes bellow.
3) Current line and match brackets. Planned...? Implemented...?

I am toying with this issue myself, and I already implemented a hack of a system for displaying and loading SL. I am currently loading parts of GtkSourceView SH definitions, and I can display in a rather good quality C/C++/C# syntaxes. I will fix the implementation I have to display DIFF and other goodies (I am still messing the implementation...). I used as a base the SH example supplied by the trolls with some spin ups.

If found that using RegEx for for the painting is extreamly painfull, as in big files (~1000 lines) text will take about 5 seconds to load. I will try to see if the code for settign the QSyntaxHighliter can be put in a QTimer::singleShot() to make this call asynchroneous and improove usability, as hack for a good SH system.

Did you write the SH yourself (as the example on Qt4.0 showed), or are you deriving QSyntaxHihlighter. In any case, how is the drawing made? (hard coded contexts or something like Kate?)

impeteperry
18th January 2006, 03:01
hi,
I'm working on a C++ IDE with build-in support for Qt4.
Basic GUI is working but QTextEdit does not match my requirements:
I'm looking for an editor which would show lines number, allow search and replace and so on...
QScintilla may have be fine but it hasn't been ported to Qt4 yet. :(
QSA implements a similar text editor but I have troubles customizing it!!! :mad:
Any ideas???
I use "kwrite" or "kate"

fullmetalcoder
18th January 2006, 09:16
I use "kwrite" or "kate"
lol
You don't seem to pay attention to profile on the right of each post! I'm a Windows user, even if I would like to change there's no way, other users would'nt agree!:(


Again, a few questions if you do not mind:
1) "display tab as X spaces", did you implement it? If so how? if not, how are you planning?
2) The syntax highlighter. It's based on the examples from the trolls? See notes bellow.
3) Current line and match brackets. Planned...? Implemented...?

[...]

If found that using RegEx for for the painting is extreamly painfull, as in big files (~1000 lines) text will take about 5 seconds to load. I will try to see if the code for settign the QSyntaxHighliter can be put in a QTimer::singleShot() to make this call asynchroneous and improove usability, as hack for a good SH system.

Did you write the SH yourself (as the example on Qt4.0 showed), or are you deriving QSyntaxHihlighter. In any case, how is the drawing made? (hard coded contexts or something like Kate?)
I don' mind! :D

1) three ways:
- either reimplementing the whole paint event which may be very hard.
- either using each time font gets modified :
setTabStopWidth( x * QFontMetrics( font() ).width(' ') );
- either hacking the keypress event so that any tab char is translated as x spaces [pretty uggly and stupid]

2)Sure it is! Actually I took the reimplementation from QSA and subclassed it as C++ syntax highlighter. Yes it's based on QRegExp which is an inherently slow method with large files but, well...

3)What do you call current line? Isn't that implemented in two ways?
What do you call match bracket? Indentation? Indentation is planned but not that easy!
There was a "parenthesis matcher" in QSA code but I didn't understand it's goal so I removed it!

elcuco
18th January 2006, 21:45
1) Please, don't reimplement the drawing engine. I am not a native english speaker. My native language is Spanish, but since I live in Israel, my real language is Hebrew - which as you may know already it's a complex script (google for RTL or BIDI).

If you reimplement the drawing code of the QTextEdit, you will loose any BiDI support in that widget. You will probably mess up Chinese, Hindic, and some other languages which Lars has worked so hard to get in perfect shape.

The setTabStopWidth() seems to beright way. As you will be able to convert the tab to "spaces" and back. This means you do not mess with the text the use loaded.

2) Reguarding the SH, I will see if there is a way to set it in a callback or something, otherwise th UI gets frezzed for several seconds when the initial painting is done. I also found no eay to rehighlight the code (what if the user wants to use another highlight...?)

3) current line = current pararaph in QTextDocument terminology. I want to draw the current line with a different background.

When the cursor is on "}", that char should be drawed with another background color, and the same for the first "{".

I assume you support only C/C++/H files right now...?

fullmetalcoder
19th January 2006, 09:04
3) current line = current pararaph in QTextDocument terminology. I want to draw the current line with a different background.

It's planned but not working right now.



When the cursor is on "}", that char should be drawed with another background color, and the same for the first "{".

Would be quite hard!!!



I assume you support only C/C++/H files right now...?

Entierely true.

Due to the limitations of my wrapper around QTextEdit I started porting QScintilla to Qt4.
:mad: Pretty long and hard as I never learned Qt3!

rh
19th January 2006, 10:05
Due to the limitations of my wrapper around QTextEdit I started porting QScintilla to Qt4.

Yea, i played with porting QScintilla to Qt4. Of course if qt3to4 did all the work, it would be too easy, but there is still tons of hand-massaging you have to do. Porting from scratch using Riverbank's code as a guideline might in the end be the best way to go.

fullmetalcoder
19th January 2006, 16:42
Yea, i played with porting QScintilla to Qt4. Of course if qt3to4 did all the work, it would be too easy, but there is still tons of hand-massaging you have to do. Porting from scratch using Riverbank's code as a guideline might in the end be the best way to go.

Where to find Riverbak's code? Would be happy to find an easy way!!!

elcuco
19th January 2006, 17:38
QScintilla does not support anything but Latin1 and thus it's unusable for me and many others.

fullmetalcoder
20th January 2006, 15:28
I ported QScintilla by hand from Qt3 to Qt4, it compiled without even one warning.
I then tried to use it in a very simple program and it linked with no problem, the window appeared...
but not the cursor:confused:
then tryed to copy from another editor... NO WAY!!! but the context menu displayed...:confused:
then tryed to typoe by hand a few words... NO WAY!!! What the fuck is that???:mad:
I spent 4hours porting something that doesn't work!!!

elcuco
20th January 2006, 18:33
I ported QScintilla by hand from Qt3 to Qt4, it compiled without even one warning.
I then tried to use it in a very simple program and it linked with no problem, the window appeared...
but not the cursor:confused:
then tryed to copy from another editor... NO WAY!!! but the context menu displayed...:confused:
then tryed to typoe by hand a few words... NO WAY!!! What the fuck is that???:mad:
I spent 4hours porting something that doesn't work!!!
release the code or shut up... :)

at last for the first editor!

fullmetalcoder
21st January 2006, 17:44
which code??? buggy QScintilla or working QTextEdit???

QTextEdit based now highlight current line in cyan but there's still a twist:
no simple way to make it highlight the whole line, as in Dev-C++ for example.
any ideas on how to do that?

cheers

elcuco
21st January 2006, 23:04
I would like to see a code based on QTextEdit, because of the reasons I explained before. But that's me :)

fullmetalcoder
22nd January 2006, 22:07
I should be able to post it tomorrow.

No solutions comes to me about current line colouring but I implemented the basis of a breakpoint management system.

Seems to progress!!! :D

rh
22nd January 2006, 23:10
If you want to see more information on scintilla implementations, you may want to check out:

http://www.codeproject.com

and search for "scintilla". Of course these will be implemented with MFC or in C#, but you might get some ideas.

P.S. CodeProject's search isn't very good; you'll get more hits googling the CodeProject site.

fullmetalcoder
23rd January 2006, 10:00
sorry rh but I don't think porting QScintilla would be a good way to reach my goal.

Elcuco, it's your turn to shut up! Have a look at the code and think before giving feedbacks... :D

elcuco
24th January 2006, 22:19
I should be able to post it tomorrow.

No solutions comes to me about current line colouring but I implemented the basis of a breakpoint management system.

Seems to progress!!! :D

Original message said:
You said tomorrow on the 22, now it's 24.

SHOW ME THE MONEY!
SHOW ME THE MONEY!
SHOW ME THE MONEY!

Now I do see the code...
comments tomrrow... /me shuts up now.

fullmetalcoder
25th January 2006, 08:34
Original message said:
You said tomorrow on the 22, now it's 24.

SHOW ME THE MONEY!
SHOW ME THE MONEY!
SHOW ME THE MONEY!

Now I do see the code...
comments tomrrow... /me shuts up now.

Who's the best ??? :cool:
Just kidding!

Ok implementation is not that perfect!
a corrected version is coming soon!:)

elcuco
25th January 2006, 22:37
meanwhile you is the king... me sux0rz...

don't worry, this will change over time... you just wait...

fullmetalcoder
26th January 2006, 16:23
here is the new version.

- few bugs fixes
- line number calculation working fine
- lines highlighting done inside devhighlighter

have fun!

edit : removed attached .zip; copyright notice wasn't correct:o !

elcuco
27th January 2006, 20:36
the last version you supplied does not compile here:



elcuco@opensuse:~/src/deveditor> qmake
WARNING: Failure to find: parenmatcher.cpp


Easy to fix:


elcuco@opensuse:~/src/deveditor> qmake -project -o edit.pro


Compiles ok, but does not run:


elcuco@opensuse:~/src/deveditor> time make
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. -o DevEditor.o DevEditor.cpp
DevEditor.cpp:287: warning: unused parameter ‘expr’
DevEditor.cpp:287: warning: unused parameter ‘cs’
DevEditor.cpp:287: warning: unused parameter ‘wo’
DevEditor.cpp:287: warning: unused parameter ‘forward’
DevEditor.cpp:287: warning: unused parameter ‘startAtCursor’
DevEditor.cpp:293: warning: unused parameter ‘find’
DevEditor.cpp:293: warning: unused parameter ‘replace’
DevEditor.cpp:293: warning: unused parameter ‘cs’
DevEditor.cpp:293: warning: unused parameter ‘wo’
DevEditor.cpp:293: warning: unused parameter ‘forward’
DevEditor.cpp:293: warning: unused parameter ‘startAtCursor’
DevEditor.cpp:293: warning: unused parameter ‘replaceAll’
DevEditor.cpp:302: warning: unused parameter ‘txt’
DevEditor.cpp:302: warning: unused parameter ‘first’
DevEditor.cpp: In member function ‘virtual void DevEdit::mouseMoveEvent(QMouseEvent*)’:
DevEditor.cpp:324: warning: unused variable ‘w’
DevEditor.cpp: At global scope:
DevEditor.cpp:470: warning: unused parameter ‘e’
DevEditor.cpp:746: warning: unused parameter ‘txt’
DevEditor.cpp:746: warning: unused parameter ‘first’
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. -o DevHighlighter.o DevHighlighter.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. -o DevStatus.o DevStatus.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. -o main.o main.cpp
/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. DevEditor.h -o moc_DevEditor.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. -o moc_DevEditor.o moc_DevEditor.cpp
/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. DevHighlighter.h -o moc_DevHighlighter.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. -o moc_DevHighlighter.o moc_DevHighlighter.cpp
/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. DevStatus.h -o moc_DevStatus.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. -o moc_DevStatus.o moc_DevStatus.cpp
/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/bin/rcc -name DevEditor DevEditor.qrc -o qrc_DevEditor.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtCore -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include/QtGui -I/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/include -I. -I. -I. -o qrc_DevEditor.o qrc_DevEditor.cpp
g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/lib -o edit DevEditor.o DevHighlighter.o DevStatus.o main.o moc_DevEditor.o moc_DevHighlighter.o moc_DevStatus.o qrc_DevEditor.o -L/usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/lib -lQtGui_debug -L/usr/X11R6/lib -L/home/elcuco/src/qt4-rsync/lib -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lm -lQtCore_debug -lz -ldl -lpthread

real 0m17.224s
user 0m15.705s
sys 0m1.472s
elcuco@opensuse:~/src/deveditor> ./edit
ASSERT failure in DevHighlighter::reformatBlock(): "reFormatBlock() called recursively", file DevHighlighter.cpp, line 162
Aborted


Removing that assert fixes the compilation and the application runs. Much better then previous version.

My impressions:
1) wow, that works!
2) wow... it really works!
3) damm... it's slow.

I am running this application on a AMD XP2500 and when I move thr text cursor, I see big spikes of CPU usage. The loading time, is HUGE, since the SH works way to hard on that. Using QRegExp on every line make the code to be colored on a O(N^2) complexity, which is definatly bad for GUI.

The implementation of "current line" and "breakpoint" are just bad. Marking only part of the line is very wrong, as you pointed already. Nice try, but drop it. IMHO that engine will run faster when you drop it. We must find a solution to this.

The lines numbering is pretty good, I did not find any problems with it, but even with the older code it worked for me, so I shut up...

any way... enjoy (screen shot taken on OpenSuSE 10.0), Qt4.1.0 gcc 4.0.2, xorg 6.8.2:

http://img209.imageshack.us/img209/9296/devedit5mc.th.jpg (http://img209.imageshack.us/my.php?image=devedit5mc.jpg)

fullmetalcoder
27th January 2006, 22:12
new version on rails:
- no RegExps anymore (shave off loading time!!!)
- possibility to skip line highlighting (current, breakpoint and errors)
- reworked base class of syntax highlighter for convinience
- built in find & replace

coming soon!!!

elcuco
28th January 2006, 00:33
- built in find & replace


are you stealing ideas from me... ? or just implementations.... :D :p

If you are ditching the QRexExp idea, please look at kate HL definitions. Those syntax are the best ones, they can define anything, since they not define languages but state machines.

fullmetalcoder
28th January 2006, 21:35
are you stealing ideas from me... ? or just implementations.... :D

If you are ditching the QRexExp idea, please look at kate HL definitions. Those syntax are the best ones, they can define anything, since they not define languages but state machines.

did you notice that prototype of find & replace were already present in the earlier versions? :rolleyes:

my syntax highlighting is working fine but I may have a look at your kate stuff give me somewhere to look for them... :p

edit : posted the last version

nb : it' still a beta but works pretty fine except replace function that is in early developpement state :o

fullmetalcoder
30th January 2006, 10:17
Sorry everyone but I removed all attached files because the copyright notice wasn't correct. :o
New version is coming soon with right copyright notice, fixed find & replace and improved syntax highlighting ( those who tried the old versions probably noticed that it didn't handle floats)

rianquinn
30th January 2006, 17:30
I use "kwrite" or "kate"

Missing too much to be a good editor. Not cross-platform. Needs lots of work.

rianquinn
30th January 2006, 17:34
QTextEdit was not really designed to be an editor. The best thing to do to make a good editor is make one from scratch using parts of Qt's code as a baseline That's what I am doing currently

Xagen
31st January 2006, 07:34
I should be able to post it tomorrow.

No solutions comes to me about current line colouring but I implemented the basis of a breakpoint management system.

Seems to progress!!! :D

Hi! And where is the code?
All of us want to have a look at it...
Thanks.

fullmetalcoder
31st January 2006, 15:09
Hi! And where is the code?
All of us want to have a look at it...
Thanks.

There was a twist in the copyright notice so I removed all zip files yesterday.

I used this time to :
- fix highlighting (handles floats and comments after a preprocessor)
- fix find & replace
- add a built-in loading/saving API
- add a print function
- add both of these to context menu

But current line highlighting (and breakpoints/errors as well) is still ugly!!!
No way making it kepp coloring after last character!!!!:confused: :(

Have fun and please give feedback (and hints about background coloring) !!!

elcuco
31st January 2006, 22:56
In your pro file, there is a line:


TARGET += neweditor


change it to


TARGET = neweditor


(remove the +). Otherwise it does not compile on my system. The loading is still wayy.... slow... I compared it to my code (which you trashed...) and not that fast ... my code can load much more files (and highlight them properly....), I know for sure it can load C/C++/CSS/XML/Makefile... I need to investigate why it fails on bash/sh... (to the forum, I plan on release it soon, don't worry).

The issue with the one context menu is interesting... but now with 10 commands, it's hard to find the correct item. You should start using submenus or do a window menu, like people expect.

Besides this, this is great... nice work!

fullmetalcoder
1st February 2006, 09:18
The loading is still wayy.... slow... I compared it to my code (which you trashed...) and not that fast ... my code can load much more files (and highlight them properly....), I know for sure it can load C/C++/CSS/XML/Makefile... I need to investigate why it fails on bash/sh... (to the forum, I plan on release it soon, don't worry).


Don't say my editor is slow compared to mine:
yours take more than 50 seconds to load the qrc_new-editor.cpp file produced by your project (104kb) while mine manage to load it (and highlight it as well) in less than 4 seconds !!!! Impressive isn't it? :p
Anyway, apart from that SLOOOOOOOOOOOW loading, your version isn't that bad (and I don't worry about release dates : I'm quite patient).

[quote=elcuco]
The issue with the one context menu is interesting... but now with 10 commands, it's hard to find the correct item. You should start using submenus or do a window menu, like people expect.
[quote]

It's only a core editor! The IDE is already on rails and it, of course:rolleyes: , includes a window menu. Did you try Dev-C++, there's not 10 items but about 20!!

elcuco
1st February 2006, 21:43
... so it's possible to use Dev-C++ to code Qt under windows...? I guess that would be another thread...

fullmetalcoder
2nd February 2006, 16:27
... so it's possible to use Dev-C++ to code Qt under windows...? I guess that would be another thread...

Not what I said! True anyway (I'm doing it:D ) but need ugly (to my mind) work around!
Not the topic of that thread anyway!

elcuco
4th February 2006, 18:26
me too! me too!

It's not like I want to fall behind... so here is my code.

This is not an syntax highliter only for C/C++, but an engine for lading language descriptions, and coloring files. The code just seems big, but there is a readme file which explains how to use it.

The code here can load these syntaxes:
- javascript
- php
- xml
- xsl
- css
- Makefile
- Perl
- TCL

The reason why not all languages are supported yet, is because the mime type matching is not perfect. This will be fixed soon. With luck, some other languages are already defined and working, I just could not test them...

Townk
4th February 2006, 19:50
Hi elcuco, I came here just to see your code.
I download-it, and make a test (I sugest you to do the same):
Run 'new-editor';
Than open a big CPP file, in my case "$QTDIR/src/gui/widgets/qtextedit.cpp";

Whats happen is that 'new-editor' loads the file very quick but it doesn't do the highlight and freezes the entire application.

I think you'll like to know :p

Townk
4th February 2006, 19:54
just to correct my previous post, the application does not freezes, it just take a HUGE time to be available.
By the way, I just LOVE your Firefox search like, excelent work!

elcuco
4th February 2006, 23:59
ok, did that. thanks I learned a lot.

The published code works this way:
The text first loaded by issuing a QTimer::singleShot(). This is done because I don't want that code to block my main application.

After the text has been loaded, I issue another QTimer::singleShot() to color the text. What I did not enticipate, is that the coloring would be done (by QSyntaxHighligther) in a blocking and non incremental way. I expected that lines would be colored one by one, and even slowly, the UI would be usable. Now, as you seen the coloring is done "all at once" and blocks the UI. IMHO this should be filed as a bug report to the trolls.

I also played with the loading/coloring code, and experimened with several loading/coloring methods. The code fixes are really trivial, but they learn a lot.

Loading that file on my PC with the original code: 2:02 (the published code).
Loading that file, by first setting the HL and then loading the file line by line: 4:02
Loading that file, by first setting the HL and then loading the file all at once: ~3:10

So, even tough the highliter is extramly slow, it seems I choosed the "best" way of doying it. I know how to refactor the code, and it will be done soon. Probably by net week, I will have a code which is slow, but usable.

BTW,
is it ok to keep attaching tgz's here? or do I need to upload it to an external site...?

edit:
Tried to do the same using a QThread. No luck, eigther I cannot assign parent objects from another thread, or cannot generate timers from another thread (QTextEdit or QSyntaxHighlighter do that, not sure).

Next, I will see if using the QSyntaxHighlighter from QSA improoves the speed.

fullmetalcoder
6th February 2006, 10:12
Gonna try your version elcuco.

Not even a pre-alpha of the IDE to post! :o Sorry but I work hard during the week-end to refactor trolls' code :
I subclassed QFrame and added QAbstractScrollArea's and the QTextEdit's features. After a while I got it compiling and displaying text but I got some troublesome isues:
- disabling word wrap seems to cancel drawing of the QTextDocument :confused: I didn't have enough time to understand why but I think I can make it work soon
- scrollbars drive me mad! :mad: Each time I attempt to scroll, it cause great troubles in drawing, both inside CoreEdit (the name of my widget) and outside (DevLineNumber for those who tried my last posted code) !!!

But good things have been gained :
- that version highlight current line fastly and flawlessly
- I got total control on shortcuts !!!
- multiline edit will be much easier to implement
- and so on...

If anybody is interested in helping me (that scrollbar bug is so weird and annoying!) I can post the current source

edit : actually I've got something to post and word wrap trouble was fixed
Have fun with my code!

elcuco
6th February 2006, 19:40
elcuco@linux:~/src/qt4-editors/core-edit> make
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.1-snapshot-20060203/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.1-snapshot-20060203/include/QtCore -I/usr/local/Trolltech/Qt-4.1.1-snapshot-20060203/include/QtGui -I/usr/local/Trolltech/Qt-4.1.1-snapshot-20060203/include -I. -I. -I. -o coreedit.o coreedit.cpp
In file included from coreedit.cpp:28:
coreedit.h:33:43: error: private/qtextdocumentlayout_p.h: No such file or directory
coreedit.cpp: In constructor ‘CoreEdit::CoreEdit(const QString&, QWidget*)’:
coreedit.cpp:126: error: ‘QTextDocumentLayout’ was not declared in this scope
coreedit.cpp:126: error: ‘l’ was not declared in this scope
coreedit.cpp:127: error: ‘QTextDocumentLayout’ cannot appear in a constant-expression
coreedit.cpp:127: error: parse error in template argument list
coreedit.cpp:127: error: no matching function for call to ‘qobject_cast(QAbstractTextDocumentLayout*)à ¢â‚¬â„¢
coreedit.cpp: At global scope:


Please, If you want to rewrite a new text editor widget, do this. But don't mess something working. For example, copy this text to your editor and into notepad. Move the cursor arround and understand what are you breaking if you mess too much:

אני אוכל זכוכית וזה לא כואב לי

(google for BIDI).

Iam
7th February 2006, 10:25
[QUOTE=fullmetalcoder :: Have fun with my code![/QUOTE]
it's not easy
i can't get it (i mean file):confused:

sorry i get -- just don't use Opera

fullmetalcoder
7th February 2006, 15:13
elcuco@linux:~/src/qt4-editors/core-edit> make
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.1.1-snapshot-20060203/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.1.1-snapshot-20060203/include/QtCore -I/usr/local/Trolltech/Qt-4.1.1-snapshot-20060203/include/QtGui -I/usr/local/Trolltech/Qt-4.1.1-snapshot-20060203/include -I. -I. -I. -o coreedit.o coreedit.cpp
In file included from coreedit.cpp:28:
coreedit.h:33:43: error: private/qtextdocumentlayout_p.h: No such file or directory
coreedit.cpp: In constructor ‘CoreEdit::CoreEdit(const QString&, QWidget*)’:
coreedit.cpp:126: error: ‘QTextDocumentLayout’ was not declared in this scope
coreedit.cpp:126: error: ‘l’ was not declared in this scope
coreedit.cpp:127: error: ‘QTextDocumentLayout’ cannot appear in a constant-expression
coreedit.cpp:127: error: parse error in template argument list
coreedit.cpp:127: error: no matching function for call to ‘qobject_cast(QAbstractTextDocumentLayout*)à ¢â‚¬â„¢
coreedit.cpp: At global scope:


Please, If you want to rewrite a new text editor widget, do this. But don't mess something working. For example, copy this text to your editor and into notepad. Move the cursor arround and understand what are you breaking if you mess too much:

אני אוכל זכוכית וזה לא כואב לי

(google for BIDI).

Looks like a big include problem! :confused:

I don't plan to mess up something working! I just wanted to refactor Trolls' code to get rid of the Qx / QxPrivate architecture that is awful IMO; to gain a full control on events; to shrink it and make it faster by removing all list formatting stuffs and a few other useless rich text features!

That weird scrollbar bug may stop the development of CoreEdit and make me turn back to the QTextEdit derived one but, well ... I tried!!!

gesslar
5th April 2006, 02:01
Ok, I got it to stop mucking up the numbers displaying in DevLineNumber by adding


p.eraseRect(0, 0, width(), height());

after


QPainter p(this);

in

void DevLineNumber::paintEvent(QPaintEvent *e)

I tried to chase down the bug that caused the QMainWindow to go black (very weird) when resizing, but I failed. I'm not very good at paint code :(. I also tried to figure out the line highlighting problem with using the mousewheel, scrollbar, etc, but I failed. I'm not good at math!

But I was very impressed

fullmetalcoder
5th April 2006, 12:10
Thank you for your interest but this version is moreless abandonned : the DevQt team is working on a more powerfull editor (folding, multiline editing, persistent selection...) and we started using new patterns and definitely chose to use QTextEdit as a base to avoid all those bugs...

The current version of the editor is already working nice but not finished yet so if you wish to get involved in coding such a widget join us (try Berlios developper forum or IRC to tell us your choice)