PDA

View Full Version : Implementation of right indentation in a text editor



sukanyarn
23rd September 2006, 07:28
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.

jacek
23rd September 2006, 16:44
How about just adding <p align="right"> and </p> around selected paragraph?

sunil.thaha
25th September 2006, 06:47
Is it slow even after turning off the SyntaxHighlighting ??

sukanyarn
25th September 2006, 11:34
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.

sukanyarn
25th September 2006, 11:37
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 ).

jacek
25th September 2006, 13:13
Acutally i am trying to implement indent left.
Then try something like <p style="margin-left:10px">.

sunil.thaha
25th September 2006, 14:06
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

jacek
25th September 2006, 14:44
sukanyarn is working on a text editor
But he didn't say that it's a plain text editor.

sunil.thaha
25th September 2006, 15:31
Ok, But I knew that ;-)

sukanyarn
26th September 2006, 08:11
Im sorry for the confusion. I want to implement left indentation for a Text Editor.

wysota
26th September 2006, 10:00
I would suggest running your code with profiling enabled to see what exactly causes the slowdowns.

sunil.thaha
26th September 2006, 13:06
I would also suggest to go through the implementation in other editors ;)