Terminal arguments fix and cleanup (#138)
* fix linux build error * Linux packaging: remove Alacritty from AppImage * limit APP_DIR trick to Windows only * implement Windows search path * fix terminal search
This commit is contained in:
parent
78f00febbc
commit
ca13548ba0
|
@ -325,7 +325,7 @@ void CompilerManager::run(
|
||||||
} + splitProcessCommand(arguments);
|
} + splitProcessCommand(arguments);
|
||||||
}
|
}
|
||||||
auto [filename, args, fileOwner] = wrapCommandForTerminalEmulator(
|
auto [filename, args, fileOwner] = wrapCommandForTerminalEmulator(
|
||||||
pSettings->environment().terminalPathForExec(),
|
pSettings->environment().terminalPath(),
|
||||||
pSettings->environment().terminalArgumentsPattern(),
|
pSettings->environment().terminalArgumentsPattern(),
|
||||||
execArgs
|
execArgs
|
||||||
);
|
);
|
||||||
|
|
|
@ -3068,7 +3068,7 @@ void DebugTarget::run()
|
||||||
cmd= mGDBServer;
|
cmd= mGDBServer;
|
||||||
arguments = QString(" localhost:%1 \"%2\" %3").arg(mPort).arg(mInferior,mArguments);
|
arguments = QString(" localhost:%1 \"%2\" %3").arg(mPort).arg(mInferior,mArguments);
|
||||||
#else
|
#else
|
||||||
cmd= pSettings->environment().terminalPathForExec();
|
cmd= pSettings->environment().terminalPath();
|
||||||
arguments = QString(" -e \"%1\" localhost:%2 \"%3\"").arg(mGDBServer).arg(mPort).arg(mInferior);
|
arguments = QString(" -e \"%1\" localhost:%2 \"%3\"").arg(mGDBServer).arg(mPort).arg(mInferior);
|
||||||
#endif
|
#endif
|
||||||
QString workingDir = QFileInfo(mInferior).path();
|
QString workingDir = QFileInfo(mInferior).path();
|
||||||
|
|
|
@ -4680,7 +4680,7 @@ void MainWindow::onFilesViewOpenInTerminal()
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
openShell(fileInfo.path(),"cmd.exe",getDefaultCompilerSetBinDirs());
|
openShell(fileInfo.path(),"cmd.exe",getDefaultCompilerSetBinDirs());
|
||||||
#else
|
#else
|
||||||
openShell(fileInfo.path(),pSettings->environment().terminalPathForExec(),getDefaultCompilerSetBinDirs());
|
openShell(fileInfo.path(),pSettings->environment().terminalPath(),getDefaultCompilerSetBinDirs());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6888,7 +6888,7 @@ void MainWindow::on_actionOpen_Terminal_triggered()
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
openShell(info.path(),"cmd.exe",getBinDirsForCurrentEditor());
|
openShell(info.path(),"cmd.exe",getBinDirsForCurrentEditor());
|
||||||
#else
|
#else
|
||||||
openShell(info.path(),pSettings->environment().terminalPathForExec(),getBinDirsForCurrentEditor());
|
openShell(info.path(),pSettings->environment().terminalPath(),getBinDirsForCurrentEditor());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7225,7 +7225,7 @@ void MainWindow::on_actionProject_Open_In_Terminal_triggered()
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
openShell(mProject->directory(),"cmd.exe",mProject->binDirs());
|
openShell(mProject->directory(),"cmd.exe",mProject->binDirs());
|
||||||
#else
|
#else
|
||||||
openShell(mProject->directory(),pSettings->environment().terminalPathForExec(),mProject->binDirs());
|
openShell(mProject->directory(),pSettings->environment().terminalPath(),mProject->binDirs());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,16 +125,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"group": "Bundled",
|
|
||||||
"terminals": [
|
|
||||||
{
|
|
||||||
"name": "Alacritty (Bundled)",
|
|
||||||
"path": "./alacritty",
|
|
||||||
"argsPattern": "$term -e $argv"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"group": "With minor issue",
|
"group": "With minor issue",
|
||||||
"terminals": [
|
"terminals": [
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"group": "Bundled",
|
"group": "Bundled",
|
||||||
|
"comment": "Use `%*APP_DIR*%` in path for application directory.",
|
||||||
"terminals": [
|
"terminals": [
|
||||||
{
|
{
|
||||||
"name": "UTF-8 compatible Console Host",
|
"name": "UTF-8 compatible Console Host",
|
||||||
"path": "%*APP_DIR*%/OpenConsole.exe",
|
"path": "OpenConsole.exe",
|
||||||
"argsPattern": "$term -- $argv"
|
"argsPattern": "$term -- $argv"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -3628,7 +3628,11 @@ void Settings::Environment::doLoad()
|
||||||
|
|
||||||
// check saved terminal path
|
// check saved terminal path
|
||||||
mTerminalPath = stringValue("terminal_path", "");
|
mTerminalPath = stringValue("terminal_path", "");
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
// APP_DIR trick for windows portable app
|
||||||
|
// on other platforms multiple instances share the same configuration and thus the trick may break terminal path
|
||||||
mTerminalPath.replace("%*APP_DIR*%",pSettings->dirs().appDir());
|
mTerminalPath.replace("%*APP_DIR*%",pSettings->dirs().appDir());
|
||||||
|
#endif
|
||||||
mTerminalArgumentsPattern = stringValue("terminal_arguments_pattern", "");
|
mTerminalArgumentsPattern = stringValue("terminal_arguments_pattern", "");
|
||||||
|
|
||||||
checkAndSetTerminal();
|
checkAndSetTerminal();
|
||||||
|
@ -3804,6 +3808,7 @@ void Settings::Environment::checkAndSetTerminal()
|
||||||
if(fileExists(absoluteTerminalPath)) {
|
if(fileExists(absoluteTerminalPath)) {
|
||||||
mTerminalPath = absoluteTerminalPath;
|
mTerminalPath = absoluteTerminalPath;
|
||||||
mTerminalArgumentsPattern = termItem.param;
|
mTerminalArgumentsPattern = termItem.param;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const QString &dirPath: pathList) {
|
for (const QString &dirPath: pathList) {
|
||||||
|
@ -3812,7 +3817,7 @@ void Settings::Environment::checkAndSetTerminal()
|
||||||
if(fileExists(absoluteTerminalPath)) {
|
if(fileExists(absoluteTerminalPath)) {
|
||||||
mTerminalPath = absoluteTerminalPath;
|
mTerminalPath = absoluteTerminalPath;
|
||||||
mTerminalArgumentsPattern = termItem.param;
|
mTerminalArgumentsPattern = termItem.param;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3902,9 +3907,13 @@ void Settings::Environment::doSave()
|
||||||
saveValue("current_folder",mCurrentFolder);
|
saveValue("current_folder",mCurrentFolder);
|
||||||
saveValue("default_open_folder",mDefaultOpenFolder);
|
saveValue("default_open_folder",mDefaultOpenFolder);
|
||||||
QString terminalPath = mTerminalPath;
|
QString terminalPath = mTerminalPath;
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
// APP_DIR trick for windows portable app
|
||||||
|
// on other platforms multiple instances share the same configuration and thus the trick may break terminal path
|
||||||
if (terminalPath.startsWith(pSettings->dirs().appDir())) {
|
if (terminalPath.startsWith(pSettings->dirs().appDir())) {
|
||||||
terminalPath="%*APP_DIR*%"+terminalPath.mid(pSettings->dirs().appDir().length());
|
terminalPath="%*APP_DIR*%"+terminalPath.mid(pSettings->dirs().appDir().length());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
saveValue("terminal_path",terminalPath);
|
saveValue("terminal_path",terminalPath);
|
||||||
saveValue("terminal_arguments_pattern",mTerminalArgumentsPattern);
|
saveValue("terminal_arguments_pattern",mTerminalArgumentsPattern);
|
||||||
|
|
|
@ -595,7 +595,32 @@ QStringList getExecutableSearchPaths()
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
QString path = env.value("PATH");
|
QString path = env.value("PATH");
|
||||||
QStringList pathList = path.split(PATH_SEPARATOR);
|
QStringList pathList = path.split(PATH_SEPARATOR);
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
/* follow Windows `CreateProcessW` search semantics.
|
||||||
|
* ref. https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw .
|
||||||
|
*/
|
||||||
|
QStringList searchList{};
|
||||||
|
wchar_t buffer[MAX_PATH];
|
||||||
|
// 1. the directory from which the application loaded
|
||||||
|
searchList.push_back(QApplication::instance()->applicationDirPath());
|
||||||
|
// 2. the current directory for the parent process
|
||||||
|
// here we add it because launching from GUI the current directory is relatively stable
|
||||||
|
searchList.push_back(QDir::currentPath());
|
||||||
|
// 3. the 32-bit Windows system directory
|
||||||
|
if (GetSystemDirectoryW(buffer, MAX_PATH) > 0)
|
||||||
|
searchList.push_back(QString::fromWCharArray(buffer));
|
||||||
|
if (GetWindowsDirectoryW(buffer, MAX_PATH) > 0) {
|
||||||
|
// 4. the 16-bit Windows system directory
|
||||||
|
searchList.push_back(QString::fromWCharArray(buffer) + "/System");
|
||||||
|
// 5. the Windows directory
|
||||||
|
searchList.push_back(QString::fromWCharArray(buffer));
|
||||||
|
}
|
||||||
|
// 6. the directories that are listed in the PATH environment variable
|
||||||
|
searchList.append(pathList);
|
||||||
|
return searchList;
|
||||||
|
#else
|
||||||
return pathList;
|
return pathList;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QString escapeArgument(const QString &arg, [[maybe_unused]] bool isFirstArg)
|
QString escapeArgument(const QString &arg, [[maybe_unused]] bool isFirstArg)
|
||||||
|
|
|
@ -24,9 +24,6 @@ ln -s usr/share/icons/hicolor/scalable/apps/redpandaide.svg redpandaide.svg
|
||||||
install -m755 /build/RedPanda-CPP/packages/appimage/AppRun.sh AppRun
|
install -m755 /build/RedPanda-CPP/packages/appimage/AppRun.sh AppRun
|
||||||
install -m644 /build/RedPanda-CPP/platform/linux/redpandaide.png .DirIcon
|
install -m644 /build/RedPanda-CPP/platform/linux/redpandaide.png .DirIcon
|
||||||
|
|
||||||
# copy dependency
|
|
||||||
cp /usr/local/bin/alacritty usr/bin
|
|
||||||
|
|
||||||
# create AppImage
|
# create AppImage
|
||||||
cd /build
|
cd /build
|
||||||
mksquashfs RedPandaIDE.AppDir $APPIMAGE_FILE -offset $RUNTIME_SIZE -comp zstd -root-owned -noappend -b 1M -mkfs-time 0
|
mksquashfs RedPandaIDE.AppDir $APPIMAGE_FILE -offset $RUNTIME_SIZE -comp zstd -root-owned -noappend -b 1M -mkfs-time 0
|
||||||
|
|
|
@ -86,19 +86,3 @@ RUN mkdir -p /build/qt5 && \
|
||||||
# cleanup
|
# cleanup
|
||||||
cd / && \
|
cd / && \
|
||||||
rm -r /build/qt5
|
rm -r /build/qt5
|
||||||
|
|
||||||
# Alacritty
|
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.71.1 && \
|
|
||||||
. ~/.cargo/env && \
|
|
||||||
mkdir -p /build/alacritty && \
|
|
||||||
cd /build/alacritty && \
|
|
||||||
curl -L -o alacritty-${ALACRITTY_VERSION}.tar.gz "https://github.com/alacritty/alacritty/archive/refs/tags/v${ALACRITTY_VERSION}.tar.gz" && \
|
|
||||||
tar xf alacritty-${ALACRITTY_VERSION}.tar.gz && \
|
|
||||||
cd alacritty-${ALACRITTY_VERSION} && \
|
|
||||||
echo -e '[profile.minsize]\ninherits="release"\ndebug=false\nstrip=true\nopt-level="s"' >>Cargo.toml && \
|
|
||||||
cargo build --profile minsize && \
|
|
||||||
cp target/minsize/alacritty /usr/local/bin && \
|
|
||||||
# cleanup
|
|
||||||
cd / && \
|
|
||||||
rm -r /build/alacritty && \
|
|
||||||
rustup self uninstall -y
|
|
||||||
|
|
|
@ -68,19 +68,3 @@ RUN mkdir -p /build/qt5 && \
|
||||||
# cleanup
|
# cleanup
|
||||||
cd / && \
|
cd / && \
|
||||||
rm -r /build/qt5
|
rm -r /build/qt5
|
||||||
|
|
||||||
# Alacritty
|
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.71.1 && \
|
|
||||||
. ~/.cargo/env && \
|
|
||||||
mkdir -p /build/alacritty && \
|
|
||||||
cd /build/alacritty && \
|
|
||||||
curl -L -o alacritty-${ALACRITTY_VERSION}.tar.gz "https://github.com/alacritty/alacritty/archive/refs/tags/v${ALACRITTY_VERSION}.tar.gz" && \
|
|
||||||
tar xf alacritty-${ALACRITTY_VERSION}.tar.gz && \
|
|
||||||
cd alacritty-${ALACRITTY_VERSION} && \
|
|
||||||
/bin/echo -e '[profile.minsize]\ninherits="release"\ndebug=false\nstrip=true\nopt-level="s"' >>Cargo.toml && \
|
|
||||||
cargo build --profile minsize && \
|
|
||||||
cp target/minsize/alacritty /usr/local/bin && \
|
|
||||||
# cleanup
|
|
||||||
cd / && \
|
|
||||||
rm -r /build/alacritty && \
|
|
||||||
rustup self uninstall -y
|
|
||||||
|
|
|
@ -83,20 +83,3 @@ RUN mkdir -p /build/qt5 && \
|
||||||
# cleanup
|
# cleanup
|
||||||
cd / && \
|
cd / && \
|
||||||
rm -r /build/qt5
|
rm -r /build/qt5
|
||||||
|
|
||||||
# Alacritty
|
|
||||||
RUN yum install -y cargo && \
|
|
||||||
mkdir -p /build/alacritty && \
|
|
||||||
cd /build/alacritty && \
|
|
||||||
curl -L -o alacritty-${ALACRITTY_VERSION}.tar.gz "https://github.com/alacritty/alacritty/archive/refs/tags/v${ALACRITTY_VERSION}.tar.gz" && \
|
|
||||||
tar xf alacritty-${ALACRITTY_VERSION}.tar.gz && \
|
|
||||||
cd alacritty-${ALACRITTY_VERSION} && \
|
|
||||||
echo -e '[profile.minsize]\ninherits="release"\ndebug=false\nstrip=true\nopt-level="s"' >>Cargo.toml && \
|
|
||||||
cargo build --profile minsize && \
|
|
||||||
cp target/minsize/alacritty /usr/local/bin && \
|
|
||||||
# cleanup
|
|
||||||
cd / && \
|
|
||||||
rm -r /build/alacritty && \
|
|
||||||
yum autoremove -y cargo && \
|
|
||||||
yum clean all && \
|
|
||||||
rm -r ~/.cargo
|
|
||||||
|
|
Loading…
Reference in New Issue