Selected Lines

Discussion Forums discussion Selected Lines

This topic contains 0 voices and has 5 replies.

Viewing 6 posts - 1 through 6 (of 6 total)
Author Posts
Author Posts
May 17, 2012 at 1:58 am #8554

john.byrne
Member

What functions are there to get the line numbers of the current selection?

May 17, 2012 at 2:38 pm #18978

NickDMax
Member

I am going to assume that you are talking about PYPN:

The selection is always between the Anchor and the CurrentPos. You can use the function sci.LineFromPosition to get the line number of a particular position.

Example:

sci = scintilla.Scintilla(pn.CurrentDoc());
if ( sci.Anchor <= sci.CurrentPos):
line1 = sci.LineFromPosition(sci.Anchor);
line2 = sci.LineFromPosition(sci.CurrentPos);
else:
line2 = sci.LineFromPosition(sci.Anchor);
line1 = sci.LineFromPosition(sci.CurrentPos);
pn.AddOutput("beg: " + str(line1+1) + "n")
pn.AddOutput("end: " + str(line2+1) + "n")

June 28, 2012 at 7:15 pm #18983

NickDMax
Member

This would be a great thing to add to the status bar with the other selection information. Any hints on where to look to add this Simon? I have a week of vacation so maybe I can get in a patch.

June 29, 2012 at 10:40 am #18984

simon
Key Master

CTextView::SetPosStatus

http://code.google.com/searchframe#RFQeWrsIjxs/pnwtl/textview.cpp&q=TextView%20package:pnotepad%5C.googlecode%5C.com&l=554

Thanks!

July 1, 2012 at 4:08 pm #18985

NickDMax
Member

Thanks, I think I can add that in. Something like:

“%d Characters over %d Line(s) Selected”

maybe also update the rectangular selection to give an [%d : %d] Col(s) x Row(s).

July 2, 2012 at 9:48 am #18986

simon
Key Master

Yes, in fact I was thinking the status bar might be better saying Line: %d Column: %d, although that does place additional burden on translators. The current text is cryptic.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.