aardio 代码格式化工具

https://gitee.com/pengchenggang/aardio---code-formatting-tool

修改内容

1 代码进行了一定的修改,默认ctrl+t 改成了 ctrl+s

2 原先是通过选择进行格式化,全部保存的时候,会自动全选再保存。逻辑都删除了,改成直接全部格式化保存。这样就不闪了,代码如下。

bug:这个快捷键是全局拦截

为了修复这个bug,只好换个都不用的快捷键,最后选定了 ctrl + `

//aardio代码格式化工具
//风行者 制作 v21.0
//感谢 游戏 提供的beautifier.min.js 和 script2 库源码 import ide;
import gdi;
import winex;
import win.ui;
import win.inputBox;
import web.script.json
import web.script2;
import fonts.fontAwesome; var hwndStatusBar = winex.findEx(ide.getMainHwnd(), , "Afx\:RibbonStatusBar", "");
var hwnd = winex.findEx(hwndStatusBar, , , "aardio代码格式化");
if (hwnd) return; win.modifyStyle(hwndStatusBar, , 0x2000000 /*_WS_CLIPCHILDREN*/ );
/*DSG{{*/
winform = win.form(text="aardio代码格式化";right=19;bottom=20;border="none";exmode="none";max=false;min=false;mode="child";parent=hwndStatusBar)
winform.add(
plus={cls="plus";left=0;top=0;right=20;bottom=23;bgcolor=-28642;color=16777215;font=LOGFONT(h=-16);iconStyle={font=LOGFONT(h=-20;name='FontAwesome')};iconText='\uF121';notify=1;z=1}
)
/*}}*/ winform.plus.skin({
background = {
active = 0xFF0081FF;
default = 0xFF1E90FF;
hover = 0xFF339AFF
};
color = {
default = 0xFFFFFFFF
}
}) var ws = web.script2(); ws.addCode("window=this;");
jsCode = $ "\beautifier.min.js" ws.addCode(jsCode); var opt = {
indent_char = " ";
indent_size = "4";
space_before_conditional = true; //Space before conditional: "if(x)" / "if (x)"
brace_style = "end-expand"; //"collapse","expand","end-expand","none"
keep_array_indentation = true; //Keep array indentation?
end_with_newline = true; //End script and style with newline?
comma_first = false; //Use comma-first list style?
break_chained_methods = false; //Break lines on chained methods?
indent_scripts = "keep"; //HTML <style>, <script> formatting:"keep","normal","separate"
e4x = false; //Support e4x/jsx syntax
unescape_strings = false; // Unescape printable chars encoded as \xNN or \uNNNN?
indent_inner_html = false; //Indent <head> and <body> sections?
jslint_happy = false; // Use JSLint-happy formatting tweaks?
indent_empty_lines = true; //Keep indentation on empty lines?
//Remove all extra newlines: preserve_newlines = false;max_preserve_newlines = "-1";
preserve_newlines = true;
max_preserve_newlines = "2"; //Allow unlimited newlines between tokens: max_preserve_newlines = "0"
wrap_line_length = "0";
} import fsys.table
var fTab = fsys.table("/key.table") winform.plus.oncommand = function(id, event) { // 编辑控件
var codeEditor = ide.getActiveCodeEditor()
if (!codeEditor) return; // 返回编辑代码
var code = ide.getActiveCode()
if (!code) return; var text = codeEditor.selText var formatCode var sSel, eSel = codeEditor.getsel()
if (#text) {
formatCode = ws.json.beautifier.aardio(text, opt);
}
else {
formatCode = ws.json.beautifier.aardio(code, opt);
//codeEditor.selectAll()
}
/*
//space_before_conditional = false; 时使用
if (!opt.space_before_conditional) {
formatCode = string.replace(formatCode, "@@) {", "){")
} */
codeEditor.text = formatCode;
//设置选区文本
//codeEditor.selText = formatCode; codeEditor.setFocus(eSel: sSel);
ide.save()
/*
var path = ide.getActiveDocPath()
if (#path and io.exist(path)) {
//备份
ide.save()
var sp = io.splitpath(path)
fTab.load() if (fTab.path) {
var fpath
if string.endWith(fTab.path, "\") {
fpath = fTab.path
}
else {
fpath = fTab.path + "\"
} string.save(fpath + sp.name + "_old" + sp.ext, code)
}
else {
string.save(sp.dir + sp.name + "_old" + sp.ext, code)
} }
*/ } var intervalId = winform.setInterval(
100,
function(hwnd, msg, id, tick) { var chwnd = winex.findEx(hwndStatusBar, , "@msctls_updown32") if (chwnd) {
var x, y = win.getPos(chwnd) if (x != winform.xtmp) {
winform.setPos(x - winform.width - (85 * gdi.getDpiScale()), 2)
winform.xtmp = x;
winform.redraw();
}
}
}) winform.onClose = function(hwnd, message, wParam, lParam) {
winform.clearInterval(intervalId);
} import win.ui.menu;
winform.plus.wndproc = function(hwnd, message, wParam, lParam) { select (message) {
case 0x205 /*_WM_RBUTTONUP*/ {
//鼠标右键弹起,下面获取坐标
var x, y = win.getMessagePos(lParam);
var menu = win.ui.popmenu(winform);
menu.add("退出", function() {
winform.close()
}) menu.popup(x, y);
return true;
}
}
} import win.ui.tooltip; // 在所有者窗口 winform 上创建 tooltip 提示控件
var tooltipCtrl = win.ui.tooltip(winform); // 添加一个自动模式的控件提示(TOOLINFO 对象,简称 tool )
var toolInfoPlus = tooltipCtrl.addTool(winform.plus, "格式化代码") /*快捷键设置{{*/ if (io.exist("/key.table")) {
fTab.load()
//定义快捷键Ctrl+T
hkid = winform.reghotkey(function(id, mod, vk) {
winform.plus.oncommand();
}, fTab.k, fTab.v);
}
else { inputbox = win.inputBox(winform.hwnd) inputbox.input.close()
inputbox.add({
hotkey = {
cls = "hotkey";
left = 20;
top = 46;
right = 423;
bottom = 71;
dl = 1;
dt = 1;
edge = 1;
password = password;
z = 3
}
})
inputbox.text = "格式化代码快捷键设置"
inputbox.info.text = "请在下面输入快捷键:"
inputbox.hotkey.sethotkey(2, 84) inputbox.btnOk.oncommand = function(id, event) {
if (inputbox.hotkey.gethotkey()) {
var k1, v1 = inputbox.hotkey.gethotkey() // 定义快捷键
hkid = winform.reghotkey(function(id, mod, vk) {
winform.plus.oncommand();
}, k1, v1); //保存值
fTab.mixin(
k = k1; v = v1;);
}
else {
//使用默认快捷键Ctrl+T
hkid = winform.reghotkey(function(id, mod, vk) {
winform.plus.oncommand();
}, 0x2 /*_MOD_CONTROL*/ , 84); //保存值
fTab.mixin(
k = 2; v = 84;);
} inputbox.endModal(); }; inputbox.doModal() } /*}}*/ winform.show()
win.loopMessage();

aardio 代码格式化 自动保存 自定义 ctrl + s bug:这个快捷键是全局拦截的更多相关文章

  1. [转]Xcode的快捷键及代码格式化

    Xcode比较常用的快捷键,特别是红色标注的,很常用.1. 文件CMD + N: 新文件CMD + SHIFT + N: 新项目CMD + O: 打开CMD + S: 保存CMD+OPt+S:保存所有 ...

  2. Xcode 快捷键及代码格式化

    按住apple键点击类名就可以定位到这个类中查看相关定义(在日后的开发中我们会经常这么来做,毕竟要记住iOS开发中所有的API是不现实的,有些API我们可以通过这种方法来查找) PS:下面都是网上百度 ...

  3. Xcode的快捷键及代码格式化

    1. 文件CMD + N: 新文件 CMD + SHIFT + N: 新项目CMD + O: 打开 CMD + S: 保存 CMD+OPt+S:保存所有文件 CMD + SHIFT + S: 另存为 ...

  4. phpstorm2019.1 实现保存(ctrl+s)同时格式化代码

    1.选择Edit(编辑)->Macros(宏)->Start Macro Recording(开始录制宏),如下图: 2.直接按想要录制的快捷键,先按Ctrl+ALT+L,然后键盘按Ctr ...

  5. Myeclipse学习总结(3)——Myeclipse中的代码格式化、注释模板及保存时自动格式化

    设置Myeclipse中的代码格式化.注释模板及保存时自动格式化 1:设置注释的模板: 下载此模板:  codetemplates.xml This XML file does not appear ...

  6. vscode保存代码,自动按照eslint规范格式化代码设置

    # vscode保存代码,自动按照eslint规范格式化代码设置 编辑器代码风格一致,是前端代码规范的一部分.同一个项目,或者同一个小组,保持代码风格一致很必要.就拿vue项目来说,之前做的几个项目, ...

  7. vscode代码格式化快捷键及保存时自动格式化

    一.实现vs code中代码格式化快捷键:[Shift]+[Alt]+ F 二.实现保存时自动代码格式化: 1)文件 ------.>[首选项]---------->[设置]: 2)搜索  ...

  8. prettier+ts+eslint+vscode配置代码保存自动格式化,自动remove unsed declaration,delete no-unused-imports

    每天都要开心(▽)哇: 以这个项目为案例 下面是项目的基本情况 What would you like to build? › App with Quasar CLI, let's go! Proje ...

  9. 超详细的Xcode代码格式化教程,可自定义样式

    为什么要格式化代码 当团队内有多人开发的时候,每个人写的代码格式都有自己的喜好,也可能会忙着写代码而忽略了格式的问题. 在之前,我们可能会写完代码后,再一点一点去调格式,很浪费时间. 有了ClangF ...

  10. 超详细的Xcode代码格式化教程,可自定义样式。

    超详细的Xcode代码格式化教程,可自定义样式. 为什么要格式化代码 当团队内有多人开发的时候,每个人写的代码格式都有自己的喜好,也可能会忙着写代码而忽略了格式的问题.在之前,我们可能会写完代码后,再 ...

随机推荐

  1. Nginx相关快速入门,负载均衡等

    ​​​​​​​快速入门Nginx[正向反向代理,负载均衡的概念,学会Nginx的安装和常用命令,并在实际中去应用Nginx] - 知乎 1.背景介绍:当用户使用较少时,低并发的情况下,使用内部toma ...

  2. SpringBoot分布式任务中间件开发 附视频讲解 (手把手教你开发和使用中间件)

    作者:小傅哥 博客:https://bugstack.cn 沉淀.分享.成长,让自己和他人都能有所收获! 分布式任务DcsSchedule中间件,Github地址:https://github.com ...

  3. 物色到的 c# 模拟 http post get 请求 做下笔记

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...

  4. scrapy抓取校花网图片

    一:基础版(抓取首页图片) 爬虫py文件代码: 1 # -*- coding: utf-8 -*- 2 import scrapy 3 import sys 4 import io 5 from sc ...

  5. (转)时代的见证:集成更新的Windows 7旗舰版、专业版镜像

    制作缘起:微软曾于2019年提供过两份内部集成更新的英文旗舰版.专业版镜像(参见:集成IE11+最新补丁:微软新版Windows 7镜像泄露),方便用户安装,缩短更新过程.经我们下载安装研究发现,这两 ...

  6. Dash 2.15版本新特性介绍

    本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/dash-master 大家好我是费老师,Dash不久前发布了其2.15.0版本,新增了一些实用的特性 ...

  7. PHP 会话(Session)实现用户登陆功能

    PHP 会话(Session)实现用户登陆功能 Session 的工作机制是:为每个访客创建一个唯一的 id (UID),并基于这个 UID 来存储变量.UID 存储在 cookie 中,或者通过 U ...

  8. 解决每次 git pull/push 时都需要输入账号和密码的问题

    问题 在提交代码或者拉取代码的时候,如果每次git都要输入用户名密码 解决方法 1. 终端输入 git config --global credential.helper store 2. 在git ...

  9. Linux操作系统下查询NVMe盘符、Slot ID和Bus ID的对应关系

    在拆卸NVMe PCIe 固态硬盘时,需要查询Linux操作系统下NVMe盘符.Slot ID和Bus ID的对应关系. 操作步骤打开操作系统命令终端.依次执行cd /sys/bus/pci/slot ...

  10. 基于keras的残差网络

    1 前言 理论上,网络层数越深,拟合效果越好.但是,层数加深也会导致梯度消失或梯度爆炸现象产生.当网络层数已经过深时,深层网络表现为"恒等映射".实践表明,神经网络对残差的学习比对 ...