代码拉取完成,页面将自动刷新
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)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。