"Selected Word" Doesn't Include Module Name

Working on new editor enhancements?
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

"Selected Word" Doesn't Include Module Name

Post 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?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

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

Post 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...
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

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

Post 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.
quidquid Latine dictum sit altum videtur
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

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

Post 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?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

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

Post by freak »

PB_TOOL_Cursor gives you the location of the cursor in the source code. From there you can determine the context.
quidquid Latine dictum sit altum videtur
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 794
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

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

Post 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()
Last edited by Zebuddi123 on Sun Mar 12, 2017 1:23 am, edited 2 times in total.
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
Tenaja
Addict
Addict
Posts: 1948
Joined: Tue Nov 09, 2010 10:15 pm

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

Post 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...
Last edited by Tenaja on Sun Mar 12, 2017 6:12 pm, edited 1 time in total.
User avatar
skywalk
Addict
Addict
Posts: 3960
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

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

Post 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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

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

Post by #NULL »

the code of a tool by danilo might be also helpful:
http://www.purebasic.fr/english/viewtop ... 60#p381060
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

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

Post 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.)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

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

Post 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.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

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

Post 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...
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Post Reply