Posted by: Professor Bernd | Date: 2020-04-16 03:25 | IP: IP Logged
How can I get the correct CaretX pos in VBScript if there are tabs in the text of a line?
Posted by: pspad | Date: 2020-04-16 05:53 | IP: IP Logged
What for is it needed? If you set caretX, you are on this position, right?
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.
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.
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.
Posted by: Professor Bernd | Date: 2020-04-16 16:36 | IP: IP Logged
You already have the function. 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.
Posted by: pspad | Date: 2020-04-16 16:40 | IP: IP Logged
I know, but I need to publish it into scripting.
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.
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?
Converts text with tabs to text with spaces.
Example "sLine = obj.TabsToSpaces(obj.lineText)"
That would be great!
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
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?
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?