It is currently Wed Jan 27, 2021 4:04 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: "Selected Word" Doesn't Include Module Name
PostPosted: Tue Mar 07, 2017 6:34 pm 
Offline
Addict
Addict

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


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Thu Mar 09, 2017 10:37 pm 
Offline
Addict
Addict

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


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Thu Mar 09, 2017 11:39 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5818
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Fri Mar 10, 2017 4:13 pm 
Offline
Addict
Addict

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


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Fri Mar 10, 2017 6:44 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5818
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Fri Mar 10, 2017 11:07 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Feb 01, 2012 3:30 pm
Posts: 767
Location: Nottinghamshire UK
Hi c4s Get`s all the selection

Zebuddi. :)

Code:
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()

_________________
malleo, caput, bang. Ego, comprehendunt in tempore


Last edited by Zebuddi123 on Sun Mar 12, 2017 1:23 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Fri Mar 10, 2017 11:50 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 1719
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.

Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Sat Mar 11, 2017 12:32 am 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3382
Location: Boston, MA
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


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Sat Mar 11, 2017 11:44 am 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1288
Location: right here
the code of a tool by danilo might be also helpful:
http://www.purebasic.fr/english/viewtopic.php?p=381060#p381060


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Sat Mar 11, 2017 11:01 pm 
Offline
Addict
Addict

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


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Sun Mar 12, 2017 12:02 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1288
Location: right here
it's not as simple as you might think.
Code:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: "Selected Word" Doesn't Include Module Name
PostPosted: Sun Mar 12, 2017 6:08 pm 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1981
Location: Germany
#NULL wrote:
it's not as simple as you might think.
Code:
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!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye