Results 1 to 20 of 48

Thread: a Text Editor with line numbers...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a Text Editor with line numbers...

    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 !
    Last edited by fullmetalcoder; 30th January 2006 at 09:19.
    Current Qt projects : QCodeEdit, RotiDeCode

  2. #2
    Join Date
    Jan 2006
    Posts
    371
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a Text Editor with line numbers...

    the last version you supplied does not compile here:

    Qt Code:
    1. elcuco@opensuse:~/src/deveditor> qmake
    2. WARNING: Failure to find: parenmatcher.cpp
    To copy to clipboard, switch view to plain text mode 

    Easy to fix:
    Qt Code:
    1. elcuco@opensuse:~/src/deveditor> qmake -project -o edit.pro
    To copy to clipboard, switch view to plain text mode 

    Compiles ok, but does not run:
    Qt Code:
    1. elcuco@opensuse:~/src/deveditor> time make
    2. 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
    3. DevEditor.cpp:287: warning: unused parameter ‘expr’
    4. DevEditor.cpp:287: warning: unused parameter ‘cs’
    5. DevEditor.cpp:287: warning: unused parameter ‘wo’
    6. DevEditor.cpp:287: warning: unused parameter ‘forward’
    7. DevEditor.cpp:287: warning: unused parameter ‘startAtCursor’
    8. DevEditor.cpp:293: warning: unused parameter ‘find’
    9. DevEditor.cpp:293: warning: unused parameter ‘replace’
    10. DevEditor.cpp:293: warning: unused parameter ‘cs’
    11. DevEditor.cpp:293: warning: unused parameter ‘wo’
    12. DevEditor.cpp:293: warning: unused parameter ‘forward’
    13. DevEditor.cpp:293: warning: unused parameter ‘startAtCursor’
    14. DevEditor.cpp:293: warning: unused parameter ‘replaceAll’
    15. DevEditor.cpp:302: warning: unused parameter ‘txt’
    16. DevEditor.cpp:302: warning: unused parameter ‘first’
    17. DevEditor.cpp: In member function ‘virtual void DevEdit::mouseMoveEvent(QMouseEvent*)’:
    18. DevEditor.cpp:324: warning: unused variable ‘w’
    19. DevEditor.cpp: At global scope:
    20. DevEditor.cpp:470: warning: unused parameter ‘e’
    21. DevEditor.cpp:746: warning: unused parameter ‘txt’
    22. DevEditor.cpp:746: warning: unused parameter ‘first’
    23. 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
    24. 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
    25. 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
    26. /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
    27. 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
    28. /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
    29. 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
    30. /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
    31. 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
    32. /usr/local/Trolltech/Qt-4.1.0-snapshot-20051125/bin/rcc -name DevEditor DevEditor.qrc -o qrc_DevEditor.cpp
    33. 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
    34. 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
    35.  
    36. real 0m17.224s
    37. user 0m15.705s
    38. sys 0m1.472s
    39. elcuco@opensuse:~/src/deveditor> ./edit
    40. ASSERT failure in DevHighlighter::reformatBlock(): "reFormatBlock() called recursively", file DevHighlighter.cpp, line 162
    41. Aborted
    To copy to clipboard, switch view to plain text mode 

    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:


  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a Text Editor with line numbers...

    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!!!
    Current Qt projects : QCodeEdit, RotiDeCode

  4. #4
    Join Date
    Jan 2006
    Posts
    371
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a Text Editor with line numbers...

    Quote Originally Posted by fullmetalcoder
    - built in find & replace
    are you stealing ideas from me... ? or just implementations....

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a Text Editor with line numbers...

    Quote Originally Posted by elcuco
    are you stealing ideas from me... ? or just implementations....

    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?

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

    edit : posted the last version

    nb : it' still a beta but works pretty fine except replace function that is in early developpement state
    Last edited by fullmetalcoder; 30th January 2006 at 09:18.
    Current Qt projects : QCodeEdit, RotiDeCode

  6. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a Text Editor with line numbers...

    Sorry everyone but I removed all attached files because the copyright notice wasn't correct.
    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)
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 13:51
  3. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.