mirror of
https://github.com/felixangell/phi.git
synced 2024-10-10 22:58:22 +03:00
handle alt f4; buffer pane over buffers
This commit is contained in:
parent
c9d915a7af
commit
faa0d58d3f
@ -549,6 +549,14 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// temporary for the really slow
|
||||||
|
// exit times with alt f4...
|
||||||
|
if ALT_DOWN {
|
||||||
|
if key == sdl.K_F4 {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch key {
|
switch key {
|
||||||
case sdl.K_CAPSLOCK:
|
case sdl.K_CAPSLOCK:
|
||||||
CAPS_LOCK = !CAPS_LOCK
|
CAPS_LOCK = !CAPS_LOCK
|
||||||
@ -1051,6 +1059,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
|||||||
a, colorStack = int32(colorStack[len(colorStack)-1]), colorStack[:len(colorStack)-1]
|
a, colorStack = int32(colorStack[len(colorStack)-1]), colorStack[:len(colorStack)-1]
|
||||||
ctx.SetColor(strife.HexRGB(a))
|
ctx.SetColor(strife.HexRGB(a))
|
||||||
}
|
}
|
||||||
|
|
||||||
last_w, last_h = ctx.String(string(char), b.ex+(rx+((x_col-1)*last_w)), b.ey+(ry+(y_col*last_h)))
|
last_w, last_h = ctx.String(string(char), b.ex+(rx+((x_col-1)*last_w)), b.ey+(ry+(y_col*last_h)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
gui/buffer_pane.go
Normal file
26
gui/buffer_pane.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package gui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/felixangell/strife"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BufferPane struct {
|
||||||
|
BaseComponent
|
||||||
|
Buff *Buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBufferPane(buff *Buffer) *BufferPane {
|
||||||
|
return &BufferPane{
|
||||||
|
BaseComponent{},
|
||||||
|
buff,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BufferPane) OnUpdate() bool {
|
||||||
|
b.Buff.processInput(nil)
|
||||||
|
return b.Buff.OnUpdate()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BufferPane) OnRender(ctx *strife.Renderer) {
|
||||||
|
b.Buff.OnRender(ctx)
|
||||||
|
}
|
43
gui/view.go
43
gui/view.go
@ -13,7 +13,7 @@ type View struct {
|
|||||||
BaseComponent
|
BaseComponent
|
||||||
|
|
||||||
conf *cfg.TomlConfig
|
conf *cfg.TomlConfig
|
||||||
buffers map[int]*Buffer
|
buffers map[int]*BufferPane
|
||||||
focusedBuff int
|
focusedBuff int
|
||||||
commandPalette *CommandPalette
|
commandPalette *CommandPalette
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ type View struct {
|
|||||||
func NewView(width, height int, conf *cfg.TomlConfig) *View {
|
func NewView(width, height int, conf *cfg.TomlConfig) *View {
|
||||||
view := &View{
|
view := &View{
|
||||||
conf: conf,
|
conf: conf,
|
||||||
buffers: map[int]*Buffer{},
|
buffers: map[int]*BufferPane{},
|
||||||
}
|
}
|
||||||
|
|
||||||
view.Translate(width, height)
|
view.Translate(width, height)
|
||||||
@ -63,8 +63,8 @@ func (n *View) focusPalette(buff *Buffer) {
|
|||||||
|
|
||||||
func (n *View) UnfocusBuffers() {
|
func (n *View) UnfocusBuffers() {
|
||||||
// clear focus from buffers
|
// clear focus from buffers
|
||||||
for _, buff := range n.buffers {
|
for _, buffPane := range n.buffers {
|
||||||
buff.SetFocus(false)
|
buffPane.Buff.SetFocus(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +87,9 @@ func (n *View) removeBuffer(index int) {
|
|||||||
bufferWidth := n.w / len(n.buffers)
|
bufferWidth := n.w / len(n.buffers)
|
||||||
|
|
||||||
// translate all the components accordingly.
|
// translate all the components accordingly.
|
||||||
for i, buff := range n.buffers {
|
for i, buffPane := range n.buffers {
|
||||||
buff.Resize(bufferWidth, n.h)
|
buffPane.Buff.Resize(bufferWidth, n.h)
|
||||||
buff.SetPosition(bufferWidth*i, 0)
|
buffPane.Buff.SetPosition(bufferWidth*i, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,15 +110,15 @@ func (n *View) ChangeFocus(dir int) {
|
|||||||
n.focusedBuff = 0
|
n.focusedBuff = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
prevBuff.SetFocus(false)
|
prevBuff.Buff.SetFocus(false)
|
||||||
if buff, ok := n.buffers[n.focusedBuff]; ok {
|
if buffPane, ok := n.buffers[n.focusedBuff]; ok {
|
||||||
buff.SetFocus(true)
|
buffPane.Buff.SetFocus(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *View) getCurrentBuff() *Buffer {
|
func (n *View) getCurrentBuff() *Buffer {
|
||||||
if buff, ok := n.buffers[n.focusedBuff]; ok {
|
if buffPane, ok := n.buffers[n.focusedBuff]; ok {
|
||||||
return buff
|
return buffPane.Buff
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -144,9 +144,8 @@ func (n *View) OnUpdate() bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if buff, ok := n.buffers[n.focusedBuff]; ok {
|
if buffPane, ok := n.buffers[n.focusedBuff]; ok {
|
||||||
buff.processInput(nil)
|
buffPane.OnUpdate()
|
||||||
buff.OnUpdate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
n.commandPalette.OnUpdate()
|
n.commandPalette.OnUpdate()
|
||||||
@ -155,8 +154,8 @@ func (n *View) OnUpdate() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *View) OnRender(ctx *strife.Renderer) {
|
func (n *View) OnRender(ctx *strife.Renderer) {
|
||||||
for _, buffer := range n.buffers {
|
for _, buffPane := range n.buffers {
|
||||||
buffer.OnRender(ctx)
|
buffPane.OnRender(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
n.commandPalette.OnRender(ctx)
|
n.commandPalette.OnRender(ctx)
|
||||||
@ -185,13 +184,13 @@ func (n *View) AddBuffer() *Buffer {
|
|||||||
var bufferWidth int
|
var bufferWidth int
|
||||||
bufferWidth = n.w / (c.index + 1)
|
bufferWidth = n.w / (c.index + 1)
|
||||||
|
|
||||||
n.buffers[c.index] = c
|
n.buffers[c.index] = NewBufferPane(c)
|
||||||
n.focusedBuff = c.index
|
n.focusedBuff = c.index
|
||||||
|
|
||||||
// translate all the components accordingly.
|
// translate all the buffers accordingly.
|
||||||
for i, buff := range n.buffers {
|
for i, buffPane := range n.buffers {
|
||||||
buff.Resize(bufferWidth, n.h)
|
buffPane.Buff.Resize(bufferWidth, n.h)
|
||||||
buff.SetPosition(bufferWidth*i, 0)
|
buffPane.Buff.SetPosition(bufferWidth*i, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c
|
return c
|
||||||
|
Loading…
Reference in New Issue
Block a user