platformio-vscode-ide icon indicating copy to clipboard operation
platformio-vscode-ide copied to clipboard

Feature request: Custom buttons and commands in VSC toolbar

Open chepo92 opened this issue 4 years ago • 3 comments

I know I can make custom task and the build button task can be customized with one in settings https://docs.platformio.org/en/latest/integration/ide/vscode.html#ide-vscode-settings

But what about the others? As example:

  • I want a button that Uploads code without building/checking and that doesn't do autoclean
  • A button to show available COM's
  • Etc

It would be nice to have easy to customize buttons in the toolbar.

chepo92 avatar May 01 '20 05:05 chepo92

I second this. Would be so so ergonomic / useful. Even without custom icon just a short label + tooltip on mouseover would be good enough. Not afraid of editing a JSON file as "easy way" either.

pak-man avatar Sep 09 '21 09:09 pak-man

If this were possible then the forceUploadAndMonitor setting could be eliminated (because you could just map the upload button to the Upload And Monitor task).

belm0 avatar May 19 '22 13:05 belm0

Thanks, we will work on this in 3.0 release.

ivankravets avatar May 19 '22 13:05 ivankravets

Implemented in the latest development version (upcoming PlatformIO IDE 3.0). Please re-test with the pre-release version. See the instructions below:

Screen Shot 2022-12-11 at 14 42 36

You will need to edit platformio-ide.toolbar option. See default declarations https://github.com/platformio/platformio-vscode-ide/blob/develop/package.json#L856. The text field can contain icons, see https://code.visualstudio.com/api/references/icons-in-labels#icon-listing

The full list of commands can be found via VSCode > Settings > Keybindings. You can declare multiple commands for one button.

We would be thankful for your feedback.


Example

    "platformio-ide.toolbar": [
        {
            "text": "Clean",
            "commands": [
                {
                    "id": "workbench.action.tasks.runTask",
                    "args": [
                        "PlatformIO: Clean"
                    ]
                }
            ]
        },
        {
            "text": "$(list-selection)",
            "commands": [
                {
                    "id": "platformio-ide.runPIOCoreCommand",
                    "args": "pio device list"
                }
            ]
        },
        {
            "text": "$(terminal)",
            "commands": [
                {
                    "id": "workbench.action.terminal.sendSequence",
                    "args": {
                        "text": "echo 1\n"
                    }
                }
            ]
        }
    ]
Screenshot 2022-12-18 at 20 08 38

ivankravets avatar Dec 18 '22 18:12 ivankravets

Implemented in the latest development version (upcoming PlatformIO IDE 3.0). Please re-test with the pre-release version. See the instructions below: You will need to edit platformio-ide.toolbar option. See default declarations https://github.com/platformio/platformio-vscode-ide/blob/develop/package.json#L856. The text field can contain icons, see https://code.visualstudio.com/api/references/icons-in-labels#icon-listing

OK, but how would one add the aforementioned "Upload and Monitor"? There is no command ID (e.g. platformio-ide.uploadAndMonitor) for that. (It's not obvious to me, despite poring over the code, where the command IDs themselves are defined.)

tookitogo avatar Jan 06 '23 23:01 tookitogo

Do you mean PlatformIO: Upload and Monitor? Please check other PlatformIO's commands via Terminal > Run Task... > PlatformIO > ...`

ivankravets avatar Jan 09 '23 15:01 ivankravets

OK, but how would one add the aforementioned "Upload and Monitor"? There is no command ID (e.g. platformio-ide.uploadAndMonitor) for that. (It's not obvious to me, despite poring over the code, where the command IDs themselves are defined.)

I had the same idea in mind 😅 This is my solution:

        {
            "text": "$(debug-alt)",
            "tooltip": "PlatformIO: Upload & Monitor",
            "commands": [
                {
                    "id": "workbench.action.tasks.runTask",
                    "args": [
                        "PlatformIO: Upload and Monitor"
                    ]
                }
            ]
        },

sivar2311 avatar Jan 11 '23 08:01 sivar2311

@ivankravets Hello, Regarding associating the Upload and Monitor task to the toolbar, I think your intention is probably to assume @sivar2311's solution. However, it does not correctly target the active environment when there are multiple environments. Because it can not make the current active environment explicit to pio run.

Actual command line passed to the vscode terminal with the above way.

It --environment argument is missing.

C:\Users\[CURRENT_USER]\.platformio\penv\Scripts\platformio.exe run --targert upload --target monitor

So, it seems to me that solving this problem is also related #2623 to making the Upload and Monitor task practical from the Toolbar even in the case of multiple environments.

Can I expect this to be resolved by fixing #2623 in a drastic way? Or have other workarounds?

Hieromon avatar Feb 07 '23 07:02 Hieromon

@ivankravets We encountered the same issue in Tasmota. https://github.com/arendst/Tasmota/discussions/17997

Jason2866 avatar Feb 19 '23 21:02 Jason2866

@ivankravets Thx, do i understand correctly that the --environment is still not there? This will not solve the issues in custom platformio toolbar.

Jason2866 avatar Feb 24 '23 18:02 Jason2866

Upload & Monitor with an active environment was achieved by the following settings:

{
  "text": "$(arrow-right)",
  "tooltip": "PlatformIO: Upload & Monitor",
  "commands": [
    {
      "id": "workbench.action.tasks.runTask",
      "args": "PlatformIO: Upload and Monitor (${command:platformio-ide.activeEnvironment})"
    }
  ]
},

Thanks.

Hieromon avatar Mar 16 '23 13:03 Hieromon