mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
添加c、c#、wsl支持
This commit is contained in:
parent
528c60825f
commit
21d2f52ee9
@ -133,6 +133,18 @@ let programs = {
|
|||||||
argv: '',
|
argv: '',
|
||||||
ext: 'php'
|
ext: 'php'
|
||||||
},
|
},
|
||||||
|
c: {
|
||||||
|
bin: 'gcc',
|
||||||
|
argv: '-o',
|
||||||
|
ext: 'c',
|
||||||
|
codec: utools.isWindows() ? 'gbk' : ''
|
||||||
|
},
|
||||||
|
csharp: {
|
||||||
|
bin: 'C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc.exe',
|
||||||
|
argv: '/Nologo',
|
||||||
|
ext: 'cs',
|
||||||
|
codec: 'gbk'
|
||||||
|
},
|
||||||
lua: {
|
lua: {
|
||||||
bin: 'lua',
|
bin: 'lua',
|
||||||
argv: '',
|
argv: '',
|
||||||
@ -289,7 +301,7 @@ let showCustomize = () => {
|
|||||||
<option value="ignore">隐藏并忽略输出</option>
|
<option value="ignore">隐藏并忽略输出</option>
|
||||||
<option value="text">显示纯文本输出</option>
|
<option value="text">显示纯文本输出</option>
|
||||||
<option value="html">显示html格式的输出</option>
|
<option value="html">显示html格式的输出</option>
|
||||||
<option value="terminal" id="showInTerm">在终端显示输出</option>
|
<option value="terminal" id="showInTerm" disabled>在终端显示输出</option>
|
||||||
<option value="clip">复制到剪贴板</option>
|
<option value="clip">复制到剪贴板</option>
|
||||||
<option value="send">发送到活动窗口</option>
|
<option value="send">发送到活动窗口</option>
|
||||||
<option value="notice">发送系统通知</option>
|
<option value="notice">发送系统通知</option>
|
||||||
@ -485,18 +497,19 @@ let programCheck = () => {
|
|||||||
case 'custom':
|
case 'custom':
|
||||||
$('.customscript').show();
|
$('.customscript').show();
|
||||||
$('.simulation').hide();
|
$('.simulation').hide();
|
||||||
$('#showInTerm').show()
|
$('#showInTerm').prop("disabled", false);
|
||||||
break;
|
break;
|
||||||
case 'simulation':
|
case 'simulation':
|
||||||
$('.simulation').show();
|
$('.simulation').show();
|
||||||
$('.customscript').hide();
|
$('.customscript').hide();
|
||||||
$('#showInTerm').hide()
|
$('#showInTerm').prop("disabled", true);
|
||||||
mode = 'javascript';
|
mode = 'javascript';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$('.customscript').hide();
|
$('.customscript').hide();
|
||||||
$('.simulation').hide();
|
$('.simulation').hide();
|
||||||
$('#showInTerm').show()
|
$('#showInTerm').prop("disabled", false);
|
||||||
|
(mode == 'csharp' || mode == 'c') && (mode = 'text/x-' + mode)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
window.editor.setOption("mode", mode);
|
window.editor.setOption("mode", mode);
|
||||||
|
BIN
src/logo/c.png
Normal file
BIN
src/logo/c.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
src/logo/csharp.png
Normal file
BIN
src/logo/csharp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
@ -448,17 +448,31 @@ runCodeFile = (cmd, option, terminal, callback) => {
|
|||||||
// 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
|
// 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
|
||||||
if (ext == 'bat' || ext == 'ps1') cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), 'GBK');
|
if (ext == 'bat' || ext == 'ps1') cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), 'GBK');
|
||||||
fs.writeFileSync(script, cmd);
|
fs.writeFileSync(script, cmd);
|
||||||
var argvs = [script]
|
// var argvs = [script]
|
||||||
if (argv) {
|
// if (argv) {
|
||||||
argvs = argv.split(' ')
|
// argvs = argv.split(' ')
|
||||||
argvs.push(script);
|
// argvs.push(script);
|
||||||
|
// }
|
||||||
|
var child, cmdline
|
||||||
|
if (bin.slice(-7) == 'csc.exe') {
|
||||||
|
cmdline = `pushd "${path.dirname(script)}" && ${bin} ${argv} "${script}" && "${script.slice(0, -2) + 'exe'}"`
|
||||||
|
} else if (bin == 'gcc') {
|
||||||
|
var suffix = utools.isWindows() ? '.exe' : ''
|
||||||
|
cmdline = `pushd "${path.dirname(script)}" && ${bin} ${argv} ${script.slice(0, -2)} "${script}" && "${script.slice(0, -2) + suffix}"`
|
||||||
|
} else if (utools.isWindows() && bin == 'bash') {
|
||||||
|
cmdline = `${bin} ${argv} "${script.replace(/\\/g, '/').replace(/C:/i, '/mnt/c')}"`
|
||||||
|
} else {
|
||||||
|
cmdline = `${bin} ${argv} "${script}"`
|
||||||
}
|
}
|
||||||
var child;
|
|
||||||
if (bin) {
|
|
||||||
// 在终端中输出
|
// 在终端中输出
|
||||||
if (terminal) {
|
if (terminal) {
|
||||||
if (utools.isWindows()) {
|
if (utools.isWindows()) {
|
||||||
child = child_process.spawn(`start cmd /k ${bin} ${argv} "${script}"`, { encoding: 'buffer', shell: true })
|
if (bin.slice(-7) == 'csc.exe' || bin == 'gcc') {
|
||||||
|
cmdline = cmdline.split("&&")
|
||||||
|
cmdline = cmdline[0] + "&&" + cmdline[1] + "&& start cmd /k " + cmdline[2]
|
||||||
|
} else {
|
||||||
|
cmdline = `start cmd /k ${cmdline}`
|
||||||
|
}
|
||||||
} else if(utools.isMacOs()){
|
} else if(utools.isMacOs()){
|
||||||
var appleScript = `if application "Terminal" is running then
|
var appleScript = `if application "Terminal" is running then
|
||||||
tell application "Terminal"
|
tell application "Terminal"
|
||||||
@ -473,20 +487,12 @@ runCodeFile = (cmd, option, terminal, callback) => {
|
|||||||
activate
|
activate
|
||||||
end tell
|
end tell
|
||||||
end if`;
|
end if`;
|
||||||
child = child_process.spawn('osascript', ['-e', appleScript], { encoding: 'buffer' })
|
cmdline = `osascript -e '${appleScript}'`
|
||||||
} else {
|
} else {
|
||||||
return message('Linux 不支持在终端输出')
|
return message('Linux 不支持在终端输出')
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
child = child_process.spawn(bin, argvs, { encoding: 'buffer' })
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (terminal) {
|
|
||||||
child = child_process.spawn(`start cmd /k "${script}"`, { encoding: 'buffer', shell: true })
|
|
||||||
} else {
|
|
||||||
child = child_process.spawn(script, { encoding: 'buffer' })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
child = child_process.spawn(cmdline, { encoding: 'buffer', shell: true })
|
||||||
// var chunks = [],
|
// var chunks = [],
|
||||||
// err_chunks = [];
|
// err_chunks = [];
|
||||||
child.stdout.on('data', chunk => {
|
child.stdout.on('data', chunk => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user