mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 15:55:25 +03:00
re-implemented close_buffer; fixed highlight line flickering
This commit is contained in:
parent
445d645ab9
commit
e6fa391b06
@ -926,7 +926,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
|||||||
highlightLinePosY := ey + (ry + b.curs.ry*last_h) - (b.cam.y * last_h)
|
highlightLinePosY := ey + (ry + b.curs.ry*last_h) - (b.cam.y * last_h)
|
||||||
highlightLinePosX := ex + rx
|
highlightLinePosX := ex + rx
|
||||||
|
|
||||||
ctx.Rect(highlightLinePosX, highlightLinePosY, b.w, last_h, strife.Fill)
|
ctx.Rect(highlightLinePosX, highlightLinePosY, b.w-ex, last_h, strife.Fill)
|
||||||
}
|
}
|
||||||
|
|
||||||
var visibleLines int = 50
|
var visibleLines int = 50
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
func CloseBuffer(b *Buffer) bool {
|
func CloseBuffer(b *Buffer) bool {
|
||||||
|
view := b.parent
|
||||||
|
view.ChangeFocus(-1)
|
||||||
|
view.removeBuffer(b.index)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
25
gui/view.go
25
gui/view.go
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/felixangell/phi/cfg"
|
"github.com/felixangell/phi/cfg"
|
||||||
"github.com/felixangell/strife"
|
"github.com/felixangell/strife"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// View is an array of buffers basically.
|
// View is an array of buffers basically.
|
||||||
@ -72,6 +73,24 @@ func sign(dir int) int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *View) removeBuffer(index int) {
|
||||||
|
log.Println("Removing buffer index:", index)
|
||||||
|
delete(n.buffers, index)
|
||||||
|
|
||||||
|
// only resize the buffers if we have
|
||||||
|
// some remaining in the window
|
||||||
|
if len(n.buffers) > 0 {
|
||||||
|
bufferWidth := n.w / len(n.buffers)
|
||||||
|
|
||||||
|
// translate all the components accordingly.
|
||||||
|
for i, buff := range n.buffers {
|
||||||
|
buff.Resize(bufferWidth, n.h)
|
||||||
|
buff.SetPosition(bufferWidth*i, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (n *View) ChangeFocus(dir int) {
|
func (n *View) ChangeFocus(dir int) {
|
||||||
prevBuff, _ := n.buffers[n.focusedBuff]
|
prevBuff, _ := n.buffers[n.focusedBuff]
|
||||||
|
|
||||||
@ -132,17 +151,13 @@ func (n *View) AddBuffer() *Buffer {
|
|||||||
// note that we +1 the components because
|
// note that we +1 the components because
|
||||||
// we haven't yet added the panel
|
// we haven't yet added the panel
|
||||||
var bufferWidth int
|
var bufferWidth int
|
||||||
bufferWidth = n.w / (len(n.buffers) + 1)
|
bufferWidth = n.w / (c.index + 1)
|
||||||
|
|
||||||
n.buffers[c.index] = c
|
n.buffers[c.index] = c
|
||||||
n.focusedBuff = c.index
|
n.focusedBuff = c.index
|
||||||
|
|
||||||
// translate all the components accordingly.
|
// translate all the components accordingly.
|
||||||
for i, buff := range n.buffers {
|
for i, buff := range n.buffers {
|
||||||
if buff == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
buff.Resize(bufferWidth, n.h)
|
buff.Resize(bufferWidth, n.h)
|
||||||
buff.SetPosition(bufferWidth*i, 0)
|
buff.SetPosition(bufferWidth*i, 0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user