Page 3 of 3 FirstFirst 123
Results 41 to 48 of 48

Thread: a Text Editor with line numbers...

  1. #41
    Join Date
    Jan 2006
    Location
    Curitiba - Brazil
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    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!
    --
    Thiago dos Santos Alves
    Computer Scientist

    thiago.salves@gmail.com
    -----------------------------------------------------
    "A mind that opens to a new idea never gets its original size again."
    - Albert Einstein

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

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

    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.
    Last edited by elcuco; 5th February 2006 at 18:26.

  3. #43
    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...

    Gonna try your version elcuco.

    Not even a pre-alpha of the IDE to post! 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 I didn't have enough time to understand why but I think I can make it work soon
    - scrollbars drive me 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!
    Attached Files Attached Files
    Last edited by fullmetalcoder; 6th February 2006 at 15:16.
    Current Qt projects : QCodeEdit, RotiDeCode

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

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

    Qt Code:
    1. elcuco@linux:~/src/qt4-editors/core-edit> 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.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
    3. In file included from coreedit.cpp:28:
    4. coreedit.h:33:43: error: private/qtextdocumentlayout_p.h: No such file or directory
    5. coreedit.cpp: In constructor ‘CoreEdit::CoreEdit(const QString&, QWidget*)’:
    6. coreedit.cpp:126: error: ‘QTextDocumentLayout’ was not declared in this scope
    7. coreedit.cpp:126: error: ‘l’ was not declared in this scope
    8. coreedit.cpp:127: error: ‘QTextDocumentLayout’ cannot appear in a constant-expression
    9. coreedit.cpp:127: error: parse error in template argument list
    10. coreedit.cpp:127: error: no matching function for call to ‘qobject_cast(QAbstractTextDocumentLayout*)’
    11. coreedit.cpp: At global scope:
    To copy to clipboard, switch view to plain text mode 

    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).

  5. #45
    Join Date
    Feb 2006
    Posts
    2

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

    [QUOTE=fullmetalcoder :: Have fun with my code![/QUOTE]
    it's not easy
    i can't get it (i mean file)

    sorry i get -- just don't use Opera
    Last edited by Iam; 7th February 2006 at 10:43.

  6. #46
    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
    Qt Code:
    1. elcuco@linux:~/src/qt4-editors/core-edit> 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.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
    3. In file included from coreedit.cpp:28:
    4. coreedit.h:33:43: error: private/qtextdocumentlayout_p.h: No such file or directory
    5. coreedit.cpp: In constructor ‘CoreEdit::CoreEdit(const QString&, QWidget*)’:
    6. coreedit.cpp:126: error: ‘QTextDocumentLayout’ was not declared in this scope
    7. coreedit.cpp:126: error: ‘l’ was not declared in this scope
    8. coreedit.cpp:127: error: ‘QTextDocumentLayout’ cannot appear in a constant-expression
    9. coreedit.cpp:127: error: parse error in template argument list
    10. coreedit.cpp:127: error: no matching function for call to ‘qobject_cast(QAbstractTextDocumentLayout*)’
    11. coreedit.cpp: At global scope:
    To copy to clipboard, switch view to plain text mode 

    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!

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

  7. #47
    Join Date
    Jan 2006
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

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

    Ok, I got it to stop mucking up the numbers displaying in DevLineNumber by adding

    Qt Code:
    1. p.eraseRect(0, 0, width(), height());
    To copy to clipboard, switch view to plain text mode 

    after

    Qt Code:
    1. QPainter p(this);
    To copy to clipboard, switch view to plain text mode 

    in
    Qt Code:
    1. void DevLineNumber::paintEvent(QPaintEvent *e)
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by gesslar; 5th April 2006 at 02:06.

  8. #48
    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...

    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)
    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, 10:49
  2. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 14:51
  3. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 10:16
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 19: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.