PS: doesn't look like c.frame.top.lineEdit.text() gives anything useful 
from within a command ;-(

On Tuesday, December 10, 2024 at 8:43:48 AM UTC jkn wrote:

> Thanks Thomas, I will take a look at this.
>
> My original motivation for this is that I have a small script which could 
> benefit from exhibiting 'variant behaviour'. I was thinking of either 
> invoking via the minibuffer: "mycommand parm", or via a set of custom menu 
> entries, each of which invoked the command with a different parameter. I 
> guess the latter is not going to work via parsing the minibuffer.
>
>     Regards
>     J^n
>
>
> On Monday, December 9, 2024 at 11:31:11 PM UTC [email protected] wrote:
>
>> I found it.  Here's how you can get the text of the minibuffer's line 
>> editor.  What I don't know is whether it will still  be there once your 
>> command starts executing.  You can try that for yourself.
>>
>> # type some text into the minibuffer before executing the following
>> le = c.frame.top.lineEdit
>> g.es(le.text())
>>
>> On Monday, December 9, 2024 at 6:02:21 PM UTC-5 Thomas Passin wrote:
>>
>>> If you use Find/Replace, it picks up the arguments from the minibuffer 
>>> the same way.  There's nothing to stop you from asking for an argument, 
>>> inputting all of them, and having your command extract them all.
>>>
>>> Hmm, I tried a command and added some text after its name in the 
>>> minibuffer after the command's name (I used vr3-show).  The command 
>>> executed.  Maybe your script could read the contents of the minibuffer, 
>>> move past the its own name, and get the args from the rest of the input. 
>>> You would have to find the widget name of the minibuffer single line edit.  
>>> I don't happen to know it.
>>>
>>> On Monday, December 9, 2024 at 5:38:01 PM UTC-5 jkn wrote:
>>>
>>>> Thanks for the pointer Thomas.
>>>>
>>>> That looks like not exactly what I am thinking of - it seems to be 
>>>> oriented towards "command<return>argument1<return>argument2<return>" in 
>>>> the 
>>>> minibuffer. I confess I have never used a Leo command that operates in 
>>>> that 
>>>> way! my loss, I am sure.
>>>>
>>>> I am thinking more of "command arg1 arg2 arg3<return>" - so 
>>>> 'non-interactive', perhaps. But perhaps the available mechanisms will 
>>>> provide that, Ii will have a read.
>>>>
>>>>     Regards
>>>>     J^n
>>>>
>>>>
>>>> On Monday, December 9, 2024 at 9:58:06 PM UTC [email protected] wrote:
>>>>
>>>>> There's a node in LeoDocs about getting arguments.  Look for the 
>>>>> headline "Getting interactive input in scripts and commands".
>>>>>
>>>>> sys.argv will give you the arguments that the Python interpreter 
>>>>> received at startup.
>>>>>
>>>>> Another way I've passed arguments to a script is via the clipboard, 
>>>>> but of course you have to get them into the clipboard first.
>>>>>
>>>>> On Monday, December 9, 2024 at 4:36:37 PM UTC-5 jkn wrote:
>>>>>
>>>>>> I've been meaning to ask this for ever...Is there a way to pass 
>>>>>> argument(s) to leo @command-s?
>>>>>>
>>>>>> If I have a node like
>>>>>>
>>>>>> @command test_args
>>>>>>         import sys
>>>>>>         g.es(sys.argv))
>>>>>>
>>>>>> and run "test_args 1 2 abcd"
>>>>>>
>>>>>> none of "1 2 abcd" get printed - only sys.argv from the initial 
>>>>>> invocation of Leo.
>>>>>>
>>>>>> is there a way for something like this to work? Apologies if it is 
>>>>>> already documented, I cannot find it.
>>>>>>
>>>>>>     Thanks
>>>>>>     Jon N
>>>>>>
>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/7d20265b-a2e4-49db-80fd-326bb67113b2n%40googlegroups.com.

Reply via email to