qt 使用插件astyle_artistic style (astyle) 的使用配置
1。将astyle运行路径加到系统PATH变量中
2。添加变量ARTISTIC_STYLE_OPTIONS
ASTYLE_HOME=~/tools/astyle
ARTISTIC_STYLE_OPTIONS=${ASTYLE_HOME}/conf.opt
PATH=${PATH}:${ASTYLE_HOME}/build/gcc/bin:${ASTYLE_HOME}/scripts
export ASTYLE_HOME ARTISTIC_STYLE_OPTIONS PATH
其中,conf.opt是配置astyle参数的文件,存放位置任意,只要变量名一样就行。
${ASTYLE_HOME}/scripts不是必须加到PATH中,此目录下存放的是SHELL脚本,作用:在任何目录下运行此脚本,可以format要格式化的代码。
下面是conf.opt和astyle_format.sh 文件内容
# use linux as Predefined Style Options
style=linux
# This option will allow the comments to be indented with the code
indent-col1-comments
# Insert space padding around operators.
pad-oper
# Add brackets to unbracketed one line conditional statements
add-brackets
# Force use of the specified line end style
lineend=linux
# Indent a C/C++, C#, or Java file.
mode=java
# Converts tabs into spaces in the non-indentation part of the line.
# The number of spaces inserted will maintain the spacing of the tab.
convert-tabs
# Indent using 4 spaces per indent
indent=spaces=4
# delete empty lines within a function or method.
# delete-empty-lines
# insert space padding after paren headers only
pad-header
unpad-paren
add-brackets
#!/bin/bash
#---------------------------------------------------------#
# the script is used to format code
# 1. give code name to format
# can give multi one time
# 2. give directory to format all code file recursive
# it have two arguments:first is the directory to format
# second is the directory to save the backup code files
#---------------------------------------------------------#
# astyle_home=/opt/corp/projects/accessoam/3GPP/cu_nbi_thirdparties/astyle
# astyle_bin=${astyle_home}/bin
function help(){
echo "the script is used to format code.";
echo "usage:astyle_format.sh Util.java";
echo " astyle_format.sh Util.java Log.java ...";
echo " astyle_format.sh /home/ldyang/src /home/ldyang/bak";
echo
exit;
}
function validate(){
if [ "$#" -eq 0 ]; then
help
fi
if [ "$#" -eq 2 ]; then
if [ -d "$1" -a ! -d "$2" ]; then
echo "error arguments.";
help
fi
if [ ! -d "$1" -a -d "$2" ]; then
echo "error arguments.";
help
fi
if [ ! -d "$1" -a ! -d "$2" ]; then
if [ ! -f "$1" -o ! -f "$2" ];then
echo "file not exist.";
help
fi
fi
else
for arg
do
if [ ! -f $arg ];then
echo "file not exist.";
help
fi
done
fi
}
#--------- function clean backup files------------------------------#
function clean(){
indir=$1
outdir=$2
sub=${outdir:0-1}
if [ ! "$sub" = '/' ];then
outdir=$outdir'/';
fi
fileext=".orig"
# USE ONE OF THE FOLLOWING TO COPY OR MOVE THE FILES
#copyfiles=cp
copyfiles=mv
# display the variables
echo
echo "/"$copyfiles/" Artistic Style backup files"
echo "FROM $indir"
echo "TO $outdir"
echo
# validate input directory
if [ ! -d "$indir" ] ; then
echo "Input directory does not exist!"
echo
exit
fi
if [ "$indir" == "$outdir" ]; then
echo "Input and output directories are the same!"
echo
exit
fi
# optional statement to run Artistic Style
# astyle -R "%indir%/*.cpp" "%indir%/*.h"
# if [ $? -ne 0 ] ; then read -sn1 -p "Error executing astyle!"; fi
# variables for fle processing
#echo "processing files..."
fileHasSpaces=false # a file or directory name has spaces
extLength=${#fileext} # length of the file extension
# loop thru the input directory to find the .orig files
# then move the .orig file to the new directory
for file in `find "$indir" -type f -name "*$fileext" ` ; do
# allow spaces in file names for Cygwiin on Windows
# test if this is a continuation line and build $infile
if [ $fileHasSpaces = true ] ; then
infile+=' '$file
else
infile=$file
fi
# test end of string for no file extension
if [ ! "${infile:(-$extLength)}" = $fileext ] ; then
fileHasSpaces=true
continue
fi
fileHasSpaces=false
# echo $infile
# replace input file directory with output directory
# ${string/substring/replacement}
outfile=${infile/$indir/$outdir}
# echo $outfile
# strip filename from back of the output file
# ${string%substring} - /* strips from last '/' to end
outpath=${outfile%/*}
# echo $outpath
# strip filename from back of the output file
# ${string%substring} - /* strips from last '/' to end
outpath=${outfile%/*}
# echo $outpath
# create output directory
[ ! -d "$outpath" ] && mkdir -p "$outpath"
# copy or move the files
$copyfiles -f "$infile" "$outpath"
if [ $? -ne 0 ] ; then
read -sn1 -p "press any key to continue!"
echo
fi
# echo for every 100 files processed
let count++
let mod=count%100
[ $mod -eq 0 ] && echo $count files processed
done
echo $count files processed
echo
}
#---------end function clean backup files------------------------------#
function format_single(){
while [ "$1" ]; do
/opt/corp/projects/accessoam/3GPP/cu_nbi_thirdparties/astyle/bin/astyle "$1"
shift
done
}
function ergodic(){
arg1=$1;
len=${#arg1}
sub=${arg1:0-1}
if [ "$sub" = '/' ];then
arg1=${arg1:0:(len-1)}
fi
for file in `ls $arg1`
do
if [ -d $arg1"/"$file ]
then
ergodic $arg1"/"$file
else
local path=$arg1"/"$file
local name=$file
if [ "${name##*.}" = "java" ]
then
/opt/corp/projects/accessoam/3GPP/cu_nbi_thirdparties/astyle/bin/astyle -r
$path
clean $arg1"/" "$2"
fi
fi
done
}
function format_rec(){
codedir="$1";
bakdir="$2";
ergodic "$codedir" "$bakdir"
}
# call function validate
validate $@;
if [ "$#" -eq 2 ] ; then
if [ -d "$1" ] ; then
if [ -d "$2" ] ; then
format_rec "$1" "$2"
fi
fi
if [ -f "$1" -a -f "$2" ] ;then
format_single "$1" "$2";
fi
fi
if [ "$#" -ne 2 ]; then
if [ -f "$1" ] ;then
format_single $@;
fi
else
validate $@;
fi
shell脚本说明:
首先我SHELL只会一点,所以这个脚本写的比较别扭。然后就是clean函数里面的脚本来自于artistic style网站自带的scripts shell脚本。
qt 使用插件astyle_artistic style (astyle) 的使用配置相关推荐
- qt 使用插件astyle_使用astyle格式化代码
一.基本命令 astyle --style=ansi main.cs (ansi/linux:使用ansi/linux风格格式化main.cs) 了解上面的命令就可以格式化一个文件了,下面来看如何格式 ...
- Qt Creator添加Qt Designer插件
Qt Creator添加Qt Designer插件 添加Qt Designer插件 查找Qt Designer插件 在macOS上配置Qt Designer插件 匹配的构建密钥 添加Qt Design ...
- 20.QT中插件编程
插件编程 插件可以理解为动态库,一种固定接口的动态库.以下摘自网友的理解.代码参考自官方示例. Qt插件本身是动态库,除此之外,它定义了一组专用的接口,从动态库中导出,供 Qt 的插件管理体系 发现和 ...
- 无法初始化Qt平台插件
工具: qt5.6+python3.7.0+pycharm2019.3.3 报错: This application failed to start because no Qt platform pl ...
- pycharm此应用程序无法启动,因为无法初始化qt平台插件
pycharm此应用程序无法启动,因为无法初始化qt平台插件 This application failed to start because no Qt platform plugin could ...
- 此应用程序无法启动,因为没有Qt平台插件可以初始化,重新安装应用程序可能会解决此问题
最近在学GUI编程--PyQt5 结果第一个程序就出现了问题 说没有qt平台插件可以初始化 *而我此时的python虚拟环境是这样的 在这虚拟环境中是有中文的* 然后把python虚拟环境替换成了全英 ...
- 自定义Qt Designer插件
采用创建Qt Designer插件的方式来创建QwBattery类,并将其安装到UI设计器的组件面板里.该类的功能与上篇所讲的QmyBattery类功能一样. 要创建UI设计器插件类,单击Qt Cre ...
- 解决pyqt5 无法初始化Qt平台插件的问题
问题 今天在pycharm安装完pyqt5后 运行实例 发现报如下错误 此应用程序未能启动,因为无法初始化Qt平台插件.重新安装应用程序可能会解决此问题 This application failed ...
- VS Code 安装插件、自定义模板、自定义配置参数、自定义主题、配置参数说明、常用的扩展插件
1. 下载和官网教程 下载地址:https://code.visualstudio.com/ 官方教程:https://code.visualstudio.com/docs 2. 安装插件 安装扩展插 ...
最新文章
- Android---Android 屏幕尺寸与密度
- eeglab中文教程系列(17)-DIPFIT对独立成分进行等价偶极子定位
- linux多点触控软件测试,测试工程师日常工作中高频Linux命令
- 6、宏定义与预处理、函数与函数库
- myeclipse里html添加背景颜色,myeclipse怎么设置主题-设置myeclipse主题背景颜色的教程 - 河东软件园...
- [cloud][sdn] neutron了解
- java关于注释的使用错误的是,java考试练习题
- Verilog奇偶校验_zt
- filezilla linux服务器端,FileZilla Server安装配置教程
- 红外红外传感器电路图及工作原理
- 计算机联锁系统硬件结构,计算机联锁系统各部硬件.ppt
- 树莓派:树莓派的各个引脚
- Word 去除页眉横线
- mysql视图默认校对规则_MySQL 校对规则
- Django的语言模板
- 大龄程序猿的出路在哪里
- 华为 日志服务器 配置文件,华为设置日志服务器配置
- 将字符串小写数字转换为大写数字
- 如何设计一个高并发的秒杀架构?
- 植物大战僵尸(1):实现无限阳光
热门文章
- a标签的使用--发送电子邮件(mailto)
- 给html元素追加style,JS给元素添加样式的2种方法
- Mysql 时间戳转换 FROM_UNIXTIME(unix_timestamp,format)
- python丨制表符丨对齐
- xlwings删除数据_xlwings 操作 excel
- Keras框架下的猫狗识别(一)
- 联想电脑 linux bios设置,联想电脑bios设置图解教程
- Android ScrollView嵌套GridView导致GridView只显示一行item
- TabLayout的基本用法(一)
- 模拟路由器使用距离向量算法更新路由表