Results 1 to 12 of 12

Thread: Implementation of right indentation in a text editor

  1. #1
    Join Date
    Sep 2006
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Question Implementation of right indentation in a text editor

    Hi,

    I am trying to implement indent left feature in a text editor. ( I am using Qt 3.3.2 ).
    I have implemented it, but it is dead slow.
    I tried implementing this feature in 3 ways.

    1.
    With the help of getSelection I get the paraFrom and paraTo.
    I take one line ( para ) at a time. Process it. I.e, removing required blank spaces.
    And then, remove that para ( the old one with blank spaces ) and insert a new one with insertPara .

    Efficiency : very very poor

    2. I used cursor and keyboard actions using moveCursor and doKeyboardActions function.
    And tried to removing blank spaces directly hence avoiding insertPara and removePara functions

    Efficiency : very poor

    3. I get the selected text, process it, set it back using insert command ( instead of doing line by line).
    Efficiency : poor

    Now, i wonder how can i make it efficient!
    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementation of right indentation in a text editor

    How about just adding <p align="right"> and </p> around selected paragraph?

  3. #3
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementation of right indentation in a text editor

    Is it slow even after turning off the SyntaxHighlighting ??
    We can't solve problems by using the same kind of thinking we used when we created them

  4. #4
    Join Date
    Sep 2006
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Implementation of right indentation in a text editor

    Hi,
    Acutally i am trying to implement indent left.
    Without Syntax highlighter also , it is dead slow.
    It is not because of syntax highlighter, it is becasue of string manipulations.
    plus setting the text back to the text editor once the text is manipulated.
    As i told before i tried using keyboard actions and move cursor in order to skip setting back the text to the editor. It is even slower.

  5. #5
    Join Date
    Sep 2006
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Implementation of right indentation in a text editor

    Hi,
    Thanks for the reply. I guess u mean to say to use SetAlignment function?
    I feel Alignment is different from indenting. I can not use left align to indent left to the desired spaces ( set in tab ).

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementation of right indentation in a text editor

    Quote Originally Posted by sukanyarn View Post
    Acutally i am trying to implement indent left.
    Then try something like <p style="margin-left:10px">.

  7. #7
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementation of right indentation in a text editor

    Quote Originally Posted by jacek View Post
    Then try something like <p style="margin-left:10px">.
    Can it be used in the plain Text mode ?

    sukanyarn is working on a text editor
    We can't solve problems by using the same kind of thinking we used when we created them

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementation of right indentation in a text editor

    Quote Originally Posted by sunil.thaha View Post
    sukanyarn is working on a text editor
    But he didn't say that it's a plain text editor.
    Last edited by jacek; 25th September 2006 at 17:35. Reason: typo

  9. #9
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementation of right indentation in a text editor

    Ok, But I knew that ;-)
    We can't solve problems by using the same kind of thinking we used when we created them

  10. #10
    Join Date
    Sep 2006
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Implementation of right indentation in a text editor

    Im sorry for the confusion. I want to implement left indentation for a Text Editor.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Implementation of right indentation in a text editor

    I would suggest running your code with profiling enabled to see what exactly causes the slowdowns.

  12. #12
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implementation of right indentation in a text editor

    I would also suggest to go through the implementation in other editors
    We can't solve problems by using the same kind of thinking we used when we created them

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. visible text of textedit
    By regix in forum Qt Programming
    Replies: 3
    Last Post: 26th June 2006, 09:02
  3. a Text Editor with line numbers...
    By fullmetalcoder in forum Qt Programming
    Replies: 47
    Last Post: 5th April 2006, 11:10

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.