You are here: PSPad forum > English discussion forum > How can I get the current cursor X position?

How can I get the current cursor X position?

Goto Page: 1 2 Next

#1 How can I get the current cursor X position?

Posted by: tinyBigGAMES | Date: 2019-10-15 21:07 | IP: IP Logged

I see %line%, which gives me the current line, cool. But I also need the horizontal position as well. Possible? I would think there would be something like %column% or something.

--
Jarrod Davis
Owner/Lead Developer @ tinyBigGames
tinybiggames.com

Options: Reply | Quote | Up ^


#2 Re: How can I get the current cursor X position?

Posted by: tinyBigGAMES | Date: 2019-10-15 21:39 | IP: IP Logged

Hmm, I just realized I have everything I need to calc the horizontal position, so this has become a non-issue. However, I just ran into my next problem. Sigh.

So, what I'm trying to do is add context help, which will use the compiler services for this. I need to pass it the current source, the word the cursor is under, and the x and y position of the cursor.

The three items (code, word, and line) I can get the horizontal position. I'm taking advantage of the "Set File as Main for Compiler," however, it will ALWAYS return that file in %file%. I guess what I need is something like %current_file%, which is always the current file.

I got the context help working, but only if "Set File as Main for Compiler" is turned off. Is there a workaround, something I can change, code, or whatever to solve this?

It becomes a pain to uncheck this each time I'm trying to get context help.

--
Jarrod Davis
Owner/Lead Developer @ tinyBigGames
tinybiggames.com

Options: Reply | Quote | Up ^


#3 Re: How can I get the current cursor X position?

Posted by: pspad | Date: 2019-10-16 04:25 | IP: IP Logged

Hello
I guess you need it in scripting.
There are functions like caretX(), caretY(), setCaretPos(x, y), setBlockBegin(), setBlockEnd(), blockBeginX(), blockBeginY(), selStart(), selEnd()

You can combine it, cause current cursor (caret) position is automatically blocke begin and settings block end is current position + length of word...

Options: Reply | Quote | Up ^


#4 Re: How can I get the current cursor X position?

Posted by: tinyBigGAMES | Date: 2019-10-16 21:50 | IP: IP Logged

Hi, ok, thanks for the reply. I will look into that. Thanks again.

Context Help Video

I have context help working now actually. See the video above. It's working very well. The only issue is I can't have "Set File as Main for Compiler" active when using it because I need to send the %current_file% to the compiler to figure out the context string to submit to the help file.

Is it possible to get the current file regardless if "Set File as Main for Compiler" is set?

--
Jarrod Davis
Owner/Lead Developer @ tinyBigGames
tinybiggames.com

Options: Reply | Quote | Up ^


#5 Re: How can I get the current cursor X position?

Posted by: Professor Bernd | Date: 2019-10-24 20:37 | IP: IP Logged

@ tinyBigGAMES

Are you still interested in a solution, or have you already found one?

I am currently working on a similar task and maybe I can help you.

Greetings,
Bernd.

Options: Reply | Quote | Up ^


#6 Re: How can I get the current cursor X position?

Posted by: tinyBigGAMES | Date: 2019-10-25 05:43 | IP: IP Logged

Hi, thanks. I ended up making a light-weight IDE for my compiler project, clicky

But I am super curious as to how you got it working. Was there something in already or did you have to code it?

--
Jarrod Davis
Owner/Lead Developer @ tinyBigGames
tinybiggames.com

Options: Reply | Quote | Up ^


#7 Re: How can I get the current cursor X position?

Posted by: pspad | Date: 2019-10-25 07:23 | IP: IP Logged

I use lvkactivescript library (you need to find old free version) from Lasse Karlsen

There is many new scripting engines based on Pascal e.t.c. Maybe it would be better way than use this old one.

Options: Reply | Quote | Up ^


#8 Re: How can I get the current cursor X position?

Posted by: Professor Bernd | Date: 2019-10-25 13:08 | IP: IP Logged

pspad:
I guess you need it in scripting.

In my task I used a VBScript which I stored in the script folder "...\PSPad\Script\VBScript\".

In the script I can use

runPSPadAction("aLangHelp")

I specify a shortcut (F1, or Alt+F1) and a few settings to make it work. When you press the shortcut, the help for the active document is called.

Your light-weight IDE looks very interesting! Did you program it yourself, or can I download it somewhere? I would be very interested. Thanks.

Options: Reply | Quote | Up ^


#9 Re: How can I get the current cursor X position?

Posted by: tinyBigGAMES | Date: 2019-10-25 20:00 | IP: IP Logged

Ahh I see. Ok cool thanks to everyone that assisted with this.

The IDE I coded is for my GamePascal compiler project. You can find it here: github.com

--
Jarrod Davis
Owner/Lead Developer @ tinyBigGames
tinybiggames.com

Options: Reply | Quote | Up ^


#10 Re: How can I get the current cursor X position?

Posted by: Professor Bernd | Date: 2019-10-25 22:11 | IP: IP Logged

I'm impressed. Very good work!

Thanks for the link!

Bernd.

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