This commit is contained in:
Dongdong Zhou 2018-11-27 16:10:39 +00:00
parent 135900c1f2
commit ad8ca95267
3 changed files with 19 additions and 2 deletions

View File

@ -2,19 +2,29 @@ package main
import (
"net/http"
"os"
_ "net/http/pprof"
"github.com/crane-editor/crane/editor"
"github.com/crane-editor/crane/log"
)
func main() {
os.Setenv("PATH", "/Users/Lulu/.cargo/bin:/Users/Lulu/go/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/local/sbin")
go func() {
http.ListenAndServe("localhost:6020", nil)
}()
file, err := os.OpenFile("/Users/Lulu/.crane/log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
log.Fatal(err)
}
log.Base().SetOutput(file)
editor, err := editor.NewEditor()
if err != nil {
log.Errorln(err)
return
}
log.Infoln("now run editor")
editor.Run()
}

View File

@ -147,6 +147,11 @@ func NewEditor() (*Editor, error) {
if err == nil {
e.homeDir = user.HomeDir
}
log.Infoln("current wd is", e.cwd)
if e.cwd == "/" {
e.cwd = e.homeDir
os.Chdir(e.homeDir)
}
loadKeymap(e)
e.initSpecialKeys()
e.states = newStates(e)
@ -306,7 +311,9 @@ func NewEditor() (*Editor, error) {
e.xi.Conn.Close()
})
e.clipboard = e.app.Clipboard()
log.Infoln("init main window")
e.initMainWindow()
log.Infoln("init main window done")
return e, nil
}
@ -490,7 +497,7 @@ func (e *Editor) initMainWindow() {
mainSplitter.AddWidget(e.diagnosticsPanel.view)
e.mainSplitter = mainSplitter
e.diagnosticsPanel.height = 250
e.mainSplitter.SetSizes([]int{ e.height - e.diagnosticsPanel.height,e.diagnosticsPanel.height,})
e.mainSplitter.SetSizes([]int{e.height - e.diagnosticsPanel.height, e.diagnosticsPanel.height})
e.mainSplitter.ConnectSplitterMoved(func(pos, index int) {
e.diagnosticsPanel.view.Hide()
e.diagnosticsPanel.view.Show()

View File

@ -43,7 +43,7 @@ func NewPlugin() *Plugin {
// Run is
func (p *Plugin) Run() {
file, err := os.OpenFile("/tmp/log", os.O_APPEND|os.O_WRONLY, 0666)
file, err := os.OpenFile("/tmp/log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
log.Fatal(err)
}