mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 15:55:25 +03:00
make everything run!
fixed a few minor issues where i changed the library and there were some breaking changes. everything now compiles and the editor will now run and close properly, still no key input but events are somewhat properly handled.
This commit is contained in:
parent
5ad1c514b4
commit
0756852058
@ -101,6 +101,11 @@ func (b *Buffer) processTextInput() {
|
||||
}
|
||||
|
||||
func (b *Buffer) processActionKey() {
|
||||
// we dont process key input so
|
||||
// these are a bunch of stupid dummy case statements but
|
||||
// the logic for them should work! we just need to handle
|
||||
// key events which hasn't been implemented properly in the
|
||||
// strife library yet.
|
||||
switch {
|
||||
case 2 == 6:
|
||||
initial_x := b.curs.x
|
||||
|
44
main.go
44
main.go
@ -22,7 +22,7 @@ type NateEditor struct {
|
||||
func (n *NateEditor) init(cfg *cfg.TomlConfig) {
|
||||
n.AddComponent(gui.NewView(800, 600, cfg))
|
||||
|
||||
font, err := strife.LoadFont("./res/firacode.ttf")
|
||||
font, err := strife.LoadFont("./res/firacode.ttf", 14)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -42,29 +42,29 @@ func (n *NateEditor) update() {
|
||||
}
|
||||
|
||||
func (n *NateEditor) render(ctx *strife.Renderer) {
|
||||
ctx.Clear()
|
||||
|
||||
ctx.SetFont(n.defaultFont)
|
||||
|
||||
for _, child := range n.GetComponents() {
|
||||
gui.Render(child, ctx)
|
||||
}
|
||||
|
||||
ctx.Display()
|
||||
}
|
||||
|
||||
func main() {
|
||||
config := cfg.Setup()
|
||||
|
||||
windowWidth, windowHeight := 800, 600
|
||||
window, err := strife.CreateRenderWindow(windowWidth, windowHeight, &strife.RenderConfig{
|
||||
Alias: true,
|
||||
Accelerated: false,
|
||||
VerticalSync: false,
|
||||
ww, wh := 800, 600
|
||||
window := strife.SetupRenderWindow(ww, wh, strife.DefaultConfig())
|
||||
window.SetTitle("Hello world!")
|
||||
window.SetResizable(true)
|
||||
window.Create()
|
||||
|
||||
window.HandleEvents(func (evt strife.StrifeEvent) {
|
||||
switch evt.(type) {
|
||||
case *strife.CloseEvent:
|
||||
window.Close()
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
size := "16"
|
||||
@ -83,7 +83,8 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
window.SetIcon(icon)
|
||||
window.SetIconImage(icon)
|
||||
defer icon.Destroy()
|
||||
}
|
||||
|
||||
editor := &NateEditor{running: true}
|
||||
@ -92,9 +93,20 @@ func main() {
|
||||
timer := strife.CurrentTimeMillis()
|
||||
num_frames := 0
|
||||
|
||||
for !window.CloseRequested() {
|
||||
for {
|
||||
window.PollEvents()
|
||||
if window.CloseRequested() {
|
||||
break
|
||||
}
|
||||
|
||||
editor.update()
|
||||
editor.render(window.GetRenderContext())
|
||||
|
||||
{
|
||||
ctx := window.GetRenderContext()
|
||||
ctx.Clear()
|
||||
editor.render(ctx)
|
||||
ctx.Display()
|
||||
}
|
||||
num_frames += 1
|
||||
|
||||
if strife.CurrentTimeMillis()-timer > 1000 {
|
||||
|
Loading…
Reference in New Issue
Block a user