Page 1 of 1

"Selected Word" Doesn't Include Module Name

Posted: Tue Mar 07, 2017 6:34 pm
by c4s
How can I get the IDE's full "word currently under the cursor" for procedures/constants/variables of modules?

Unfortunately in this case the environment variable PB_TOOL_Word or the %WORD argument is unusable... Because when hovering e.g. over MyProc() of MyModule::MyProc() it should return MyModule::MyProc instead of just MyProc, right? Do you have any suggestion how I can get the currently selected fully qualified name in a cross-platform way?

Re: "Selected Word" Doesn't Include Module Name

Posted: Thu Mar 09, 2017 10:37 pm
by c4s
Don't you agree that it's unusable like this for modules? I'd say this is even a bug. I clarifying reply from a team member would be highly appreciated...

Re: "Selected Word" Doesn't Include Module Name

Posted: Thu Mar 09, 2017 11:39 pm
by freak
Well, it returns the word at the cursor as the description says. It doesn't perform any deeper analysis of what that word means or the context in which it appears. Its not a bug.

If you need context information you will have to parse that yourself.

Re: "Selected Word" Doesn't Include Module Name

Posted: Fri Mar 10, 2017 4:13 pm
by c4s
Thanks for your reply, freak.
freak wrote:Well, it returns the word at the cursor as the description says. It doesn't perform any deeper analysis of what that word means or the context in which it appears. Its not a bug.
I know what you mean but define "word" in the context of a programming language IDE. It would simply make more sense in that case and since you're in control I thought you'd agree.
freak wrote:If you need context information you will have to parse that yourself.
Too bad. How?

Re: "Selected Word" Doesn't Include Module Name

Posted: Fri Mar 10, 2017 6:44 pm
by freak
PB_TOOL_Cursor gives you the location of the cursor in the source code. From there you can determine the context.

Re: "Selected Word" Doesn't Include Module Name

Posted: Fri Mar 10, 2017 11:07 pm
by Zebuddi123
Hi c4s Get`s all the selection

Zebuddi. :)

Code: Select all

Procedure.s sScintillaGetSelection()
	Protected  iScintilla.i  = Val( GetEnvironmentVariable("PB_TOOL_Scintilla")), iStart.i, iEnd.i,  iIndex.i,  sString.s, iResult.i
	If iScintilla
		SendMessageTimeout_(iScintilla, #SCI_GETSELECTIONSTART , 0, 0, #SMTO_ABORTIFHUNG, #SCI_START, @iStart)
		SendMessageTimeout_(iScintilla, #SCI_GETSELECTIONNEND  , 0, 0, #SMTO_ABORTIFHUNG, #SCI_START, @iEnd)
		For iIndex = iStart To iEnd-1
			SendMessageTimeout_(iScintilla, #SCI_GETCHARAT, iIndex , 0, #SMTO_ABORTIFHUNG, #SCI_START, @iResult)
			sString + Chr(iResult)
		Next
		ProcedureReturn sString
	EndIf
EndProcedure

OpenConsole()
Print(sScintillaGetSelection())
Input()
CloseConsole()

Re: "Selected Word" Doesn't Include Module Name

Posted: Fri Mar 10, 2017 11:50 pm
by Tenaja
c4s wrote:...define "word" in the context of a programming language IDE.
I have never read it as being described as anything but an individual collection of allowable characters terminated on both ends by allowable termination characters. In PB's case, those termination characters would be spaces, but may also include symbols. So, it sounds like you just don't like the commonly accepted definition...

Re: "Selected Word" Doesn't Include Module Name

Posted: Sat Mar 11, 2017 12:32 am
by skywalk
c4s wrote:
freak wrote:If you need context information you will have to parse that yourself.
Too bad. How?
Search for Tool code that returns the entire line your cursor is on. Then use StringField(Line$, indx, "::") in a loop to build what you want. I don't think line continuation allows breaks within 'module names::procedures', so 1 line should suffice.

Re: "Selected Word" Doesn't Include Module Name

Posted: Sat Mar 11, 2017 11:44 am
by #NULL
the code of a tool by danilo might be also helpful:
http://www.purebasic.fr/english/viewtop ... 60#p381060

Re: "Selected Word" Doesn't Include Module Name

Posted: Sat Mar 11, 2017 11:01 pm
by c4s
Zebuddi123 wrote:Hi c4s Get`s all the selection [...]
Thanks for the code, Zebuddi123! Too bad that there doesn't seem to be an easy (built-in) cross-platform way, or is it?
Tenaja wrote:I have never read it as being described as anything but an individual collection of allowable characters terminated on both ends by allowable termination characters. In PB's case, those termination characters would be spaces.
So? It seems that you actually agree with me! ;) (Emphasis by me.)

Re: "Selected Word" Doesn't Include Module Name

Posted: Sun Mar 12, 2017 12:02 pm
by #NULL
it's not as simple as you might think.

Code: Select all

m::var(0)\arr[0]\s
           ^
           cursor here, what would you like to get in that case?
arr[0] ?
arr[0]\s ?
m::var(0)\arr ?
m::var(0)\arr[0]\s ?
'arr' is simply the correct word at cursor position.
..and just think about UseModule / With,EndWith etc.

Re: "Selected Word" Doesn't Include Module Name

Posted: Sun Mar 12, 2017 6:08 pm
by c4s
#NULL wrote:it's not as simple as you might think.

Code: Select all

m::var(0)\arr[0]\s
           ^
           cursor here, what would you like to get in that case?
arr[0] ?
arr[0]\s ?
m::var(0)\arr ?
m::var(0)\arr[0]\s ?
'arr' is simply the correct word at cursor position.
..and just think about UseModule / With,EndWith etc.
For me it's obvious: The whole thing of course ("m::var(0)\arr[0]\s")! That way I'm able to get the part that I want/need, else I don't even have the option...