Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing line number along side of trichedit ???

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Is there a component which has the functionality of
TRichEdit and also has a bar on the side showing
line number? If you know where I can download such a
component, please tell! I dont feel like reinventing
the wheel ...

Thanx in advance,

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Guys,

I really need this but can't make it like that myself simply because i dont know how to make a component. I only made 1 before and i required allot of help for it.

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Bobbafet
Why don't you simply put a number at the start of each line either as you write it or with a loop, and then strip it off when you want to access the text?

Steve.



 
sggaunt,

I dont know how to do that! And it would look much
nicer if I just had a TRichEdit with a panel showing the
linenumber. If you don't know what mean look at the picture
on this url: something like that would be really nice !!! If you dont where i can get a component like that could you please explain the
procedure you suggested?

Thanx allot,

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
Hi BobbaFet
I think we may be out of sync on this one? But anyway.
The first proc adds the line numbers, assuming that there are some lines of text in the richedit(Red).
the second one takes them off again (in the richedit) but you can apply the same principle to the lines after you extract them into a string varable for example.

procedure TAMS.addClick(Sender: TObject);
var a: integer;
begin
for a := 0 to red.lines.count -1 do
red.Lines[a] := inttostr(a) + ' '+ red.lines[a];
end;

procedure TAMS.removeClick(Sender: TObject);
var a: integer;
begin
for a := 0 to red.lines.count do
red.Lines[a] := copy(red.lines[a], pos(' ', red.lines[a])+ 1, 100);
end;

You could stick a thin memo (or listbox) down the left hand side of the richedit and bung the linenumbers in that using the same principle (in fact it would be simpler to do this) and (assuming you use the same font) the numbers should line up with the text. You would have to make them scroll together of course. Try aligning them on a panel to simplify matters.

Steve
 
Hey thats a good idea Steve, i like the two memo's idea!
i could just make the left one gray and be done with it!
I'll let you know how it worked out !!!

Thanks allot,

BobbaFet
Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
hi steve,

Im still playing around with the code just to get it
right for me. But should you come across such a component
please tell me ok.

If anyelse knows about such a component as on the
DONT HESITATE TO TELL ME !!! ;-)

Cheers,

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
bobbafet I found one that shows the line numbers on the left side. The component is called GsMemo you can find a DL at Since im writing, I guess i'll ask a question too.

Does anyone know how to add moving to the last line of a memo with code? Might be a dumb question but i have not been able to find out. I do a ctrl-pagedown on the keyboard but would like to have it done after it finishes processing the info.....

thnx
 
what do you mean by "to add moving" ???

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
Xermian wants to programmatically move the cursor to the end of the memo.

Code:
Memo.SetFocus;
Memo.SelStart := Length(Memo.Lines.Text);
Memo.SelLength := 0;
 
yes thats right i want to move to the last line of the memo instead of being at the top line

 
Hi Xerman,

How did you get the numbers to show in the gutter
on the left side ??? I cant seem to make it happen :-(
Is it a slow component on loading from file ??? It seems
to flicker allot when i use GSMemo1.Lines.LoadFromFile(bla).

Thanx allot,

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
Sorry about not that last post, I had overlooked the the
property where you turn it on or off :) And the flickering seems to have disappeared !!!

So once again sorry about the last post,

BobbaFet Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
sorry for the delay i did not log in yesterday. Glad to hear you found property to change it.

Xerman
 
Hi all,

I am having trouble though with get GsMemo.FindText and GsMemo.ReplaceText :-( I cant figure those GsFindOptions out! I looked in the source and it said
TGsFindOptions = set of (foMatchCase, foEntireScope)

So i tried it like this:

GsMemo.FindText(FindDialog1.FindText,foEntireScope,false)
GsMemo.FindText(FindDialog1.FindText,TGsFindOptions(foEntireScope),false)

But that doesnt work either :-(

Can you please help me with this?
I dont know what I'm doing wrong!

BobbaFet
Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
Have not tried those options out, but i'll see if they work for me or how they work. I'll post back as soon as I check it out...

Xerman
 
Ok I checked it and this is how I got it to work.
GSMemo1.FindText(edit1.text,[],False);
GSMemo1.ReplaceText(edit1.text,edit2.text,[],False);

although they are in different areas you can not do one after the other for some reason you can not have them after each other. I have not found out what to use for FindOptions but the empty brackets let me compile the program and they do find and replace. I tried it with a 64 mb file modified the last line about 1500000 lines of about 60 chars in length each line. It found the last line in about 3 seconds or even less at some times.

Xerman
 
Hi Xerman,

I must be really lousy programmer or something, because
I did exactly what you said and it wont do ANYTHING at all
!!! I loaded a 10 kb java applet mine in it and couldnt find
anyhting at all not even the words that are common in that
applet. I have for example the word randomizer in 110th line and it cant find or replace it. Is it supposed to select the found words automatically or do I still have to write additional code (seeing how it differs from a normal TCustomMemo.FindText).

I am sorry but there is no documentation with the component
and I don't know anyone else who uses this component :-(

Can you please post the entire code for replacing and finding you used.

BobbaFet
I hope this helps,

BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
hmmm strange. Basically I made a test project with the following.

1. GSMemo named GSMemo1
2. Button To clear and Load a text file
GSMemo1.Clear;
GSMemo1.LoadFromFile('c:\11.txt');
3. 2 TEdits edit1 for find text
edit2 for replace text
4. 2 more buttons Find and Replace button.
Find button when clicked does the following
GSMemo1.FindText(edit1.text,[],False);
Replace button when clicked does the following
GSMemo1.ReplaceText(edit1.text,edit2.text,[],False);

thats all the code I put into it if you still have problems email me your code if you can and I i'll see if I can't see what might be causing the problem.

Xerman
mariom@rio.bravo.net
 
Hi Xerman,

I'll email you the entire app. It's not that big anyway.
But dont be scared of since I hardly ever name my components
usually just leave the name that is given by Delphi.
I am using Delphi 5 btw.

BobbaFet

BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

Heineken is like making love in a cano... it's f*cking close to water !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top