广告

本站里的文章大部分经过自行整理与测试

2017年4月5日星期三

GNOME - gedit 插件 - C / C++ / java 编译与运行


1) 安装 gedit 插件

$ sudo apt-get install gedit-plugins

2) 在 gedit 设置与启动 Manage External Tools

Edit - Preferences - Plugins - External Tools

Tools - Manage External Tools...

编译 C / C++  / JAVA 

#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=`echo $fullname | cut -d. -f1`
suffix=`echo $fullname | cut -d. -f2`

if [ $suffix = "c" ]; then
gcc $fullname -o $name -O2 -Wall -std=gnu99 -static -lm 
elif [ $suffix = "cpp" ] || [ $suffix = "c++" ] || [ $suffix = "cc" ] || [ $suffix = "cxx" ] || [ $suffix = "C" ]; then
g++ $fullname -o $name -O2 -Wall -std=gnu++0x -static -lm
elif [ $suffix = "java" ]; then
javac $fullname -encoding UTF-8 -sourcepath . -d .
fi

Shortcut key: Ctrl+F5
Save: Current document
Input: Nothing
Output: Nothing
Applicability: All documents | C,C++,Java


运行 C / C++ / JAVA

#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=`echo $fullname | cut -d. -f1`
suffix=`echo $fullname | cut -d. -f2`
dir=$GEDIT_CURRENT_DOCUMENT_DIR

if [ $suffix = "c" ]; then
gnome-terminal --hide-menubar --working-directory=$dir -t "Terminal-$name" -x bash -c "$dir/$name; echo;echo 'press ENTER to continue';read"
elif [ $suffix = "cpp" ] || [ $suffix = "c++" ] || [ $suffix = "cc" ] || [ $suffix = "cxx" ] || [ $suffix = "C" ]; then
gnome-terminal --hide-menubar --working-directory=$dir -t "Terminal-$name" -x bash -c "$dir/$name; echo;echo 'press ENTER to continue';read"
elif [ $suffix = "java" ]; then
gnome-terminal --hide-menubar --working-directory=$dir -t "Terminal-$name" -x bash -c "java -classpath . $name echo;echo 'press ENTER to continue';read"
fi

Shortcut key: F5
Save: Nothing
Input: Nothing
Output: Nothing
Applicability: All documents | C,C++,Java

没有评论:

发表评论