You are here: PSPad forum > English discussion forum > VBScript get CaretX from line with tabs

VBScript get CaretX from line with tabs

Goto Page: 1 2 Next

#1 VBScript get CaretX from line with tabs

Posted by: Professor Bernd | Date: 2020-04-16 03:25 | IP: IP Logged

Hello.

How can I get the correct CaretX pos in VBScript if there are tabs in the text of a line?

image

Bernd.

Options: Reply | Quote | Up ^


#2 Re: VBScript get CaretX from line with tabs

Posted by: pspad | Date: 2020-04-16 05:53 | IP: IP Logged

Hello
What for is it needed? If you set caretX, you are on this position, right?

Options: Reply | Quote | Up ^


#3 Re: VBScript get CaretX from line with tabs

Posted by: Professor Bernd | Date: 2020-04-16 14:42 | IP: IP Logged

It is for external use with my CallTipViewer.

With VBScript I call the CallTip, pass it CaretX, and calculate the position of the first letter of the function name. Then I position the CallTip exactly under the function name.

image

This works fine as long as there are no tabs in the line. So I might need a "CaretTabX" to position the CallTip correctly when there are tabs in the line.

Bernd.

Options: Reply | Quote | Up ^


#4 Re: VBScript get CaretX from line with tabs

Posted by: pspad | Date: 2020-04-16 16:28 | IP: IP Logged

OK, understand. I need to add another function what will calculate cursor position from expanded tabs.

Options: Reply | Quote | Up ^


#5 Re: VBScript get CaretX from line with tabs

Posted by: Professor Bernd | Date: 2020-04-16 16:36 | IP: IP Logged

You already have the function. winking smiley It shows the position of the expanded tabs in the PSPad status bar (see screenshot in posting #1). It would only be necessary to provide the value in VBScript. smiling smiley

Bernd.

Options: Reply | Quote | Up ^


#6 Re: VBScript get CaretX from line with tabs

Posted by: pspad | Date: 2020-04-16 16:40 | IP: IP Logged

I know, but I need to publish it into scripting.

Options: Reply | Quote | Up ^


#7 Re: VBScript get CaretX from line with tabs

Posted by: Professor Bernd | Date: 2020-04-17 05:24 | IP: IP Logged

Hi Jan, I made a mistake. Can I please change the feature request?

My tests have shown that calculating the cursor position from extended tabs to position my CallTip does not work. sad smiley

What would work would be a function to convert the line with tabs to a line with spaces. Like the function "Convert Tabs to Spaces" in the menu "Edit" / "Special conversion". Even the tab width is read automatically, which is very useful.

I am very sorry that I was wrong. Would it be possible to provide a function in VBScript to convert a line of tabs to a line of spaces?

Like

"TabsToSpaces(string): string"
Converts text with tabs to text with spaces.

Example "sLine = obj.TabsToSpaces(obj.lineText)"

That would be great! smiling smiley

Bernd.

Options: Reply | Quote | Up ^


#8 Re: VBScript get CaretX from line with tabs

Posted by: pspad | Date: 2020-04-17 05:53 | IP: IP Logged

You can call the PSPad action aTabToSpaces from scripting
It will work on selected text or on the whole file

Options: Reply | Quote | Up ^


#9 Re: VBScript get CaretX from line with tabs

Posted by: Professor Bernd | Date: 2020-04-17 06:35 | IP: IP Logged

Unfortunately this is not possible, because the action aTabToSpaces calls the dialog, this would disable my CallTip. In addition, it would convert in the real text of the user, what the user might not want.

I need a function that works without dialog and does not change the user's text.

Is this possible?

Bernd.

Options: Reply | Quote | Up ^


#10 Re: VBScript get CaretX from line with tabs

Posted by: pspad | Date: 2020-04-17 06:59 | IP: IP Logged

Yes, I will do it. Do you want to add tabwidth as another parameter or should I take it from PSpad settings?

Options: Reply | Quote | Up ^


Goto Page: 1 2 Next





Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR