English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 02 September 2023, 20:31   #1
Azvareth
Registered User
 
Join Date: Nov 2019
Location: Landskrona/Sweden
Age: 55
Posts: 38
ARexx -> DOPUS5 [Custom Handler] Q

Hi!

I have for a little while played around with Dopus 5.91 OS3 and ARexx.

What I am trying to achieve is, to connect a newly opened lister to a custom handler...

This is what I am trying to do
Launch a "global" handler with PORTNAME using waitpkt to receive a message
when I have a packet,
I then extract the data that "should" be there according to the documentation.

However, there seem not to be any.

Here is how I try to connect a custom lister handle which is invoked with
[DOPUSMENU] -> [SETTINGS] -> [SCRIPTS] -> Open Lister
method, that is calling an Arexx script with the following snippet

Code:
/* Test to call a handler */
OPTIONS Results
if show(p, "DOPUS5_EXT") Then do
    ADDRESS "DOPUS.1"                   /* we always run DOPUS no need to ctrl*/
    lister set handler "DOPUS5_EXT"     /* try to set this lister to the custom port*/
end

Exit



I am guessing I am doing it wrong here as the only result from the handler is when receiving a message
that I catch and output with
Code:
args.0 = getarg(pkt,0)
say args.0
results in exactly how I called the "lister set ..." at the first place,
say args.0 becomes LISTER SET HANDLER DOPUS5_EXT

It might be that I am calling it wrongly, but if I are to call it with extra args I need to know the newly
opened lister handle and there seems not to be any method for that?

No matter what drawer I click on, this is the only result... and no more messages are forwarded to
the handler, no click on icons, no resizes or anything else in the docs.

Yes, I have read the docs (dopus magellan 5.66), does any other updated docs exists? The 5.92
docs seems to be a copy of earlier docs only?
I also have read lots of code from the Aminet in this topic, I have not found many examples and not
any of my specific usecase...


Question:
1. Does anyone know how to get the active/focused listers handle?
2. Does anyone know if there is more deeper docs, with maybe example snippets?
3. Or does anyone who knows, like to share how it should be done?
Azvareth is offline  
Old 03 September 2023, 12:51   #2
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,304
Lister handling can be a bit tricky because of DOpus asynchronous nature.
Quote:
Originally Posted by Azvareth View Post
1. Does anyone know how to get the active/focused listers handle?
This should work:
Code:
LISTER QUERY ACTIVE ; activehandler = result
Quote:
2. Does anyone know if there is more deeper docs, with maybe example snippets?
I used the DOpus 5.82 manual in guide format. It has an appendix part you may have missed. The DOpus PLUS CD comes with a lot of stuff.
daxb is offline  
Old 03 September 2023, 19:19   #3
Azvareth
Registered User
 
Join Date: Nov 2019
Location: Landskrona/Sweden
Age: 55
Posts: 38
Thank you @daxb, it works... I also found the documentation and examples you mentioned. a few more methods in there then from the previous documentation...


And... now I only need to figure out how to catch the previously focused/active lister. Or from which lister I opened my new lister from and how to access a lister windows structure from ARexx.

And no, it was not a question... Just what I am struggling with, It seems like (as for now) that functionality is missing.
Azvareth is offline  
Old 03 September 2023, 22:45   #4
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,304
Hmm... I'm not sure what you mean but "lister query" has a lot of keywords/items and you can get all lister handles that exists. If you can't assign a lister to its handle maybe there is a workaround like lister attributes you know.
daxb is offline  
Old 04 September 2023, 00:19   #5
Azvareth
Registered User
 
Join Date: Nov 2019
Location: Landskrona/Sweden
Age: 55
Posts: 38
ahhh

turned out I did not need to create and connect a lister to a handler, as of yet anyway. Still coding on it...

what I am trying to do is: mimicking the effect one has when one click on a drawer and holding down control key (at least in emulation) without the need to hold down the control key.

That is, have the impression that each drawer that is opened, will have it's new content in the same lister it was opened from, it is as for now an illusion, but that is what I am trying to do.

I have not seen any settings in DOpus that enables that functionality despite actually being built into the filemanager/dekstop application.

Anyway, thank you again, you put me on the right track.

Last edited by Azvareth; 04 September 2023 at 00:21. Reason: wrong wording - corrected
Azvareth is offline  
Old 06 September 2023, 02:46   #6
Azvareth
Registered User
 
Join Date: Nov 2019
Location: Landskrona/Sweden
Age: 55
Posts: 38
uhmmm

Just for fun, I tested to install a handler and work on generated events...
split into two parts, when a lister is opened a custom handler is attached to that lister

the custom handler takes arg0 to arg6 and prints it out (into tco)

The event system seems to be very broken (unless I don't get it)
-no doubleclick event from the lister is sent to the handler
-- not when clicking on icons or inside the lister or the "lister window top bar"
-an active event is sent to the handler when the lister is created
-- no event is sent when the lister is focused/activated
-an inactive event is sent when the lister is closed
-- no events is sent when a lister lost focus or is inactivated
- when clicking the toolbar go up one drawer, the lister goes inactive then goes to active state when loading of new content is done, the same seems to be true when going down a drawer from the same lister (ctrl+click)

If anyone is around that designed, updated or modified DOPUS5 (or anyone with knowledge) is this how it was planned to work?
Azvareth is offline  
Old 06 September 2023, 14:01   #7
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,304
You mean using ports to send messages? Unfortunately, I've no experience with that. I only used simple send to lister commands and can remember that you need sometimes to use "wait for lister" (because of async) and/or a "refresh lister" to make changes appear.
Maybe you can find an example in DOpus scripts/modules that may help you. The mentioned CD and Aminet should have a lot of stuff to check. 20 years ago there exists www sites full of DOpus content.

You may try to use DOpus 5.82 instead of 5.9 just to check if new bugs are responsible.
daxb is offline  
Old 07 September 2023, 00:35   #8
Azvareth
Registered User
 
Join Date: Nov 2019
Location: Landskrona/Sweden
Age: 55
Posts: 38
yes, I use a loop for that

Code:
ADDRESS DOPUS.1
do j = 0 to 25                      /* Amiga is slow, even in emulation so we loop with a delay and breakout early  */
    lister query active             /* get the active newly opened lister, if we do not have one - we cannot run    */
    if rc = 0 then leave            /* we found an active lister so leave early                                     */
    call delay(10)                  /* 0.2 seconds / loop which totals in 5 seconds ?                                */
end; if rc >= 20 then exit          /* the loop did not find any active lister so we exit the script                */
But it was weird with 5.8...

I do not even get any events that is visible in the output (tco) , but the script still works...

it works faster but... yea! the new DOPUS version is better to use...
Azvareth is offline  
Old 07 September 2023, 11:35   #9
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,304
I guess that will not work this way but I'm not sure what you want to do.
daxb is offline  
Old 07 September 2023, 22:09   #10
Azvareth
Registered User
 
Join Date: Nov 2019
Location: Landskrona/Sweden
Age: 55
Posts: 38
My end goal, to speak in Windows language is to emulate the same functionality as
"Open new Folder in same Window", that is reuse the same lister for any other opened sublister...

Unfortunatly DOPUS miss AREXX functions/flags/properties and methods like
OnBeforeOpenLister with a return flag canOpen for example
OnAfterOpenLister
OnDoubleClick
OnActivate - OnFocus
OnInActivate - OnFocusLost

So I managed to create a working script (2 actually) that waits until a new lister is opened and flagged as active, the first one when opened move to the position of the previous lister thus "hides" it from view, then I closed the old lister if it was a parent of the new lister and flagged as a source lister...

The second script just took the path of the new lister, closed it... And then set the path of the previously lister to that path...

Both versions works to slow to be meaningful except for that you don't have a million windows opened when you reach your destination...

Natively
Doubleclick events and
Open in same lister works when a lister is not in icon or icon view action mode, so it feels like DOPUS internally has more then one open a lister functions and those functions differ slightly on how they are implemented, and not just in how the final view is presented to the user...


[Added a bit later - work in progress]
Code:
/* try to get lister handle
Original author: Azvareth
   Note to self: This script seems to get quite large
                 + 180 lines
                 perhaps time to reevaluate the methods,
                 instead of closing the old source,
                 just get the path from the newly opened
                 lister and set old source to new path and
                 then close the new lister?

  Original Name: on_openLister_$date_$ver.dopus5
          Usage: in settings->script->Open Lister
                 add this script as an arexx method

        Purpose: When opening a new drawer by mouse,
                 resize the newly opened drawer to the 
                 previously one, and close the previous
                 drawer... mimicing "open in same window"
                 yea there should be a setting in DOPUS
                 for that, as you have this behaviour when
                 holding down control (in emulation at least),
                 at least an option to reverse that behaviour.
*/

options results
DO_DEBUG = 1                        /* a flag to output strings when looking for errors, 1 for debug, 0 to ignore   */

if ~show( 'l', "rexxsupport.library" ) then
    if ~addlib('rexxsupport.library', 0, -30, 0 ) then do
        debug('Could not open rexxsupport.library')
        Exit 0
    end

ADDRESS DOPUS.1
do j = 0 to 25                      /* Amiga is slow, even in emulation so we loop with a delay and breakout early  */
    lister query active             /* get the active newly opened lister, if we do not have one - we cannot run    */
    if rc = 0 then leave            /* we found an active lister so leave early                                     */
    call delay(10)                  /* 0.2 seconds / loop which totals in 5 seconds                                 */
end; if rc >= 20 then exit          /* the loop did not find any active lister so we exit the script                */

activehandler = result                              /* save the active lister handle                                */
lister query activehandler path; apath = result     /* get the active lister full path                              */

lister query source stem srcpanes                   /* query for the source listers                                 */
srccount = srcpanes.count                           /* get the count of source listers                              */
if srccount < 1 then do                             /* if count = 0 then no source listers found, nothing to do     */
    if DO_DEBUG=1 then dopus request "'no source listers found, exit script'"
    exit
end

do i = 0 To srccount-1                                      /* and loop thru all source listers                         */
    if srcpanes.i = activehandler then do                   /* Exit if the source lister is the same as active lister   */
        if DO_DEBUG=1 then dopus request "'source listers and active lister are the same, exit script'"
        exit
    end
    lister set srcpanes.i off                               /* turn off all source listers                              */
end

parse upper var apath adev ":" adir                         /* split full path to device and file parts                 */
lister query srcpanes.0 path; spath = result                /* get the source lister full path                          */
parse upper var spath sdev ":" sdir                         /* split full path to device and filepath                   */
if adev = sdev then do                                      /* if same we are on the same device, continue              */
    if length(adir) > length(sdir) then do                  /* if lenth is greater we might be in a subdir              */
        lister query srcpanes.0 position; srcpos = result   /* copy old lister position                                 */
        lister close activehandler                          /* finally we can close the newly created lister            */
        lister read srcpanes.0 "'"||apath||"'"              /* set the source lister path to new lister path            */
        lister set srcpanes.0 source                        /* set old souce lister to source again                     */
        lister set srcpanes.0 sort name                     /*  */
        lister refresh srcpanes.0
        /* TODO check if we really are a child of source lister */
    end; else do
        if DO_DEBUG=1 then dopus request "'active lister has a shorter path then source lister, and canot be a child'"
    end
end; else do
    if DO_DEBUG=1 then dopus request "'source lister devicename and active lister devicename are not the same'"
end




Exit

Last edited by Azvareth; 07 September 2023 at 23:35.
Azvareth is offline  
Old 08 September 2023, 17:32   #11
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,304
I guess I now understand what you want to do. You are not in lister text mode and a double click on an icon should not open a new lister. Instead it should open the directory in its lister like it does in lister text mode. So a workaround for icon mode is the goal.

The best would be to change the DOpus 5.9x source code or just use lister text mode.

If you still want to workaround the DOpus WB emulation behaviour you may activate a drawer by single click and use a hotkey to do the ARexx stuff as an alternative. This way it should be possible to switch to lister text mode -> change to directory -> switch back to lister icon mode without the need of open a new lister. The ARexx script would be much simpler (a few lines of code).
daxb is offline  
Old 08 September 2023, 21:19   #12
Azvareth
Registered User
 
Join Date: Nov 2019
Location: Landskrona/Sweden
Age: 55
Posts: 38
uhmmm ehh no ? not sure what you mean here but...

I am in icon action, the new lister is opened in icon action as well...

I have connected the script to Settings->scripts->open lister event event and it is working somewhat, yea it has some residue from the old script that is wrong, but it works.

maybe I am using the naming of the listers wrong, I see everything as a lister with different view modes?

The ctrl+click methods works in "icon action view" and "icon view", in list view it just count the size of the drawer...

Currently the script only works in "icon action view" as it is what I did target...

Yea I would love to change the source, but I do not even know how to compile it without changing anything at all, I have figured out it is compiled with gcc though? perhaps.

If there are any tutorials on that it would be nice to know, there is no docs on how to compile it on dopus5 on github as far as I can see, nor in the downloaded files.

[late edit]
I created this and connected it to the event mentioned above, it works in icon action view... it might be a hint to do something for someone else, idk. it is an expansion and cleanup from the example in previous post.

Code:
/* try to get lister handle
Original author: Azvareth
   Note to self: This script seems to get quite large
                 + 180 lines
                 perhaps time to reevaluate the methods,
                 instead of closing the old source,
                 just get the path from the newly opened
                 lister and set old source to new path and
                 then close the new lister?

  Original Name: on_openLister_$date_$ver.dopus5
          Usage: in settings->script->Open Lister
                 add this script as one arexx method
                 works when lister is in icon action

        Purpose: When opening a new drawer by mouse,
                 resize the newly opened drawer to the 
                 previously one, and close the previous
                 drawer... mimicing "open in same window"
                 yea there should be a setting in DOPUS
                 for that, as you have this behaviour when
                 holding down control (in emulation at least),
                 at least an option to reverse that behaviour.
*/
options results
DEBUG = 0                       /* a flag to output strings when looking for errors, 1 for debug, 0 to ignore       */
                                /* to speed up thing in script, as the debug function is an external script, it is  */
                                /* replaced with an empty function in this script file, comment it out to start     */
                                /* debug again                                                                      */

ADDRESS DOPUS.1
lister query all stem ap        /* query for all listers                                                            */
if ap.count < 2 then Exit 0     /* nothing to do with one lister                                                    */

/*TODO can we speed up this ? */
/* we don't have the handler yet, so we can't wait for it or set a busy flag to it                                  */
do j = 0 to 25                      /* Amiga is slow, even in emulation so we loop with a delay and breakout early  */
    lister query active             /* get the active newly opened lister, if we do not have one - we cannot run    */
    if rc = 0 then leave            /* we found an active lister so leave early                                     */
    call delay(10)                  /* 0.2 seconds / loop which totals in 5 seconds                                 */
end; if rc >= 20 then exit          /* the loop did not find any active lister so we exit the script                */

activehandler = result                              /* save the active lister handle                                */
lister wait activehandler quick                     /* it seems we need to wait until lister has loaded the files?  */

lister query source stem srcpanes                   /* query for the source listers                                 */
srccount = srcpanes.count                           /* get the count of source listers                              */
if srccount < 1 then do                             /* if count = 0 then no source listers found, nothing to do     */
    lister set activehandler visible on             /* show the only lister that is present                         */
    lister set activehandler source                 /* set old souce lister to source again                         */
    exit 0
end

lister set activehandler visible off                /* hide the new lister, can't do it any faster?                 */

do i = 0 To srccount-1                                      /* and loop thru all source listers                     */
    if srcpanes.i = activehandler then do                   /* Exit if source lister is the same as active lister   */
        lister set activehandler visible on                 /* show the only lister that is present                 */
        lister set activehandler source                     /* set old souce lister to source again                 */
        exit 0
    end
    lister set srcpanes.i off                               /* turn off all source listers                          */
end

lister query activehandler path; apath = result             /* get the active lister full (active)path              */

parse upper var apath adev ":" adir                         /* split full path to device and file parts             */
lister query srcpanes.0 path; spath = result                /* get the source lister full path                      */
parse upper var spath sdev ":" sdir                         /* split full path to device and filepath               */

if adev = sdev then do                                      /* if same we are on the same device, continue          */
    if length(adir) > length(sdir) then do                  /* if lenth is greater we might be in a subdir          */

        tadir = translate(translate(adir ,":"," ") ," ","/")    /* translated active path                               */
        tsdir = translate(translate(sdir ,":"," ") ," ","/")    /* translated source path                               */

        si = words(tsdir); ai = words(tadir)                /* get source and active listers dir counts                 */
        if ai = si+1 then do                                /* active lister path should be one more then the source    */
            if word(tadir,si) = word(tsdir,si) then do      /* compare active "next to last dir" with source "last dir"     */
                                                            /* finally we are sure we are parent and child                  */
                lister query srcpanes.0 position; srcpos = result       /* copy old lister position                         */
                lister close activehandler                              /* and now we can close the "newly" created lister  */
                lister read srcpanes.0 "'"||apath||"'"                  /* set the source lister path to new lister path    */
                lister set srcpanes.0 sort name                         /* try to display it sorted, does not work yet      */
                lister refresh srcpanes.0                               /* but we have started to implement it              */
                lister set srcpanes.0 source                            /* set old souce lister to source again             */
            end; else do                                    /* we did not live up to be a parent and a child so             */
                lister set activehandler visible on         /* we have not yet closed the active lister so show it  */
                lister set activehandler source
                Exit 0
            end
        end; else do                                        /* path count does not add up, so it is not a child     */
            lister set activehandler visible on             /* we have not yet closed the active lister so show it  */
            lister set activehandler source
            Exit 0
        end
    end; else do
        lister set activehandler visible on                 /* we have not yet closed the active lister so show it  */
        lister set activehandler source
        Exit 0
    end
end; else do
    lister set activehandler visible on                     /* we have not yet closed the active lister so show it  */
    lister set activehandler source
end
Exit 0

debug:
return 0

Last edited by Azvareth; 09 September 2023 at 02:53.
Azvareth is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Worms TDC > Custom levels > Noob-tech-ninja support.Games 5 08 January 2024 21:49
[opus5][arexx] double click action with custom lister peceha Coders. Scripting 2 12 March 2018 20:18
Problem executing DOpus5 Arexx Script ... beltrixx support.Apps 1 01 August 2015 22:16
ARexx <-> ActiveX Bridge amix request.UAE Wishlist 6 18 October 2007 01:28
Arexx script (txt => hex) Uukrul Coders. General 10 09 September 2001 04:02

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:54.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08461 seconds with 15 queries