1 Star 5 Fork 0

rocket049/super-run

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
exam.go 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
package main
/*
#cgo pkg-config: qtermwidget5 Qt5Widgets Qt5Gui Qt5Core
#include <stdlib.h>
extern void* createTermWidget(int startnow, void * parent);
extern void termSendText(void *p,char *s);
extern void termSetMinimumHeight(void *p,int minh);
extern char *termSelectedText(void *p);
extern void termConnectFinish2Close(void *p);
extern void termSetTermFont(void *p, void *f);
extern void termSendKeyEvent(void *p, void *e);
*/
import "C"
import (
"strings"
"unsafe"
)
func getQTermPtr(p unsafe.Pointer) uintptr {
t := C.createTermWidget(1, p)
return uintptr(t)
}
func termChangeDir(p uintptr, d string) {
arg := strings.Replace(d, "\"", "\\\"", 0)
termSendText(p, "cd \""+arg+"\"\n")
}
func termSendText(p uintptr, s string) {
C.termSendText(unsafe.Pointer(p), C.CString(s))
}
func termSetMiniHeight(p uintptr, h int) {
C.termSetMinimumHeight(unsafe.Pointer(p), C.int(h))
}
func termSelectedText(p uintptr) string {
return C.GoString(C.termSelectedText(unsafe.Pointer(p)))
}
func termConnectFinish2Close(p uintptr) {
C.termConnectFinish2Close(unsafe.Pointer(p))
}
func buildCmdLine(prog string, envs, args []string) string {
var cmd = []string{}
for _, v := range envs {
cmd = append(cmd, v)
}
cmd = append(cmd, prog)
for _, v := range args {
arg := strings.Replace(v, "\"", "\\\"", 0)
cmd = append(cmd, "\""+arg+"\"")
}
return strings.Join(cmd, " \\\n") + "\n"
}
func termSetTermFont(p uintptr, f unsafe.Pointer) {
C.termSetTermFont(unsafe.Pointer(p), f)
}
func termSendKeyEvent(p uintptr, e unsafe.Pointer) {
C.termSendKeyEvent(unsafe.Pointer(p), e)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rocket049/super-run.git
git@gitee.com:rocket049/super-run.git
rocket049
super-run
super-run
master

搜索帮助