nkh / P5-App-Asciio

Plain ASCII diagram
https://nkh.github.io/P5-App-Asciio/
56 stars 4 forks source link

replace code-box with more generic type #43

Closed nkh closed 1 year ago

nkh commented 1 year ago

@qindapao you have implemented the code-box but I think these points could be better

we already have 2 types of command boxes

I have implemented in a933d8adea6280cfea6ba041e801471f2967eed4 a new type of command box, one that takes command verbatim. try it and let me know if you think it's a good replacement for the code box (how often do you use it?)

p3

I had to change the implementation of the exec box a bit because the old version would run each line as a separate command, the new one takes the command verbatim.

it also can take a start command, here is how they are added to the stencils

create_element
    (
    NAME => 'Boxes/exec verbatim',
    CLASS => 'App::Asciio::stripes::exec_box',
    TEXT_ONLY => '$',
    EDITABLE => 1,
    NO_BORDER => 1,
    RUN_VERBATIM => 1,
    ) ,

create_element
    (
    NAME => 'Boxes/exec add lines',
    CLASS => 'App::Asciio::stripes::exec_box',
    TEXT_ONLY => '$',
    EDITABLE => 1,
    NO_BORDER => 1,
    RUN_VERBATIM => 1,
    VERBATIM_COMMAND => "nl -n ln -w 2 -s' ' 2>&1 "
    ) ,

We still have the possibility for a user input that looks like the code-box but I'd rather have it use the above mechanism for execution.

qindapao commented 1 year ago

@nkh

I have tried your revised version, and the effect is very good. It support editing it again.Use your implementation

The command box really creates an infinite number of possibilities

qindapao commented 1 year ago

Please help update the document, and must tell the user the details.

For an example of a command box combined with an external tool, we may need to document it as a topic to help users use it better.

I think this part already belongs to the advanced usage of asciio, and it is extremely efficient to use it well

qindapao commented 1 year ago

exec add lines There is a small bug that needs to be fixed

When the user does not have any input directly click OK, the program will hang

nkh commented 1 year ago

Good catch but that's not a bug, if the command requires input it will wait for it; it's a user error.

But your point is valid, I've added a timeout for all commands, it's set to 2 seconds for now, running the code that adds line will now fail and display this message.

              Can't execute 'nl -n ln -w 2 -s' ' 2>&1 ':
              output:                                   

              error:                                    
               [31744]                                  
nkh commented 1 year ago

I also have added #44 to make the dialogs more usable

nkh commented 1 year ago

@qindapao I just committed 65bcb73, the exec boxes are refactored, use a larger dialog, and there's some documentation in mdbook.../stencils/asciio_exec_box.

nkh commented 1 year ago

@qindapao

please check this work, I've added these four stencils so they can be reached via the popup

'Asciio/Boxes/exec' 'Asciio/Boxes/exec verbatim' 'Asciio/Boxes/exec verbatim once' 'Asciio/Boxes/exec add lines'

the documentation is in stencils/asciio_exec_box

the simplest way to use them is via the bindings I have also added

if all is good for you we can close this ticket

qindapao commented 1 year ago

@nkh

It is much more valuable than my implementation, I like it very much, please close issuee.