Exemplo n.º 1
0
Arquivo: main.go Projeto: ochz/lime
func main() {
	flag.Parse()

	log4go.AddFilter("file", log4go.FINEST, log4go.NewFileLogWriter("debug.log", *rotateLog))
	defer func() {
		py.NewLock()
		py.Finalize()
	}()

	if err := termbox.Init(); err != nil {
		log4go.Exit(err)
	}
	defer func() {
		termbox.Close()
		log4go.Debug(util.Prof)
		if err := recover(); err != nil {
			log4go.Crash(err)
		}
	}()

	var t tbfe
	t.dorender = make(chan bool, render_chan_len)
	t.layout = make(map[*backend.View]layout)
	t.loop()
}
Exemplo n.º 2
0
Arquivo: dht.go Projeto: screscent/dht
func randNodeId() []byte {
	b := make([]byte, 20)
	if _, err := rand.Read(b); err != nil {
		l4g.Exit("nodeId rand:", err)
	}
	return b
}
Exemplo n.º 3
0
func main() {
	if err := termbox.Init(); err != nil {
		log4go.Exit(err)
	}

	var t tbfe
	t.visibleregion = make(map[*backend.View]primitives.Region)
	t.loop()
}
Exemplo n.º 4
0
func main() {
	bin.IncludeHelp()
	err := bin.Run()
	// TODO: HACK! See https://code.google.com/p/log4go/issues/detail?id=8
	// Give log4go a chance to catch up and print all its messages
	time.Sleep(time.Second)
	if err != nil {
		log4go.Exit(err)
	}
}
Exemplo n.º 5
0
func main() {
	log4go.AddFilter("file", log4go.FINEST, log4go.NewFileLogWriter("debug.log", true))
	defer func() {
		py.NewLock()
		py.Finalize()
	}()

	if err := termbox.Init(); err != nil {
		log4go.Exit(err)
	}

	var t tbfe
	t.dorender = make(chan bool, render_chan_len)
	t.layout = make(map[*backend.View]layout)
	go t.renderthread()
	t.loop()
}
Exemplo n.º 6
0
func (t *tbfe) loop() {
	qml.Init(nil)
	engine := qml.NewEngine()

	engine.Context().SetVar("lines", t)
	engine.Context().SetVar("frontend", t)
	engine.Context().SetVar("editor", backend.GetEditor())

	backend.OnNew.Add(func(v *backend.View) {
		fv := &frontendView{bv: v}
		v.Buffer().AddCallback(fv.bufferChanged)
		v.Settings().AddOnChange("blah", func(name string) {
			if name == "lime.syntax.updated" {
				// force redraw, as the syntax regions might have changed...
				for i := range fv.FormattedLine {
					fv.formatLine(i)
				}
			}
		})

		t.views[v] = fv
		t.Len = len(t.views)
		qml.Changed(t, &t.Len)
	})

	ed := backend.GetEditor()
	ed.SetFrontend(t)
	ed.LogInput(false)
	ed.LogCommands(false)
	c := ed.Console()

	t.Console = &frontendView{bv: c}
	c.Buffer().AddCallback(t.Console.bufferChanged)

	if sc, err := textmate.LoadTheme("../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"); err != nil {
		log4go.Error(err)
	} else {
		scheme = sc
	}

	defer func() {
		fmt.Println(util.Prof)
	}()

	w := ed.NewWindow()
	v := w.OpenFile("main.go", 0)
	v.Settings().Set("trace", true)
	v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")
	c.Buffer().AddCallback(t.scroll)

	sel := v.Sel()
	sel.Clear()
	sel.Add(Region{0, 0})

	{
		w, h := 800, 600
		t.lock.Lock()
		t.layout[v] = layout{0, 0, w, h - console_height - 1, Region{}, 0}
		t.layout[c] = layout{0, h - console_height + 1, w, console_height - 5, Region{}, 0}
		t.lock.Unlock()
		t.Show(v, Region{1, 1})
	}
	t.Show(v, Region{100, 100})
	t.Show(v, Region{1, 1})
	//	t.Len, _ = v.Buffer().RowCol(v.Buffer().Size())

	ed.Init()
	sublime.Init()

	component, err := engine.LoadFile("main.qml")
	if err != nil {
		log4go.Exit(err)
	}
	window := component.CreateWindow(nil)
	window.Show()

	log4go.Debug("Done")
	window.Wait()
}
Exemplo n.º 7
0
func (t *tbfe) loop() {
	qml.Init(nil)
	engine := qml.NewEngine()

	engine.Context().SetVar("lines", t)
	engine.Context().SetVar("frontend", t)
	engine.Context().SetVar("editor", backend.GetEditor())

	backend.OnNew.Add(func(v *backend.View) {
		fv := &frontendView{bv: v}
		v.Buffer().AddCallback(fv.bufferChanged)
		v.Settings().AddOnChange("blah", func(name string) {
			if name == "lime.syntax.updated" {
				// force redraw, as the syntax regions might have changed...
				for i := range fv.FormattedLine {
					fv.formatLine(i)
				}
			}
		})

		fv.Title.Text = v.Buffer().FileName()
		if len(fv.Title.Text) == 0 {
			fv.Title.Text = "untitled"
		}

		w2 := t.windows[v.Window()]
		w2.views = append(w2.views, fv)
		w2.Len = len(w2.views)
		t.qmlChanged(w2, &w2.Len)
	})

	backend.OnLoad.Add(func(v *backend.View) {
		w2 := t.windows[v.Window()]
		i := 0
		for i, _ = range w2.views {
			if w2.views[i].bv == v {
				break
			}
		}
		v2 := w2.views[i]
		v2.Title.Text = v.Buffer().FileName()
		t.qmlChanged(v2, &v2.Title)
	})

	ed := backend.GetEditor()
	ed.SetFrontend(t)
	ed.LogInput(false)
	ed.LogCommands(false)
	c := ed.Console()
	t.Console = &frontendView{bv: c}
	c.Buffer().AddCallback(t.Console.bufferChanged)
	c.Buffer().AddCallback(t.scroll)

	component, err := engine.LoadFile("main.qml")
	if err != nil {
		log4go.Exit(err)
	}

	wg := sync.WaitGroup{}
	backend.OnNewWindow.Add(func(w *backend.Window) {
		wg.Add(1)
		fw := &frontendWindow{bw: w, window: component.CreateWindow(nil)}
		t.windows[w] = fw
		fw.window.Show()
		fw.window.Set("myWindow", fw)

		go func() {
			fw.window.Wait()
			wg.Done()
		}()
	})

	// TODO: should be done backend side
	if sc, err := textmate.LoadTheme("../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"); err != nil {
		log4go.Error(err)
	} else {
		scheme = sc
	}

	defer func() {
		fmt.Println(util.Prof)
	}()

	w := ed.NewWindow()
	v := w.OpenFile("main.go", 0)
	// TODO: should be done backend side
	v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")
	v = w.OpenFile("../../backend/editor.go", 0)
	// TODO: should be done backend side
	v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")

	ed.Init()
	sublime.Init()
	wg.Wait()
}
Exemplo n.º 8
0
Arquivo: main.go Projeto: nicecai/lime
func (t *tbfe) loop() {
	qml.Init(nil)
	engine := qml.NewEngine()

	engine.Context().SetVar("lines", t)
	engine.Context().SetVar("frontend", t)
	engine.Context().SetVar("editor", backend.GetEditor())

	backend.OnNew.Add(func(v *backend.View) {
		v.Settings().AddOnChange("lime.frontend.html.render", func(name string) { t.dirty = true })
	})
	backend.OnModified.Add(func(v *backend.View) {
		t.dirty = true
	})
	backend.OnSelectionModified.Add(func(v *backend.View) {
		t.dirty = true
	})

	ed := backend.GetEditor()
	ed.SetFrontend(t)
	ed.LogInput(false)
	ed.LogCommands(false)
	c := ed.Console()
	if sc, err := textmate.LoadTheme("../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"); err != nil {
		log4go.Error(err)
	} else {
		scheme = sc
	}

	defer func() {
		fmt.Println(util.Prof)
	}()

	w := ed.NewWindow()
	v := w.OpenFile("main.go", 0)
	v.Settings().Set("trace", true)
	v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")
	c.Buffer().AddCallback(t.scroll)

	sel := v.Sel()
	sel.Clear()
	sel.Add(Region{0, 0})

	{
		w, h := 800, 600
		t.lock.Lock()
		t.layout[v] = layout{0, 0, w, h - console_height - 1, Region{}, 0}
		t.layout[c] = layout{0, h - console_height + 1, w, console_height - 5, Region{}, 0}
		t.lock.Unlock()
		t.Show(v, Region{1, 1})
	}
	t.Show(v, Region{100, 100})
	t.Show(v, Region{1, 1})
	t.Len, _ = v.Buffer().RowCol(v.Buffer().Size())

	ed.Init()
	sublime.Init()

	component, err := engine.LoadFile("main.qml")
	if err != nil {
		log4go.Exit(err)
	}
	window := component.CreateWindow(nil)
	window.Show()
	qml.Changed(t, &t.Len)

	log4go.Debug("Done")
	window.Wait()
}