你如何让 Execute 在 Geany 中做任何事情?

问题描述:

我是第一次尝试 Geany.编译和构建工作正常(并且确实会自动检测到命令),但是我根本无法让执行执行任何操作.

I am trying out Geany for the first time. Compile and Build work fine (and indeed the commands are automatically detected), however I have been unable to make Execute do anything at all.

我的设置:

  • 创建一个新项目
  • 将基本的 C hello world 保存为 hello-world.c

(我使用的是 Kubutuntu 14.04.)

(I am using Kubutuntu 14.04.)

无需额外设置,按 F9 或单击构建"->构建"即可正确构建可执行文件.但是,当我按 F5 或单击 Build -> Execute 时,会出现一个带有 $ 提示的终端窗口,没有其他提示.

With no extra setup, pressing F9 or clicking Build -> Build correctly builds the executable. However, when I press F5 or click Build -> Execute, a terminal window appears with a $ prompt, and nothing else.

我尝试过构建 -> 设置构建命令并将执行旁边的命令更改为各种内容,包括echo hi there",但结果始终相同:$ 提示,没有别的.

I have tried going to Build -> Set Build Commands and changing the command next to Execute to various things, including "echo hi there", but the result is always the same: a $ prompt, and nothing else.

如何让 F5 做任何事情?

How do I make F5 do anything?

更新:我已经创建了全新安装 Ubuntu 14.04 和 Kubuntu 14.04 的虚拟机.Geany 在 Ubuntu 上按预期工作,F5 运行程序.在 Kubuntu 上,我遇到了在运行 Kubuntu 14.04 的笔记本电脑上遇到的相同问题.所以这似乎是一个 Kubuntu 特定的问题.

Update: I have created VMs with clean installs of Ubuntu 14.04 and Kubuntu 14.04. Geany on Ubuntu works as expected, and F5 runs the program. On Kubuntu, I get the same issue I get on my laptop running Kubuntu 14.04. So it seems this is a Kubuntu specific problem.

解决方案

在编辑 -> 首选项 -> 工具中,将终端更改为

Solution

In Edit -> Preferences -> Tools, change the Terminal from

x-terminal-emulator -e "/bin/sh %c"

x-terminal-emulator -e /bin/sh %c

说明

当您按下 Execute 时,Geany 会执行 Edit -> Preferences -> Tools 中指定的终端,将 %c 替换为 Build -> Set Build Commands 中设置的 Execute 命令.

Explanation

When you press Execute, Geany executes the terminal specified in Edit -> Preferences -> Tools, replacing %c with the Execute command set in Build -> Set Build Commands.

在 Ubuntu 中,默认终端模拟器支持 -e 传递一个包含整个命令行的引号中的单个参数,并且 Execute 会按预期工作.但是Kubuntu默认的终端模拟器是Konsole,不支持这个;它仅支持将 -e 之后的其余参数用作命令行.当 KDE 尝试实现它时,引入了此错误,因此他们恢复了更改.

In Ubuntu, the default terminal emulator supports -e being passed a single parameter in quotes which contains an entire command line, and Execute works as expected. However, the default terminal emulator in Kubuntu is Konsole, which does not support this; it only supports using the rest of arguments after -e as a command line. When KDE attempted to implement it, this bug was introduced so they reverted the change.

Konsole 将支持 Geany 在 KDE 4.14.2 中默认使用的终端模拟器参数,因此一旦支持,将不再需要此解决方法.

Konsole will support the terminal emulator parameters that Geany uses by default from KDE 4.14.2, so once that's out, this workaround will no longer be needed.