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
    England
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

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

    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).
    Last edited by Corran; 13th January 2006 at 17:58.

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

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

    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?

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

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

    Quote Originally Posted by Corran
    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!!!

    Dear elcuco, your beast appeared to me!!!
    Looks nice but still needs a little work.
    Quote Originally Posted by elcuco
    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...
    Last edited by fullmetalcoder; 10th February 2006 at 15:41.
    Current Qt projects : QCodeEdit, RotiDeCode

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

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

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

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.