From 6682bed311a75be4d1d8e117bf2f514eb763a547 Mon Sep 17 00:00:00 2001 From: abutcher-gh Date: Mon, 14 Apr 2025 22:11:51 +0100 Subject: [PATCH] TerminalControl: Support MinGW path translation style (C:\ -> C:/) (#18759) ## Summary of the Pull Request Support drag-n-drop path translation in the style used by MinGW programs. In particular for usage with shells like `ash` from busybox (https://frippery.org/busybox/). ## Detailed Description of the Pull Request / Additional comments Provides a new option "mingw" for "pathTranslationStyle". Shown as "MinGW" with translation documented as `(C:\ -> C:/)` in the UI. As per the other modes, this translates `\` to `/` but stops there. There is no prefix/drive translation. ## Validation Steps Performed Run using `busybox ash` shell. Dragged directories and files from both local disks and network shares onto terminal. All were appropriately single quoted and had their backslashes replaced with forward slashes. They were directly usable by the `ash` shell. Language files containing the other options have been updated to include the new one. ## PR Checklist - [ ] Closes #xxx - [ ] Tests added/passed - [x] Documentation updated - [Docs PR #849](https://github.com/MicrosoftDocs/terminal/pull/849) - [ ] Schema updated (if necessary) Co-authored-by: Adam Butcher --- doc/cascadia/profiles.schema.json | 5 +++-- src/cascadia/TerminalControl/IControlSettings.idl | 3 ++- src/cascadia/TerminalControl/TermControl.cpp | 6 ++++++ .../TerminalSettingsEditor/Resources/de-DE/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/en-US/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/es-ES/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/fr-FR/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/it-IT/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/ja-JP/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/pt-BR/Resources.resw | 4 ++++ .../Resources/qps-ploc/Resources.resw | 4 ++++ .../Resources/qps-ploca/Resources.resw | 4 ++++ .../Resources/qps-plocm/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/ru-RU/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/zh-CN/Resources.resw | 4 ++++ .../TerminalSettingsEditor/Resources/zh-TW/Resources.resw | 4 ++++ .../TerminalSettingsSerializationHelpers.h | 3 ++- 17 files changed, 65 insertions(+), 4 deletions(-) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 8726d8303c..d60db96aac 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -3114,12 +3114,13 @@ }, "pathTranslationStyle": { "default": "none", - "description": "Controls how file paths are transformed when they are dragged and dropped on the terminal. Possible values are \"none\", \"wsl\", \"cygwin\" and \"msys2\".", + "description": "Controls how file paths are transformed when they are dragged and dropped on the terminal. Possible values are \"none\", \"wsl\", \"cygwin\", \"msys2\" and \"mingw\".", "enum": [ "none", "wsl", "cygwin", - "msys2" + "msys2", + "mingw" ], "type": "string" } diff --git a/src/cascadia/TerminalControl/IControlSettings.idl b/src/cascadia/TerminalControl/IControlSettings.idl index ccd4445c48..ad621fdff8 100644 --- a/src/cascadia/TerminalControl/IControlSettings.idl +++ b/src/cascadia/TerminalControl/IControlSettings.idl @@ -26,7 +26,8 @@ namespace Microsoft.Terminal.Control None = 0, WSL, Cygwin, - MSYS2 + MSYS2, + MinGW, }; // Class Description: diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index a20b5f9d4c..60833fdd92 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -97,6 +97,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation /* WSL */ L"/mnt/", /* Cygwin */ L"/cygdrive/", /* MSYS2 */ L"/", + /* MinGW */ {}, }; static constexpr wil::zwstring_view sSingleQuoteEscape = L"'\\''"; static constexpr auto cchSingleQuoteEscape = sSingleQuoteEscape.size(); @@ -119,6 +120,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation pos += cchSingleQuoteEscape; } + if (translationStyle == PathTranslationStyle::MinGW) + { + return; + } + if (fullPath.size() >= 2 && fullPath.at(1) == L':') { // C:/foo/bar -> Cc/foo/bar diff --git a/src/cascadia/TerminalSettingsEditor/Resources/de-DE/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/de-DE/Resources.resw index 80b052f11d..679417567f 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/de-DE/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/de-DE/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Profil wird nicht mehr erkannt diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index 5d98ce728e..57525e58a5 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -2316,6 +2316,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Profile no longer detected diff --git a/src/cascadia/TerminalSettingsEditor/Resources/es-ES/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/es-ES/Resources.resw index f03362e5b4..0be7181131 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/es-ES/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/es-ES/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + El perfil ya no se ha detectado diff --git a/src/cascadia/TerminalSettingsEditor/Resources/fr-FR/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/fr-FR/Resources.resw index c491860f73..78d6d4f832 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/fr-FR/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/fr-FR/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Le profil n’est plus détecté diff --git a/src/cascadia/TerminalSettingsEditor/Resources/it-IT/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/it-IT/Resources.resw index 1c69bc653f..c314989f0a 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/it-IT/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/it-IT/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Profilo non più rilevato diff --git a/src/cascadia/TerminalSettingsEditor/Resources/ja-JP/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/ja-JP/Resources.resw index 32c791239a..d7f660c8de 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/ja-JP/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/ja-JP/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + プロファイルは検出されなくなりました diff --git a/src/cascadia/TerminalSettingsEditor/Resources/pt-BR/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/pt-BR/Resources.resw index e3ab70e74c..207ba0e0f3 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/pt-BR/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/pt-BR/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Perfil não detectado diff --git a/src/cascadia/TerminalSettingsEditor/Resources/qps-ploc/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/qps-ploc/Resources.resw index 38c4dd4bc8..b7933d2b72 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/qps-ploc/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/qps-ploc/Resources.resw @@ -2316,6 +2316,10 @@ MSYS2 (C:\ -> /c) !!! !! {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Ρřσƒīŀē ⁿο łøňġèя ðёτęςτęď !!! !!! ! diff --git a/src/cascadia/TerminalSettingsEditor/Resources/qps-ploca/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/qps-ploca/Resources.resw index 38c4dd4bc8..b7933d2b72 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/qps-ploca/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/qps-ploca/Resources.resw @@ -2316,6 +2316,10 @@ MSYS2 (C:\ -> /c) !!! !! {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Ρřσƒīŀē ⁿο łøňġèя ðёτęςτęď !!! !!! ! diff --git a/src/cascadia/TerminalSettingsEditor/Resources/qps-plocm/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/qps-plocm/Resources.resw index 38c4dd4bc8..b7933d2b72 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/qps-plocm/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/qps-plocm/Resources.resw @@ -2316,6 +2316,10 @@ MSYS2 (C:\ -> /c) !!! !! {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Ρřσƒīŀē ⁿο łøňġèя ðёτęςτęď !!! !!! ! diff --git a/src/cascadia/TerminalSettingsEditor/Resources/ru-RU/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/ru-RU/Resources.resw index 58109ce443..9c6b2b8486 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/ru-RU/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/ru-RU/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + Профиль больше не обнаруживается diff --git a/src/cascadia/TerminalSettingsEditor/Resources/zh-CN/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/zh-CN/Resources.resw index 8e3dd54e60..48f70b7149 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/zh-CN/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/zh-CN/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + 不再检测到配置文件 diff --git a/src/cascadia/TerminalSettingsEditor/Resources/zh-TW/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/zh-TW/Resources.resw index 4bf8f371ff..647caf9c78 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/zh-TW/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/zh-TW/Resources.resw @@ -2312,6 +2312,10 @@ MSYS2 (C:\ -> /c) {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + MinGW (C:\ -> C:/) + {Locked="MinGW","C:\","C:/"} An option to choose from for the "path translation" setting. + 已不再偵測到設定檔 diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index fa355b39ba..448eae5e43 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -794,10 +794,11 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::DefaultInputScope) JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::PathTranslationStyle) { - static constexpr std::array mappings = { + static constexpr std::array mappings = { pair_type{ "none", ValueType::None }, pair_type{ "wsl", ValueType::WSL }, pair_type{ "cygwin", ValueType::Cygwin }, pair_type{ "msys2", ValueType::MSYS2 }, + pair_type{ "mingw", ValueType::MinGW }, }; };